  function overTD(td,color){td.bgColor=color;} 

  function outTD(td,color){td.style.cursor='default';td.bgColor=color;}

  

  function confirmar ( mensaje ) { 

    return confirm( mensaje ); 

  } 



function openWindow(url,name,features) { 

  window.open(url,name,features);

} 



function quitarAcentos(cadena)

  { 

	  var sinAcento=new Array('a','e','i','o','u');

      var conAcento=new Array('á','é','í','ó','ú');

	  

	  var resultado=""; var longitud;

	  resultado=cadena.toLowerCase();

	  longitud=resultado.length;

	  for (i=0; i<5; i++)

		 { posicion=resultado.indexOf(conAcento[i]);

		   while (posicion!=-1)

			{ resultado=resultado.substring(0,posicion)+sinAcento[i]+resultado.substring(posicion+1,longitud);

			  posicion=resultado.indexOf(conAcento[i]);}      

		 }

	  return resultado;

  }



function delSpaces(idElement, str, type)

  {

	  if (type=='all')

	     {

		    var out = "", flag = 0;

		    for (i = 0; i < str.length; i++) 

			    {

				  if (str.charAt(i) != " ") 

				     {

					    out += str.charAt(i);

					    flag = 0;

				     }

				  else 

				     {

					    if (flag == 0) 

						   {

							  out += "";

							  flag = 1;

						   }

				     }

			    }

		    document.getElementById(idElement).value = out;

		 }

	  else

	     {

			cadena = document.getElementById(idElement).value;

			document.getElementById(idElement).value = cadena.trim();

			

		 }

	  document.getElementById(idElement).value=document.getElementById(idElement).value.toUpperCase()

  }



String.prototype.trim= function() 

   {

       return this.replace(/(^\s*)|(\s*$)/g,""); 

   }



function convertirMayus(idElemento)

  {

     document.getElementById(idElemento).value=document.getElementById(idElemento).value.toUpperCase();  

  }





function GeneraRFC(wpaterno,wmaterno,wnombre,dia,mes,anio) {

var arre8=new Array('DE ','DEL ','LA ','LOS ','LAS ','Y ','MC ','MAC ','VON ','VAN ')   

var arre6=new Array('JOSE ','MARIA ','J ','MA ')

var arre2=new Array('A','E','I','O','U','a','e','i','o','u')

var arre9=new Array('')

var anex11=new Array('*','0','1','2','3','4','5','6','7','8','9','&','\\','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');

var anex12=new Array('')

var anex21=new Array('')

var anex22=new Array('')

var anex31=new Array('')

var anex32=new Array('')

var sino='s'





   malas = 'BUEIBUEYCACACACOCAGACAGOCAKACAKOCOGECOJAKOGEKOJOKAKAKULOMAMEMAMO';

   malas = malas + 'MEARMEASMEONMIONCOJECOJICOJOCULOFETOGUEYJOTOKACAKACOKAGA';

   malas = malas + 'KAGOMOCOMULAPEDAPEDOPENEPUTAPUTOQULORATARUIN';

   for(x=0;x<malas.length;x=x+4) { arre9[x] = malas.substring(x,x+4)  }



   taba12 = '000001020304050607080910101112131415161718192122232425262728293233343536373839';

   for(x=0;x<taba12.length;x=x+2) { anex12[x] = taba12.substring(x,x+2) }



   malas = '';

   taba12 = '';

   taba21 = '00010203040506070809101112131415161718192021222324252627282930313233';

   taba22 = '123456789ABCDEFGHIJKLMNPQRSTUVWXYZ';

   for(x=0;x<taba21.length/2;x++) { anex21[x] = taba21.substring(2*x,2*x+2)  }

   for(x=0;x<taba22.length;x++){ anex22[x] = taba22.substring(x,x+1) }



   taba21 = '';

   taba22 = '';

   taba11 = '0123456789ABCDEFGHIJKLMN&OPQRSTUVWXYZ*';

   taba12 = '0001020304050607080910111213141516171819202122232425262728293031323334353637';



   for(x=0;x<taba11.length;x++) { anex31[x] = taba11.substring(x,x+1)  }

   for(x=0;x<taba12.length;x=x+2) { anex32[x] = taba12.substring(x,x+2) }



   wpaterno = wpaterno.toUpperCase();

   wmaterno = wmaterno.toUpperCase();

   wnombre  = wnombre.toUpperCase();



   wanual = eval(anio + mes + dia);



   if (nacio(wanual)==false) {

      alert('La fecha de nacimiento es \nincorrecta');

      return;

   }             



   if (los3(wpaterno,wmaterno,wnombre)==false) {

      alert('El nombre del Empleado es \nincorrecto');

      return;

   }

   

   wnumer6 = String(wanual);

   wnumer6 = wnumer6.substring(wnumer6.length-6,wnumer6.length);

   paterno = trim(wpaterno);

   materno = trim(wmaterno);

   nombre = trim(wnombre);



   finice = false;

   paterno = octava(paterno,arre8);

   materno = octava(materno,arre8);

   nombre  = octava(nombre,arre8);

   nombre  = sexta(nombre,arre6);

   paterno = tercera(paterno);

   materno = tercera(materno);

   nombre  = tercera(nombre);



   if ( (paterno.length == 0) || (materno.length == 0) ) { 

      un_apell = septima(paterno,materno,nombre);

      wrfc = un_apell.substring(0,2) + nombre.substring(0,2);

      wrfc = novena(wrfc,arre9); 

      wrfc = wrfc + wnumer6 + homoni(wpaterno,wmaterno,wnombre,anex11,anex12,anex21,anex22);

      wrfc = digito(wrfc,anex31,anex32);

      finice = true;

   }



   if (!finice ) {

      if (paterno.length < 3) {

         wrfc = paterno.substring(0,1) + materno.substring(0,1) + nombre.substring(0,2) 

         wrfc = novena(wrfc,arre9); 

         wrfc = wrfc + wnumer6 + homoni(wpaterno,wmaterno,wnombre,anex11,anex12,anex21,anex22);

         wrfc = digito(wrfc,anex31,anex32);

         finice = true;

      }

   }   



   if (!finice) { 

      wrfc = paterno.substring(0,1) + prime_segu(paterno,arre2) + materno.substring(0,1) + nombre.substring(0,1);

      wrfc = novena(wrfc,arre9); 

      wrfc = wrfc + wnumer6 + homoni(wpaterno,wmaterno,wnombre,anex11,anex12,anex21,anex22);

      wrfc = digito(wrfc,anex31,anex32);                 

   }



   return (wrfc.substring(0,4) + wrfc.substring(4,10)+wrfc.substring(10,13));

}



