// JavaScript Document 
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr;for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document;if(d.images){if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments;for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){d.MM_p[j]=new Image;d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x;if(!d) d=document;if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n];for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n);return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments;document.MM_sr=new Array;for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x;if(!x.oSrc) x.oSrc=x.src;x.src=a[i+2];}
}
/*INICIA VALIDACION F5*/

var asciiF5 = 116;

function interceptKeyDown(e) {
    keyCode = e.keyCode;
    if( keyCode == asciiF5) {
        e.keyCode = 505;
        return false;
    }
   return true;
}

attachEventListener(document,"keydown",interceptKeyDown,true);

function interceptKeyPress(e) {
    if( !e ) {
        if( window.event ) e = window.event;
        else return;
    }

    //NS 4, NS 6+, Mozilla 0.9+, Opera
    if( typeof( e.which ) == 'number' ) {
        var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : void 0;
        if(e.charCode == null || e.charCode == 0 ){
            if( keyCode == asciiF5) {
                e.stopPropagation();
                e.preventDefault();
            }
        }

    }
}

attachEventListener(document,"keypress",interceptKeyPress,true);

function attachEventListener( obj, type, func, capture ) {
    if(window.addEventListener){ // Mozilla, Netscape, Firefox
        obj.addEventListener( type, func, capture );
    } else { // IE
        obj.attachEvent( 'on' + type, func );
    }
}

/*TERMINA VALIDACION F5*/


/*************Funciones predeterminadas validas para varios navegadores**********************/
function soloNumeros(e){
    caracter = (document.all) ? e.keyCode : e.which;

    if (caracter>=48&&caracter<=57)//numeros
        return true;
    if(caracter==9||caracter==11||caracter==0||caracter==8)
        return true;
   return false;
}

function soloEmail(e){
     caracter = (document.all) ? e.keyCode : e.which;

    if (caracter>=97&&caracter<=122) //minusculas
        return true;
    if (caracter>=65&&caracter<=90)//mayusculas
        return true;
    if (caracter>=48&&caracter<=57) //numeros
        return true;
    if  (caracter==95||caracter==45||caracter==46||caracter==8||
        caracter==64||caracter==9||caracter==11||caracter==0)
       return true;

   return false;
}

function soloTexto(e){
    caracter = (document.all) ? e.keyCode : e.which;

    if (caracter>=97&&caracter<=122) //minusculas
        return true;
    if (caracter>=65&&caracter<=90)//mayusculas
        return true;
    if(caracter==32||caracter==9||caracter==11||caracter==0||caracter==8)
        return true;

   return false;
}

function soloComentarios(e){
    caracter = (document.all) ? e.keyCode : e.which;

    if (caracter>=97&&caracter<=122) //minusculas
        return true;
    if (caracter>=65&&caracter<=90)//mayusculas
        return true;
    if (caracter>=48&&caracter<=57) //numeros
        return true;
    if (caracter!=34&&caracter!=39)
        return true;
     if(caracter==32||caracter==9||caracter==11||caracter==0||caracter==8)
        return true;

    return false;
}

function soloCalleNumero(e){
    caracter = (document.all) ? e.keyCode : e.which;

    if (caracter>=97&&caracter<=122) //minusculas
        return true;
    if (caracter>=65&&caracter<=90)//mayusculas
        return true;
    if (caracter>=48&&caracter<=57) //numeros
        return true;
    if (caracter==35)
        return true;
    if (caracter==32||caracter==9||caracter==11||caracter==0||caracter==8)
        return true;

    return false;
}

function soloFechas(e){

    caracter = (document.all) ? e.keyCode : e.which;

    if (caracter>=48&&caracter<=57) //numeros
        return true;
    if (caracter==47)
        return true;
    if(caracter==9||caracter==11||caracter==0||caracter==8)
        return true;

    return false;
}

function validaNumeros(numero){
    var filtro=/^([0-9])*$/;

    if(!filtro.test(numero))
         return false;

    return true;
}

