<!--

//Detect IE
var IEBrowser = (navigator.appVersion.indexOf("MSIE")!=-1);

//Verificar si una direccion de correo esta escrita correctamente
function isEmailValid(email) 
{ 
    return /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w{2,}$/.test(email); 
} 

function isDefined(variable)
{
	return eval('(typeof('+variable+') != "undefined");');
}

function RemoveinvalidCharsInJs(inputStr)
{
	var returnValue = RemoveSubString(inputStr, '\'');
	returnValue = RemoveSubString(returnValue, '"');
	return returnValue;
}

function RemoveLastSeparator(inputString, separatorChar)
{
	if(inputString.length == 0)
		return '';
	
	if(inputString.substring(inputString.length-1, inputString.length) == separatorChar)
		return inputString.substring(0, inputString.length-1);
	
	return inputString.substring(0, inputString.length);
}

function CleanHTMLToClient(textToClean, ControlToStore)
{
	Resultat=""
	Resultat = textToClean.replace(/<br>/gi, String.fromCharCode(10));
	if(ControlToStore!=null && ControlToStore.value!=null)
		ControlToStore.value = Resultat;
}

function EncodeHTMLToServer(textToEncode, ControlToStore)
{
	var Resultat="";
	
	for (i=0;i<textToEncode.length;i++)
	{
		numer=textToEncode.charCodeAt(i);
		if((numer==13)&&(textToEncode.charCodeAt(i+1)==10))
			{
				i++;
				Resultat += '<br>';
			}
		else
			Resultat += String.fromCharCode(numer);			
	}
	if(ControlToStore!=null && ControlToStore.value!=null)
		ControlToStore.value = Resultat;
}

function renderHTML(textToEncode)
{
	var Resultat="";
	var numer = 0;
	
	for (i=0;i<textToEncode.length;i++)
	{
		numer=textToEncode.charCodeAt(i);
		if((numer==13)&&(textToEncode.charCodeAt(i+1)==10))
			{
				i++;
				Resultat += '<br>';
			}
		else
			Resultat += String.fromCharCode(numer);			
	}
	return Resultat;
}

//obtener imagen y texto del estatus de una evaluacion de competencias
function GetSkillEvalStatusText(statusID)
{
	if (statusID.toString() == '0' || statusID.toString() == 'False')
		return ('<img src=\'../images/iconos/check_wrong.gif\' width=\'9\' height=\'9\' hspace=\'4\'> No contestada');
	else
		return ('<img src=\'../images/iconos/check_right.gif\' width=\'9\' height=\'9\' hspace=\'4\'> Contestada');
}

function GetPriorityLight(priorityID)
{
	var lightStr = 'gray';
	switch(priorityID)
	{
		case '3': lightStr = 'red_on';
			break;
		case '2': lightStr = 'yellow_on';
			break;
	}
	return lightStr;
}

//texto de la prioridad de capacitacion
function GetPriorityText(priorityID)
{
	var textStr = 'Deseable';
	switch(priorityID)
	{
		case '3': textStr = 'Prioritario';
			break;
		case '2': textStr = 'Necesario';
			break;
	}
	return textStr;
}

//estatus de la definicion de objetivos
function GetObjectivesStatus(statusID)
{
	var textStr = '';
	switch(statusID)
	{
		case '0': textStr = 'No definidos';
			break;
		case '1': textStr = 'Definición incompleta';
			break;
		case '2': textStr = 'Definidos esperando aprobación';
			break;
		case '3': textStr = 'Aprobados';
			break;
		case '4': textStr = 'Evaluados';
			break;			
	}
	return textStr;
}

//barra grafica de avance
function GetPercentageBar(percentageParam, advanceParam, maxLength)
{
	var boxWidth = Math.round(percentageParam * maxLength);
	var boxPixFile = 'pixel_red';

	if (percentageParam > 0.25)
		if (percentageParam > 0.50)
			if (percentageParam > 0.75)
				boxPixFile = 'pixel_green';
			else
				boxPixFile = 'pixel_yellow';
		else
			boxPixFile = 'pixel_orange';
	
	return '<img src=\'../images/' + boxPixFile + '.gif\' style=\'border:1px solid #333333\' height=\'10\' width=\''+ boxWidth +'\' title=\''+ advanceParam +'\'>';
}

function GetSpanTitle(inputStr, titleParam)
{
	var titleValue = (titleParam == undefined) ? inputStr : titleParam;
	
	if (inputStr.length == 0)
		return inputStr;
	else
		return '<span title="'+ titleValue.toString() +'">' + inputStr.toString() + '</span>';
}