function nacio(Arg1) {

var Local1=new Array('31','28','31','30','31','30','31','31','30','31','30','31')



   bb = false;



   if (Arg1==0) { return bb; }

   todo = String(Arg1);

   bb = true;

   uno = eval(todo.substring(6,8));

   dos = eval(todo.substring(4,6));

   tres = eval(todo.substring(0,4));

      

   if (uno<=0) { return bb }

   if (dos<=0) { return bb}

   if (dos > 12) { return bb }



   bisies = Local1[dos-1];

   sanual = String(tres);

   sanual2 = eval(sanual);



   if (dos==2) { if ((parseInt(sanual2 / 4)*4 )== sanual2) { bisies++ } } 

   if (uno>bisies) {

      bb = false;

      return bb;

   }

   

   bb = true;

   return bb        

}



function los3(Arg1,Arg2,Arg3) {

   wlos3 = trim(Arg1) + ' ' + trim(Arg2) + ' ' + trim(Arg3);

   if (wlos3.length <= 6 ) { return false } else { return true }

}



function octava(Arg1,arre8) { 

   for(xx=0;xx<arre8.length;xx++) { 

      do {

         Arg1 = Arg1.replace(arre8[xx],'');

         posi = Arg1.indexOf(arre8[xx]); 

      } while (posi != -1)   

   }

   return Arg1

}



function sexta(Arg1,arre) {

   posi =Arg1.indexOf(' ');



   if (posi > -1 ) { 

      for(xx=0;xx<arre.length;xx++) {

         do {

            Arg1 = Arg1.replace(arre[xx],'') ;

            posi2 = Arg1.indexOf(arre[xx]);

         } while (posi2 != -1)    

      }

   }

   return Arg1      

}



function tercera(Arg1) {

   if (Arg1.substring(0,2) == 'CH') { 

      Arg1 = Arg1.replace('CH','C')

   } else {

      if(Arg1.substring(0,2) == 'LL') { Arg1 = Arg1.replace('LL','L') }

   }

   return Arg1   

}



function septima(ArgP,ArgM,ArgN) {

   if ((ArgP.length == 0) && (ArgM.length > 0)) {

      unosolo = ArgM

   } else {

      if ((ArgP.length > 0) && (ArgM.length == 0)) { unosolo = ArgP } else { unosolo = ArgN  }

   }



   return unosolo

} 



function novena(Arg1,arre) {

   for(xx=0;xx<arre.length;xx++) {

      if (arre[xx] == Arg1.substring(0,4)) { Arg1 = Arg1.substring(0,3) + 'X' }

   }

   return Arg1

}