function validaFecha(fecha){
   var filtro = /^([0][1-9]|[12][0-9]|3[01])(\/)(0[1-9]|1[012])\2(\d{4})$/;
   
   if(!filtro.test(fecha))
       return false;

   return true;
}

/***********************Funciones predeterminadas*******************************************/


function mayuscula(caracter)
{
                var caracter_m=caracter.toUpperCase();
                return caracter_m;
}

function correo(caracter)
{  

        if (letra(caracter)==true || numero(caracter)==true) //letras y numeros
                return true;
        if(caracter == 64 || caracter == 46 || caracter == 95 || caracter == 45) // @  .  _  -
                return true
        return false;	
}	
function trim(caracter)
{var lon = caracter.length;
        var x = 0;
                var cad_temp = '';
                while(x<lon)
                        {

                                if(caracter.charCodeAt(x) != 13 && caracter.charCodeAt(x) != 10)
                                        {
                                        cad_temp = cad_temp+caracter.charAt(x);

                                        }
                                x++;
                        }

                return cad_temp;
}
function letra(caracter)
{
        if (caracter>=97&&caracter<=122) //minusculas
                return true;
        if (caracter>=65&&caracter<=90)//mayusculas
                return true;
        return false;	
}	
function numero(caracter)
{

        if (caracter>=48&&caracter<=57) //numeros
                return true;
        return false;	
}	
function textoynum(caracter)
{
        if (letra(caracter)==true || numero(caracter)==true) //letras y numeros
                return true;
        if (caracter==32||caracter==209||caracter==241||caracter==225||caracter==233||caracter==237||caracter==243||caracter==250||caracter==46)
                return true;

        return false;	
}		
function show(object,object2,object3) 
{

if(document.form1.TRAMITE.value == 'S'){

         $("#"+object2+"").fadeOut()
         $("#"+object+"").fadeIn("slow")
         $("#"+object3+"").hide()
         $("#requisitos").hide()
         $("#botones").fadeIn("slow")
/*document.form1.action = document.getElementById("TRAMITE").options[document.getElementById("TRAMITE").selectedIndex].id;
document.form2.submit();*/
}
if(document.form1.TRAMITE.value == 'E'){

//         node = document.getElementById(object).style.display ='none';
//         node = document.getElementById(object2).style.display ='none';
//          node = document.getElementById(object3).style.display ='none';
// node = document.getElementById(object).style.visibility='hidden';
//         node = document.getElementById(object2).style.visibility='visible';
//         document.getElementById(object2).style.display ='inline';
         $("#"+object+"").fadeOut()
         $("#"+object3+"").fadeOut()
         $("#botones").fadeOut()
         $("#"+object2+"").fadeIn("slow")

}

if(document.form1.TRAMITE.value == 'R')
{
         $("#"+object2+"").fadeOut()
         $("#"+object+"").fadeIn("slow")
         $("#"+object3+"").fadeIn("slow")
         $("#botones").fadeIn("slow")
//  node = document.getElementById(object).style.display ='none';
//         node = document.getElementById(object2).style.display ='none';
//          node = document.getElementById(object3).style.display ='none';
// node = document.getElementById(object2).style.visibility='hidden';
//         node = document.getElementById(object).style.visibility='visible';
//          node = document.getElementById(object3).style.visibility='visible';
//         document.getElementById(object).style.display ='inline';
//          document.getElementById(object3).style.display ='inline';

document.form1.action = document.getElementById("TRAMITE").options[document.getElementById("TRAMITE").selectedIndex].id;
}
}

function calendario(file,window) 
{  
         msgWindow=open('',window,'resizable=yes,width=280,height=270,screenX=400,screenY=300,top=300,left=400');  
         msgWindow.location.href = file;  
         if(msgWindow.opener == null) 
                msgWindow.opener = self;
}

/*Funciones para utilizar AJAX*/

