function obtenerlargopagina () 
{
	var scnWid,scnHei;
	if (self.innerHeight) // all except Explorer
	{
		scnWid = self.innerWidth;
		scnHei = self.innerHeight - 205;
		if (scnHei <= 0)
		  scnHei = 1;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		scnWid = document.documentElement.clientWidth;
		scnHei = document.documentElement.clientHeight - 230;
		if (scnHei <= 0)
		  scnHei = 1;
		//alert(scnWid + " " + scnHei);
	}
	else if (document.body) // other Explorers
	{
		scnWid = document.body.clientWidth;
		scnHei = document.body.clientHeight - 205;
		if (scnHei <= 0)
		  scnHei = 1;
	}
   return(scnHei + 'px');
}


function formatoFecha(nombre)
{
    var texto = document.getElementById(nombre).value;
    var keynum;
    if(window.event)
    {
        e = window.event;
        keynum = e.keyCode
    }
    else if(e.which)
    {
        keynum = e.which
    }

    //alert(keynum);
    if ((keynum <= 105 && keynum >= 96)|| (keynum <= 57 && keynum >= 48))
    {
        /*if (texto.length == 2) La forma antigua
        {
            document.getElementById(nombre).value=document.getElementById(nombre).value+"/";
        }
        if (texto.length == 5)
        {
            document.getElementById(nombre).value=document.getElementById(nombre).value+"/";
        }*/
        var texto2="";
        if (texto.charAt(2) != '/')
        {
            texto2="";
            for (x=0;x<=texto.length-1;x++)
            {
                if (x == 2)
                    texto2=texto2+'/';
                texto2=texto2+texto.charAt(x);
            }
        }
        
        if (texto2 != "")
            texto=texto2;
            
        if (texto.charAt(5) != '/')
        {
            texto2="";
            for (x=0;x<=texto.length-1;x++)
            {
                if (x == 5)
                    texto2=texto2+'/';
                texto2=texto2+texto.charAt(x);
            }
        }
        if (texto2 != "")
        {
            texto=texto2.split('/');
            if (texto.length >= 3)
            {
                texto="";
                for(x=0;x<=texto2.length-1;x++)
                {
                    if ((texto2.charAt(x)=='/') && (x != 2) && (x != 5))
                    {
                        texto+='0';
                    }
                    else
                    {
                        texto+=texto2.charAt(x);
                    }
                }
                texto2=texto;
            }
            document.getElementById(nombre).value=texto2;
        }
    }
    else
    {   
        if ((keynum == 8)||(keynum >= 37 && keynum <=40)||(keynum == 13 || keynum ==9 || keynum==17 || keynum==46 || keynum==16 || keynum==20))
        {}
        else
            DatosValidosFecha(nombre)
    }
}

function DatosValidosFecha(nombre)
{
    var texto = document.getElementById(nombre).value;
    var texto2="";
    for (x=0;x<=texto.length-1;x++)
    {
        if ((texto.charAt(x) >= 0 && texto.charAt(x)<=9)||(texto.charAt(x)=="/"))
            texto2=texto2+texto.charAt(x);
    }
    document.getElementById(nombre).value=texto2;
}

function SistemaOperativo() 
{
    if (navigator.userAgent.indexOf('IRIX') != -1) {var SO = "Irix" }
    else if ((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('98') != -1)) {var SO= "Windows 98"}
    else if ((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('95') != -1)) {var SO= "Windows 95"}
    else if (navigator.appVersion.indexOf("16") !=-1) {var SO= "Windows 3.1"}
    else if (navigator.userAgent.indexOf("NT 5.1") !=-1) {var SO= "Windows XP"}
    else if (navigator.userAgent.indexOf("NT 5.2") !=-1) {var SO= "Windows Server 2003"}
    else if (navigator.userAgent.indexOf("NT 5") !=-1) {var SO= "Windows 2000"}
    else if (navigator.userAgent.indexOf("NT 6") !=-1) {var SO= "Windows Vista"}
    else if (navigator.appVersion.indexOf("NT") !=-1) {var SO= "Windows NT"}
    else if (navigator.appVersion.indexOf("SunOS") !=-1) {var SO= "SunOS"}
    else if (navigator.appVersion.indexOf("Linux") !=-1) {var SO= "Linux"}
    else if (navigator.userAgent.indexOf('Mac') != -1) {var SO= "Macintosh"}
    else if (navigator.appName=="WebTV Internet Terminal") {var SO="WebTV"}
    else if (navigator.appVersion.indexOf("HP") !=-1) {var SO="HP-UX"}
    else {var SO= "No identificado"}
    return SO;
}