function homoni(wpaterno,wmaterno,wnombre,anex11,anex12,anex21,anex22) {

   valores = '0';

   wbase = trim(trim(wpaterno) + " " + trim(wmaterno) +" " + trim(wnombre));





   for(x=0;x<wbase.length;x++){

      unok = wbase.substring(x,x+1);

      if (unok==' ') { unok = '*' }



      bandera = false; 

      for(y=0;y<anex11.length;y++) {

         if(anex11[y] == unok) { 

            valores = valores + anex12[y*2];

            bandera = true; 

         } 

      }   

      if (bandera == false) { valores = valores + '00'  }           

   }



   sumas = 0;

   for(x=0;x<(valores.length-1);x++){

      prod1 = eval(valores.substring(x,x+2)); 

      prod2 = eval(valores.substring(x+1,x+2));

      prod3 = prod1 * prod2;

      sumas = sumas + prod3;

   }



   zumass = String(sumas);

   zumass = zumass.substring(zumass.length-3,zumass.length);

   zumas = eval(zumass);

   solotres = zumas;

   cociente = Math.floor(solotres / 34);

   residuo = solotres - cociente * 34;



   if (cociente < 10) { wrok = "0" + String(cociente) } else { wrok = String(cociente) }

  

   homo = "1";

   for(x=0;x<anex21.length;x++) { if (wrok == anex21[x]) { homo = anex22[x]  }  }     



   if (residuo < 10 ) { wrok = "0" + String(residuo) } else { wrok = String(residuo) }

   bandera = false;

   for(x=0;x<anex21.length;x++) { 

      if (wrok == anex21[x]) { 

         homo = homo + anex22[x];

         bandera = true; 

      } 

   }   

   if (bandera == false) { homo = homo + "1" }



   return  homo

}



function digito(wrfc,anex31,anex32) {

   valores = '';



   for(x=0;x<wrfc.length;x++) {

      unok = wrfc.substring(x,x+1);

      if (unok == '') { unok = '*'; }

      

      bandera = false;          

      for(y=0;y<anex31.length;y++) {

         if(anex31[y] == unok) { 

            valores = valores + anex32[y*2];

            bandera = true; 

         } 

      }   

      if (bandera == false) { valores = valores + '00'  }           

   }    



   sumas = 0;

   trece = 13;



   for(x=0;x<12;x++) {

      prod1 = eval(valores.substring(2*x,2*x+2));   

      prod3 = prod1 * trece;

      sumas = sumas + prod3;

      trece = trece - 1;

   }



   cociente = Math.floor(sumas / 11);

   residuo  = Math.floor(sumas) - cociente * 11;                



   if (residuo == 0) { 

      dijito = "0" 

   } else {

      valor = 11 - residuo;

 

      if (valor == 10) { 

         dijito = 'A' 

      } else {

         entrer = String(valor);

         dijito = entrer.substring(entrer.length-1,entrer.length);

      }

   }



   return wrfc + dijito   

}



function prime_segu(paterno,arre2) {

   letra = paterno.substring(1,2);

   bandera = true;



// busca la primera vocal en el Apellido Paterno

   for(x=1;((x<paterno.length)&&(bandera==true));x++) {

      for(y=0;y<arre2.length;y++) { 

         if (arre2[y] == paterno.substring(x,x+1)) { 

            letra = arre2[y];

            bandera = false;

         }

      }

   } 

   return letra

}



function trim(s) {

   while (s.substring(0,1) == ' ') { s = s.substring(1,s.length);  }

   while (s.substring(s.length-1,s.length) == ' ') { s = s.substring(0,s.length-1);  }

   return s;

}

// JavaScript Document



//Validacion de campos para números

    function soloNumeros() { 

           var key=window.event.keyCode;//codigo de tecla. 

           if (key < 48 || key > 57) {//si no es numero  

              window.event.keyCode=0;//anula la entrada de texto. 

           }

    }

	

//Validacion para que no se acepte enter

	//function getKey(keyStroke) {  

	//isNetscape=(document.layers); 

	//eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;    

	//if (eventChooser==13) {      

	  // return false; 

	   //}  

	//} 

	//document.onkeypress = getKey;   



//Validacion para quitar espacios en blanco

    function sinTrim(s) {

      	   while (s.substring(0,1) == ' ') { 

	          s = s.substring(1,s.length); 

	 	   }

       	   while (s.substring(s.length-1,s.length) == ' ') { 

	          s = s.substring(0,s.length-1); 

	 	   }

       	   return s;

		   

    }

//Validacion para formato de fecha

   function verifecha(fecha,ventana) {

		  if (fecha != ''){

		   expresion = /^\d{4}\-\d{1,2}\-\d{1,2}$/;

		   if (!expresion.test(fecha)) {

		          alert("Fecha erronea");

				  switch(ventana) {

				    case 1 ://inserta taxi

					  document.frmForma.txtFecCircula.value = '';

				      document.frmForma.txtFecCircula.focus();

                      return;

					  break;

  				    case 2 ://inserta chofer

					  document.frmForma.txtFecVnto.value = '';

				      document.frmForma.txtFecVnto.focus();

                      return;

					  break;

				  }

		   }

		  }

    }

				  

    