function getHTTPObject() 
 {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
          xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch (E) {
   xmlhttp = false;
   }
}
@else
   xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
        {
   try {xmlhttp = new XMLHttpRequest();} catch (e) {xmlhttp = false;} 
}
return xmlhttp;
}

 var http = getHTTPObject(); // We create the HTTP Object
 var nombre = "";
 var opcion = 0;

 //Esta es la funcion que llamas desde el evento con el ke kieres invocar el ajax
 function CargaAjax(op,nom) 
 {
            var url = "";
        var valores = "";
        if(nom == 'actualizaBancoLic')
                {

                        nombre = nom;
                        url = "librerias/AjaxBuscaClave.jsp?";
                        valores = 	"arg0="+document.formatoAlta.vinMarca.value+"&arg1="+document.formatoAlta.vinLinea.value+
                                                "&arg2="+document.formatoAlta.vinVersion.value;

                }

        if(url != "")
                {

                http.open("GET", url + valores, true);		
                http.onreadystatechange = handleHttpResponse;
                http.send();
                }
}	 
function separaCadena(Cadena)
        {
                var cadtemp = "";
                var cad = "abcdefghijklmnopqrstuvwxwzABCDEFGHIJKLMNOPQRSTUVWXYZ.,-_=+!@#$%^&*()1234567890";
        var y = 0;
        var x = 0;
                 for(x = 0 ; x< Cadena.length;x++)
                                                          {
                                                           for(y = 0 ; y < cad.length ;  y++)
                                                                        {
                                                                        if(Cadena.charAt(x) == cad.charAt(y))
                                                                                {
                                                                                cadtemp = cadtemp + Cadena.charAt(x);
                                                                                }
                                                                        }
                                                          }
                                return cadtemp
        }
 /*Aqui es donde realmente obtienes la respuesta*/