function informacion_navegador()
{
    this.nombre = navigator.appName;
    this.version = navigator.appVersion.substring(22,25);
}

function AdobeReader()
{
    this.installed=false;
    this.version='0.0';

    if (navigator.plugins && navigator.plugins.length)
    {
        for ( var x = 0, l = navigator.plugins.length; x < l; ++x )
        {
            if (navigator.plugins[x].description.indexOf('Adobe Acrobat') != -1)
            {
                this.version=parseFloat(navigator.plugins[x].description.split('Version ')[1]);
                if (this.version.toString().length == 1) 
                    this.version+='.0';
                this.installed=true;
                break;
            }
        }
    }
    else 
    if (window.ActiveXObject)
    {
        for (x=2; x<10; x++)
        {
            try
            {
                oAcro=eval("new ActiveXObject('PDF.PdfCtrl."+x+"');");
                if (oAcro)
                {
                    this.installed=true;
                    this.version=x+'.0';
                }
            }
            catch(e) {}
        }
        try
        {
            oAcro4=new ActiveXObject('PDF.PdfCtrl.1');
            if (oAcro4)
            {
                this.installed=true;
                this.version='4.0';
            }
        }
        catch(e) {}
        try
        {
            oAcro7=new ActiveXObject('AcroPDF.PDF.1');
            if (oAcro7)
            {
                this.installed=true;
                this.version='7.0';
            }
        }
        catch(e) {}
    }
}
/// Requerido para poder realizar el filtro dentro de los select en ie6
var timerLetra=null;
var letras="";

function limpiarTimer()
{
    clearTimeout(timerLetra);
    letras="";
}

function FiltroSelect(evt,elem)
{
    var navegador = new informacion_navegador();
    var keynum;
    if(window.event)    
    {
        e = window.event;
        keynum = e.keyCode
    }
    else if(e.which)
    {
        keynum = e.which
    }
    
    if (navegador.version <= 7)
    {
        clearTimeout(timerLetra);
        
        var select=document.getElementById(elem.id);        
        if ((keynum != 38) && (keynum != 40) && (keynum != 9) && (keynum != 13))
        {
            if (((keynum >= 48) && (keynum <= 57)) || ((keynum >= 65) && (keynum <= 90)))
            {
                letras+=String.fromCharCode(keynum);
                letras=letras.toUpperCase();
                var x=0;
                for (x=0;x<=select.options.length-1;x++)
                {
                    var textoOption=select.options[x].text.toUpperCase();
                    if (textoOption.indexOf(letras) == 0)
                    {
                        select.selectedIndex=select.options[x].index;
                        break;
                    }
                }
                timerLetra = setTimeout("limpiarTimer()", 700)
                return false;
            }
        }
        else if ((keynum == 13))
        {
            if (select.onchange)
                select.onchange();
                
            if ((select.onkeypress)&&(evt.type!='keypress'))
                select.onkeypress();
                
            if ((select.onkeydown)&&(evt.type!='keydown'))
                select.onkeydown();
                
            if ((select.onkeyup)&&(evt.type!='keyup'))
                select.onkeyup();
            
            return false; 
        }
        else if ((keynum == 9))
        {
            if (select.onchange)
                select.onchange();
                
            if ((select.onkeypress)&&(evt.type!='keypress'))
                select.onkeypress();
                
            return true;
        }
        else
        { 
            return true; 
        }
    }
    else
    {
        return true;
    }
}

