function confirmDelete(deleteUrl, strDisplay) {
	if ( confirm (strDisplay) ) 
		window.location.href = deleteUrl;
} 

function popUp( url, windowName, width, height, boolShowScrollBar, resizable, boolGiveFocus) {
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
	newWin = window.open( url, windowName, "scrollbars=" + boolShowScrollBar + ",width=" + width + ",height=" + height + ",resizable=" + resizable + ",top=" + wint + ",left=" + winl);
	if ( boolGiveFocus )
		newWin.focus();
	return false;
}

function disableSubmits (form, formType) {
	if (form.submitted)
		return false;
	else { 
		this.submitted = true; 
		/*
		for (var i = 0; i < form.elements.length; i++)
			if ( form.elements[i].type.toLowerCase() == formType.toLowerCase() )
				form.elements[i].disabled = true;
		*/
		return true; 
	}
}

function charsLeft ( localForm, textArea, charMax ) {
	var numChars = textArea.value.length
	left = eval(charMax - numChars)
	if (left <= "-1")
	{
		var value = textArea.value.substr(0, charMax);
		textArea.value = value;
		var left = "0"
	}
	localForm.left.value = "Te quedan " + left + " espacios.";
}


//set all of the checkboxes to the value of the "Select All" checkbox
function CheckAll( objForm, strSelectAllCheckBoxName, strCheckBoxNames, boolHighLightRows ){
	var selectAllVal = objForm [strSelectAllCheckBoxName].checked;	//determine if the "select all" box is selected
	for (var i=0; i < objForm.elements.length; i++){
		var e = objForm.elements[i];
		if ( e.type == 'checkbox' ){
			//check the highlight color if the box is not the "Select All" checkbox
			if (e.name != strSelectAllCheckBoxName && boolHighLightRows ){
				if ( e.checked ) 
					rowHightLightOff(e);
				else
					rowHightLightOn (e);
			}
			
			if (e.name == strCheckBoxNames)
				e.checked = selectAllVal;
		}
	}
}

function checkSingleBox( objForm, objCheckBox, strSelectAllCheckBoxName, boolHighLightRows )
{
	if ( boolHighLightRows ){
		if (objCheckBox.checked)
			rowHightLightOn (objCheckBox);
		else
			rowHightLightOff(objCheckBox);
	}
	
	var TB=TO=0;
	for (var i=0; i < objForm.elements.length; i++){
		var e = objForm.elements[i];
		if ((e.name != strSelectAllCheckBoxName) && (e.type=='checkbox')){
			TB++;
			if (e.checked)
				TO++;
		}
	}
	objForm [strSelectAllCheckBoxName].checked = (TO==TB)?true:false;
}

function rowHightLightOn (E){
//	while (E.tagName != "TR"){
//		E = E.parentElement;
//	}
//	E.className="HightlightRow";
}

function rowHightLightOff (E){
//	while (E.tagName != "TR"){
//		E=E.parentElement;
//	}
//	E.className="";
}

function limitOptions(oSel, howmany){
	var opt, i = 0, msg = '', thismany = howmany, toomany = new Array();
	opt = oSel.options[i++];
	while ( opt != null){
		if (opt.selected) 
			--howmany;
		if (howmany < 0) 
			toomany[toomany.length] = opt;
		opt = oSel.options[i++];
	}
	if (howmany < 0){
		msg += 'El número máximo de selecciones son ' + thismany + '.';
		//msg += '\n\nPlease observe this limit.\n\n';
		alert(msg);
		i = 0;
		opt = toomany[i++]
		while ( opt != null ) {
			opt.selected = false;
			opt = toomany[i++]
		}
		return false;
	}
}