function handleHttpResponse() 
 {
    var respuesta = "";
          var i = 0;
          var temp = "";
          var ban = 0;

           var valores = "";


    if(http.readyState == 4) 
        {var x = 0;
              respuesta = http.responseText.split("%");


                if(nombre == 'buscaSerie')
                        {

                        document.formatoAlta.errorStr.value = "";	
                        if(respuesta[0] == -1)
                                {
                                 alert("Ya existe un vehiculo registrado con la misma serie  \n Por Favor Comuniquese al 01 800 027 39 99 o Pres�ntese a la Recaudaci�n de Rentas Correspondiente");
                                 document.formatoAlta.errorStr.value = "Ya existe un vehiculo registrado con la misma serie  \n Por Favor Comuniquese al 01 800 027 39 99 o Pres�ntese a la Recaudaci�n de Rentas Correspondiente";
                                }
                        if(respuesta[0] == 1)
                                {
                                valores = respuesta[1].split("&");
                                document.formatoAlta.Anio.value = Trim(valores[0]);
                                document.formatoAlta.Anio.readOnly = true;
                                document.formatoAlta.Serie.readOnly = true;
                                document.formatoAlta.Procedencia.value = valores[10];
                                temp=document.getElementById("Procedencia").selectedIndex;
                                tempo =  document.getElementById("Procedencia").options[temp].text;
                                document.getElementById("Procedencia").options.length = 0;
                                document.getElementById("Procedencia").style.display ='inline';
                                document.getElementById("Procedencia").options[0] = new Option(tempo,valores[10]);		
                                document.getElementById("Procedencia").options[0].id = valores[10];
                                document.getElementById("Marca").options.length = 0;
                                document.getElementById("Marca").style.display ='inline';
                                document.getElementById("Marca").options[0] = new Option(valores[2],valores[1]);		
                                document.getElementById("Marca").options[0].id = valores[1];
                                document.getElementById("Linea").options.length = 0;
                                document.getElementById("Linea").style.display ='inline';
                                document.getElementById("Linea").options[0] = new Option(valores[4],valores[3]);		
                                document.getElementById("Linea").options[0].id = valores[3];
                                document.getElementById("Version").options.length = 0;
                                document.getElementById("Version").style.display ='inline';
                                document.getElementById("Version").options[0] = new Option(valores[6],valores[5]);		
                                document.getElementById("Version").options[0].id = valores[4];
                                document.formatoAlta.Clase.value = valores[7];
                                temp = document.getElementById("Clase").options[valores[7]].text;
                                document.getElementById("Clase").options.length = 0;
                                document.getElementById("Clase").style.display ='inline';
                                document.getElementById("Clase").options[0] = new Option(temp,valores[7]);
                                document.getElementById("Tipo").options.length = 0;
                                document.getElementById("Tipo").style.display ='inline';
                                document.getElementById("Tipo").options[0] = new Option(valores[9],valores[8]);
                                document.formatoAlta.CM3.value = Trim(valores[11]);
                                document.formatoAlta.CM3.readOnly = true;
                                document.formatoAlta.Capacidad.value = valores[12];
                                document.formatoAlta.Capacidad.readOnly = true;
                                document.formatoAlta.descrCapacidad.value = valores[13];
                                document.formatoAlta.Categoria.value = valores[14];
                                document.formatoAlta.descrCapacidad.readOnly = true;
                                }
                        if(respuesta[0] == 2)
                                {
                                        i= 2;

                                        if(respuesta.length > 3 )
                                                {   
                                                        document.formatoAlta.Anio.value = Trim(respuesta[1]);
                                                        document.formatoAlta.Anio.readOnly = true;
                                                        document.formatoAlta.Serie.readOnly = true;
                                                        document.getElementById("trvin").style.display = 'block';

                                                        document.getElementById("VIN").options.length = 0;
                                                        document.getElementById("VIN").style.display ='inline';
                                                        document.getElementById("VIN").options[0] = new Option('-Seleccione Version-','0');

                                                          while(respuesta.length>i )
                                                                {

                                                                  valores = respuesta[i].split("&");	
                                                                  if(valores[1]!=undefined )
                                                                          {

                                                                                document.getElementById("VIN").options[i-1] = new Option(valores[1],valores[0]);		
                                                                                document.getElementById("VIN").options[i-1].id = valores[1];
                                                                          }// fin del if(valores[1]!=undefined)
                                                                          i++;
                                                                }//fin while
                                                }//respuesta.length >  2
                                                if(respuesta.length == 3 )
                                                {

                                                         document.formatoAlta.Anio.value = Trim(respuesta[1]);
                                                        document.formatoAlta.Anio.readOnly = true;
                                                                  valores = respuesta[2].split("&");	
                                                                  if(valores[1]!=undefined )
                                                                          {
                                                                                  SeleccionaVin(valores[0]);


                                                                          }// fin del if(valores[1]!=undefined)

                                                                //fin while
                                                }//respuesta.length == 3
                                                if(respuesta.length == 2 )
                                                {
                                                        document.formatoAlta.Anio.value = Trim(respuesta[1]);
                                                        document.formatoAlta.Anio.readOnly = true;
                                                        document.getElementById("novin").style.display = 'block';
                                                }//respuesta.length == 2
                                }
                        if(respuesta[0] == 0)
                                {
                                        document.formatoAlta.Anio.value = Trim(respuesta[1]);
                                document.formatoAlta.Anio.readOnly = true;
                                }
                        }

                if(nombre == 'Marca')
                        {

                          document.getElementById(nombre).options.length = 0;
                          document.getElementById(nombre).style.display ='inline';
                          document.getElementById(nombre).options[0] = new Option('--','0');	
                          document.getElementById("Linea").options.length = 0;
                          document.getElementById("Linea").style.display ='inline';
                          document.getElementById("Linea").options[0] = new Option('--','0');
                          document.getElementById("Version").options.length = 0;
                          document.getElementById("Version").style.display ='inline';
                          document.getElementById("Version").options[0] = new Option('--','0'); 
                          ban = 1;
                          document.getElementById("Tipo").options.length = 0;
                          document.getElementById("Tipo").style.display ='inline';
                          document.getElementById("Tipo").options[0] = new Option('--','0'); 

                                while(respuesta.length>i )
                                        {
                                          valores = respuesta[i].split("&");	
                                          if(valores[1]!=undefined )
                                                  {

                                                        valores[0] =  separaCadena(valores[0]);
                                                        document.getElementById(nombre).options[i+1] = new Option(valores[1],valores[0]);		
                                                        document.getElementById(nombre).options[i+1].id = valores[1];
                                                  }// fin del if(valores[1]!=undefined)

                                                i++;
                                        }

                        }
                if(nombre == 'Linea')
                        {

                          document.getElementById(nombre).options.length = 0;
                          document.getElementById(nombre).style.display ='inline';
                          document.getElementById(nombre).options[0] = new Option('--','0');	
                          document.getElementById("Version").options.length = 0;
                          document.getElementById("Version").style.display ='inline';
                          document.getElementById("Version").options[0] = new Option('--','0'); 

                                while(respuesta.length>i )
                                        {
                                          valores = respuesta[i].split("&");	
                                          if(valores[1]!=undefined )
                                          {

                                                valores[0] =  separaCadena(valores[0]);
                                                document.getElementById(nombre).options[i+1] = new Option(valores[1],valores[0]);		
                                                document.getElementById(nombre).options[i+1].id = valores[1];
                                          }// fin del if(valores[1]!=undefined)



                                                i++;
                                        }
                        }//fin de linea
                        if(nombre == 'Version' || nombre == 'Tipo' || nombre == 'Clase'|| nombre == 'Procedencia')
                        {

                          document.getElementById(nombre).options.length = 0;
                          document.getElementById(nombre).style.display ='inline';
                          document.getElementById(nombre).options[0] = new Option('--','0');	


                                while(respuesta.length>i )
                                        {
                                          valores = respuesta[i].split("&");	
                                           if(valores[1]!=undefined )
                                          {

                                                valores[0] =  separaCadena(valores[0]);
                                                document.getElementById(nombre).options[i+1] = new Option(valores[1],valores[0]);		
                                                document.getElementById(nombre).options[i+1].id = valores[1];
                                          }// fin del if(valores[1]!=undefined)



                                                i++;
                                        }
                        }//fin de Version
                        if(nombre == 'descrCapacidad')
                        {
                        document.getElementById(nombre).value = respuesta[0];
                        document.getElementById('Categoria').value = respuesta[1];
                        }//fin de descrCapacidad
                        if(nombre == 'ClaveVehicular')
                        { 


                                          valores = respuesta[0].split("&");	
                                          valores[0] = trim(valores[0]);
                                 if(valores[0] == '-1')
                                        {
                                         alert("No se encontro informacion para esa Clave Vehicular  \n Por Favor Comuniquese al 01 800 027 39 99 o Pres�ntese a la Recaudaci�n de Rentas Correspondiente");	
                                        }
                                        else
                                        {
                                                if(valores[1]!=undefined )
                                                        {	
                                                        document.getElementById("Marca").options.length = 0;
                                                        document.getElementById("Marca").style.display ='inline';
                                                        document.getElementById("Marca").options[0] = new Option(valores[1],valores[0]);		
                                                        document.getElementById("Marca").options[0].id = valores[0];
                                                        } 
                                                          valores = respuesta[1].split("&");	
                                                          valores[0]= trim(valores[0]);
                                                if(valores[1]!=undefined )
                                                        {	
                                                                document.getElementById("Linea").options.length = 0;
                                                                document.getElementById("Linea").style.display ='inline';
                                                                document.getElementById("Linea").options[0] = new Option(valores[1],valores[0]);		
                                                                document.getElementById("Linea").options[0].id = valores[0];
                                                        }  
                                                          valores = respuesta[2].split("&");	
                                                         valores[0]= trim(valores[0]);
                                                if(valores[1]!=undefined )
                                                        {			
                                                        document.getElementById("Version").options.length = 0;
                                                        document.getElementById("Version").style.display ='inline';
                                                        document.getElementById("Version").options[0] = new Option(valores[1],valores[0]);		
                                                        document.getElementById("Version").options[0].id = valores[0];
                                                        }
                                        }

                        }//fin de ClaveVehicular
        }

        if(ban == 1)
        {
          CargaAjax('0','Clase');
            temp = document.getElementById('Serie').value;

                                if(temp.length == 17) 
                                    {

                                                validaSerie(temp);
                                        }
        }
}