function getPath(archivo)
{
    //Devuelve la ruta con el archivo teniendo que estar el archivo en la misma carpeta que la pagina 
    var path= window.location.href;
    path=path.split("/");
    var x=0;
    var txtfinal="";
    for (x=0;x<=path.length-2;x++)
    {
        txtfinal+=path[x]+'/';
    }
    return txtfinal+=archivo;
}

function SetCombo2(elem)
{
    ShowLoading();
    var delay = function() { SetCombo2(elem); };
	setTimeout(delay,10);
}
var xmlhttp;
function SetCombo(elem)
{
    var combo ="";
    var archivo="";
    var comparacion="";
    if (elem.id=='EstadoMadre')
    {
        combo = "MunicipioMadre"
        archivo="Xml/Municipios-"+elem.value+".xml";
        comparacion=elem.value;
    }
    else if (elem.id=='EstadoRes')
    {
        combo = "MunicipioRes"
        archivo="Xml/Municipios-"+elem.value+".xml";
        comparacion=elem.value;
    }
    else if (elem.id=='MunicipioRes')
    {
        combo = "LocalidadRes"
        archivo="Xml/Localidades-"+document.getElementById('EstadoRes').value+"-"+elem.value+".xml";
        comparacion=document.getElementById('EstadoRes').value;
    }
    else if (elem.id=='EstadoCert')
    {
        combo = "MunicipioCert"
        archivo="Xml/Municipios-"+elem.value+".xml";
        comparacion=elem.value;
    }
    else if (elem.id=='MunicipioCert')
    {
        combo = "LocalidadCert"
        archivo="Xml/Localidades-"+document.getElementById('EstadoCert').value+"-"+elem.value+".xml";
        comparacion=document.getElementById('EstadoCert').value;
    }
    else if (elem.id=='NUnidad')
    {
        combo = "Unidad"
        archivo="Xml/Unidades.xml";
    }
    else if (elem.id=='Unidad')
    {
        combo = "NUnidad"
        archivo="Xml/Unidades.xml";
    }
    else if (elem.id=="Cedula")
    {
        combo = "Cedula";
        archivo="Xml/Cedulas.xml";
        comparacion=elem.value;
    }

    if (combo!="")
    {
        var RutaArchivo = getPath(archivo);
        
        if (elem.id!="Cedula")
        {
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            xmlhttp.open("GET",RutaArchivo,false);
            //xmlhttp.setRequestHeader("Pragma", "cache" );
            xmlhttp.send(null);
            xmlObj=xmlhttp.responseXML.documentElement;
        }
        else
        {
            //var RutaArchivo = getPath(archivo); asi estaba antes de lo nuevo
            var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
            xmlDoc.async="false";
            xmlDoc.load(RutaArchivo);
            xmlObj=xmlDoc.documentElement;
        }
        if (xmlObj != null)
        {
            if ((combo != 'NUnidad') && (combo != 'Unidad'))
            {
                if (combo=="Cedula") // Para cuando se cambie la Cedula
                {
                    combo=elem;
                    var CedulaEncontrada=0;
                    xmlObj2=xmlDoc.documentElement; 
                    //xmlObj2=xmlhttp.responseXML.documentElement;
                    for (var x = xmlObj2.childNodes.length-1 ; x >= 0; x--) 
                    {
                        if (xmlObj2.childNodes(x).getAttribute("CEDULA")==comparacion)
                        {
                          if ((document.getElementById("unidadOculto").value == "")||(document.getElementById("unidadOculto").value == "0"))
                          {
                            document.getElementById("NombreC").value =          xmlObj2.childNodes(x).childNodes(0).firstChild.text;
                            document.getElementById("TAppC").value =            xmlObj2.childNodes(x).childNodes(5).firstChild.text;
                            document.getElementById("TApmC").value =            xmlObj2.childNodes(x).childNodes(6).firstChild.text;
                            document.getElementById("MunicipioCert").value =    xmlObj2.childNodes(x).childNodes(1).firstChild.text;
                            document.getElementById("MunicipioCert").onblur();
                            document.getElementById("LocalidadCert").value =    xmlObj2.childNodes(x).childNodes(2).firstChild.text;
                            document.getElementById("CalleCert").value =        xmlObj2.childNodes(x).childNodes(3).firstChild.text;
                            document.getElementById("TelefonoCert").value =     xmlObj2.childNodes(x).childNodes(4).firstChild.text;
                            CedulaEncontrada=1;
                          }
                          break;
                        }
                    }
                    if (CedulaEncontrada==0)
                    {
                        document.getElementById("NombreC").value =          '';
                        document.getElementById("TAppC").value =            '';
                        document.getElementById("TApmC").value =            '';
                        //document.getElementById("EstadoCert").value =       '1';
                        //document.getElementById("MunicipioCert").value =    '';
                        document.getElementById("LocalidadCert").value =    '';
                        document.getElementById("CalleCert").value =        '';
                        document.getElementById("TelefonoCert").value =     '';
                        document.getElementById("NombreC").focus();
                    }
                    else
                    {
                        document.getElementById("FechaCert").focus();
                    }
                }
                else // Para los combos de municipio y localidades
                {
                    combo = document.getElementById(combo);
                    BorrarElementosCombo(combo);
                    var estado=null;
                    var indexSelect=null;
                    
                    if (elem.id=='MunicipioRes')
                    {
                        estado=document.getElementById('EstadoRes');
                    }
                    else if (elem.id=='MunicipioCert')
                    {
                        estado=document.getElementById('EstadoCert');
                    }
                    
                    for (var x = xmlObj.childNodes.length-1 ; x >= 0; x--) 
                    {
                        if (xmlObj.childNodes(x).getAttribute("IDESTADO")==comparacion)
                        {
                            var tr = document.createElement('OPTION');
		                    combo.options.add(tr);
		                    tr.innerText = xmlObj.childNodes(x).childNodes(1).firstChild.text;
		                    tr.value = xmlObj.childNodes(x).childNodes(0).firstChild.text;
		                    
		                    if (estado != null)
		                    {
		                        if (elem.value== 1 && estado.value==1 && xmlObj.childNodes(x).childNodes(0).firstChild.text == '1' )
                                {
                                    indexSelect=((xmlObj.childNodes.length-1)-x);
                                }
                            }
                        }
                    }
                    
                    if (indexSelect != null)
                    {
                        combo.selectedIndex = indexSelect;    
                    }
                }     
            }
            else // Para cuando es unidades el que se cambio
            {
                var unidad = document.getElementById('Unidad');
                if (unidad.options.length==0)
                {
                    for (var x = xmlObj.childNodes.length-1 ; x >= 0; x--) 
                    {
                        var tr = document.createElement('OPTION');
                        unidad.options.add(tr);
		                tr.innerText = xmlObj.childNodes(x).childNodes(0).firstChild.text;
		                tr.value = xmlObj.childNodes(x).getAttribute("IDUNIDAD");
                    }   
                }
            
                var Calle_Nac = document.getElementById('Calle_Nac');
                var Mpo_Nac = document.getElementById('Mpo_Nac');
                var Loc_Nac = document.getElementById('Loc_Nac');
                var Ent_Nac = document.getElementById('Ent_Nac');
                //var txtCalle_Nac = document.getElementById('txtCalle_Nac');
            
                BorrarElementosCombo(Calle_Nac);
                BorrarElementosCombo(Mpo_Nac);
                BorrarElementosCombo(Loc_Nac);
                BorrarElementosCombo(Ent_Nac);
                
                for (var x = xmlObj.childNodes.length-1 ; x >= 0; x--) 
                {
                    if (xmlObj.childNodes(x).getAttribute("IDUNIDAD")==elem.value)
                    {
                        try
                        {
                            var tr = document.createElement('OPTION');
                            Calle_Nac.options.add(tr);
		                    tr.innerText = xmlObj.childNodes(x).childNodes(7).firstChild.text;
		                    tr.value = xmlObj.childNodes(x).childNodes(7).firstChild.text;
		                    tr.selected = true;
        		            
		                    //txtCalle_Nac.value = xmlObj.childNodes(x).childNodes(7).firstChild.text;
        		            
		                    var tr = document.createElement('OPTION');
		                    Mpo_Nac.options.add(tr);
		                    tr.innerText = xmlObj.childNodes(x).childNodes(4).firstChild.text;
		                    tr.value = xmlObj.childNodes(x).childNodes(3).firstChild.text;
		                    tr.selected = true;
        		            
		                    var tr = document.createElement('OPTION');
		                    Loc_Nac.options.add(tr);
		                    tr.innerText = xmlObj.childNodes(x).childNodes(6).firstChild.text;
		                    tr.value = xmlObj.childNodes(x).childNodes(5).firstChild.text;
		                    tr.selected = true;
        		            
		                    var tr = document.createElement('OPTION');
		                    Ent_Nac.options.add(tr);
		                    tr.innerText = xmlObj.childNodes(x).childNodes(2).firstChild.text;
		                    tr.value = xmlObj.childNodes(x).childNodes(1).firstChild.text;
		                    tr.selected = true;
		                }
		                catch (err)
		                {}
                        
                        break;
                    }
                }
                combo=unidad;
            }
        }
        LlenarHide(combo.id);
    }
}