function AddComboItem(comboListObject, newItemString, newItemValue)
{
	//Agregar elementos intermedios
	var lclObjOpt 	= window.document.createElement("OPTION");
	lclObjOpt.text 	= newItemString;
	lclObjOpt.value = newItemValue;
	try {
      comboListObject.add(lclObjOpt, null);
    }
    catch(ex) {
      comboListObject.add(lclObjOpt);
    }
}

function openModal(){
if (window.showModalDialog('mensajes/modalControl.asp','dialogHeight: 160px; dialogWidth: 600px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: No; status: No;'))
	document.location.href = 'controlModule.asp';
}

function OpenModalWindow(windowURL, width, height)
{
	window.showModalDialog(  windowURL, "",   "dialogHeight:"+height+"px;dialogWidth:"+width+"px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: No; status: No;");
}

function OpenWindow(target){ 
popupWin = window.open(target, "Impresiones", "toolbar=yes,directories=no,status=no,menubar=yes,width=850,height=450,left=30,top=30"); 
popupWin.focus(); 
}

function OpenWindow2(target){ 
popupWin = window.open(target, "Impresiones", "toolbar=yes,directories=no,status=no,scrollbars=yes,menubar=yes,width=750,height=450,left=30,top=30"); 
popupWin.focus(); 
}

function ClearCombo(combo)
{
	while (combo.options.length > 0)
		combo.remove(0);
}
		
function FillCombo(combo, response, defaultString, selected)
{
	ClearCombo(combo);		
	var itemArray = response.split('~');
	
	AddComboItem(combo,defaultString,"");
	
	for (thisIndex=0; thisIndex<itemArray.length; thisIndex++)
	{
		var itemValues=itemArray[thisIndex].split('|');
		
		if(itemValues.length>1)
		{
			var item=AddComboItem(combo,itemValues[1],itemValues[0]);
			if(itemValues[1]==selected)
				item.selected=true;
		}
	}
}

//cargar datos de un XML a combo
function FillComboXML(combo, responseObj, defaultString, defaultValue, selectedItem)
{
	ClearCombo(combo);		
	
	if (defaultString != null)
		AddComboItem(combo, defaultString, defaultValue);
	
	if (responseObj != null)
	{
		var xmlDocument = responseObj.responseXML;
		var parenElement = xmlDocument.documentElement;
		if (parenElement == null)
			parenElement = xmlDocument;
			
		for (loopIndex = 0; loopIndex < parenElement.childNodes.length; loopIndex++)
		{
			var item = AddComboItem(combo, parenElement.childNodes[loopIndex].childNodes[0].nodeValue, parenElement.childNodes[loopIndex].getAttribute('id'));
			if(parenElement.childNodes[loopIndex].getAttribute('id') == selectedItem)
				item.selected=true;
			
		}
	}
}


//cargar datos de un XML a combo. XML con estructura especifica
function FillComboXMLStructured(combo, responseObj, defaultString, defaultValue, selectedItem, catalogName)
{
	ClearCombo(combo);		
	
	if (defaultString != null)
		AddComboItem(combo, defaultString, defaultValue);
	
	if (responseObj != null)
	{
		var xmlDocument = responseObj.responseXML;
		var parenElement = xmlDocument.documentElement;
		if (parenElement == null)
			parenElement = xmlDocument;
			
		for (loopIndex = 0; loopIndex < parenElement.childNodes.length; loopIndex++)
		{
			switch(catalogName)
			{
				default:
					var id = GetNodeValue(parenElement.childNodes[loopIndex].childNodes[0]);
					var text = GetNodeValue(parenElement.childNodes[loopIndex].childNodes[1]);
					
					var item = AddComboItem(combo, text, id);
					if(id == selectedItem)
						item.selected=true;
			}
		}
	}
}

function IsValueInArray(arrayObj, value)
{
	if(arrayObj==null) return false;
	if(arrayObj=='undefined') return false;
	
	for(var i=arrayObj.length-1; i>=0; i--)
	{
		if (arrayObj[i] == value)
		{
			return true;
		}
	}
	return false;
}

function ComboBox_GetTextByValue(tagId, value)
{
	if(tagId==null) return '';
	if(tagId=='undefined') return '';
	var comboObj = GetElement(tagId);
	
	for(var i=comboObj.options.length-1; i>=0; i--)
	{
		if (comboObj.options[i].value == value)
		{
			return comboObj.options[i].text;
		}
	}
	return '';
}