function validaEmail(strEmail) 
{var at="@" 
    var dot="." 
      var lat=strEmail.indexOf(at) 
      var lstr=strEmail.length 
                  var ldot=strEmail.indexOf(dot) 
     if (strEmail.indexOf(at)==-1)
     {
               alert("El correo electronico es invalido") 
                                   document.form.mail.value = "";
                return false 
        }
      if (strEmail.indexOf(at)==-1 || strEmail.indexOf(at)==0 || strEmail.indexOf(at)==lstr)
     {
         alert("El correo electronico es invalido") 
        return false 
        } 
     if (strEmail.indexOf(dot)==-1 || strEmail.indexOf(dot)==0 || strEmail.indexOf(dot)==lstr)
      {
               alert("El correo electronico es invalido")
                                   document.form.mail.value = "";
                  return false
          } 
        if (strEmail.indexOf(at,(lat+1))!=-1)
      {
                alert("El correo electronico es invalido") 
                document.form.mail.value = "";
                                        return false
          } 
     if (strEmail.substring(lat-1,lat)==dot || strEmail.substring(lat+1,lat+2)==dot)
    { 
            alert("El correo electronico es invalido")
                                document.form.mail.value = "";
           return false 
       } 
  if (strEmail.indexOf(dot,(lat+2))==-1)
            { 
                    alert("El correo electronico es invalido")
                                                document.form.mail.value = "";
                     return false 
            }
        if (strEmail.indexOf(" ")!=-1)
 { 
         alert("El correo electronico es invalido")
                         document.form.mail.value = "";
           return false
      }
return true
} 
function textCounter(field, countfield, maxlimit)
{
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else 
countfield.value = maxlimit - field.value.length;
}