function BorrarElementosCombo(combo)
{
    if (combo.options)
    {
        for(i=combo.options.length-1 ; i>=0 ; i--)
        {
            combo.remove(i);
        }
    }
}

function SetOptionOnSelect(select,valor)
{
    if (select.options)
    {
        for(i=select.options.length-1 ; i>=0 ; i--)
        {
            if (select.options[i].value==valor)
            {
                select.options[i].selected;
                select.selectedIndex =i;
                break
            }
        }
    }
}
function validaDatosNacimiento(tipo)
{   
    if (tipo == 2)
    {
        var estado = document.getElementById('EstadoMadre').value;
        if (estado > 32)
        {
            document.getElementById('NCurp').value = "";
        }
        else
        {
            var curp = document.getElementById('NCurp').value;
            if (curp == "" || curp.length != 18)
            {
                if (DameCampoGet("opcion") == 1)
                {
                    alert("El campo curp esta incorrecto, no puede ser vacio ni tener una longitud menor de 18 caracteres");
                    document.getElementById('NCurp').focus;
                    return false;
                }
            }
            
            if(!CurpIgual(document.getElementById('Nombre').value, document.getElementById('TApp').value, document.getElementById('TApm').value, document.getElementById('NFechaMadre').value, document.getElementById('EstadoMadre').value, "M", document.getElementById('NCurp').value))
            {
                alert("La curp no concuerda con los datos ingresados");
                return false;
            }
        }

        var dia =  document.getElementById('NFechaMadre').value.split("/")[0];
        var mes =  document.getElementById('NFechaMadre').value.split("/")[1];
        var anno = document.getElementById('NFechaMadre').value.split("/")[2];
        var anno = parseInt(anno,10) + 12;
        var fechaMadre = new Date(anno+"/"+mes+"/"+dia);
        
        
        var fechaServer = document.getElementById('FechaServer').value.substring(0,10).split('/');
        fechaServer = new Date(fechaServer[2]+"/"+fechaServer[1]+"/"+fechaServer[0]);
        
        if (fechaMadre > fechaServer)
        {
            alert("La fecha de nacimiento de la madre no es correcta favor de verificarla");
            document.getElementById('NFechaMadre').focus;
            return false;
        }
    }
    if (tipo == 1)
        { abo = document.getElementById('NAbortos').value;
          mue = document.getElementById('NMuertos').value;
            if (parseInt(abo,"10") > parseInt(mue,"10"))
            {
                window.alert("Valor fuera de rango (no puede haber mas Abortos que Nacidos Muertos)");
	            document.getElementById('NAbortos').value = '';
	            document.getElementById('NAbortos').focus();
	            return false;
            }
        }    
    if ((document.getElementById('NEmb').value != '') &&
    (document.getElementById('NMuertos').value != '') &&
    (document.getElementById('NOrden').value != '') &&
    (document.getElementById('NVivos').value != ''))
    {
        emb = document.getElementById('NEmb').value;
        mue = document.getElementById('NMuertos').value;
        viv = document.getElementById('NVivos').value;
        ant = document.getElementById('HAnterior').value;
        ord = document.getElementById('NOrden').value; 
        error = false;
            
        var ordenValido = parseInt(mue,"10")+parseInt(viv,"10");
        
        if (ord != ordenValido)
        {
            window.alert("El Orden de Nacimiento o el numero de Nacidos Muertos esta fuera de rango");
	        document.getElementById('NMuertos').value = "";
	        document.getElementById('NMuertos').focus();
	        return false;
        }
        else
	    {
	        if ((emb - mue) < 1) 
            { inicia = 1; }
            else { inicia = emb - mue; }
          
            if ((document.getElementById('NVivos').value < inicia)||(document.getElementById('NVivos').value > 25))
            {
                window.alert('El numero de Nacidos Vivos esta fuera de rango');
                document.getElementById('NVivos').value = "";
                document.getElementById('NVivos').focus();
                return false;
            }
            else if ((mue == 0)&&(ant == 2))
            {
                alert('Valor fuera de rango (no hay nacidos muertos)');
                document.getElementById('HAnterior').value = '';
                document.getElementById('HAnterior').focus();
                asignaRadio('HAnterior', 'RAnterior', 4);
                return false;
            }
            else if ((mue == 1)&&(viv == 1)&&(ant != 2))
            {
                alert('Valor fuera de rango (el anterior nacio muerto)');
                document.getElementById('HAnterior').value = '2';
                document.getElementById('HAnterior').focus();
                asignaRadio('HAnterior', 'RAnterior', 4);
                return false;
            }
            else if ((emb == 1)&&(viv == 1)&&(mue == 0)&&(ant != 3))
            {
                 alert('Valor fuera de rango (no ha tenido mas hijos)');                  
                 document.getElementById('HAnterior').value = '3';
                 document.getElementById('HAnterior').focus();
                 asignaRadio('HAnterior', 'RAnterior', 4);
                 return false;
            }   
            else if ((parseInt(viv,"10")+parseInt(mue,"10") > 1)&&(ant == 3))
            {
                 alert('Valor fuera de rango (si ha tenido mas hijos)');                  
                 document.getElementById('HAnterior').value = '';
                 document.getElementById('HAnterior').focus();
                 asignaRadio('HAnterior', 'RAnterior', 4);
                 return false;
            }  
            else
            {   
                return true;
            }  
	        
	    }
    }
}