function ComboBox_SelectByValue(tagId, value)
{
	if(tagId==null) return;
	if(tagId=='undefined') return;
	var comboObj = GetElement(tagId);
	
	for(var i=comboObj.options.length-1; i>=0; i--)
	{
		if (comboObj.options[i].value == value)
		{
			comboObj.selectedIndex = i;
			return;
		}
	}
	return;
}

//Local search
function ComboBox_localSearch(ComboBox, typedText, searchType)
{
	if(ComboBox.length ==0)
		return false;
		
	for (i=0;i<ComboBox.length;i++) 
	{
		if (searchType == 'value')
		{
			if (ComboBox.options[i].value == typedText)
			{
				ComboBox.selectedIndex = i;
				return i;
			}
		}
		else
		{	
			if (ComboBox.options[i].text.toUpperCase().indexOf(typedText.toUpperCase()) > -1)
			{
				ComboBox.selectedIndex = i;
				return i;
			}
		}
	}
	
	return -1;
}

//remover un renglon de un tableBody
function DeleteTableRow(tBodyID, rowID)
{
	var tbody = GetElement(tBodyID);
	
	if (tbody != undefined)
	{
		for (var rowIndex=0; rowIndex<tbody.rows.length; rowIndex++)
		{
			if(tbody.rows[rowIndex].id == rowID)
			{
				tbody.deleteRow(rowIndex);
				break;
			}
		}
	}
	
	return tbody.rows.length;
}

//-- Mostrar todos los elementos del tipo indicado
function showAllByTag(tagName,dispType) {
	var elements = document.getElementsByTagName(tagName);
	var i = 0;
	if (dispType == "") {
	        dispType = 'inline';
	}
	while (i < elements.length) {
	        elements[i].style.display = dispType;
	        i++;
	        }
}

//-- Ocultar todos los elementos del tipo indicado
function hideAllByTag(tagName) {
	var elements = document.getElementsByTagName(tagName);
	var i = 0;
	while (i < elements.length) {
	        elements[i].style.display = "none";
	        i++;
	        }
}


//Get Element (Object) found by its ID
function GetElement(tagId) 
{
	var lclObj = document.getElementById(tagId);
	if(lclObj && lclObj.length && lclObj[0].id==tagId)
		lclObj=lclObj[0];
	return lclObj;
}

function GetNodeValue(nodeObject)
{
	if(typeof nodeObject == 'object') {
		if (nodeObject.firstChild != null)
			return nodeObject.firstChild.nodeValue;
		else
			return null;
	}
	return null;
}

//obtener etiqueta de la opcion seleccionada en una lista
function GetSelectedLabel(elementID)
{
	var lclObj = GetElement(elementID);
	if (lclObj.selectedIndex == -1)
		return '';
	else
		return lclObj.options[lclObj.selectedIndex].text;
}

//Get form element value
function GetTagValue(elementID)  //obj,use_default,delimiter
{
	var use_default = false;
	var delimiter = ',';
	
	if (elementID == '')
		return null;
	
	var lclObj = GetElement(elementID);
	
	if(null==lclObj)
		return null;
		
	switch(lclObj.type)
	{
		case 'radio': 
		case 'checkbox': 
			return(((use_default)?lclObj.defaultChecked:lclObj.checked)?lclObj.value:null);
		
		case 'text': 
		case 'hidden': 
		case 'textarea': 
		case 'file':
			return(use_default)?lclObj.defaultValue:lclObj.value;
		
		case 'password': 
			return((use_default)?null:lclObj.value);
		case 'select-one':
			if(lclObj.options==null)
			{
				return null;
			}
			if(use_default)
			{
				var o=lclObj.options;
				for(var i=0;i<o.length;i++)
				{
					if(o[i].defaultSelected)
					{
						return o[i].value;
					}
				}
				return o[0].value;
			}
			if(lclObj.selectedIndex<0)
			{
				return null;
			}
			return (lclObj.options.length>0)?lclObj.options[lclObj.selectedIndex].value:null;
			
		case 'select-multiple':
			if(lclObj.options==null)
			{
				return null;
			}
			var values=new Array();
			for(var i=0;i<lclObj.options.length;i++)
			{
				if((use_default&&lclObj.options[i].defaultSelected)||(!use_default&&lclObj.options[i].selected))
				{
					values[values.length]=lclObj.options[i].value;
				}
			}
			
			return(values.length==0)?null:CommifyArray(values,delimiter);
	}
			
	//alert("FATAL ERROR: Field type "+lclObj.type+" is not supported for this function");
	return null;
}