function valida_ServDomPago()
{
document.form.direccion.value = document.form.calle.value + " " + document.form.colonia.value; 

if(document.form.nombre.value == "")
{

 alert("El nombre de la persona que recibira el tramite es Obligatorio")

  return false;

}
if(document.form.lada.value == "")
{
 alert("Favor de Capturar la LADA de su ciudad.")
          return false;
}
if(document.form.telefono.value == "")
{
 alert("El campo telefono esta vacio y es un campo obligatorio.")

  return false;
}
 if(document.form.ladacel.value == ""){
     alert("Favor de capturar la LADA de su celular.")

  return false;
 }
 if(document.form.celular.value == ""){
     alert("El campo Tel. celular esta vacio y es un campo obligatorio")

  return false;
 }
if(document.form.mail.value == "")
{
 alert("Favor de Capturar su correo electronico")

  return false;
}
if(document.form.calle.value == "")
{
 alert("Es indispensable que especifique la calle y numero de su domicilio")
         return false;
}
if(document.form.calle.value == "")
{
 alert("Es indispensable que especifique la Colonia donde se encuentra su domicilio")
         return false;
}
if(document.form.fecha_recoge.value == "")
{
 alert("Es necesario que seleccione una fecha de Entrega")
          return false;
}
if(document.form.municipio.value == "0")
{
 alert("Es indispensable que especifique el municipio donde se entregara el tramite")
         return false;
}
if(document.form.nombre.value.indexOf("'")!= -1)
{
alert("El uso de comillas no es permitido");	
 return false;
}

if(document.form.lada.value.indexOf("'")!= -1)
{
alert("El uso de comillas no es permitido");	
 return false;
}

if(document.form.telefono.value.indexOf("'")!= -1)
{
alert("El uso de comillas no es permitido");	
 return false;
}

if(document.form.direccion.value.indexOf("'")!= -1)
{
alert("El uso de comillas no es permitido");	
 return false;
}

if(document.form.comentario.value.indexOf("'")!= -1)
{
alert("El uso de comillas no es permitido");	
 return false;
}	
}

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.value;



}
function seleccionaMenuBanco()	
{
        var d  = document.formaPago;
        var bancoClave="0";
        var servicio="";
        var url="";
        var tsn="";
        var datosBanco = d.datosBanco.value;
        var datosBancoArreglo = datosBanco.split("|");


        bancoClave = datosBancoArreglo[0];
        servicio = datosBancoArreglo[1];
        url = datosBancoArreglo[2];
        tsn = datosBancoArreglo[3];




        if( bancoClave == "0")
         {
               document.getElementById("realizarPago").style.display="inline";
               document.getElementById("validaPago").style.display="none";
               document.getElementById("msgDomicilio").innerHTML="El tr&aacute;mite podr&aacute; realizarlo con cualquier tarjeta de cr&eacute;dito o d&eacute;bito, excepto American Express. ";
               //document.getElementById("medioPago").style.display="none";
         }
        else
         {
             document.getElementById("realizarPago").style.display="none";
             document.getElementById("validaPago").style.display="inline";
             document.getElementById("validaPago").disabled='';
             document.getElementById("msgDomicilio").innerHTML='';
                        d.url.value	= url;
                        d.banco.value  = bancoClave;


                        if( bancoClave == "-1")
                                d.submit();


                        if(tsn == 0 && Number(d.nivel.value) == 1) 	/*si no tiene mas niveles*/
                                                                d.action = "grabaDatos.jsp";							
                                                else 	{
                                                                d.Saction = d.archivoActual.value;	
                                if(tsn==0)
                                    d.nivel.value = 1;
                                   else
                                        d.nivel.value = 2;
                                /*if(Number(d.nivel.value)>1)
                                        d.nivel.value = Number(d.nivel.value)-1;
                                else	
                                        d.nivel.value = Number(d.nivel.value)+1;*/

                                d.submit();
                                                }	
           }

}