function pasarListToHideCedula()
{
    var Cedula = document.getElementById("Cedula").value;
    var NombreC = document.getElementById("NombreC").value;
    var TAppC = document.getElementById("TAppC").value;
    var TApmC = document.getElementById("TApmC").value;
    var EstadoCert = document.getElementById("EstadoCert").value;
    var MunicipioCert = document.getElementById("MunicipioCert").value;
    var LocalidadCert = document.getElementById("LocalidadCert").value;
    var CalleCert = document.getElementById("CalleCert").value;
    var TelefonoCert = document.getElementById("TelefonoCert").value;
    document.getElementById("listBoxCedula").value= Cedula +"-"+ NombreC +"-"+ TAppC +"-"+ TApmC +"-"+ EstadoCert +"-"+ MunicipioCert +"-"+ LocalidadCert +"-"+ CalleCert +"-"+ TelefonoCert
}

function pasarListToHide(elem,elemRespaldo)
{
    if (elem.options.length >0 )
    {
        var optionsList = '';
        for (var i=0; i<elem.options.length; i++)
        {
            var optionText = elem.options[i].text;
            var optionValue = elem.options[i].value;
      
            if ( optionsList.length > 0 )
                optionsList += ';';
      
            if (elem.options[i].selected)
                optionsList += optionText + ':' + optionValue + ':' + 'selected';
            else
                optionsList += optionText + ':' + optionValue;
        }
        elemRespaldo.value = optionsList;
    }
}

