		var win = null;
		var preEl ;
		var orgBColor;
		var orgTColor;
		var aAcentoVocales = new Array(String.fromCharCode(225),String.fromCharCode(233),String.fromCharCode(237),String.fromCharCode(243),String.fromCharCode(250))
		var redTColor = "#00FFFF"
		
		/*Validacion de la fecha*////////////////////////////////////////////////////////////////////////////////////////////
		var isNav4 = false, isNav5 = false, isIE4 = false
		var strSeperator = "/"; 
		var vDateType = 3;
		var vYearType = 4;
		var vYearLength = 2;
		var err = 0;
		if(navigator.appName == "Netscape") {
			if (navigator.appVersion < "5") {
				isNav4 = true;
				isNav5 = false;
			}else if (navigator.appVersion > "4") {
				isNav4 = false;
				isNav5 = true;
			}
		}else {
			isIE4 = true;
		}


//-------navegacion-----------//
function setMedicion()
{
	document.all.hdMedicion_ID.value=document.all.cboMedicion.options[document.all.cboMedicion.selectedIndex].value;
}
function CargarMedicion()
{   
	var objcboMedicion=document.all.cboMedicion;
	var objcboAnio=document.all.cboAnio;
	objcboMedicion.options.length=0
	
	CargarCombo(objcboMedicion,"M","[@Anio_ID ='"+ objcboAnio.options[objcboAnio.selectedIndex].value +"']",false);
	
	document.all.hdAnio_ID.value=document.all.cboAnio.options[document.all.cboAnio.selectedIndex].value;
	//if (document.all.cboMedicion.options[document.all.cboAnio.selectedIndex].value)
}
/*function CargarAnio()
{   
	var objcboAnio=document.all.cboAnio;
	//var objcboAnio=document.all.cboAnio;
	//var objCboYacimiento=document.all.cboYacimiento;
	//--------Elimino las opciones del combo de Area y de yacimiento  -------
	//objCboArea.options.length=0
	//objCboYacimiento.options.length=0
	//--------Cargo el combo de Area como el pasi como condicion -------
	//if (objCboPais.options[objCboPais.selectedIndex].value!="Todos")
	//	CargarCombo(objCboArea,"xA","[@PaisId ='"+ objCboPais.options[objCboPais.selectedIndex].value +"']",true);
	//else
		CargarCombo(document.all.cboAnio,'A','',true);
	//--------Actualizo Yacimiento con la opcion de Todos y Con los yacimientos de todas las areas -------
	//CargarOpcionTodos(objCboYacimiento);
	//for (iCargarArea=0; iCargarArea< objCboArea.options.length; iCargarArea++)
	//	CargarYacimiento(objCboArea.options[iCargarArea].value);
}*/
function CargarCombo(objCbo,strObj,strAtt,bTodos)
{
	var strSel = null;
	var oxmlAgr= document.all.xmlAgr;
	var objhdAnio_ID = document.all.hdAnio_ID;
	var objhdMedicion_ID = document.all.hdMedicion_ID;
	
	if (objhdAnio_ID != null && objhdAnio_ID.value!= "" && objCbo.id=='cboAnio')
	{
		//cargarMedicion();
		strSel =objhdAnio_ID.value;
	}
	if (objhdMedicion_ID != null && objhdMedicion_ID.value!= "" && objCbo.id=='cboMedicion')
	{
		//if (document.all.cboMedicion.options.length!=0)
			strSel =objhdMedicion_ID.value;
		//else
		//	strSel==null;
	}		
	if (bTodos)
		CargarOpcionTodos(objCbo);
	if (oxmlAgr.readyState == "complete")
	{	
		var oNodes = oxmlAgr.XMLDocument.selectNodes("Agrupamientos/"+strObj+strAtt);
		//alert(strObj+strAtt);			
		for (var iCargarCombo=0; iCargarCombo<oNodes.length; iCargarCombo++)
		{
		
			oNode = oNodes.nextNode;
			if (oNode != null) 
			{
				var objOption = document.createElement("OPTION");
				objCbo.options.add(objOption);
				objOption.innerText = oNode.attributes.getNamedItem("Desc").text;
				objOption.value = oNode.attributes.getNamedItem("Id").text;
				if (strSel != null)
				{
					if (strSel == objOption.value)
					{
						objOption.selected = true;
						 /*if (strSel.attributes.getNamedItem("Editable").text=="False")
							objCbo.disabled=true;*/
							
					}
				}
			}
		}
	}
}
function CargarOpcionTodos(objCbo)
{	var objOption = document.createElement("OPTION");
	objCbo.options.add(objOption);
	objOption.innerText = 'Todos';
	objOption.value = 'Todos'
}
var win = null;
var preEl ;
var orgBColor;
var orgTColor;
function isNumericDecimal(s)
{		
	var cantpuntos=0;
	if(s == null)
	return false;
	if(s.length == 0)
	return false;
	for(var i=0; i<s.length; ++i)
	{//el - es porque no esta tomando el primer caracter
		if("-0123456789.".indexOf(s.charAt(i)) <= 0)
		{
			return false;
		}
		if (s.charAt(i)=='.')
			cantpuntos++;
	}
	if (cantpuntos>1)
		return false;
	return true;
}
function isNumericDecimalNegativo(s)
{		
	var cantpuntos=0;
	var cantMenos=0;	
	if(s == null)
	return false;
	if(s.length == 0)
	return false;
	
	for(var i=0; i<s.length; ++i)
	{//el * es porque no esta tomando el primer caracter		
		if('*0123456789.-'.indexOf(s.charAt(i)) <= 0)
		{							
			return false;
		}
		if (s.charAt(i)=='.')
			cantpuntos++;
		if (s.charAt(i)=='-')
			cantMenos++;
	}
	if (cantpuntos>1)
		return false;
	if (cantMenos>1)
		return false;
		
		
	return true;
}
function isAllNumeric(s)
{		
	var cantpuntos=0;
	if(s == null)
	return false;
	if(s.length == 0)
	return false;
	for(var i=0; i<s.length; ++i)
	{//el - es porque no esta tomando el primer caracter
		if("-0123456789".indexOf(s.charAt(i)) <= 0)
		{
			return false;
		}
	}
	return true;
}