//Set form element value
function SetTagValue(elementID, newValue)  //obj,use_default,delimiter
{
	if (elementID == '')
		return;
	
	var lclObj = GetElement(elementID);
	
	if(null==lclObj)
		return;
		
	switch(lclObj.type)
	{
		//case 'radio': 
		//case 'checkbox': 
		
		case 'text': 
		case 'hidden': 
		case 'textarea': 
			lclObj.value = newValue;
		
		case 'select-one':
			if(lclObj.options==null)
				return;
			
			var o=lclObj.options;
			for(var i=0;i<o.length;i++)
			{
				if(o[i].value == newValue)
				{
					lclObj.selectedIndex = i;
					break;
				}
			}
			
		//case 'select-multiple':
	}
		
}


function CleanFormTags(tagsArrayString)
{
	var tagsArray = tagsArrayString.split("|");
	
	for (thisIndex=0; thisIndex<tagsArray.length; thisIndex++) {
		ClearTagValue(tagsArray[thisIndex]);
	}
}

function ClearTagValue(elementID)
{
	if (elementID == '')
	return;
	
	var lclObj = GetElement(elementID);
	
	if(null==lclObj || undefined==lclObj)
		return;
		
	switch(lclObj.type)
	{
		case 'radio': 
		case 'checkbox': 
			lclObj.checked = false;
		
		case 'text': 
		case 'hidden': 
		case 'textarea': 
		case 'file':
			lclObj.value = '';
		
		case 'password': 
			lclObj.value = '';
			
		case 'select-multiple':
		case 'select-one':
			lclObj.selectedIndex = 0;
	}
}


function switchRowColor(objectID, highlightcolor)
{
		var object = document.getElementById(objectID);
		switchRowColor2(object, highlightcolor);
}

function switchRowColor2(objectRef, highlightcolor)
{
		var object = objectRef;
		if (object.tagName == "TD")
			var row = object.parentElement;
		else
			var row =object;

		if (row.highlighted == null || !row.highlighted)
		{
			row.highlighted = true;
			row.originalBackgroundColor=row.style.backgroundColor;
			row.style.backgroundColor=highlightcolor;
		}
		else
		{
			row.highlighted = false;
			row.style.backgroundColor=row.originalBackgroundColor;
		}
}

function HighlightRow()
{
	this.originalBackgroundColor = this.style.backgroundColor;
	this.style.backgroundColor = this.bgcolor2;
}
function UnHighlightRow()
{
	this.style.backgroundColor = this.originalBackgroundColor;
}

function highlightRowColor(objectID, highlightcolor, on)
{
		var object = document.getElementById(objectID);
		if (object.tagName == "TD")
			var row = object.parentElement;
		else
			var row =object;

		if (!row.highlighted)
		{
			if(on)
				switchRowColor(objectID, highlightcolor);
		}
		else
		{
			if(!on)
				switchRowColor(objectID, highlightcolor);
		}
}

//Hides and appears description and editable elements, to activate EDIT pages.
function switchEditElements(startEdit){	
	var elements = document.getElementsByTagName('span')
	if (startEdit)
	{
		for (i=0; i<elements.length; i++){
			if(elements[i].id.substr(0,5)=='show_')
				elements[i].style.display = 'none';
			if(elements[i].id.substr(0,5)=='edit_')
				elements[i].style.display = '';
		}
	}
	else
	{
		for (i=0; i<elements.length; i++){
			if(elements[i].id.substr(0,5)=='edit_')
				elements[i].style.display = 'none';
			if(elements[i].id.substr(0,5)=='show_')
				elements[i].style.display = '';
		}
	}
}


//function onKeyPress(DataType, MinValue, MaxValue){
function onKeyPress(event,DataType){
	//TAB and ENTER keys accepted
	if (event.keyCode==9||event.keyCode==13)
		return;
	// . accepted
	if (DataType==3&&event.keyCode==46)
		return;
	// - accepted
	if (DataType==3&&event.keyCode==45)
		return;
	//digits accepted
	if (event.keyCode<48 || event.keyCode>57)
		event.returnValue = false;
}

function onKeyDown(event, element){
	//switch enter for tab
	if (event.keyCode==13)
		event.keyCode=9;
}

function RestrictUserInput(elem) {
    if (/[^\d]/g.test(elem.value))
       elem.value = elem.value.replace(/[^\d]/g, '');
}


