function updateListOptions(list, arr, start, idKey, nameKey, sel) {
	sel = sel || '';
    for (var i = start, n = list.options.length; i < n; i++) {
        list.remove(start);
    }
    for (var i = 0, n = arr.length; i < n; i++) {
        var opt = document.createElement("option");
        opt.value = idKey ? (arr[i][idKey]) : (arr[i].Key || arr[i][0]);
        opt.text = nameKey ? (arr[i][nameKey]) : (arr[i].Value || arr[i][1]);
        if(!opt.text || !opt.text.length) {
            opt.text = opt.value;
        }
        try {
            list.add(opt);
        }
        catch (e) {
            list.add(opt, null);
        }
    }
    list.value = sel;
};

function clearChildren(el){
    for (var i = 0, n = el.children.length; i < n; i++) {
		el.removeChild(el.children[0]);
	}
}

function checkValidators(group) 
{
	for(var i=0; i< Page_Validators.length; i++ ) {
		var vl = Page_Validators[i];
		if(vl.disabled){
			continue;
		}
		if(group){
			if(vl.validationGroup != group){
				continue;
			}
		} 
		ValidatorValidate(vl);
		if (!vl.isvalid)  {
			alert(Page_Validators[i].errormessage);
			break;
		}
	}
	ValidatorUpdateIsValid(); 
	return Page_IsValid;
}

function attachEventHandler(el, eventName, handler){
    if(el.attachEvent){
        el.attachEvent("on" + eventName, handler);
    }
    else if(el.addEventListener){
        el.addEventListener(eventName, handler, false);
    }
}

function escapeText(s){
	s = s.replace('>', '&gt;');
	s = s.replace('<', '&lt;');
	return s;
}