function LlenarHide(Modificado)
{
    if (Modificado=='MunicipioMadre')
        pasarListToHide(document.getElementById('MunicipioMadre'),document.getElementById('listBoxMunicipioMadre'));
    else if (Modificado=='MunicipioRes')
        pasarListToHide(document.getElementById('MunicipioRes'),document.getElementById('listBoxMunicipioRes'));
    else if (Modificado=='LocalidadRes')
        pasarListToHide(document.getElementById('LocalidadRes'),document.getElementById('listBoxLocalidadRes'));
    else if (Modificado=='Unidad')
    {
        document.getElementById('listBoxNUnidad').value=document.getElementById('NUnidad').value;
        pasarListToHide(document.getElementById('Unidad'),document.getElementById('listBoxUnidad'));
        pasarListToHide(document.getElementById('Calle_Nac'),document.getElementById('listBoxCalle_Nac'));
        pasarListToHide(document.getElementById('Mpo_Nac'),document.getElementById('listBoxMpo_Nac'));
        pasarListToHide(document.getElementById('Loc_Nac'),document.getElementById('listBoxLoc_Nac'));
        pasarListToHide(document.getElementById('Ent_Nac'),document.getElementById('listBoxEnt_Nac'));
    }
    else if (Modificado=='MunicipioCert')        
        pasarListToHide(document.getElementById('MunicipioCert'),document.getElementById('listBoxMunicipioCert'));
    else if (Modificado=='LocalidadCert')        
        pasarListToHide(document.getElementById('LocalidadCert'),document.getElementById('listBoxLocalidadCert'));
    else if (Modificado=='Cedula')
        pasarListToHideCedula();
}