function trim(stringToTrim)
{
	if (stringToTrim == undefined || stringToTrim == null)
		return null;
	
	return stringToTrim.replace(/^\s+/,'');
} 

//get DateFormat in english - month/day/year, considering parameter comes in spanish - day/month/year
function EnglishDateFormat(dateParam)
{
	if (dateParam == '')
	{
		return (dateParam);
	}
	else
	{
		var paramArray = dateParam.split("/");
		var month = paramArray[1];
		var day = paramArray[0];
		var year = paramArray[2];
		
		//completar con 0s
		if(day*1 < 10)
			day = '0' + day.toString();
		
		if(month*1 < 10)
			month = '0' + month.toString();
		
		return (month + "/" + day + "/" + year);
	}
}

//get DateFormat in spanish - day/month/year, considering parameter comes in english
function SpanishDateFormat(dateParam)
{
	//remover hora
	var noHourArray	= dateParam.split(" ");
	
	if (noHourArray[0] == '')
	{
		return (dateParam);
	}
	else
	{
		var paramArray = noHourArray[0].split("/");
		var month = paramArray[1];
		var day = paramArray[0];
		var year = paramArray[2];
		
		//completar con 0s
		if(day*1 < 10)
			day = '0' + day.toString();
		
		if(month*1 < 10)
			month = '0' + month.toString();
		
		return (day + "/" + month + "/" + year);
	}
}

function GetDateObject(dateParam)
{
	var newDateObj 	= new Date();
	var paramArray 	= dateParam.split("/");
	
	newDateObj.setFullYear(paramArray[2]*1, paramArray[0]*1-1, paramArray[1]*1);
	
	return newDateObj;
}

//input date as yyyy/mm/dd, and number of days to add
//output yyyy/mm/dd
function AddDays(strDate,iDays)
{
strDate = Date.parse(strDate);
strDate = parseInt(strDate, 10);
strDate = strDate + iDays*(24*60*60*1000);
strDate = new Date(strDate);
returnValue = strDate.getFullYear() + "/" + strDate.getMonth()*1+1 + "/" + strDate.getDate();

return returnValue;
}

function DateAdd(interval,n,dt)
{
	if(!interval||!n||!dt) return;	
	
	var s=1,m=1,h=1,dd=1,i=interval;
	
	if(i=='month'||i=='year')
	{
		dt=new Date(dt);
		if(i=='month')
		{
			newMonth = dt.getMonth() + n;
			if (newMonth > 11)
				newMonth = newMonth - 12;
			dt.setMonth(dt.getMonth()+n);
			if(dt.getMonth() != newMonth)
			{
				//overshot month due to date, so go to last day of previous month 
				dt.setDate(0);
			}
		}
		if(i=='year') dt.setFullYear(dt.getFullYear()+n);		
	}
	else if (i=='second'||i=='minute'||i=='hour'||i=='day'){
		dt=Date.parse(dt);
		if(isNaN(dt)) return;
		if(i=='second') s=n;
		if(i=='minute'){s=60;m=n}
		if(i=='hour'){s=60;m=60;h=n};
		if(i=='day'){s=60;m=60;h=24;dd=n};
		dt+=((((1000*s)*m)*h)*dd);
		dt=new Date(dt);
	}
	return dt;
}

//-------------- new Validation Functions

//Validates a value against a regular expression and limit values
function ValueValidator(stringRegExp, inputValue, selectionRange, OldValue, DecimalSeparator, MinValue, MaxValue){
	var validation = true;
	var objRegExp = new RegExp(stringRegExp.toString());
	var endIndex = selectionRange.text.length;
	while(selectionRange.expand("character")){}
	var startIndex = OldValue.length - selectionRange.text.length;
	endIndex = endIndex + startIndex;
	var newValueCandidate = OldValue.substring(0,startIndex) + inputValue + OldValue.substring(endIndex,OldValue.length);
	if(!objRegExp.test(newValueCandidate))
		return false;
	else
	{
		//Validate for MinValue and MaxValue
		if (MinValue!=null || MaxValue!=null)
		{
			var CompareNum = parseFloat(newValueCandidate.replace(DecimalSeparator,'.'));
			if (MinValue!=null && CompareNum < MinValue) validation = false;
			if (MaxValue!=null && CompareNum > MaxValue) validation = false;
			return validation;
		}
		else
			return true;
	}
}