function seleccionaMenuServicio() {
        var d = document.formaPago;
        var bancoClave="0";
        var bancoDescr="";
        var url="";
        var tsn="";

        var datosBanco=d.datosServicio.value;
        var datosBancoArreglo = datosBanco.split("|");
        bancoClave = datosBancoArreglo[0];
        bancoDescr = datosBancoArreglo[1];
        url = datosBancoArreglo[2];
        tsn = datosBancoArreglo[3];

        if(bancoClave!="0")  { /*si eligio un banco*/
                        d.url.value = url;
                        d.banco.value=bancoClave;

                                if(tsn == 0) 	/*si no tiene mas niveles*/
                                                d.action="";							
                                else 	{
                                                d.action = d.archivoActual.value;
                                                d.nivel.value=Number(d.nivel.value)+1;
                                                d.submit();
                                                }

                var  frm;
                if(document.all){ 
                        //frm=document.all.frmUserCode
                         frm=document.all[d.url.value];
                }
                if(document.getElementById){ 
                        frm=document.getElementById(d.url.value);
                }
//			if(d.banco.value=="3")	d.servicioBanco.value=frm.servicio.value;
//			alert(d.servicioBanco.value);
  }
}


function validaRealizarPago() {
        var d = document.formaPago;


                if(d.banco.value=="" || d.banco.value=="0") {
                                alert("Debe seleccionar Banco");
                                return("");
                }

                var  frm;
                if(document.all){ 
                        //frm=document.all.frmUserCode
                         frm=document.all[d.url.value];
                }
                if(document.getElementById){ 
                        frm=document.getElementById(d.url.value);
                }
                if (frm){
                  
                    if(d.banco.value=="2" || d.banco.value=="5"){
                            document.getElementById("validaPago").disabled="disabled"
                            window.location.href='index.jsp'
                    }
                    frm.submit();
		}
}

  function seleccionaMunicipio(objeto, campo)
{
       // alert(objeto.value.length+" - "+objeto.value);
       

    if(objeto.value.length > 2 )
        {
        switch (Number(objeto.value))
            {
            case 686:campo.value = 1;
                         break;
            case 664:campo.value = 2;
                        break;
            case 646:campo.value = 3;
                        break;
            case 665:campo.value = 4;
                        break;
             case 661:campo.value = 5;
                        break;  
               default:
                    campo.value;
              }          
         }

}
function pagoDomicilio(){
    
    document.form_domicilio.submit();
}