function KeypressPunto13Federal(elem)
{
    var keynum;
    if(window.event)    
    {
        e = window.event;
        keynum = e.keyCode
    }
    else if(e.which)
    {
        keynum = e.which
    }
    
    if ((keynum == 13)||(keynum == 9))
    {
        if((elem.value == '1') || (elem.value == '9'))
        {
            document.getElementById('NEscolar').focus();
        }
        else
        {
            document.getElementById('Afiliacion').focus();
        }
        return false;
    }
    else
    {return true;}
}

function CargarUnidad(tipo)
{
    if (tipo==1)
    {
        if (document.getElementById('NUnidad').value != '')
        {
            asignaCombo('NUnidad','Unidad'); 
            SetCombo(document.getElementById('NUnidad'));
        }
    }
}

function savefile()
{
    try
    {
//        var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
//        xmlDoc.async="false";
//        xmlDoc.loadXml("C:\\WINDOWS\\Cernac\\VersionXml.xml");
//        xmlObj=xmlDoc.documentElement; 
//        
//        if (xmlObj == null)
//        {
            var fso = new ActiveXObject("Scripting.FileSystemObject");
            folderBool = fso.FolderExists("C:\\WINDOWS\\Cernac");
            if (folderBool == false)
            {
                var newFolderName = fso.CreateFolder("C:\\WINDOWS\\Cernac");
                alert("Se creo la carpeta");
            }
//            alert("Se generarian los xml");
//        }
//        else
//        {
//            alert("Estarian Generados los xml ya se pueden usar");
//        }
    }
    catch (err)
    {
            alert('Error : '+err.description);
    }
}