//Validates Currency Values
function ValidateCurrency(InputObj, minvalue, maxvalue){
	var key = window.event.keyCode;
	var selectionRange = document.selection.createRange ();
	var TextBoxValue = InputObj.value;
	
	var DecimalSeparator = '.';
	var DecimalDigits = 2;
	var MinValue = minvalue;
	var MaxValue = maxvalue;
	var NegativeSign = "";
	if (MinValue < 0) var NegativeSign = "-?";
	
	var stringRegExp = "(^"+NegativeSign+"\\d*\\"+DecimalSeparator+"?\\d{0,"+DecimalDigits+"}$)";
	if (!ValueValidator(stringRegExp, String.fromCharCode(key), selectionRange, TextBoxValue, DecimalSeparator, MinValue, MaxValue))
		event.keyCode = 0;	
}

//Validates Clipboard against a regular expression to allow or deny pasting it in the TextBox
function ValidateClipboard(InputObj, minvalue, maxvalue, DataType){
//	var Clipboard = igtbl_trim(window.clipboardData.getData("Text"));
	var ClipBoard = window.clipboardData.getData("Text");
	if (!event || Clipboard.length==0 || Clipboard == undefined) return;
	
	var selectionRange = document.selection.createRange ();
	var TextBoxValue = this.value;
		
	var MinValue = minvalue;
	var MaxValue = maxvalue;
		var NegativeSign = "";
	// Allow for negative sign to be approved by Regular Expression
	if (MinValue < 0) var NegativeSign ="-?";
	
	switch(DataType){
		case 3: //Currency
			var stringRegExp = "(^-?\\d*\\.?\\d{0,2}$)";
			if (!ValueValidator(stringRegExp, Clipboard, selectionRange, TextBoxValue, Culture.CurrencyDecimalSeparator, MinValue, MaxValue))
				event.returnValue = false;
			break;
	}	
	return;
}

function Format(num,decimaldigits,symbol,dot,groupseparator,groupdigits, percentFormat){
		var DecimalDigits = 1;
		for (var i=0; i<decimaldigits; i++)
			DecimalDigits = DecimalDigits * 10;
		var RegularExp = new RegExp("/\\" + symbol + "|\\" + groupseparator + "/g");
		num = num.toString().replace(RegularExp,'');
		num = num.replace(dot,'.');	//replace decimal separator with '.' for Math class properties
		if(isNaN(num)) return "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*DecimalDigits+0.50000000001);
		cents = num%DecimalDigits;
		centsStr = cents.toString();
		num = Math.floor(num/DecimalDigits).toString();
		for (var i=0; i<decimaldigits-centsStr.length; i++)
			centsStr = "0" + centsStr;
		cents = centsStr;
		for (var i = 0; i < Math.floor((num.length-(1+i))/groupdigits); i++)
			num = num.substring(0,num.length-((groupdigits+1)*i+groupdigits))+groupseparator+num.substring(num.length-((groupdigits+1)*i+groupdigits));
		if (percentFormat)
			return (((sign)?'':this.NegativeSign) + num + dot + cents + symbol);
		else
			return (((sign)?'':this.NegativeSign) + symbol + num + dot + cents);
}

function FormatCurrency(InputObj){
	InputObj.value = Format(InputObj.value, 2, '$', '.' , ',', 3, false);
}

function CleanFormat(InputObj,DataType){
	if (InputObj.value.substring(0,1)=='$')
		InputObj.value = InputObj.value.substring(1,InputObj.value.length);
	InputObj.value = InputObj.value.replace(',','');
}
//------------Functions

function Navigate(Module){
eval("document.location='" + Module + "'");
}

function ParentNavigate(Module){
eval("window.parent.location='" + Module + "'");
}


function replaceAll(oldStr,findStr,repStr) {
  var srchNdx = 0;  // srchNdx will keep track of where in the whole line
                    // of oldStr are we searching.
  var newStr = "";  // newStr will hold the altered version of oldStr.
  while (oldStr.indexOf(findStr,srchNdx) != -1)  
                    // As long as there are strings to replace, this loop
                    // will run. 
  {
    newStr += oldStr.substring(srchNdx,oldStr.indexOf(findStr,srchNdx));
                    // Put it all the unaltered text from one findStr to
                    // the next findStr into newStr.
    newStr += repStr;
                    // Instead of putting the old string, put in the
                    // new string instead. 
    srchNdx = (oldStr.indexOf(findStr,srchNdx) + findStr.length);
                    // Now jump to the next chunk of text till the next findStr.           
  }
  newStr += oldStr.substring(srchNdx,oldStr.length);
                    // Put whatever's left into newStr.             
  return newStr;
}