function imprimir(){
    
    document.getElementById("botones").style.display='none';
    window.print();
    document.getElementById("botones").style.display='inline';
    
}

/*************Validar index************/

function hacesubmit(){
    if (document.form1.TRAMITE.value == 0)
    {
            alert('Por favor seleccione un Tramite.');
            document.form1.TRAMITE.focus();
            result = false;
    }else if (document.form1.LICENCIA.value == "")
    {
            alert('Por favor ingrese un Numero de Licencia.');
            document.form1.LICENCIA.focus();
            result = false;
    }else if(!validaNumeros(document.form1.LICENCIA.value))
    {
        alert('Favor de solo capturar numeros.');
        document.form1.LICENCIA.value = ""
        document.form1.LICENCIA.focus();
        result = false;
    }else /*if(!document.form1.TIPO_CONSULTA[0].checked && !document.form1.TIPO_CONSULTA[1].checked ) {
        alert('Por favor seleccione un tipo de tramite a realizar.');
            //document.form1.TIPO_CONSULTA[0].focus();
            result = false;
    } else */{

    if(document.form1.TRAMITE.value == 'S'){
      document.form1.action="presupuestoExpedicion.jsp"
    }else{
      document.form1.action="presupuestoLicencia.jsp";
    }
    document.form1.method="post";
    document.getElementById('once').disabled=true;
    document.form1.submit();
    }

}
/***************index*************/

function validaMunicipio(municipio){
    var mpo = municipio
    if(mpo != $("#mpoLicencia").val()){
        if (!confirm("La licencia es de " +municipioDescr($("#mpoLicencia").val())+
            ", \u00BFDesea cambiar el municipio de entrega a "+municipioDescr(mpo)+" ?")){
            $("#municipio").val(1);
         } 
    }
}

function municipioDescr(municipio){
    switch(municipio){
        case '1':
            return 'Mexicali'
        break;
        case '2':
            return 'Tijuana'
        break;
        case '3':
            return 'Ensenada'
        break;
        case '4':
            return 'Tecate'
        break;
        case '5':
            return 'Rosarito'
        break;
    }
}

function esFechaValida(elemento,error){
    var campo = $("#"+elemento+"");
    var campoError = $("#"+error+"");
    if(campo.val() == ""){
        campoError.html("Capture la fecha de Nacimiento.");
        campoError.addClass("input-error-msg");
        campo.addClass("input_error");
        return false;
    }else if(!validaFecha(campo.val())){
        campoError.addClass("input-error-msg");
        campo.addClass("input_error");
        campoError.html("Formato invalido. Ej: D&iacute;a/Mes/A&ntilde;o");
        return false;
    }
    return true;
}

function consultaExp(tipoLic,movto){
   $("#tipoLic").val(tipoLic);
   $("#movto").val(movto);
}

function validaExpedicion(){
   if($("#movto").val() == "" && $("#tipoLic").val() == ""){
       alert("Seleccione el tipo de licencia para continuar.");
       return false;
   }else if(!esFechaValida('fecNacimiento','errorFec')){
       return false;
   }
   $("#fechaNac").val($("#fecNacimiento").val())
   document.getElementById('form2').submit();
}

function capturaFecha(evt){
   if(!soloFechas(evt)){
       return false;
   }
   return true;
}