function ShowLoading()
{
    var form = document.getElementById('form1');
    if (form!=null)
    {
        var newdiv = document.getElementById('divCargando');
        if (newdiv == null)
        {
            newdiv = document.createElement('div');
            newdiv.setAttribute('id','divCargando');
            newdiv.innerHTML = ' Cargando ... ';
            newdiv.style.position= 'absolute';
            //newdiv.style.z-index= '105';
            
            form.appendChild(newdiv);
        }
        
        var scrOfX = 0, scrOfY = 0, myWidth = 0 , myHeight = 0;
        if( typeof( window.pageYOffset ) == 'number' ) {
	        //Netscape compliant
	        scrOfY = window.pageYOffset;
	        scrOfX = window.pageXOffset;
	        myWidth = window.innerWidth;
            myHeight = window.innerHeight;
        } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
	        //DOM compliant
	        scrOfY = document.body.scrollTop;
	        scrOfX = document.body.scrollLeft;
	        myWidth = document.body.clientWidth;
            myHeight = document.body.clientHeight;
        } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
	        //IE6 standards compliant mode
	        scrOfY = document.documentElement.scrollTop;
	        scrOfX = document.documentElement.scrollLeft;
	        myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
        }

        document.body.style.cursor='wait';
        newdiv.style.display = 'block';
        newdiv.style.right= ((scrOfX+myWidth)-10)+'px';
        newdiv.style.top= (((scrOfY+myHeight)/2)-10)+'px';
    }
}

function OcultarLoading()
{
    var div = document.getElementById('divCargando');
    if (div != null)
    {
        div.style.display = 'none';
	    document.body.style.cursor='default';
    }
}

function ValidarHora(elem,blur)
{
    var texto2="";
    
    if (elem.value.indexOf(":")==-1)
    {
        if (elem.value.charAt(2) != ':')
        {
            texto2="";
            for (x=0;x<=elem.value.length-1;x++)
            {
                if (x == 2)
                    texto2=texto2+':';
                texto2=texto2+elem.value.charAt(x);
            }
        }
    }
    else
    {
        //var texto3=elem.value.split(':');
        //texto3
        /*if (elem.value.charAt(2) != ':')
        {
            for (x=0;x<=elem.value.length-1;x++)
            {
                if (elem.value.charAt(x) != ':')
                    texto2=texto2+elem.value.charAt(x);
                if (x == 2)
                    texto2=texto2+':';
            }
        }*/
    }
    
    if (texto2 != "")
        elem.value=texto2;
        
    if (blur == 1)
    {
        var texto=elem.value.split(':');
        var error="";
        
        if ((texto[0].length != 2) || (texto[1].length != 2))
        {
            if (error=="")
                error="El formato de la hora tiene que ser de 24hrs 00:01";
        }
        
        var numeros="1234567890"
        for (x=0;x<=elem.value.length-1;x++)
        {
            if (x!=2)
            {
                if (numeros.indexOf(elem.value.charAt(x))==-1)
                {
                    if (error=="")
                        error="!!!Solo se permiten numeros!!!";
                    break;
                }
            }
        }
        
        if ((texto[0] < 00) || (texto[0] > 23))
        {
            if (error=="")
                error="La hora solo se puede desde 00-23";
        }
        
        if ((texto[1] < 00) || (texto[1] > 59))
        {
            if (error=="")
                error="Los minutos solo se puede desde 00-59";
        }
        
        if (error!="")
        {
            alert(error);
            elem.focus();
        }
    }
}

if (parent.document.getElementById("SessionTimeoutOculto"))
{
    parent.document.getElementById("SessionTimeoutOculto").click();
}

function DameCampoGet(name)
{
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( window.location.href );
    if (results == null)
        return "";
    else
        return results[1];
}