//format a String to be used as Regular Expression
function FormatRegExpString(convertString)
{
	convertString = convertString.replace(/\\/g,'\\\\');
	convertString = convertString.replace(/\//g,'\\/');
	convertString = convertString.replace(/\*/g,'\\*');
	convertString = convertString.replace(/\$/g,'\\$');
	convertString = convertString.replace(/\+/g,'\\+');
	convertString = convertString.replace(/\?/g,'\\?');
	convertString = convertString.replace(/\./g,'\\.');
	convertString = convertString.replace(/\^/g,'\\^');
	convertString = convertString.replace(/\[/g,'\\[');
	convertString = convertString.replace(/\]/g,'\\]');
	convertString = convertString.replace(/\(/g,'\\(');
	convertString = convertString.replace(/\)/g,'\\)');
	convertString = convertString.replace(/\{/g,'\\{');
	convertString = convertString.replace(/\}/g,'\\}');
	convertString = convertString.replace(/\|/g,'\\|');				
	
	return convertString;
	
}   

//Remove substring
function RemoveSubString(thisString,thisSubString){
	eval('var re = /' + FormatRegExpString(thisSubString) + '/g');
	return thisString.replace(re, "");
}



//Replace substring
function ReplaceSubString(thisString,thisSubString,newSubString){
	eval('var re = /' + FormatRegExpString(thisSubString) + '/g');
	return thisString.replace(re, newSubString);
}

//Obtener un numero al azar entre cero y cinco mil
function get_random()
{
    var ranNum= Math.floor(Math.random()*5000);
    return ranNum;
}

//obtener la posicion de un objeto
function GetObjectPosition(lclObj) {
	var curleft = curtop = 0;
	if (lclObj.offsetParent) {
		curleft = lclObj.offsetLeft
		curtop = lclObj.offsetTop
		while (lclObj = lclObj.offsetParent) {
			curleft += lclObj.offsetLeft
			curtop += lclObj.offsetTop
		}
	}
	return [curleft,curtop];
}

function GetWindowClientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}

function GetWindowClientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}

function GetWindowScrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}

function GetWindowScrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

//--------------- COVER LAYERS

function ShowConnectionMessage(showValue, useAllScreen)
{
	if (useAllScreen)
	{
		ShowCoverLayer(showValue);
		ShowMessage(showValue);
	}
	else
	{
		ShowConfirmMessage(showValue, 'Estableciendo conexión con servidor...');
	}
}

function ShowTopMessage(showValue, messageStr)
{
	var messageDiv = GetElement('topMessageDIV');
	var messageTag = GetElement('topMessageTAG');

	if (messageDiv != undefined && messageTag != undefined)
	{
		messageTag = messageStr;
		
		if(showValue)
			slidedown(messageDiv);
		else
			slideup(messageDiv);
	}
}

function SetTopMessage(setConfirmIcon, autoClose, messageStr)
{
	var messageDiv = GetElement('topMessageDIV');
	var messageTag = GetElement('topMessageTAG');

	if (messageDiv != undefined && messageTag != undefined)
	{
		//if(setConfirmIcon)
		// -- falta: cambiar icono a confirmacion
		
		messageTag = messageStr;
		
		//Cerrar mensaje luego de 5 segundos
		if(autoClose)
			setTimeout('ShowTopMessage(false, null)',5000);
	}
}

function ShowFullScreenMessage(showValue, messageStr)
{
	ShowCoverLayer(showValue);
	if (messageStr != '')
		document.getElementById("fulScreenMessageString").innerHTML = messageStr;
		
	ShowMessage(showValue);
	
	//regresar valor original
	if (!showValue)
		document.getElementById("fulScreenMessageString").innerHTML = 'Estableciendo conexión con servidor...';
}

// Cambiar mensaje de la ventana de conexion a servidor
function SetConnectionMessage(messageString)
{
	GetElement('fulScreenMessageString').innerHTML = messageString;
}

function ShowCoverLayer(showValue){
	docu	= document.body;
	coscura	= document.getElementById('iCoverLayer');
	coscura.style.height=docu.scrollHeight+'px';
	if(showValue) 
		coscura.style.visibility = "visible";
	else 
		coscura.style.visibility = "hidden";
}