function isNumeric(s)
{		
	if(s == null)
	return false;
	if(s.length == 0)
	return false;
	for(var i=0; i<s.length; ++i)
	{//el - es porque no esta tomando el primer caracter
		if("-0123456789".indexOf(s.charAt(i)) > 0)
		{
			return true;
		}
	}
	return false;
}

function isLetter(s)
{		
	if(s == null)
		return false;
	if(s.length == 0)
		return false;
	for(var i=0; i<s.length; ++i)
	{//el - es porque no esta tomando el primer caracter
		if("-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(s.charAt(i)) > 0)
		{
			return true;
		}
	}
return false;
}

function popUpFila(url,name,w,h,s){
	cierroWin();
	if (idDgFila == null){
		alert('Debe Seleccionar una fila');
	}else{
		popUrl(url,name,w,h,s); 
	}
}

function popUpFilaPlus(url,name,w,h,s,bToolbar,bResizable,bMenubar) {
	cierroWin();
	if (idDgFila == null){
		alert('Debe Seleccionar una fila');
	}else{
		popUrlplus(url,name,w,h,s,bToolbar,bResizable,bMenubar) ; 
	}
}
function popUpFilaPlusNoClose(url,name,bToolbar,bResizable,bMenubar) {
	if (idDgFila == null){
		alert('Debe Seleccionar una fila');
	}else{
		popUrlplusNoClose(url,name,bToolbar,bResizable,bMenubar) ; 
	}
}
function popUrlplusNoClose(url,name,bToolbar,bResizable,bMenubar) 
{
	var xleft = (screen.width / 2 - 790 / 2);
	var ytop =0; 
	win = window.open(url,name,"scrollbars=yes,status=yes,titlebar=0,toolbar=" + bToolbar + ",resizable=" + bResizable + ",menubar=" + bMenubar + ",width=790,height=480" + ",top=" + ytop + ",left=" + xleft);
	win.focus();
}
function popUrlplus(url,name,w,h,s,bToolbar,bResizable,bMenubar) 
{
	cierroWin();
	var xleft = (screen.width / 2 - w / 2);
	var ytop = (screen.height /2 - h / 2)-70; 
	if (s=='')
	{
		s = '0';
	}
//	win = window.open(url,name,"scrollbars=" + s + ",status=yes,titlebar=0,toolbar=" + bToolbar + ",resizable=" + bResizable + ",menubar=" + bMenubar + ",width=" + w + ",height="+ h  +",top=" + ytop + ",left=" + xleft);

	win = window.open(url,"'"+name+"'");
	//win.focus();
	//"scrollbars=" + s + ",status=0,resize=0,width=" + w + ",height="+ h  +",top=" + ytop + ",left=" + xleft
}


function popUrl(url,name,w,h,s) 
{
	cierroWin();
	var xleft = screen.width / 2 - w / 2;
	var ytop = screen.height /2 - h / 2 ; 

	if (s=='')
	{
		s = '0';
	}
	win = window.open(url,name,"scrollbars=" + s + ",status=yes,titlebar=0,toolbar=no,resizable=yes,menubar=no,width=" + w + ",height="+ h  +",top=" + ytop + ",left=" + xleft);
	win.focus();
	//"scrollbars=" + s + ",status=0,resize=0,width=" + w + ",height="+ h  +",top=" + ytop + ",left=" + xleft
}
function Modal(url,name,w,h)
{
	var x = window.showModalDialog(url,name,"center:yes;dialogWidth:" + w + "px;dialogHeight:" + h +"px");
}

function showMenu()
{
	document.all.tblMenu.style.display = "none";
	document.all.tblMenuHide.style.display =""; 
}
function hideMenu()
{
	document.all.tblMenu.style.display = ""; 
	document.all.tblMenuHide.style.display ="none";
	
}

function cierroWin() {
  //if (win && win.open && !win.closed) win.close();
  if (win != null && win.open) win.close();
}

// cierra el popup actual y recarga el opener 
function recargarDatos()
{
	if (window.opener != null)
	{
		window.opener.document.forms.item(0).submit();
		//window.opener.location.reload();
	}
	window.close();
}

/*Hilight row datagrid*/
function HighLightTR(backColor,textColor){ 
	 
	if(typeof(preEl)!='undefined'){
		preEl.style.background = orgBColor;
		try{
			ChangeTextColor(preEl,orgTColor);
		}
		catch(e){;}
	}
	var el = event.srcElement;
	el = el.parentElement;
	orgBColor = el.style.background;
	orgTColor = el.style.color;
	el.style.background = backColor;

	try{
		ChangeTextColor(el,textColor);
		}
	catch(e){
		;
	}
	preEl = el; 
}
	
function ChangeTextColor(a_obj,a_color){  
	for (i=0;i<a_obj.cells.length;i++){
	a_obj.cells(i).style.color=a_color; 
	}
}

function ChangeTextColorB(a_obj,a_color, colorFondo){  
	for (i=0;i<a_obj.cells.length;i++){
	a_obj.cells(i).style.color=a_color;
	a_obj.cells(i).style.background = colorFondo;
	}
}
/*es para setear el valor de un hidden*/
function setHidden(Id,hiddenField)
{
	hiddenField.value = Id;
}

var idDgFila = null;
/*var idMedicion=null;
var idVisita=null;
var idEESS=null;
var idAnio=null;*/
var idDgTr = null;
var arrIdValue = null; 
// debe ser llamada despues de saveDgFilaId que es la que guarda el Id
function saveDgTrId(Id, hiddenField)
{
	idDgTr = Id;
	hiddenField.value = idDgFila;
}

function saveDgFilaId(id)
{
	idDgFila = id;
}
function confirmarEliminar(){
	if (idDgFila == null){
		alert('Debe Seleccionar una fila');
		return false;
	}else{
		if (confirm('Confirma que desea eliminar el registro seleccionado?')){
			return true;
		}
		return false;
	}
}

function saveValor(hdVar,valor)
{
	hdVar.value = valor;
}
//ejemplo funciones para grillas con ids compuestos
/*function confirmarEliminarMV()
{
	if (confirm('Confirma que desea eliminar el registro seleccionado?'))
	{
		return true;
	}
		return false;
}*/
/*function saveDgFilaIdMV(idMed,idVis,idAn,idES)
{
	idMedicion = idMed;
	idVisita=idVis;
	idAnio=idAn;
	idEESS=idES;	
}*/
/*function saveDgTrIdMV(hdIdMed,hdIdVis,hdIdAnio,hdIdEESS)
{
	hdIdMed.value = idMedicion;
	hdIdVis.value=idVisita;
	hdIdEESS.value=idEESS;
	hdIdAnio.value=idAnio;
}*/

function cancelarNoEntero(){
	if (!(window.event.keyCode >= 48 && window.event.keyCode <= 57 )){
		if (window.event.keyCode != 13){
			window.event.keyCode = 0;
		}
	}
}

function cancelarNoNumericoPonderacion()
{
	var el = event.srcElement;
	el = el.parentElement;
	el = el.parentElement;
	var pondera = el.cells[8].children[0].checked;
	
	if(!pondera)
		window.event.keyCode = 0;
	else
	{
		if (window.event.keyCode == 46)
			window.event.keyCode = 44;
		if (!((window.event.keyCode >= 48 && window.event.keyCode <= 57) || (window.event.keyCode == 45)))
		{
			if (window.event.keyCode != 44 && window.event.keyCode != 13)
				window.event.keyCode = 0;
		}
	}
}

function cancelarNoNumerico(){
// 46: punto window.event.keyCode != 46 && 
// 44: coma
	if (window.event.keyCode == 46){
		window.event.keyCode = 44;
	}
	if (!(window.event.keyCode >= 48 && window.event.keyCode <= 57)){
		if (window.event.keyCode != 44 && window.event.keyCode != 13){
			window.event.keyCode = 0;
		}
	}
}
function cancelarNoNumericoConNegativos(){
// 46: punto window.event.keyCode != 46 && 
// 44: coma
	if (window.event.keyCode == 46){
		window.event.keyCode = 44;
	}
	if (!((window.event.keyCode >= 48 && window.event.keyCode <= 57) || (window.event.keyCode == 45))){
		if (window.event.keyCode != 44 && window.event.keyCode != 13){
			window.event.keyCode = 0;
		}
	}
}


function validarEntrada(a){
	var e = '';
	var re;
				
	e = a;
	re = /</g;
	e = e.replace(re,'< ');
	return e;
}

function locationFila(url){
	if (idDgFila == null){
		alert('Debe Seleccionar una fila');
	}else{
		window.location = url + idDgFila;
	}
}

// para pasar a numero una cadena en formato: "," separador decimal "." separador de miles.
function pasarANumero(cadena){
	var re;
	var num;
	
	num = cadena;
	re = /\,/g;
	num = num.replace(re, '.');
	return (num * 1);
}

// cierro el popup del calendario.
function cierroWinCal(){
	if (winCal){
		winCal.close();
	}
}

// obj: objeto en el que se realiza la validacion
// e: event
// max: longitud maxima
function validarMaxLongitud(obj, e, max) { 
	tecla=(document.all)?e.keyCode:e.which; 
	if(obj.value.length >= max && tecla != 8 && tecla != 37 
		&& tecla != 38 && tecla != 39 && tecla != 40 && tecla != 18 
		&& tecla != 17 && tecla != 16 && tecla != 46) 
	return false;
}

// Inicializa el tamaño de la ventana
// elementId: el id de la tabla que contiene la pagina
function inicializarTamanio(elementId){
	var miTabla = document.getElementById(elementId);
	var w = miTabla.getAttribute('clientWidth') + 20;
	var h = miTabla.getAttribute('clientHeight') + 55;
	if (w > 750){
		w = 750;
	}
	if (h > 550){
		h = 550;
	}
	window.resizeTo(w, h);
	var xleft = screen.width / 2 - w / 2;
	var ytop = screen.height /2 - h / 2 ; 
	window.moveTo(xleft, ytop);
}

function lstPasarEntreLists(fbox, tbox){
	var arrFbox = new Array();
    var arrTbox = new Array();
    var arrLookup = new Array();
    var i;
    for (i = 0; i < tbox.options.length; i++){
        arrLookup[tbox.options[i].text] = tbox.options[i].value;
        arrTbox[i] = tbox.options[i].text;
    }
    var fLength = 0;
    var tLength = arrTbox.length;
    for(i = 0; i < fbox.options.length; i++){
        arrLookup[fbox.options[i].text] = fbox.options[i].value;
        if (fbox.options[i].selected && fbox.options[i].value != ""){
            arrTbox[tLength] = fbox.options[i].text;
            tLength++;
        }else{
            arrFbox[fLength] = fbox.options[i].text;
            fLength++;
        }
    }
    fbox.length = 0;
    tbox.length = 0;
    var c;
    for(c = 0; c < arrFbox.length; c++){
        var no = new Option();
        no.value = arrLookup[arrFbox[c]];
        no.text = arrFbox[c];
        fbox[c] = no;
    }
    for(c = 0; c < arrTbox.length; c++){
        var no = new Option();
        no.value = arrLookup[arrTbox[c]];
        no.text = arrTbox[c];
        tbox[c] = no;
    }
}

function lstPasarEntreListsTodos(oCboOrigen, oCboDestino){
	var iCant = oCboOrigen.length;
	var option;
	for (var iDesde = 0; ( iDesde < iCant); iDesde++){
		option = new Option(oCboOrigen.options[0].text,oCboOrigen.options[0].value);
		oCboDestino.add(option);    
		oCboOrigen.options[0]=null;
	}
	return false ;
}

function lstListarIdItem(oCbo){
	var iCant = oCbo.length ;
	var sLista = '' ;	
	
	for (var iDesde = 0; ( iDesde < iCant); iDesde++){
		if (sLista != ''){
			sLista = sLista + ';';
		}
		sLista = sLista  + oCbo.options[iDesde].text + ',' + oCbo.options[iDesde].value;
	}
	return sLista;
}

function Trim(s) 
{
  // Remove leading spaces and carriage returns
  
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }

  // Remove trailing spaces and carriage returns

  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function FormatDateComp(obj) {
var s="";
if (obj.length == 10)
{
	s=obj.substring(6, 10) + obj.substring(3, 5) + obj.substring(0, 2);
}
if (obj.length == 8)
{
	s="20" + obj.substring(6, 8) + obj.substring(3, 5) + obj.substring(0, 2);
}
return s;
}
function check_date(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = "/";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if ((DateValue == null) || (Trim(DateValue) == '') || (DateValue.length == 0))
   {
	err = 18;
   }
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
      
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   /*if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }*/
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   //alert(field.substr(2,1));
   //alert(field.substr(5,1));
   //alert(seperator);
   if (field.substr(2,1) != seperator  || field.substr(5,1) !=  seperator){
    err = 99;
   }
   if (err == 0) {
		return true;
      //DateField.value = day + seperator + month + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
		return false;
      alert("Fecha incorrecta.");
      //DateField.select();
	  //DateField.focus();
   }
}


function lstListarId(oCbo)
{
	var iCant = oCbo.length ;
	var sLista = '' ;	
	for (var iDesde = 0; ( iDesde < iCant); iDesde++)
		{
			if (sLista == '')
			{
				sLista = oCbo.options[iDesde].value ;
			}
			else
			{
				sLista = sLista  + ',' + oCbo.options[iDesde].value   ;
			}
		}
	return sLista 
}


function SelectAllCheckboxes(spanChk)
{
    
    // Added as ASPX uses SPAN for checkbox 
    var oItem = spanChk.children;
    var theBox=oItem.item(0);
    xState=theBox.checked;    
    

        elm=theBox.form.elements;
        for(i=0;i<elm.length;i++)
        if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
            {
            //elm[i].click();
            if(elm[i].checked!=xState)
            elm[i].click();
            //elm[i].checked=xState;
            }
}



function isCurrency(Plata, Control)
{

	var nNum = 0;			
	var nDollarSign = 0;	
	var nDecimal = 0;		
	var nCommas = 0;		
	var txtLen;			
	var xTxt;			
	var sDollarVal;		
	var bComma;				
	var decPos;			
	var nNumCount = 0;		
	var i;				
	var x;					
	var msgErr = '';
	xTxt = Plata;
	txtLen = xTxt.value.length

	for(i = 0; i < txtLen; i++)
	{
		x = xTxt.value.substr(i, 1);
		if(x == ",")
			nDecimal = nDecimal + 1;
		else if(x == ".")
			nCommas = nCommas + 1;
		else if(parseInt(x) >= 0 || parseInt(x) <= 9)
			nNum = nNum + 1;
		else
		{
			msgErr = msgErr + 'El valor ingresado en ' + Control + ' es  incorrecto.Solo debes ingresar caracteres numericos.\n';
			return msgErr;
		}
	}

	if(nDecimal > 1)
	{
		msgErr = msgErr + 'El valor ingresado en ' + Control + ' no puede  contenar mas de una coma.\n';
		return msgErr;
	}
	if(nDecimal == 1)
	{
		
		decPos = (txtLen - 1) - xTxt.value.indexOf(",");
		if(decPos > 4)
		{
			
			msgErr = msgErr + 'El valor ingresado en ' + Control + ' tiene un punto  decimal en una posición incorrecta.\n';
			return msgErr;
		}
	}
	if(nCommas == 0)
	{
		return true;
	}
	else
	{
		nNum = nNum - decPos;
		sDollarVal = xTxt.value.substr(0, (nNum + nCommas));
		if(sDollarVal.lastIndexOf("0", 0) == 0 )
		{
			msgErr = msgErr + 'El valor ingresado en ' + Control + ' no puede  comenzar con 0.\n';
			return msgErr;
		}
		else if(sDollarVal.lastIndexOf(",", 0) == 0)
		{
			msgErr = msgErr + 'El valor ingresado en ' + Control + ' puede comenzar  con una coma.\n';
			return msgErr;
		}
		else if(sDollarVal.indexOf(",", (sDollarVal.length - 1)) ==  
(sDollarVal.length - 1))
		{
			msgErr = msgErr + 'El valor ingresado en ' + Control + ' no puede  finalizar con una coma.\n';
			return msgErr;
		}
		else
		{
			bComma = false;
			for(i = 0; i < sDollarVal.length; i++)
			{
				x = sDollarVal.substr(i, 1);
				if(parseInt(x) >= 0 || parseInt(x) <= 9)
				{
					nNumCount = nNumCount + 1;
					if(nNumCount > 3)
					{
						msgErr = msgErr + 'El valor ingresado en ' + Control + ' contiene  una coma mal posicionada.\n';
						return msgErr;
					}
				}
				else
				{
					if(nNumCount != 3 && bComma)
					{
						msgErr = msgErr + 'El valor ingresado en ' + Control + ' contiene  una coma mal posicionada.\n';
						return msgErr;
					}
					nNumCount = 0;
					bComma = true;
				}
			}
			if(nNumCount != 3 && bComma)
			{
				msgErr = msgErr + 'El valor ingresado en ' + Control + ' contiene una  coma mal posicionada.\n';
				return msgErr;
			}
		}
	}
}


		function DateFormat(vDateName, vDateValue, e, dateCheck, dateType) 
		{
			try
			{
				vDateType = dateType;
				if (vDateValue == "~") 
				{
					alert("AppVersion = "+navigator.appVersion+" \nNav. 4 Version = "+isNav4+" \nNav. 5 Version = "+isNav5+" \nIE Version = "+isIE4+" \nYear Type = "+vYearType+" \nDate Type = "+vDateType+" \nSeparator = "+strSeperator);
					vDateName.value = "";
					vDateName.focus();
					return true;
				}
				var whichCode = (window.Event) ? e.which : e.keyCode;
				if (vDateValue.length > 8 && isNav4) 
				{
					if ((vDateValue.indexOf("-") >= 1) || (vDateValue.indexOf("/") >= 1))
						return true;
				}
				var alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";
				if (alphaCheck.indexOf(vDateValue) >= 1) 
				{
					if (isNav4) 
					{
						vDateName.value = "";
						vDateName.focus();
						vDateName.select();
						return false;
					}
					else 
					{
						vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
						return false;
					}
				}
				if (whichCode == 8)
					return false;
				else 
				{
					var strCheck = '47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';
					if (strCheck.indexOf(whichCode) != -1) 
					{
						if (isNav4) 
						{
							if (((vDateValue.length < 6 && dateCheck) || (vDateValue.length == 7 && dateCheck)) && (vDateValue.length >=1)) 
							{
								alert("Fecha Inv" + aAcentoVocales[0] + "lida\nPor favor reingrese");
								vDateName.value = "";
								vDateName.focus();
								vDateName.select();
								return false;
							}
							if (vDateValue.length == 6 && dateCheck) 
							{
								var mDay = vDateName.value.substr(2,2);
								var mMonth = vDateName.value.substr(0,2);
								var mYear = vDateName.value.substr(4,4)
								if (mYear.length == 2 && vYearType == 4) 
								{
									var mToday = new Date();
									var checkYear = mToday.getFullYear() + 30; 
									var mCheckYear = '20' + mYear;
									if (mCheckYear >= checkYear)
										mYear = '19' + mYear;
									else
										mYear = '20' + mYear;
								}
								var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
								if (!dateValid(vDateValueCheck)) 
								{
									alert("Fecha Inv" + aAcentoVocales[0] + "lida\nPor favor reingrese");
									vDateName.value = "";
									vDateName.focus();
									vDateName.select();
									return false;
								}
								return true;
							}
							else 
							{
								if (vDateValue.length >= 8  && dateCheck) 
								{
									if (vDateType == 3)
									{
										var mMonth = vDateName.value.substr(2,2);
										var mDay = vDateName.value.substr(0,2);
										var mYear = vDateName.value.substr(4,4)
										vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
									}
									var vDateTypeTemp = vDateType;
									vDateType = 1;
									var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
									if (!dateValid(vDateValueCheck)) 
									{
										alert("Fecha Inv" + aAcentoVocales[0] + "lida\nPlease Re-Enter");
										vDateType = vDateTypeTemp;
										vDateName.value = "";
										vDateName.focus();
										vDateName.select();
										return false;
									}
									vDateType = vDateTypeTemp;
									return true;
								}
								else 
								{
									if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) 
									{
										alert("Fecha Inv" + aAcentoVocales[0] + "lida\nPlease Re-Enter");
										vDateName.value = "";
										vDateName.focus();
										vDateName.select();
										return false;
									}
								}
							}
						}
						else 
						{
							if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) 
							{
								alert("Fecha Inv" + aAcentoVocales[0] + "lida\nPor favor reingrese");
								vDateName.value = "";
								vDateName.focus();
								return true;
							}
							if (vDateValue.length >= 8 && dateCheck) 
							{
								if (vDateType == 3)
								{
									var mDay = vDateName.value.substr(0,2);
									var mMonth = vDateName.value.substr(3,2);
									var mYear = vDateName.value.substr(6,4)
								}
								if (vYearLength == 4) 
								{
									if (mYear.length < 4) 
									{
										alert("Fecha Inv" + aAcentoVocales[0] + "lida\nPlease Re-Enter");
										vDateName.value = "";
										vDateName.focus();
										return true;
									}
								}
								var vDateTypeTemp = vDateType;
								vDateType = 1;
								var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
								if (mYear.length == 2 && vYearType == 4 && dateCheck) 
								{
								var mToday = new Date();
								var checkYear = mToday.getFullYear() + 30; 
								var mCheckYear = '20' + mYear;
								if (mCheckYear >= checkYear)
									mYear = '19' + mYear;
								else
									mYear = '20' + mYear;
								vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
								if (vDateTypeTemp == 3)
									vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
							} 
							if (!dateValid(vDateValueCheck)) 
							{
								alert("Fecha Inv" + aAcentoVocales[0] + "lida\nPor favor reingrese");
								vDateType = vDateTypeTemp;
								vDateName.value = "";
								vDateName.focus();
								return true;
							}
							vDateType = vDateTypeTemp;
							return true;
						}
						else 
						{
							if (vDateType == 3) 
							{
								if (vDateValue.length == 2) 
								{
									vDateName.value = vDateValue+strSeperator;
								}
								if (vDateValue.length == 5) 
								{
									vDateName.value = vDateValue+strSeperator;
								}
							}		
							return true;
						}
					}
					if (vDateValue.length == 10&& dateCheck) 
					{
						if (!dateValid(vDateName)) 
						{
							alert("Fecha Inv" + aAcentoVocales[0] + "lida\nPor favor reingrese");
							vDateName.focus();
							vDateName.select();
						}
					}
					return false;
				}
				else
				{
					if (isNav4) 
					{
						vDateName.value = "";
						vDateName.focus();
						vDateName.select();
						return false;
					}
					else
					{
						vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
						return false;
					}
				}
			}
			}
			catch(e)
			{
				showErr(e);
			}
		}
		
		