//Validacion de vacios

   function validacionChofer(){



        if (document.frmForma.txtNombre.value == '') {

  		    alert ("Escriba Nombre o Razon Social")

			document.frmForma.txtNombre.focus();

			return;

		}

		

		if (document.frmForma.txtPais.value == '') {

  		    alert ("Escriba Pais")

			document.frmForma.txtPais.focus();

			return;

		}

		 if (document.frmForma.txtCalle.value == '') {

  		    alert ("Escriba Calle")

			document.frmForma.txtCalle.focus();

			return;

		}

        

		

		if (document.frmForma.txtNumExt.value == '') {

  		    alert ("Escriba Numero Exterior")

			document.frmForma.txtNumExt.focus();

			return;

		}

         if (document.frmForma.txtColonia.value == '') {

  		    alert ("Escriba Colonia")

			document.frmForma.txtColonia.focus();

			return;

		}

		

		      

        if (document.frmForma.txtDelegacion.value == '') {

  		    alert ("Escriba Delegacion")

			document.frmForma.txtDelegacion.focus();

			return;

		}

        

				

		if (document.frmForma.txtEstado.value == '') {

  		    alert ("Escriba Estado")

			document.frmForma.txtEstado.focus();

			return;

		}

        

		if (document.frmForma.txtLadaTelefono.value == '') {

  		    alert ("Escriba Lada de Telefono")

			document.frmForma.txtLadaTelefono.focus();

			return;

		}

		

		if (document.frmForma.txtTelefono.value == '') {

  		    alert ("Escriba Telefono")

			document.frmForma.txtTelefono.focus();

			return;

		}	

        			  

        if (document.frmForma.txtCorreo.value == '') {

  		    alert ("Escriba Correo Electronico")

			document.frmForma.txtCorreo.focus();

			return;

		}

		

		

		  

  Cadena = document.frmForma.txtCorreo.value;

    Punto = Cadena.substring(Cadena.lastIndexOf('.') + 1, Cadena.length)               

    Dominio = Cadena.substring(Cadena.lastIndexOf('@') + 1, Cadena.lastIndexOf('.'))       

    Usuario = Cadena.substring(0, Cadena.lastIndexOf('@'))                     

    Reserv = "@/º\"\'+*{}\\<>?¿[]áéíóú#·¡!^*;,:"                        

       

    

    valido = true   

       

    

    for (var Cont=0; Cont<Usuario.length; Cont++) {   

        X = Usuario.substring(Cont,Cont+1)   

        if (Reserv.indexOf(X)!=-1)   

                    valido = false   

    }   

  

    

    for (var Cont=0; Cont<Punto.length; Cont++) {   

        X=Punto.substring(Cont,Cont+1)   

        if (Reserv.indexOf(X)!=-1)   

            valido = false   

    }   

                           

    

    for (var Cont=0; Cont<Dominio.length; Cont++) {   

        X=Dominio.substring(Cont,Cont+1)   

        if (Reserv.indexOf(X)!=-1)   

            valido = false   

        }   

  

    

    if (Punto.length<2 || Dominio <1 || Cadena.lastIndexOf('.')<0 || Cadena.lastIndexOf('@')<0 || Usuario<1) {   

        valido = false   

    }   

       

    

    if (!valido) {   

        

       alert ("Escriba Correo Electronico Correctamente")

			document.frmForma.txtCorreo.focus();

			return;  

    }   


   	    //insercion();	

        document.frmForma.guardar.disabled= true;
		document.forms[0].submit();

  }

  

function validacionCat2(){	  

     

        if (document.frmForma.txtnombre.value == '') {

  		    alert ("Escribir Nombre")

			document.frmForma.txtnombre.focus();

			return;

		}		  

		

		if (document.frmForma.txtcorreoe.value == '') {

  		    alert ("Escribir Correo Electronico")

			document.frmForma.txtcorreoe.focus();

			return;

		}		  

		

		if (document.frmForma.txtusuario.value == '') {

  		    alert ("Escribir el Usuario")

			document.frmForma.txtusuario.focus();

			return;

		}

		

		if (document.frmForma.txtpass.value == '') {

  		    alert ("Escribir Password")

			document.frmForma.txtpass.focus();

			return;

		}		  

		

		

		

   	    insercion();	

        document.frmForma.guardar.disabled= true;

  }







function validacionCat3(){	  

     

       

		

		

   	    insercion();	

        document.frmForma.guardar.disabled= true;

		document.frmForma.borrando2.disabled= true;

		

		

  }


function cambia_iframe(page) { //v3.0
	parent.document.getElementById("principal").src=page;
}

  // JavaScript Document
function resizeIframe(id) { //v3.0  
	parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px"	
}