function ShowMessage(showValue) {
	var tableObj = document.getElementById("iMessageTable");
	var objLayer = document.getElementById("iMessageLayer");
	
	if(showValue) 
		objLayer.style.display = '';
	else 
		objLayer.style.display = 'none';
	
	var left = ((document.body.clientWidth - tableObj.width) / 2) + GetWindowScrollLeft();
	var top  = ((document.body.clientHeight - tableObj.height) / 2) + GetWindowScrollTop();
		
	objLayer.style.left = parseInt(left);
	objLayer.style.top 	= parseInt(top);
}

//TEMPORAL
function ShowLocalMessage(messageDIVid, showValue) {
	var objLayer = GetElement(messageDIVid);
	
	if(showValue) 
		objLayer.style.display = '';
	else 
		objLayer.style.display = "none";	
		
	var left = ((document.body.clientWidth - objLayer.offsetWidth) / 2) + GetWindowScrollLeft();
	var top  = ((document.body.clientHeight - objLayer.offsetHeight) / 2) + GetWindowScrollTop();
		
	objLayer.style.left = parseInt(left);
	objLayer.style.top 	= parseInt(top);
}

function ShowConfirmMessage(showValue, messageStr)
{
	if (messageStr != '')
		document.getElementById("TopMessageString").innerHTML = messageStr;
	
	if(showValue) 
		document.getElementById("TopMessageTable").style.display = '';
	else 
		document.getElementById("TopMessageTable").style.display = 'none';
}

function ShowConnectionTag(idTag)
{
	var tagObject = GetElement(idTag);
	if (tagObject != undefined)
		tagObject.style.display = '';
}

function CloseConnectionTag(idTag, timeInterval)
{
	var tagObject = GetElement(idTag);
	if (tagObject != undefined)
	{
		if(timeInterval == 0)
			tagObject.style.display = 'none';
		else
			setTimeout("CloseConnectionTag('"+ idTag +"', 0)", timeInterval);	
	}
}

function SetConnectionTag(idTag, messageType, messageStr)
{
	var tagObject = GetElement(idTag);
	if (tagObject != undefined)
	{
		switch(messageType)
		{
			case 'confirm':
				if (messageStr == '')
					messageStr = 'Comando ejecutado satisfactoriamente';
					
				tagObject.innerHTML = '<img src="../images/iconos/checked_green.gif" width="14" height="12" hspace="5">' + messageStr;
				break;
				
			case 'wait':
				if (messageStr == '')
					messageStr = 'Conectando a servidor...';
					
				tagObject.innerHTML = '<img src="../images/iconos/antenna.gif" width="14" height="12" hspace="5">' + messageStr;
				break;
			
			case 'stop':
				if (messageStr == '')
					messageStr = 'Atención';
					
				tagObject.innerHTML = '<img src="../images/iconos/stop.gif" width="14" height="12" hspace="5">' + messageStr;
				break;
			
			case 'alert':
				if (messageStr == '')
					messageStr = 'Atención';
					
				tagObject.innerHTML = '<img src="../images/iconos/alert2.gif" width="16" height="12" hspace="5">' + messageStr;
				break;
		}
	}
}


/* hides TAG objects under specified floating DIV */
function hideUnderneathElements( elmID, overDiv )
{
	var obj, objLeft, objTop, objParent, objLeft, objTop, objParent, objHeight, objWidth;

    for( i = 0; i < document.all.tags( elmID ).length; i++ )
    {
      obj = document.all.tags( elmID )[i];
      if( !obj || !obj.offsetParent || obj.parentControl == overDiv.id)
      {
        continue;
      }
  
      // Find the element's offsetTop and offsetLeft relative to the BODY tag.
      objLeft   = obj.offsetLeft;
      objTop    = obj.offsetTop;
      objParent = obj.offsetParent;
      
      while( objParent.tagName.toUpperCase() != "BODY" )
      {
        objLeft  += objParent.offsetLeft;
        objTop   += objParent.offsetTop;
        objParent = objParent.offsetParent;
      }
  
      objHeight = obj.offsetHeight;
      objWidth = obj.offsetWidth;
  
      if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
      else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
      else if( overDiv.offsetTop >= ( objTop + objHeight ));
      else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
      else
      {
        obj.style.visibility = "hidden";
      }
    }
}

/*
* unhides <select> and <applet> objects (for IE only)
*/
function showHiddenElementByTag( elmID )
{
	var obj;
	
    for( i = 0; i < document.all.tags( elmID ).length; i++ )
    {
      obj = document.all.tags( elmID )[i];
      
      if( !obj || !obj.offsetParent )
      {
        continue;
      }
    
      obj.style.visibility = "";
    }
}
    

-->