<!--ASP:Script:1.00-->

// ASP/PHP Web Application Builder (http://www.webapplicationbuilder.com)
// © City Business Logic, 2001-2003 - All Rights Reserved
// You may use this script in your own, non-competing
// projects on the condition that you leave this message in tact.

//Función de Reload
//function MM_reloadPage(init) {  //reloads the window if Nav4 resized
//  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
//    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
//  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
//}
//MM_reloadPage(true);

//Agregar a Favoritos
function addToFavorites(url, description) {
  if (window.external)
  {
   window.external.AddFavorite(url, description)
  }
  else
  { 
   alert("Su navegador no soporta esta función. \n Solo Internet Explorer permitido. \n Presione CTRL+D para agregar marcador en otros navegadores.");
  }
}
 
//Check Edad
function CheckEdad (date0) {

var date1, anac, mnac, dnac; // Fecha de Nacimiento
date1 = date0;
anac = date1.substr(0, 4);  //Get substring.
mnac = date1.substr(5, 2);
dnac = date1.substr(8, 2);

var date2, aact, mact, dact; // Fecha Actual
date2 = new Date();
aact = date2.getFullYear();
mact = date2.getMonth()+1;
dact = date2.getDate();

var acal; // Calculo de Año
acal = aact - anac;
mnac = Math.abs(mnac);
dnac = Math.abs(dnac);
mact = Math.abs(mact);
dact = Math.abs(dact);

var mres, dres, edad; // resultados

if (document.form1.x_FTB5.value == false || acal == 0){
	alert("Edad no valida, registre correctamente su Fecha de Nacimiento!");
    document.form1.btn_fecha.focus();	
	}
	else
	{
if (mnac==mact & dnac<dact || mnac<mact)
   {mres = 0;}
   else
   {mres = 1;}

if (mres==1)
   {edad = acal - 1;}
    else
   {edad = acal;}

if (edad<18){	
	alert("Edad no valida, registre correctamente su Fecha de Nacimiento!");
    document.form1.btn_fecha.focus();	
	}
	else
	{document.form1.x_FTB6.value = edad;}
}
return true;
}

//Check forma de Busqueda
function CheckForm () {
	//Check for a word to search
	if (document.Busqueda_sec.pSearch.value==""){
		alert("Favor de escribir al menos una palabra clave para ser buscada");
		document.Busqueda_sec.pSearch.focus();
		return false;
	}
	
	return true
}

//envio de página OIC
function formCheckOIC001() {

if (document.frmOIC001.nombreR.value == false)
   {
     alert("Registre Nombre del Remitente!");
	 document.frmOIC001.nombreR.focus();  	 
	 return false;
   }

if (document.frmOIC001.nombreD.value == false)
   {
     alert("Registre Nombre del Destinatario!");
	 document.frmOIC001.nombreD.focus();  	 
	 return false;
   }
   
if (document.frmOIC001.email.value == false)
   {
     alert("Registre Correo Electrónico!");
     document.frmOIC001.email.focus();  	 
	 return false;
   }

var mail = document.frmOIC001.email.value;
var simb = "@";
var poin = ".";
var resu = mail.search(simb);
var pore = mail.search(poin);
var size = mail.length;

if (resu == -1)
   {
     alert("Escriba corectamente el Correo Electronico, falta @!");
     document.frmOIC001.email.focus();  	 
	 return false;
   }
if (pore == -1)
   {
     alert("Escriba corectamente el Correo Electronico, falta .!");
     document.frmOIC001.email.focus();  	 
	 return false;
   }

var total = resu + 2;
if (total == size)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.frmOIC001.email.focus();  	 
	 return false;
   }   
var confirmar = confirm('¿Deseas Enviar?');
if (confirmar == true)
   {
   return true;
   }
    else
   {
    return false; 
   }    	
}   

//encuesta de página OIC
function formCheckOIC002() {

if (document.frmOIC002.valest.value == false)
   {
     alert("Seleccione Opción del 1 al 5!");
	 return false;
   }
var confirmar = confirm('¿Deseas Enviar?');
if (confirmar == true)
   {   
   NewWindow('http://wwwview.ciqa.mx:8080/oic/encuesta.asp?pag='+document.frmOIC002.pag.value+'&valest='+document.frmOIC002.valest.value,'encuesta','610','320','no','center');
   return true;
   }
    else
   {
    return false; 
   }    	   
}

//comentarios de página OIC
function formCheckOIC003() {

if (document.frmOIC003.comentarios.value == false)
   {
     alert("Registre Comentarios!");
	 document.frmOIC003.comentarios.focus(); 	 
	 return false;
   }
var confirmar = confirm('¿Deseas Enviar?');
if (confirmar == true)
   {   
   return true;
   }
    else
   {
    return false; 
   }    	   
}

//envio de mail para cursos
function formCheck() {
var curso = document.Mail.curso.value 
var region = document.Mail.region.value
var fecha = document.Mail.fecha.value 
var comentarios = document.Mail.comentarios.value 
var nombre = document.Mail.nombre.value
var empresa = document.Mail.empresa.value
var puesto = document.Mail.puesto.value
var telfax = document.Mail.tel_fax.value
var email = document.Mail.email.value
var facnom = document.Mail.factura_nombre.value
var faccal = document.Mail.factura_calle_y_no.value
var faccol = document.Mail.factura_colonia.value
var faccd = document.Mail.factura_cd_edo_cp.value
var facrfc = document.Mail.factura_rfc.value
var facate = document.Mail.factura_atencion_a.value
var facpag = document.Mail.forma_pago.value

if (curso == false)
   {
     alert("Registre Curso!");
	 document.Mail.curso.focus();  	 
	 return false;
   }

if (region == false)
   {
     alert("Registre Región!");
	 document.Mail.region.focus();  	 
	 return false;
   }

if (fecha == false)
   {
     alert("Registre Fecha!");
	 document.Mail.fecha.focus();  	 
	 return false;
   }

if (comentarios == false)
   {
     alert("Registre Comentarios!");
	 document.Mail.comentarios.focus();  	 
	 return false;
   }

if (nombre == false)
   {
     alert("Registre Nombre!");
	 document.Mail.nombre.focus();  	 
	 return false;
   }

if (empresa == false)
   {
     alert("Registre Empresa!");
	 document.Mail.empresa.focus();  	 
	 return false;
   }

if (puesto == false)
   {
     alert("Registre Puesto!");
	 document.Mail.puesto.focus();  	 
	 return false;
   }

if (telfax == false)
   {
     alert("Registre Tel o Fax!");
	 document.Mail.tel_fax.focus();  	 
	 return false;
   }

if (email == false)
   {
     alert("Registre Correo Electrónico!");
     document.Mail.email.focus();  	 
	 return false;
   }

var mail = Mail.email.value;
var simb = "@";
var poin = ".";
var resu = mail.search(simb);
var pore = mail.search(poin);
var size = mail.length;

if (resu == -1)
   {
     alert("Escriba corectamente el Correo Electronico, falta @!");
     document.Mail.email.focus();  	 
	 return false;
   }
if (pore == -1)
   {
     alert("Escriba corectamente el Correo Electronico, falta .!");
     document.Mail.email.focus();  	 
	 return false;
   }

var total = resu + 2;
if (total == size)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.Mail.email.focus();  	 
	 return false;
   }

if (facnom == false)
   {
     alert("Registre Nombre para datos de Facturación!");
     document.Mail.factura_nombre.focus();  	 
	 return false;
   }

if (faccal == false)
   {
     alert("Registre Domicilio para datos de Facturación!");
     document.Mail.factura_calle_y_no.focus();  	 
	 return false;
   }

if (faccol == false)
   {
     alert("Registre Colonia para datos de Facturación!");
     document.Mail.factura_colonia.focus();  	 
	 return false;
   }

if (faccd == false)
   {
     alert("Registre Cuidad/Estado/CP para datos de Facturación!");
     document.Mail.factura_cd_edo_cp.focus();  	 
	 return false;
   }

if (facrfc == false)
   {
     alert("Registre RFC para datos de Facturación!");
     document.Mail.factura_rfc.focus();  	 
	 return false;
   }

if (document.Mail.factura_rfc.value.length < 10)
   {
     alert("RFC no puede ser menor de 10 caracteres!");
	 document.Mail.factura_rfc.focus();  	 
	 return false;
   }

if (document.Mail.factura_rfc.value.length > 13)
   {
     alert("RFC no puede ser mayor de 13 caracteres!");
	 document.Mail.factura_rfc.focus();  	 
	 return false;
   }

if (facate == false)
   {
     alert("Registre Atención a para datos de Facturación!");
     document.Mail.factura_atencion_a.focus();  	 
	 return false;
   }

var confirmar = confirm('¿Deseas Registrar esta Solicitud?');
if (confirmar == true)
   {
   return true;
   }
    else
   {
    return false; 
   }    	
}   

//encuesta de página CIQA
function formCheckCIQA001() {

var confirmar = confirm('¿Deseas Enviar?');
if (confirmar == true)
   {   
  document.frmCIQA001.submit;
  return true;
   }
    else
   {
    return false; 
   }   
}

//Carga de imagenes
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];}}
}

//Checa campo de busqueda vacio
function check_search() {      
if (document.Busqueda.pSearch.value == "")
   {
   document.Busqueda.pSearch.value="x"
   }
}

//Checa campo de busqueda vacio - inicio www.ciqa.mx
function check_search_dir() {      
if (document.Busqueda_dir.pSearch.value == "")
   {
   document.Busqueda_dir.pSearch.value="x"
   }
}

//Checa campo de busqueda vacio - inicio www.ciqa.mx
function check_search_sec() {      
if (document.Busqueda_sec.pSearch.value == "")
   {
   document.Busqueda_sec.pSearch.value="x"
   }
}

//Regresa Enfoque de RFC
function ReturnRFC() {      
window.close();
window.opener.document.frmMain.x_FTB3.focus()
return false;
}

//Validación RFC
function CheckRFC() {   
   var rfc=document.frmMain.x_FTB3.value 
   settings='width=300,height=125,top=200,left=300,scrollbars=yes,location=no,directories=no,status=no,titlebar=no,menubar=no,toolbar=no,resizable=no';
   mypage="ValidRFC.asp?rfc="+rfc;
   win=window.open(mypage,'RFC',settings);
}

//Validación de Internacional, deshabilita campos en el Registro
function CheckInt() {

if (document.frmMain.x_FTB1.value == "I")
   {
     document.frmMain.x_FTB27.style.background='#FFFFFF';
	 document.frmMain.x_FTB27.disabled= false;	 
	 document.frmMain.x_FTB29.style.background='#FFFFFF';
	 document.frmMain.x_FTB29.disabled= false;	 
	 document.frmMain.x_FTB30.style.background='#FFFFFF';
	 document.frmMain.x_FTB30.disabled= false;	 
	 document.frmMain.x_FTB31.style.background='#FFFFFF';
	 document.frmMain.x_FTB31.disabled= false;	 
	 document.frmMain.x_FTB32.style.background='#FFFFFF';
	 document.frmMain.x_FTB32.disabled= false;
	 return;
   }
	 else
     {	 	 	 	 	 
	 document.frmMain.x_FTB27.value= "";
	 document.frmMain.x_FTB27.style.background='#CCCCCC';	 
	 document.frmMain.x_FTB27.disabled= true;	 
	 document.frmMain.x_FTB29.value= "";
	 document.frmMain.x_FTB29.style.background='#CCCCCC';	 
	 document.frmMain.x_FTB29.disabled= true;	 
	 document.frmMain.x_FTB30.value= "";
	 document.frmMain.x_FTB30.style.background='#CCCCCC';	 
	 document.frmMain.x_FTB30.disabled= true;	 
	 document.frmMain.x_FTB31.value= "";
	 document.frmMain.x_FTB31.style.background='#CCCCCC';	 
	 document.frmMain.x_FTB31.disabled= true;	 
	 document.frmMain.x_FTB32.value= "";
	 document.frmMain.x_FTB32.style.background='#CCCCCC';	 
	 document.frmMain.x_FTB32.disabled= true;
	 return;
	 } 
}
	
//Validación de Internacional, deshabilita campos en la Modificación en OnLoad
function CheckInt1() {

if (document.frmMain.tipPro.value == "I")
   {
     document.frmMain.x_FTB27.style.background='#FFFFFF';
	 document.frmMain.x_FTB27.disabled= false;	 
	 document.frmMain.x_FTB29.style.background='#FFFFFF';
	 document.frmMain.x_FTB29.disabled= false;	 
	 document.frmMain.x_FTB30.style.background='#FFFFFF';
	 document.frmMain.x_FTB30.disabled= false;	 
	 document.frmMain.x_FTB31.style.background='#FFFFFF';
	 document.frmMain.x_FTB31.disabled= false;	 
	 document.frmMain.x_FTB32.style.background='#FFFFFF';
	 document.frmMain.x_FTB32.disabled= false;
	 return;
   }
	 else
     {	 	 	 	 	 
	 document.frmMain.x_FTB27.style.background='#CCCCCC';	 
	 document.frmMain.x_FTB27.disabled= true;	 	 
	 document.frmMain.x_FTB29.style.background='#CCCCCC';	 
	 document.frmMain.x_FTB29.disabled= true;	 
	 document.frmMain.x_FTB30.style.background='#CCCCCC';	 
	 document.frmMain.x_FTB30.disabled= true;	 
	 document.frmMain.x_FTB31.style.background='#CCCCCC';	 
	 document.frmMain.x_FTB31.disabled= true;	 
	 document.frmMain.x_FTB32.style.background='#CCCCCC';	 
	 document.frmMain.x_FTB32.disabled= true;
	 return;
	 } 
}

//Validación de Internacional, deshabilita campos en la Modificación On Checked
function CheckInt2(valor) {

document.frmMain.tipPro.value= valor;

if (valor == "I")
   {
     document.frmMain.x_FTB27.style.background='#FFFFFF';
	 document.frmMain.x_FTB27.disabled= false;	 
	 document.frmMain.x_FTB29.style.background='#FFFFFF';
	 document.frmMain.x_FTB29.disabled= false;	 
	 document.frmMain.x_FTB30.style.background='#FFFFFF';
	 document.frmMain.x_FTB30.disabled= false;	 
	 document.frmMain.x_FTB31.style.background='#FFFFFF';
	 document.frmMain.x_FTB31.disabled= false;	 
	 document.frmMain.x_FTB32.style.background='#FFFFFF';
	 document.frmMain.x_FTB32.disabled= false;
	 return;
   }
	 else
     {	 	 	 	 	 
	 document.frmMain.x_FTB27.style.background='#CCCCCC';	 
	 document.frmMain.x_FTB27.disabled= true;	 	 
	 document.frmMain.x_FTB29.style.background='#CCCCCC';	 
	 document.frmMain.x_FTB29.disabled= true;	 
	 document.frmMain.x_FTB30.style.background='#CCCCCC';	 
	 document.frmMain.x_FTB30.disabled= true;	 
	 document.frmMain.x_FTB31.style.background='#CCCCCC';	 
	 document.frmMain.x_FTB31.disabled= true;	 
	 document.frmMain.x_FTB32.style.background='#CCCCCC';	 
	 document.frmMain.x_FTB32.disabled= true;
	 return;
	 } 
}

//Validación de Inicio
function FieldValidIni() {
 
if (document.form1.fldUsername01.value == false)
   {
     alert("Registre Nombre de Usuario!");
	 document.form1.fldUsername01.focus();  	 
	 return false;
   }
if (document.form1.fldPassword01.value == false)
   {
     alert("Registre Contraseña!");
	 document.form1.fldPassword01.focus();  	 
	 return false;
   }

return true;

}

//Validación Solicitud Enlace
function Valid_1() {

if (document.form1.fld1.value == false)
   {
     alert("Campo Requerido: Nombre, Denominación o Razón Social");
	 document.form1.fld1.focus();  	 
	 return false;
   }

if (document.form1.fld2.value == false)
   {
     alert("Campo Requerido: Calle");
	 document.form1.fld2.focus();  	 
	 return false;
   }
if (document.form1.fld3.value == false)
   {
     alert("Campo Requerido: Número");
	 document.form1.fld3.focus();  	 
	 return false;
   }

if (document.form1.fld4.value == false)
   {
     alert("Campo Requerido: Colonia");
	 document.form1.fld4.focus();  	 
	 return false;
   }
   
if (document.form1.fld5.value == false)
   {
     alert("Campo Requerido: Código Postal");
	 document.form1.fld5.focus();  	 
	 return false;
   }
   
//fld6 Razón Social es Validado con País   
if (document.form1.fld7.value == false)
   {
     alert("Campo Requerido: Atención");
	 document.form1.fld7.focus();  	 
	 return false;
   }

if (document.form1.fld7a.value == false)
   {
     alert("Campo Requerido: Correo Electrónico!");
     document.form1.fld7a.focus();  	 
	 return false;
   }

var mail = document.form1.fld7a.value;
var simb = "@";
var poin = ".";
var resu = mail.search(simb);
var pore = mail.search(poin);
var size = mail.length;

if (resu == -1)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.form1.fld7a.focus();  	 
	 return false;
   }
if (pore == -1)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.form1.fld7a.focus();  	 
	 return false;
   }

var total = resu + 2;
if (total == size)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.form1.fld7a.focus();  	 
	 return false;
   }
   
if (document.form1.fld8a.value == false)
   {
     alert("Campo Requerido: Larga distancia Tel");
	 document.form1.fld8a.focus();  	 
	 return false;
   }

if (document.form1.fld8.value == false)
   {
     alert("Campo Requerido: Número de Teléfono");
	 document.form1.fld8.focus();  	 
	 return false;
   }

if (document.form1.fld9a.value == false)
   {
     alert("Campo Requerido: Larga distancia Fax");
	 document.form1.fld9a.focus();  	 
	 return false;
   }

if (document.form1.fld9.value == false)
   {
     alert("Campo Requerido: Fax");
	 document.form1.fld9.focus();  	 
	 return false;
   }

if (document.form1.fld10.value == false)
   {
     alert("Campo Requerido: Área / Departamento");
	 document.form1.fld10.focus();  	 
	 return false;
   }


if (document.form1.fld11.value == false)
   {
     alert("Campo Requerido: Pais");
	 document.form1.fld11.focus();  	 
	 return false;
   }   
if (document.form1.fld11.value == "Mexico")
   {   
   	if (document.form1.fld61.value == false)
	   {
    	 alert("Registre Clave de Razón Social/Nombre RFC!");
	     document.form1.fld61.focus();  	 
		 return false;
	   }
	if (document.form1.fld61.value.length < 3 || document.form1.fld61.value.length > 4)
	   {
	     alert("Registre correctamente Clave de Razón Social/Nombre RFC!");
		 document.form1.fld61.focus();  	 
		 return false;
	   }	   
   	if (document.form1.fld62.value == false)
	   {
    	 alert("Registre Año/Mes/Día RFC!");
	     document.form1.fld62.focus();  	 
		 return false;
	   }
	if (document.form1.fld62.value.length < 6)
	   {
	     alert("Registre correctamente Año/Mes/Día RFC!");
		 document.form1.fld62.focus();  	 
		 return false;
	   }	   
   	if (document.form1.fld63.value == false)
	   {
    	 alert("Registre Homoclave RFC!");
	     document.form1.fld63.focus();  	 
		 return false;
	   }	   
	if (document.form1.fld63.value.length < 3)
	   {
	     alert("Registre correctamente Homoclave RFC!");
		 document.form1.fld63.focus();  	 
		 return false;
	   }	 

	if (document.form1.fld12.value == false)
         {
           alert("Campo Requerido: Estado");
           document.form1.fld12.focus();  	 
 	       return false;
         }
   }

if (document.form1.fld13.value == false)
   {
     alert("Campo Requerido: Ciudad");
	 document.form1.fld13.focus();  	 
	 return false;
   }

if (document.form1.fld14.value == false)
   {
     alert("Campo Requerido: Nombre, Denominación o Razón Social");
	 document.form1.fld14.focus();  	 
	 return false;
   }

if (document.form1.fld15.value == false)
   {
     alert("Campo Requerido: Calle");
	 document.form1.fld15.focus();  	 
	 return false;
   }

if (document.form1.fld16.value == false)
   {
     alert("Campo Requerido: Número");
	 document.form1.fld16.focus();  	 
	 return false;
   }
   
if (document.form1.fld17.value == false)
   {
     alert("Campo Requerido: Colonia");
	 document.form1.fld17.focus();  	 
	 return false;
   }   
   
if (document.form1.fld18.value == false)
   {
     alert("Campo Requerido: Código Postal");
	 document.form1.fld18.focus();  	 
	 return false;
   }   

if (document.form1.fld19.value == false)
   {
     alert("Campo Requerido: Atención a");
	 document.form1.fld19.focus();  	 
	 return false;
   }

if (document.form1.fld19a.value == false)
   {
     alert("Campo Requerido: Correo Electrónico!");
     document.form1.fld19a.focus();  	 
	 return false;
   }

var mail = document.form1.fld19a.value;
var simb = "@";
var poin = ".";
var resu = mail.search(simb);
var pore = mail.search(poin);
var size = mail.length;

if (resu == -1)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.form1.fld19a.focus();  	 
	 return false;
   }
if (pore == -1)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.form1.fld19a.focus();  	 
	 return false;
   }

var total = resu + 2;
if (total == size)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.form1.fld19a.focus();  	 
	 return false;
   }

if (document.form1.fld20a.value == false)
   {
     alert("Campo Requerido: Larga distancia Tel");
	 document.form1.fld20a.focus();  	 
	 return false;
   }

if (document.form1.fld20.value == false)
   {
     alert("Campo Requerido: Número de Teléfono");
	 document.form1.fld20.focus();  	 
	 return false;
   }

if (document.form1.fld21a.value == false)
   {
     alert("Campo Requerido: Larga distancia Fax");
	 document.form1.fld21a.focus();  	 
	 return false;
   }

if (document.form1.fld21.value == false)
   {
     alert("Campo Requerido: Número de Fax");
	 document.form1.fld21.focus();  	 
	 return false;
   }

if (document.form1.fld22.value == false)
   {
     alert("Campo Requerido: Pais");
	 document.form1.fld22.focus();  	 
	 return false;
   }   
if (document.form1.fld22.value == "Mexico")
   {   
	if (document.form1.fld23.value == false)
         {
           alert("Campo Requerido: Estado");
           document.form1.fld23.focus();  	 
 	       return false;
         }
   }

if (document.form1.fld24.value == false)
   {
     alert("Campo Requerido: Ciudad");
	 document.form1.fld24.focus();  	 
	 return false;
   }

var confirmar = confirm('Enviar esta Forma?');
if (confirmar == true)
   {
    return true;
   }
    else
   {
    return false; 
   }    	      
}



//Validación Solicitud Enlace
function Valid_2() {

if (document.form1.fld1_1.value == false)
   {
     alert("Campo Requerido: Nombre");
	 document.form1.fld1_1.focus();  	 
	 return false;
   }

if (document.form1.fld1_2.value == false)
   {
     alert("Campo Requerido: Puesto");
	 document.form1.fld1_2.focus();  	 
	 return false;
   }
   
if (document.form1.fld1_31.value == false)
   {
     alert("Campo Requerido: Lada");
	 document.form1.fld1_31.focus();  	 
	 return false;
   }
   
if (document.form1.fld1_3.value == false)
   {
     alert("Campo Requerido: Tel.");
	 document.form1.fld1_3.focus();  	 
	 return false;
   }   
   
if (document.form1.fld1_4.value == false)
   {
     alert("Campo Requerido: Correo Electrónico!");
     document.form1.fld1_4.focus();  	 
	 return false;
   }

var mail = document.form1.fld1_4.value;
var simb = "@";
var poin = ".";
var resu = mail.search(simb);
var pore = mail.search(poin);
var size = mail.length;

if (resu == -1)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.form1.fld1_4.focus();  	 
	 return false;
   }
if (pore == -1)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.form1.fld1_4.focus();  	 
	 return false;
   }

var total = resu + 2;
if (total == size)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.form1.fld1_4.focus();  	 
	 return false;
   }
   
if (document.form1.fld1_5.value == false)
   {
     alert("Campo Requerido: Empresa");
	 document.form1.fld1_5.focus();  	 
	 return false;
   }   
   
if (document.form1.fld1_6.value == false)
   {
     alert("Campo Requerido: Ciudad");
	 document.form1.fld1_6.focus();  	 
	 return false;
   }   
   
if (document.form1.fld2.value == false)
   {
     alert("Campo Requerido: Producto que fabrica");
	 document.form1.fld2.focus();  	 
	 return false;
   } 

if (document.form1.fld3_1.value == "Si")
   {
   
	if (document.form1.fld4.value == " ")
	   {
	     alert("Campo Requerido: Número de personas interesadas en el programa");
		 document.form1.fld4.focus();  	 
		 return false;
	   }
   
	if (document.form1.fld5_1.value == " ")
	   {
	     alert("Campo Requerido: Personas por área / A) Administativa");
		 document.form1.fld5_1.focus();  	 
		 return false;
	   }
   
	if (document.form1.fld5_2.value == " ")
	   {
    	 alert("Campo Requerido: Personas por área / B) Ingeniería");
		 document.form1.fld5_2.focus();  	 
		 return false;
	   }

	if (document.form1.fld5_3.value == " ")
	   {
	     alert("Campo Requerido: Personas por área / C) Calidad");
		 document.form1.fld5_3.focus();  	 
		 return false;
	   }

	if (document.form1.fld5_4.value == " ")
		   {
	     alert("Campo Requerido: Personas por área / D) Producción");
		 document.form1.fld5_4.focus();  	 
		 return false;
	   }
   
	if (document.form1.fld5_5.value == " ")
	   {
	     alert("Campo Requerido: Personas por área / E) Mantenimiento");
		 document.form1.fld5_5.focus();  	 
		 return false;
	   }   
   
	if (document.form1.fld5_6.value == " ")
	   {
	     alert("Campo Requerido: Personas por área / F) Otras");
		 document.form1.fld5_6.focus();  	 
		 return false;
	   }
   
	if (document.form1.fld7_12.value == false)
	   {
	     alert("Campo Requerido: Horario Lunes");
		 document.form1.fld7_12.focus();  	 
		 return false;
	   }

	if (document.form1.fld7_13.value == " ")
	   {
	     alert("Campo Requerido: Horas Lunes");
		 document.form1.fld7_13.focus();  	 
		 return false;
	   }

	if (document.form1.fld7_22.value == false)
	   {	
	     alert("Campo Requerido: Horario Martes");
		 document.form1.fld7_22.focus();  	 
		 return false;
	   }

	if (document.form1.fld7_23.value == " ")
	   {
	     alert("Campo Requerido: Horas Martes");
		 document.form1.fld7_23.focus();  	 
		 return false;
	   }

	if (document.form1.fld7_32.value == false)
	   {
	     alert("Campo Requerido: Horario Miércoles");
		 document.form1.fld7_32.focus();  	 
		 return false;
	   }

	if (document.form1.fld7_33.value == " ")
	   {
	     alert("Campo Requerido: Horas Miércoles");
		 document.form1.fld7_33.focus();  	 
		 return false;
	   }

	if (document.form1.fld7_42.value == false)
	   {
	     alert("Campo Requerido: Horario Jueves");
		 document.form1.fld7_42.focus();  	 
		 return false;
	   }

	if (document.form1.fld7_43.value == " ")
	   {
	     alert("Campo Requerido: Horas Jueves");
		 document.form1.fld7_43.focus();  	 
		 return false;
	   }

	if (document.form1.fld7_52.value == false)
	   {
	     alert("Campo Requerido: Horario Viernes");
		 document.form1.fld7_52.focus();  	 
		 return false;
	   }

	if (document.form1.fld7_53.value == " ")
	   {
	     alert("Campo Requerido: Horas Viernes");
		 document.form1.fld7_53.focus();  	 
		 return false;
	   }

	if (document.form1.fld7_62.value == false)
	   {
	     alert("Campo Requerido: Horario Sábado");
		 document.form1.fld7_62.focus();  	 
		 return false;
	   }

	if (document.form1.fld7_63.value == " ")
	   {
	     alert("Campo Requerido: Horas Sábado");
		 document.form1.fld7_63.focus();  	 
		 return false;
	   }

	if (document.form1.fld7_72.value == false)
	   {
	     alert("Campo Requerido: Horario Domingo");
		 document.form1.fld7_72.focus();  	 
		 return false;
	   }

	if (document.form1.fld7_73.value == " ")
	   {
	     alert("Campo Requerido: Horas Domingo");
		 document.form1.fld7_73.focus();  	 
		 return false;
	   }

	if (document.form1.fld9_3.value == "Otro")
	   {
	
		if (document.form1.fld9_2.value == false)
		   {
	    	 alert("Campo Requerido: Otro");
			 document.form1.fld9_2.focus();  	 
			 return false;
		   }
	   }

	if (document.form1.fld10.value == false)
	   {
	     alert("Campo Requerido: Pregunta 10, en caso de no tener, escriba NO");
		 document.form1.fld10.focus();  	 
		 return false;
	   }


	if (document.form1.fld11.value == false)
	   {
	     alert("Campo Requerido: Pregunta 11, en caso de no tener, escriba NO");
		 document.form1.fld11.focus();  	 
		 return false;
	   }   
   }

if (document.form1.fld12.value == false)
    {
      alert("Campo Requerido: Pregunta 12, en caso de no tener, escriba NINGUNA");
      document.form1.fld12.focus();  	 
      return false;
     }

var confirmar = confirm('Enviar esta Forma?');
if (confirmar == true)
   {
    return true;
   }
    else
   {
    return false; 
   }    	      
}


//Validación de Campos de Solicitud de Convenio
function FieldValidConv() {

if (document.forma.nombre.value == false)
   {
     alert("Registre Nombre de la Empresa!");
	 document.forma.nombre.focus();  	 
	 return false;
   }
if (document.forma.rfc.value == false)
   {
     alert("Registre RFC!");
     document.forma.rfc.focus();  	 
	 return false;
   }
if (document.forma.rfc.value.length < 10)
   {
     alert("RFC no puede ser menor de 10 caracteres!");
	 document.forma.rfc.focus();  	 
	 return false;
   }

if (document.forma.rfc.value.length > 13)
   {
     alert("RFC no puede ser mayor de 13 caracteres!");
	 document.forma.rfc.focus();  	 
	 return false;
   }   
if (document.forma.representante.value == false)
   {
     alert("Registre Representante de la Empresa!");
	 document.forma.representante.focus();  	 
	 return false;
   }
if (document.forma.email.value == false)
   {
     alert("Registre Correo Electrónico!");
     document.forma.email.focus();  	 
	 return false;
   }

var mail = document.forma.email.value;
var simb = "@";
var poin = ".";
var resu = mail.search(simb);
var pore = mail.search(poin);
var size = mail.length;

if (resu == -1)
   {
     alert("Escriba corectamente el Correo Electronico, falta @!");
     document.forma.email.focus();  	 
	 return false;
   }
if (pore == -1)
   {
     alert("Escriba corectamente el Correo Electronico, falta .!");
     document.forma.email.focus();  	 
	 return false;
   }

var total = resu + 2;
if (total == size)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.forma.email.focus();  	 
	 return false;
   }
if (document.forma.dir.value == false)
   {
     alert("Registre Dirección de la Empresa!");
	 document.forma.dir.focus();  	 
	 return false;
   }
if (document.forma.cuidad.value == false)
   {
     alert("Registre Cuidad!");
	 document.forma.cuidad.focus();  	 
	 return false;
   }
if (document.forma.edo.value == false)
   {
     alert("Registre Estado!");
	 document.forma.edo.focus();  	 
	 return false;
   }
if (document.forma.tel.value == false)
   {
     alert("Registre Teléfono de la Empresa!");
	 document.forma.tel.focus();  	 
	 return false;
   }
if (document.forma.fax.value == false)
   {
     alert("Registre Fax de la Empresa!");
	 document.forma.fax.focus();  	 
	 return false;
   }
if (document.forma.tipo.value == false)
   {
     alert("Registre Servicio de Intéres!");
	 document.forma.tipo.focus();  	 
	 return false;
   }
if (document.forma.convenio.value == false)
   {
     alert("Registre Comentarios!");
	 document.forma.convenio.focus();  	 
	 return false;
   }
var confirmar = confirm('¿Deseas Registrar esta Solicitud?');
if (confirmar == true)
   {
    return true;
   }
    else
   {
    return false; 
   }    	      
}

//Validación de Campos
function FieldValid() {

if (document.frmMain.x_FTB2.value == false)
   {
     alert("Registre Nombre o Razón Social!");
	 document.frmMain.x_FTB2.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB3.value == false)
   {
     alert("Registre Número de RFC!");
	 document.frmMain.x_FTB3.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB3.value.length < 10)
   {
     alert("RFC no puede ser menor de 10 caracteres!");
	 document.frmMain.x_FTB3.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB3.value.length > 13)
   {
     alert("RFC no puede ser mayor de 13 caracteres!");
	 document.frmMain.x_FTB3.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB5.value == false)
   {
     alert("Registre Representante Legal!");
	 document.frmMain.x_FTB5.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB6.value == false)
   {
     alert("Registre Giro de la Empresa!");
     document.frmMain.x_FTB6.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB7.value == false)
   {
     alert("Registre Calle del Domicilio !");
     document.frmMain.x_FTB7.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB10.value == false)
   {
     alert("Registre Colonia del Domicilio!");
     document.frmMain.x_FTB10.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB11.value == false)
   {
     alert("Registre Codigo Postal!");
     document.frmMain.x_FTB11.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB12.value == false)
   {
     alert("Registre Delegación o Municipio (Cuidad/Población)!");
     document.frmMain.x_FTB12.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB13.value == false)
   {
     alert("Registre Entidad Federativa (Estado)!");
     document.frmMain.x_FTB13.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB14.value == false)
   {
     alert("Registre Lada (Clave Larga Distancia)!");
     document.frmMain.x_FTB14.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB15.value == false)
   {
     alert("Registre Número Telefónico!");
     document.frmMain.x_FTB15.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB16.value == false)
   {
     alert("Registre Lada FAX (Clave Larga Distancia)!");
     document.frmMain.x_FTB16.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB17.value == false)
   {
     alert("Registre Número Telefónico FAX!");
     document.frmMain.x_FTB17.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB19.value == false)
   {
     alert("Registre Correo Electrónico!");
     document.frmMain.x_FTB19.focus();  	 
	 return false;
   }

var mail = document.frmMain.x_FTB19.value;
var simb = "@";
var poin = ".";
var resu = mail.search(simb);
var pore = mail.search(poin);
var size = mail.length;

if (resu == -1)
   {
     alert("Escriba corectamente el Correo Electronico, falta @!");
     document.frmMain.x_FTB19.focus();  	 
	 return false;
   }
if (pore == -1)
   {
     alert("Escriba corectamente el Correo Electronico, falta .!");
     document.frmMain.x_FTB19.focus();  	 
	 return false;
   }

var total = resu + 2;
if (total == size)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.frmMain.x_FTB19.focus();  	 
	 return false;
   }


if (document.frmMain.x_FTB20.value == false)
   {
     alert("Registre Contacto!");
     document.frmMain.x_FTB20.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB21.value == false)
   {
     alert("Registre Puesto del Contacto!");
     document.frmMain.x_FTB21.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB22.value == false)
   {
     alert("Registre Lada del Contacto (Clave Larga Distancia)!");
     document.frmMain.x_FTB22.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB23.value == false)
   {
     alert("Registre Número Telefónico del Contacto!");
     document.frmMain.x_FTB23.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB25.value == false)
   {
     alert("Registre Beneficiario!");
     document.frmMain.x_FTB25.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB26.value == false)
   {
     alert("Registre Banco!");
     document.frmMain.x_FTB26.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB28.value == false)
   {
     alert("Registre Número de Cuenta!");
     document.frmMain.x_FTB28.focus();  	 
     return false;
   }

if (document.frmMain.x_FTB34.value == false)
   {
     alert("Registre Clave!");
     document.frmMain.x_FTB34.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB35.value == false)
   {
     alert("Registre Sucursal!");
     document.frmMain.x_FTB35.focus();  	 
	 return false;
 }

if (document.frmMain.x_FTB36.value == false)
   {
     alert("Registre Plaza!");
     document.frmMain.x_FTB36.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB37.value == false)
   {
     alert("Registre Referencia!");
     document.frmMain.x_FTB37.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTBps.value == false)
   {
     alert("Registre Contraseña para futuras modificaciones!");
     document.frmMain.x_FTBps.focus();  	 
	 return false;
   }

if (document.frmMain.a.value == "A")
{

if (document.frmMain.x_FTB1.value == "I")
   {
    if (document.frmMain.x_FTB27.value == false)
       {
        alert("Registre Direccion del Banco!");
        document.frmMain.x_FTB27.focus();  	 
        return false;
       }
	if (document.frmMain.x_FTB29.value + document.frmMain.x_FTB30.value + document.frmMain.x_FTB31.value == false)
       {
         alert("Registre cuando menos un campo - ABA, ROUHING, IBAN!");
         document.frmMain.x_FTB29.focus();  	 
  	     return false;
	   } 
    if (document.frmMain.x_FTB32 == false)
       {
         alert("Registre SWIF CODE!");
         document.frmMain.x_FTB32.focus();  	 
  	     return false;
	   }	   
  }
}

if (document.frmMain.a.value == "U")
{    
 if (document.frmMain.tipPro.value == "I")
    {
      if (document.frmMain.x_FTB27.value == false)
         {
         alert("Registre Direccion del Banco!");
         document.frmMain.x_FTB27.focus();  	 
         return false;
         }
      if (document.frmMain.x_FTB29.value + document.frmMain.x_FTB30.value + document.frmMain.x_FTB31.value == false)
         {
         alert("Registre cuando menos un campo - ABA, ROUHING, IBAN!");
         document.frmMain.x_FTB29.focus();  	 
     	 return false;
         } 
      if (document.frmMain.x_FTB32.value == false)
         {
         alert("Registre SWIF CODE!");
         document.frmMain.x_FTB32.focus();  	 
         return false;
	     }	     
	}
}

if (document.frmMain.a.value == "A")
{
  var confirmar = confirm('¿Deseas Registrar sus Datos?');
}

if (document.frmMain.a.value == "U")
{
  if (document.frmMain.tipPro.value == "N" & document.frmMain.tPro.value == "I")
    {    
     alert('Se ha cambiado el tipo de Proveedor a Nacional!, los Campos Direccion del Banco, ABA, ROUTHING, IBAN serán borrados');	
     var confirmar = confirm('¿Deseas Modificar sus Datos?');
     if (confirmar == true)
        {
         document.frmMain.x_FTB27.value= "";
         document.frmMain.x_FTB29.value= "";
	     document.frmMain.x_FTB30.value= "";
	     document.frmMain.x_FTB31.value= "";
         document.frmMain.x_FTB32.value= "";
         return true; 
        }
         else
        {
  	     return false;   
	    }	  		
	}
  var confirmar = confirm('¿Deseas Modificar sus Datos?');
  if (confirmar == true)
     {
      return true;
     }
      else
     {
 	   return false; 
     }   	   
}

if (confirmar == true)
   {
     return true;
   }
	 else
   {
	return false; 
   }
}

//Check Edad
function CheckEdad (date0) {

var date1, anac, mnac, dnac; // Fecha de Nacimiento
date1 = date0;
anac = date1.substr(0, 4);  //Get substring.
mnac = date1.substr(5, 2);
dnac = date1.substr(8, 2);

var date2, aact, mact, dact; // Fecha Actual
date2 = new Date();
aact = date2.getFullYear();
mact = date2.getMonth()+1;
dact = date2.getDate();

var acal; // Calculo de Año
acal = aact - anac;
mnac = Math.abs(mnac);
dnac = Math.abs(dnac);
mact = Math.abs(mact);
dact = Math.abs(dact);

var mres, dres, edad; // resultados

if (document.form1.x_FTB5.value == false || acal == 0){
	alert("Edad no valida, registre correctamente su Fecha de Nacimiento!");
    document.form1.btn_fecha.focus();	
	}
	else
	{
if (mnac==mact & dnac<dact || mnac<mact)
   {mres = 0;}
   else
   {mres = 1;}

if (mres==1)
   {edad = acal - 1;}
    else
   {edad = acal;}

if (edad<18){	
	alert("Edad no valida, registre correctamente su Fecha de Nacimiento!");
    document.form1.btn_fecha.focus();	
	}
	else
	{document.form1.x_FTB6.value = edad;}
}
return true;
}

//Validación de Estado
function SelectedIndx()
{
	if(document.form1.x_FTB82.options[document.form1.x_FTB81.selectedIndex].text != "México")
	{
		document.form1.x_FTB81.value = "No Aplica";
	}
}

//Validación de Pais
function SelectedIndx2()
{
	if(document.form1.x_FTB81.options[document.form1.x_FTB81.selectedIndex].text != "No Aplica")
	{
		document.form1.x_FTB82.value = "México";
	}
}

//Validación de Nacionalidad
function CheckNacionalidad()
{
	if(document.form1.x_FTB82.options[document.form1.x_FTB82.selectedIndex].text == "México")
	{
		document.form1.x_FTB9.value = "Mexicana";
		document.form1.x_FTB9m.focus();
	}
}

//Validación de Promedio1
function CheckProm()
{
	if(document.form1.x_FTB27.value <= 69 || document.form1.x_FTB27.value > 100 )
	{
		alert("Promedio no valido!");
		document.form1.x_FTB27.focus();
		return false;
	}
}

//Validación de Promedio2
function CheckProm2()
{
		if(document.form1.x_FTB36.value <= 69 || document.form1.x_FTB36.value > 100 )
	{
		alert("Promedio no valido!");
		document.form1.x_FTB36.focus();
		return false;
	}
}

//Validación de Campos Solicitud Posgrado
function FieldValidPos()
{
	if(document.form1.b.value == false)
	{
		alert("Registre Programa!");
		window.location.href="fechas.asp"
	//   document.form1.x_FTB1.focus();
		return false;
	}
	
	if(document.form1.b.value == "eqa")
	{
		if(document.form1.x_FTB1a.value == false)
		{
			alert("Registre Opción Terminal!");
			document.form1.x_FTB1a.focus();
			return false;
		}
	}
	
	if (document.form1.x_FTB2.value == false)
	{
		alert("Registre su Apellido Paterno!");
		document.form1.x_FTB2.focus();
		return false;
	}
	
	if(document.form1.x_FTB3.value == false)
	{
		alert("Registre su Apellido Materno!");
		document.form1.x_FTB3.focus();
		return false;
	}
	
	if(document.form1.x_FTB4.value == false)
	{
		alert("Registre su o sus Nombres!");
		document.form1.x_FTB4.focus();
		return false;
	}
	
	//Validación Fecha de Nacimiento	
	if(document.form1.x_FTB5.value == false)
	{
		alert("Seleccione y registre una fecha valida!");
		document.form1.btn_fecha.focus();
		return false;
	}

    //Validación Edad
	if(document.form1.x_FTB6.value == false)
	{
		alert("Registre Edad!");
		document.form1.x_FTB6.focus();
		return false;
	}
	
	//Validación Clave de RFC
	if(document.form1.x_FTB7.value == false)
	{
		alert("Registre una clave RFC!");
		document.form1.x_FTB7.focus();
		return false;
	}
	
		if(document.form1.x_FTB7.value.length < 10)
	{
		alert("La clave RFC no puede ser menor a 10 caracteres!");
		document.form1.x_FTB7.focus();
		return false;
	}
	
		if(document.form1.x_FTB7.value.length > 13)
	{
		alert("La clave RFC no puede ser mayor a 13 caracteres!");
		document.form1.x_FTB7.focus();
		return false;
	}
	
	//Validación Lugar de Nacimiento
	if(document.form1.x_FTB8.value == false)
	{
		alert("Registre un Lugar de Nacimiento!");
		document.form1.x_FTB8.focus();
		return false;
	}
	
	if(document.form1.x_FTB81.value == false)
	{
		alert("Seleccione y registre un Estado!")
		document.form1.x_FTB81.focus();
		return false;
	}
	
	if(document.form1.x_FTB82.value == false)
	{
		alert("Seleccione y registre un País!");
		document.form1.x_FTB82.focus();
		return false;
	}
	
	//Validación Nacionalidad
	if(document.form1.x_FTB9.value == false)
	{
		alert("Registre Nacionalidad!");
		document.form1.x_FTB9.focus();
		return false;
	}
	
	if (document.form1.x_FTB9m.value == false)
   {
     alert("Registre Correo Electrónico!");
     document.form1.x_FTB9m.focus();  	 
	 return false;
   }


    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.form1.x_FTB9m.value))
   {
   document.form1.x_FTB12.focus();
   }
     else
   {
     alert("La dirección de email es incorrecta.");
     document.form1.x_FTB9m.focus();  
	 return false;
   }
  
	//Validación Estado Civil
	if(document.form1.edoCivil.value == "o" && document.form1.x_FTB11.value == false)
	{
		alert("Especifique Otro Estado Civil!");
		document.form1.x_FTB11.focus();
		return false;		
	}
	
	//Validación Teléfono
	if(document.form1.x_FTB12.value == false)
	{
		alert("Registre la Clave Lada!");
		document.form1.x_FTB12.focus();
		return false;
	}
	
	if(document.form1.x_FTB13.value == false)
	{
		alert("Registre un Numero Telefonico!");
		document.form1.x_FTB13.focus();
		return false;
	}

	//Validación Domicilio
	if(document.form1.x_FTB14.value == false)
	{
		alert("Registre Calle!");
		document.form1.x_FTB14.focus();
		return false;
	}
	
	if(document.form1.x_FTB15.value == false)
	{
		alert("Registre Numero Exterior o Interior!");
		document.form1.x_FTB15.focus();
		return false;
	}

	if(document.form1.x_FTB16.value == false)
	{
		alert("Registre Colonia!");
		document.form1.x_FTB16.focus();
		return false;
	}

	if(document.form1.x_FTB17.value == false)
	{
		alert("Registre Ciudad!");
		document.form1.x_FTB17.focus();
		return false;
	}
	
	if(document.form1.x_FTB18.value == "")
	{
		alert("Seleccione y Registre un Estado!");
		document.form1.x_FTB18.focus();
		return false;
	}
	
		if(document.form1.x_FTB19.value == false)
	{
		alert("Registre Codigo Postal!");
		document.form1.x_FTB19.focus();
		return false;
	}
	
	//Validacion de Lincenciatura
	if(document.form1.x_FTB26.value == false)
	{
		alert("Registre una Carrera Cursada!");
		document.form1.x_FTB26.focus();
		return false;
	}
	
	if(document.form1.x_FTB27.value == false)
	{
		alert("Registre un Promedio!");
		document.form1.x_FTB27.focus();
		return false;
	}
	
	if(document.form1.x_FTB28.value == false)
	{
		alert("Registre Institucion!");
		document.form1.x_FTB28.focus();
		return false;
	}
	
	if(document.form1.estudios1.value == "s" && document.form1.x_FTB30.value == false)
	{
		alert("Registre Fecha de Titulación!");
		document.form1.btn_fecha_tit1.focus();
		return false;
	}
	
	if(document.form1.estudios2.value == "s" && document.form1.x_FTB32.value == false)
	{
		alert("Registre Titulo Tesis!");
		document.form1.x_FTB32.focus();
		return false;
	}
	
		if(document.form1.estudios1.value == "n" && document.form1.x_FTB33.value == false)
	{
		alert("Seleccione y Registre un Fecha!");
		document.form1.btn_pas.focus();
		return false;
	}

	//Validacion Estudios de Posgrado
	if(document.form1.x_FTB34.value == false)
	{
		alert("Registre Grado Obetnido!");
		document.form1.x_FTB34.focus();
		return false;
	}	

	if(document.form1.x_FTB35.value == false)
	{
		alert("Seleccione y Registre una Fecha!");
		document.form1.btn_fecha_tit2.focus();
		return false;
	}
	
	if(document.form1.x_FTB36.value == false)
	{
		alert("Régistre un Promedio!");
		document.form1.x_FTB36.focus();
		return false;
	}
	
	if(document.form1.becaCon.value == "s" && document.form1.x_FTB38.value == false)
	{
		alert("Registre Periodo de Beca!");
		document.form1.x_FTB38.focus();
		return false;
	}

	if(document.form1.x_FTB39.value == false)
	{
		alert("Registre Instución de Egreso!");
		document.form1.x_FTB39.focus();
		return false;
	}
	
	if(document.form1.x_FTB40.value == false)
	{
		alert("Registre Titulo de Tesis!");
		document.form1.x_FTB40.focus();
		return false;
	}
	
    //Validacion Otros Estudios
	//if(document.form1.x_FTB41.value == false)
	//{
	//	alert("Registre Otros Estudios!");
	//	document.form1.x_FTB41.focus();
	//	return false;
	//}
	
	//Validacion Datos de Familiares en caso de Accidente
	if(document.form1.x_FTB42.value == false)
	{
		alert("Registre Nombre!");
		document.form1.x_FTB42.focus();
		return false;
	}

	if(document.form1.x_FTB43.value == false)
	{
		alert("Registre Parentesco!");
		document.form1.x_FTB43.focus();
		return false;
	}
			
	if(document.form1.x_FTB44.value == false)
	{
		alert("Registre Calle");
		document.form1.x_FTB44.focus();
		return false;
	}
	
	if(document.form1.x_FTB45.value == false)
	{
		alert("Registre Numero Exterior e Interior");
		document.form1.x_FTB45.focus();
		return false;
	}
					
	if(document.form1.x_FTB46.value == false)
	{
		alert("Registre Colonia!");
		document.form1.x_FTB46.focus();
		return false;
	}

	if(document.form1.x_FTB47.value == false)
	{
		alert("Registre Ciudad!");
		document.form1.x_FTB47.focus();
		return false;
	}

	if(document.form1.x_FTB48.value == false)
	{
		alert("Seleccione y Registre un Estado!");
		document.form1.x_FTB48.focus();
		return false;
	}
	
	if(document.form1.x_FTB49.value == false)
	{
		alert("Registre un Codigo Postal!");
		document.form1.x_FTB49.focus();
		return false;
	}
	
	if(document.form1.x_FTB50.value == false)
	{
		alert("Registre Lada");
		document.form1.x_FTB50.focus();
		return false;
	}

	if(document.form1.x_FTB51.value == false)
	{

		alert("Registre Telefono!");
		document.form1.x_FTB51.focus();
		return false;
	}
	
	var confirmar = confirm('¿Deseas Registrar esta Solicitud?');
	if (confirmar == true)
   	{
   		 return true;
   	}
    else
   	{
    	return false; 
   	}    	      
}

//Script de Enfoque Body
function BodyFocus() {
var win=null;
var frmMain=document.getElementById('frmMain'); 
document.frmMain.x_FTB1.focus();   
}

//Script de Enfoque Body - Giros
function BodyFocus1() {
var win=null;
var frmMain=document.getElementById('frmMain'); 
document.frmMain.detalle.focus();   
}

//Script de Enfoque Body - Giros 2
function BodyFocus2() {
var win=null;
var mod_ate=document.getElementById('mod_ate'); 
document.mod_ate.x_FTB1.focus();   
}

//Script de Enfoque Validación RFC
function RFCFocus() {
var win=null;
var frmMain=document.getElementById('frmMain'); 
document.frmMain.x_FTB1.value=document.frmMain.tipPro.value;
document.frmMain.x_FTB6.value=document.frmMain.x_FTB60.value;
document.frmMain.x_FTB13.value=document.frmMain.x_FTB130.value;
CheckInt();
document.frmMain.x_FTB3.focus();
}

//Script de Enfoque Validación de Nombre
function NomFocus() {
var win=null;
var frmMain=document.getElementById('frmMain'); 
document.frmMain.x_FTB1.value=document.frmMain.tipPro.value;
document.frmMain.x_FTB6.value=document.frmMain.x_FTB60.value;
document.frmMain.x_FTB13.value=document.frmMain.x_FTB130.value;
CheckInt();
document.frmMain.x_FTB2.focus();
}

//Script para bloqueo
function CheckBlocked() {

var key = window.event.keyCode;

if ( key > 0 && key < 10 )
	//&& key < 58 )
return; 
else
window.event.returnValue = null;
}

//Script para Números
function CheckNumeric() {

var key = window.event.keyCode;

if ( key > 47 && key < 58 )
return; 
else
window.event.returnValue = null;
}
  
//Script para Mayusculas
function toUpper()
{
  key = window.event.keyCode;
  if (key > 0x0060 && key < 0x007b)
  {
    window.event.keyCode = key - 0x0020;
  }
}

//Script para Imprimir
function varitext(text)
{
    text=document
    print(text)
}

// Script para ventana pasando datos de SubSeries
function NewWindow1(mypage,myname,w,h,scroll,pos)
{
    var win=null;
    var frmMain=document.getElementById('frmMain'); 
    var serDocX=escape(document.mod_ate.cta.value);    
	serDocX=serDocX.substr(0,20);
	
    if(serDocX=="")
	{
	  alert("Nombre de Usuario no Existe");
	  document.mod_ate.cta.focus(); 
	  
	  return;
	}
	   
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
    }
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;
    }
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20
    }
    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=yes,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    mypage=mypage+serDocX;
    win=window.open(mypage,myname,settings);        
}


// Script para ventana
function NewWindow0(mypage,myname,w,h,scroll,pos)
{
    var win=null;
    var frmMain=document.getElementById('frmMain'); 
    if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
    }
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;
    }
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20
    }
    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=no,menubar=yes,toolbar=no,resizable=no';
    win=window.open(mypage,myname,settings);        
}

// Script para ventana
function NewWindow(mypage,myname,w,h,scroll,pos)
{
    var win=null;
    //var frmMain=document.getElementById('frmMain'); 
    if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
    }
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;
    }
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20
    }
    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
    win=window.open(mypage,myname,settings);        
}

// Script para ventana
function NewWindow2(mypage,myname,w,h,scroll,pos)
{
    var win=null;
    var frmMain=document.getElementById('frmMain'); 
    if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
    }
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;
    }
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20
    }
    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=yes,resizable=no';
    win=window.open(mypage,myname,settings);        
}

// Script para ventana pasando datos 1
function NewWindowC(mypage,myname,w,h,scroll,pos)
{
    var win=null;
    var frmMain=document.getElementById('frmMain'); 
    var cliente=escape(document.mod_ate.clie.value);          	
    if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
    }
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;
    }
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20
    }
    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    mypage=mypage+cliente;
    win=window.open(mypage,myname,settings);        
}

// Script para ventana pasando datos 2
function NewWindowD(mypage,myname,w,h,scroll,pos)
{
    var win=null;
    var frmMain=document.getElementById('frmMain'); 
    var cliente=escape(document.mod_ate.clie.value);       
    if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
    }
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;
    }
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20
    }
    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    mypage=mypage+cliente;
    win=window.open(mypage,myname,settings);        
}


// Script para cambiar fondo de cajas de textos en edición (activo)
function CatCli()
{
   //var cli=encodeURI(document.mod_ate.x_FTB1.value);      
   //var cli=encodeURIComponent(document.mod_ate.x_FTB1.value);   
   //var cli=decodeURIComponent(document.mod_ate.x_FTB1.value);
   var elb=escape(document.mod_ate.x_FTB0.value);      
   var cli=escape(document.mod_ate.x_FTB1.value);
   var sol=escape(document.mod_ate.x_FTB2.value);   
   var rep=escape(document.mod_ate.x_FTB3.value);   
   var tel=escape(document.mod_ate.x_FTB4.value);   
   var fax=escape(document.mod_ate.x_FTB5.value);  
   var ema=escape(document.mod_ate.x_FTB6.value);   
   var coc=escape(document.mod_ate.x_FTB60.value);   
   var ser=escape(document.mod_ate.x_FTB7.value);
   var com=escape(document.mod_ate.x_FTB9.value);   
   var mnu=escape(document.mod_ate.mnu.value)      
   page = "acPublic001.asp?mnu="+mnu+"&elb="+elb+"&cli="+cli+"&sol="+sol+"&rep="+rep+"&tel="+tel+"&fax="+fax+"&ema="+ema+"&ser="+ser+"&com="+com+"&coc="+coc; 
   location=page;
}

// Script para cambiar fondo de cajas de textos en edición (activo)
function CatCliP()
{
   var elb=escape(document.mod_ate.x_FTB0.value);      
   var cli=escape(document.mod_ate.x_FTB1.value);
   var sol=escape(document.mod_ate.x_FTB2.value);   
   var rep=escape(document.mod_ate.x_FTB3.value);   
   var tel=escape(document.mod_ate.x_FTB4.value);   
   var fax=escape(document.mod_ate.x_FTB5.value);  
   var ema=escape(document.mod_ate.x_FTB6.value);   
   var coc=escape(document.mod_ate.x_FTB60.value);   
   var ser=escape(document.mod_ate.x_FTB7.value);
   var com=escape(document.mod_ate.x_FTB9.value);   
   page = "ac001_0.asp?elb="+elb+"&cli="+cli+"&sol="+sol+"&rep="+rep+"&tel="+tel+"&fax="+fax+"&ema="+ema+"&ser="+ser+"&com="+com+"&coc="+coc; 
   location=page;
}

// Script para cambiar fondo de cajas de textos en edición (activo)
function CatCliO()
{
   var elb=escape(document.mod_ate.x_FTB0.value);      
   var cli=escape(document.mod_ate.x_FTB1.value);
   var sol=escape(document.mod_ate.x_FTB2.value);   
   var rep=escape(document.mod_ate.x_FTB3.value);   
   var tel=escape(document.mod_ate.x_FTB4.value);   
   var fax=escape(document.mod_ate.x_FTB5.value);  
   var ema=escape(document.mod_ate.x_FTB6.value);   
   var coc=escape(document.mod_ate.x_FTB60.value);   
   var ser=escape(document.mod_ate.x_FTB7.value);
   var com=escape(document.mod_ate.x_FTB9.value);       
   page = "ac000_1_0.asp?elb="+elb+"&cli="+cli+"&sol="+sol+"&rep="+rep+"&tel="+tel+"&fax="+fax+"&ema="+ema+"&ser="+ser+"&com="+com+"&coc="+coc; 
   location=page;
}

// Script para cambiar fondo de cajas de textos en edición - Modificaciones (activo)
function CatCliM()
{
   var ate=document.mod_ate.key.value;
   var cli=escape(document.mod_ate.x_FTB1.value);             
   page = "ac001_00.asp?ate="+ate+"&cli="+cli
   location=page;
}

// Script para cambiar fondo de cajas de textos en edición - Modificaciones Especiales (activo)
function CatCliME()
{
   var ate=document.mod_ate.key.value;
   var cli=escape(document.mod_ate.x_FTB1.value);      
   page = "ac001_00.asp?ate="+ate+"&cli="+cli+"&esp=1"
   location=page;
}

// Script para fecha
function Fecha()
{
   var months=new Array(13);
   months[1]="Enero";
   months[2]="Febrero";
   months[3]="Marzo";
   months[4]="Abril";
   months[5]="Mayo";
   months[6]="Junio";
   months[7]="Julio";
   months[8]="Agosto";
   months[9]="Septiembre";
   months[10]="Octubre";
   months[11]="Noviembre";
   months[12]="Diciembre";
   var time=new Date();
   var lmonth=months[time.getMonth() + 1];
   var date=time.getDate();
   var year=time.getYear();
   
   if (year < 2000)    
      year = year + 1900; 
      document.write("<right>" + lmonth + " ");
      document.write(date + ", " + year + "</center>");
}


// Script para cambiar fondo de cajas de textos en edición (activo)
function enterField(f1)
{
   if (f1 && f1.style)
   {
     f1.style.background='#FEFDE0';
   }
}

// Script para cambiar fondo de cajas de textos en edición (desenlección)
function exitField(f1)
{
   if (f1 && f1.style)
   {
     f1.style.background='#FFFFFF'
   }
}

function ValidateKey(f1,f2,f3,f4,f5)
{
   var key=window.event.keyCode;
   if (f3=='a')
   {
     var allowed='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ :;,.?!£$%^&*()_+-*{}@~<>&"\'';
   }
   else if (f3=='n')
   {
     var allowed='0123456789,-';
   }
   else if (f3=='i')
   {
     var allowed='0123456789-';
   }
   else if (f3=='s')
   {
     var allowed=f4;
   }
   if (f3!='')
   {
      if (key!=13)
      {
         if (allowed.indexOf(String.fromCharCode(key))==-1)
         {
            key=0;
         }
      }
   }

   if (f3=='n'||f3=='i')
   {
      if (key==46)
      {
         if (f1.value.indexOf(',')>-1)
         {
            key=0;
         }
      }
   }

   if (f5=='u')
   {
      var newkey=String.fromCharCode(key).toUpperCase();
      key=newkey.charCodeAt(0);
   }
   else if (f5=='l')
   {
      var newkey=String.fromCharCode(key).toLowerCase();
      key=newkey.charCodeAt(0);
   }

   window.event.keyCode=key;
}


function ValidateField(f1,f2)
{
   if (!f1)
   {
       return true;
   }
   if (f1.type=='hidden')
   {
       return true;
   }
   currentError=document.getElementById('currentError');
   if (!currentError)
   {
       exitField(f1);
       return true;
   }
   if (currentError.value!='')
   {
      if (currentError.value!=f1.name)
      {
         exitField(f1);
         return true;
      }
   }

   if (f1.value.length<f2)
   {
      alert('Este Campo debe ser primero '+f2+' Caracteres largos');
      currentError.value=f1.name;
      f1.focus();
      f1.select();
      return false;
   }
   else
   {
      exitField(f1);
      currentError.value='';
      return true;
   }
}

function ValidateNumber(f1,f2,f3,f4,f5)
{
   if (!f1)
   {
       return true;
   }
   if (f1.type=='hidden')
   {
       return true;
   }
   currentError=document.getElementById('currentError');
   if (!currentError)
   {
       exitField(f1);
       return true;
   }
   if (currentError.value!='')
   {
      if (currentError.value!=f1.name)
      {
         exitField(f1);
         return true;
      }
   }
   if (f5==0)
   {
      return true;
   }
   if (f1.value=='')
   {
      alert('Este valor debe de ser especificado.');
      currentError.value=f1.name;
      f1.focus();
      f1.select();
      return false;
   }


   if ((f3!=0||f4!=0))
   {
      if (f1.value<f3)
      {
         alert('El valor mínimo permitido es: '+f3);
         currentError.value=f1.name;
         f1.focus();
         f1.select();
         return false;
      }
      else if (f1.value>f4)
      {
         alert('Este valor debe de ser menor o igual que '+f4);
         currentError.value=f1.name;
         f1.focus();
         f1.select();
         return false;
      }
   }

   var decimalpos=f1.value.indexOf('.');
   var fieldlen=f1.value.length;
   if (decimalpos>0)
   {
      if ((f2+1)<(fieldlen-decimalpos))
      {
        alert('Solamente '+f2+' Espacios decimales permitidos!');
        currentError.value=f1.name;
        f1.focus();
        f1.select();
        return false;
      }
   }
   exitField(f1);
   currentError.value='';
   return true;
}

function ValidateSearchNumber(f1,f2,f3,f4)
{
   if (!f1)
   {
       return true;
   }
   if (f1.value=='')
   {
      exitField(f1);
      return true;
   }
   else
   {
      return ValidateNumber(f1,f2,f3,f4);
   }
}


function ValidateDateTime(f1,f2,f3)
{
   if (!f1)
   {
       return true;
   }
   if (f1.type=='hidden')
   {
       return true;
   }
   currentError=document.getElementById('currentError');
   if (!currentError)
   {
       exitField(f1);
       return true;
   }
   if ((f3==0) & (f1.value.length==0))
   {
     exitField(f1);
     return true;
   }
   if (currentError.value!='')
   {
      if (currentError.value!=f1.name)
      {
         exitField(f1);
         return true;
      }
   }

   if (f1.value.length<12)
   {
      alert('Favor de introducir el formato  fecha /hora mostrado');
      currentError.value=f1.name;
      f1.focus();
      f1.select();
      return false;
   }

   if (f2==1)
   {
      var dd=f1.value.substring(0,2);
      var mm=f1.value.substring(2,4);
      var yy=f1.value.substring(4,8);
   }
   else if (f2==0)
   {
      var mm=f1.value.substring(0,2);
      var dd=f1.value.substring(2,4);
      var yy=f1.value.substring(4,8);
   }
   else if (f2==2)
   {
      var yy=f1.value.substring(0,4);
      var mm=f1.value.substring(4,6);
      var dd=f1.value.substring(6,8);
   }

   if (dd>31)
   {
      alert('El valor de dias no deberá ser mayor que 31!');
      currentError.value=f1.name;
      f1.focus();
      f1.select();
      return false;
   }
   if (mm>12)
   {
      alert('El Mes no deberá ser mayor que 12!');
      currentError.value=f1.name;
      f1.focus();
      f1.select();
      return false;
   }
   if (dd==31)
   {
      if (mm==4||mm==6||mm==9||mm==11)
      {
         alert('No hay día 31 en el Mes... '+mm);
         currentError.value=f1.name;
         f1.focus();
         f1.select();
         return false;
      }
   }
   if (mm==2)
   {
      if (dd>29)
      {
         alert('No hay '+dd+' días en Febrero!');
         currentError.value=f1.name;
         f1.focus();
         f1.select();
         return false;
      }
      if (dd==29)
      {
         if (yy%4!=0)
         {
            alert('No hay 29 días en Febrero de este año');
            currentError.value=f1.name;
            f1.focus();
            f1.select();
            return false;
         }
      }
   }

   var hh=f1.value.substring(8,10);
   var mm=f1.value.substring(10,12);
   if (hh>23)
   {
      alert('Las horas no podrán ser mayores que 23!');
      currentError.value=f1.name;
      f1.focus();
      f1.select();
      return false;
   }
   if (mm>59)
   {
      alert('[M13]!');
      currentError.value=f1.name;
      f1.focus();
      f1.select();
      return false;
   }
   exitField(f1);
   currentError.value='';
   return true;
}

function ValidateDate(f1,f2,f3)
{
   if (!f1)
   {
       return true;
   }
   if (f1.type=='hidden')
   {
       return true;
   }
   currentError=document.getElementById('currentError');
   if (!currentError)
   {
       exitField(f1);
       return true;
   }
   if ((f3==0) & (f1.value.length==0))
   {
     exitField(f1);
     return true;
   }
   if (currentError.value!='')
   {
      if (currentError.value!=f1.name)
      {
         exitField(f1);
         return true;
      }
   }

   if (f1.value.length<8)
   {
      alert('Favor de introducir el formato  fecha /hora mostrado');
      currentError.value=f1.name;
      f1.focus();
      f1.select();
      return false;
   }

   if (f2==1)
   {
      var dd=f1.value.substring(0,2);
      var mm=f1.value.substring(2,4);
      var yy=f1.value.substring(4,8);
   }
   else if (f2==0)
   {
      var mm=f1.value.substring(0,2);
      var dd=f1.value.substring(2,4);
      var yy=f1.value.substring(4,8);
   }
   else if (f2==2)
   {
      var yy=f1.value.substring(0,4);
      var mm=f1.value.substring(4,6);
      var dd=f1.value.substring(6,8);
   }

   if (dd>31)
   {
      alert('El valor de dias no deberá ser mayor que 31!');
      currentError.value=f1.name;
      f1.focus();
      f1.select();
      return false;
   }
   if (mm>12)
   {
      alert('El Mes no deberá ser mayor que 12!');
      currentError.value=f1.name;
      f1.focus();
      f1.select();
      return false;
   }
   if (dd==31)
   {
      if (mm==4||mm==6||mm==9||mm==11)
      {
         alert('No hay día 31 en el Mes... '+mm);
         currentError.value=f1.name;
         f1.focus();
         f1.select();
         return false;
      }
   }
   if (mm==2)
   {
      if (dd>29)
      {
         alert('No hay '+dd+' días en Febrero!');
         currentError.value=f1.name;
         f1.focus();
         f1.select();
         return false;
      }
      if (dd==29)
      {
         if (yy%4!=0)
         {
            alert('No hay 29 días en Febrero de este año!');
            currentError.value=f1.name;
            f1.focus();
            f1.select();
            return false;
         }
      }
   }
   exitField(f1);
   currentError.value='';
   return true;
}

function ValidateTime(f1,f2,f3)
{
   if (!f1)
   {
       return true;
   }
   if (f1.type=='hidden')
   {
       return true;
   }
   currentError=document.getElementById('currentError');
   if (!currentError)
   {
       exitField(f1);
       return true;

   }   
   if ((f3==0) & (f1.value.length==0))
   {
     exitField(f1);
     return true;
   }
   if (currentError.value!='')
   {
      if (currentError.value!=f1.name)
      {
         exitField(f1);
         return true;
      }
   }

   if (f1.value.length<4)
   {
      alert('Favor de introducir la hora en el formato HHMM');
      currentError.value=f1.name;
      f1.focus();
      f1.select();
      return false;
   }

   var hh=f1.value.substring(0,2);
   var mm=f1.value.substring(2,4);
   if (hh>23)
   {
      alert('Las horas no podrán ser mayores que 23!');
      currentError.value=f1.name;
      f1.focus();
      f1.select();
      return false;
   }
   if (mm>59)
   {
      alert('Los minutos no podrán ser mayores que 59');
      currentError.value=f1.name;
      f1.focus();
      f1.select();
      return false;
   }
   exitField(f1);
   currentError.value='';
   return true;
}

function processClick(f1,f2,f3,f4)
{
   if (f1.checked)
   {
     f2.value=f3;
   }
   else
   {
     f2.value=f4;
   }
   return true;
}

function processRange(f1,f2)
{
   if (!f2)
   {
       return true;
   }
   if (f1.value=='3')
   {
      f2.className='fieldSettings'
   }
   else
   {
      f2.className='fieldSettingsHidden'
   }
   var f5=eval("document.frmMain.b"+f2.name);
   if (f5)
   {
      if (f1.value=='3')
      {
         eval(f5).className='buttonColorSmall';
      }
      else
      {
         eval(f5).className='fieldSettingsHidden';
      }
   }
   return true;
}

function lineOn(f1)
{
  f1.className="lineOn"
}

function lineOff(f1)
{
  f1.className="lineOff"
}

function highlightRow(f1)
{
  if (selRow==f1)
  {
     return false;
  }
  f1.className="gridHighlight"
}

function revertRow(f1)
{
  if (selRow==f1)
  {
     return false;
  }
  if (f1.id.charAt(0)=='A')
  {
     f1.className="gridRowA"
  }
  else
  {
     f1.className="gridRowB"
  }
}

function revertRowNC(f1)
{
  if (f1.id.charAt(0)=='A')
  {
     f1.className="gridRowA";
  }
  else
  {
     f1.className="gridRowB";
  }
}

function selectRow(f1)
{
   if (selRow)
   {
      revertRowNC(selRow);
   }
   selRow=f1;
   f1.className="gridSelected";
   editButton = document.getElementById('btnEdit');
   if (editButton)
   {
      editButton.className="buttonColor";
   }
   deleteButton = document.getElementById('btnDelete');
   if (deleteButton)
   {
      deleteButton.className="buttonColor";
   }
   okButton = document.getElementById('btnOK');
   if (okButton)
   {
      okButton.className="buttonColor";
   }
}

function showRow()
{
   if (!selRow)
   {
      return false;
   }
   selectRow(selRow);
}

function editDeleteRecord(F1)
{
   if (F1=='a')
   {
      var dMode = document.getElementById('mode');
      dMode.value='add';
      var editWindow=window.open('','editWindow','width=700,height=500,scrollbars=yes,resizable=1,toolbar=no,status=0,menubar=false');
      editWindow.moveTo((screen.width-700)/2,(screen.height-500)/2);
      var frmMain=document.getElementById('frmMain');
      frmMain.submit();
      editWindow.focus();
      return true;
   }

   if (!selRow)
   {
      alert('Favor de Seleccionar un registro!');
      return false;
   }

   var f105 = document.getElementById('f105where');
   var fLookup = document.getElementById('f105where'+selRow.id.substring(4,10));
   f105.value=fLookup.value;

   if (F1=='e')
   {
      var dMode = document.getElementById('mode');
      dMode.value='edit';
      var editWindow=window.open('','editWindow','width=700,height=500,scrollbars=yes,resizable=1,toolbar=no,status=0,menubar=false');
      editWindow.moveTo((screen.width-700)/2,(screen.height-500)/2);
      var frmMain=document.getElementById('frmMain');
      frmMain.submit();
      editWindow.focus();
      return true;
   }
   else
   {
      var result
      result = confirm("Estas seguro que deseas borrar este registro?");
      if (result)
      {
         var dMode = document.getElementById('mode');
         dMode.value='delete';
         var editWindow=window.open('','editWindow','width=700,height=500,scrollbars=yes,resizable=1,toolbar=no,status=0,menubar=false');
         editWindow.moveTo((screen.width-700)/2,(screen.height-500)/2);
         var frmMain=document.getElementById('frmMain');
         frmMain.submit();
         editWindow.focus();
         return true;
      }
   }
   return true;
}

function editDeleteRecord2(F1)
{
   if (F1=='a')
   {
      var dMode = document.getElementById('mode');
      dMode.value='add';
      var editWindow=window.open('','editWindow','width=700,height=500,scrollbars=yes,resizable=1,toolbar=no,status=0,menubar=false');
      editWindow.moveTo((screen.width-700)/2,(screen.height-500)/2);
      var frmLaunch=document.getElementById('frmLaunch');
      frmLaunch.submit();
      editWindow.focus();
      return true;
   }

   if (F1=='e')
   {
      var dMode = document.getElementById('mode');
      dMode.value='edit';
      var editWindow=window.open('','editWindow','width=700,height=500,scrollbars=yes,resizable=1,toolbar=no,status=0,menubar=false');
      editWindow.moveTo((screen.width-700)/2,(screen.height-500)/2);
      var frmLaunch=document.getElementById('frmLaunch');
      frmLaunch.submit();
      editWindow.focus();
      return true;
   }
   else
   {
      var result
      result = confirm("Estas seguro que deseas borrar este registro?");
      if (result)
      {
         var dMode = document.getElementById('mode');
         dMode.value='delete';
         var editWindow=window.open('','editWindow','width=700,height=500,scrollbars=yes,resizable=1,toolbar=no,status=0,menubar=false');
         editWindow.moveTo((screen.width-700)/2,(screen.height-500)/2);
         var frmLaunch=document.getElementById('frmLaunch');
         frmLaunch.submit();
         editWindow.focus();
         return true;
      }
   }
   return true;
}

function findRecordBase (f1,f2,f3,f4,f5)
{
    var frmFind=document.getElementById('frmFindRecord');
    frmFind.action=f1;
    frmFind.refFieldName.value=f2; 
    frmFind.refReturnFieldCode.value=f3; 
    frmFind.refReturnFieldDesc.value=f4; 
    frmFind.refUpdateField.value=f5; 
    return findRecord();
}

function findRecord()
{
   var searchWindow = window.open('','_searchWindow','width=700,height=500,scrollbars=yes,resizable=1,toolbar=no,status=0,menubar=false');
   searchWindow.moveTo((screen.width-700)/2,(screen.height-500)/2);
   var frmFind=document.getElementById("frmFindRecord");
   frmFind.target='_searchWindow';
   frmFind.submit();
   searchWindow.focus();
   return true;
}

function registerVerify (f1,f2,f3,f4,f5)
{
   var frmVerify=document.getElementById('frmFindRecord');
   frmVerify.action="verify.asp";
   frmVerify.refReturnFieldCode.value=f1; 
   frmVerify.refReturnFieldDesc.value=f2; 
   frmVerify.refUpdateField.value=f3; 
   frmVerify.refField.value=f4;
   if (f4==0)
   { 
     frmVerify.refCodeValue.value=f5.value; 
   }
   else
   {
     frmVerify.refDescValue.value=f5.value; 
   }
   return true;
}

function checkVerify (f1,f2,f3,f4,f5,f6,f7)
{
   var frmVerify=document.getElementById('frmFindRecord');
   var iSame = 0;
   frmVerify.action="verify.asp";
   frmVerify.refReturnFieldCode.value=f1; 
   frmVerify.refReturnFieldDesc.value=f2; 
   frmVerify.refUpdateField.value=f3;
   frmVerify.refTable.value=f4;
   frmVerify.refField.value=f6;
   frmVerify.refDataType.value=f5;
   if (f6==0)
   { 
      if (frmVerify.refCodeValue.value!=f7.value)
      {
         iSame = 1;
      }
      frmVerify.refCodeValue.value=f7.value; 
   }
   else
   {
      if (frmVerify.refDescValue.value!=f7.value)
      {
         iSame = 1;
      }
      frmVerify.refDescValue.value=f7.value;
   }
   if (iSame == 1) 
   {
      frmVerify.target='_verifyWindow';
      return findVerify();
   }
}

function confirmFind(f1,f2)
{
  if (!selRow)
  {
     alert('Favor de Seleccionar un registro!');
     return false;
  }
  else
  {     
     if (window.opener && !opener.closed)
     {
        
        if (f1)
        {
          var f3 = document.getElementById('retFieldCode'+selRow.id.substring(4,10));        
          f1.value=f3.value;
          f1.focus();
        }
        
        if (f2)
        {
          var f4 = document.getElementById('retFieldDesc'+selRow.id.substring(4,10));
          f2.value=f4.value;
          f2.focus();
        }

        window.close();
     }
  }
}

function findVerify()
{
   var verifyWindow = window.open('','_verifyWindow','width=400,height=200,scrollbars=yes,resizable=1,toolbar=no,status=0,menubar=false');
   verifyWindow.moveTo((screen.width-400)/2,(screen.height-200)/2);
   var frmFind=document.getElementById("frmFindRecord");
   frmFind.target='_verifyWindow';
   frmFind.submit();
   verifyWindow.focus();
   return true;
}

function showOutline(f1)
{
   f1.className="menubuttonGreyRaised"
}

function removeOutline(f1)
{
   f1.className="menubuttonGrey"
}

function doStatus(f1)
{
   window.status=f1;
}

function checkCombo(f1,f2)
{
   if (f1.value=='')
   {
      f2.value=0;
      return false;
   }
   if (f2.value==0)
   {
      f2.value=1
   }
}

function nothing(){}

function verifyInput_allNumbers( theInput )
{
   var str = "0123456789";
   var n = theInput.length;
   var itMatches = 0;

   for (var i=0;i<n;i++)
   {
       itMatches = 0;
       for (var j=0;j<str.length;j++)
       {
         if ( theInput.charAt(i) == str.charAt(j) )
         {
            itMatches=1;
         }
       }

       if (itMatches==0)
       {
           i=n;
       }
   }

   if ( itMatches == 0 )
   {
      return false;
   }
   else
   {
      return true;
   }

}

function parseInput( theInput , dFormat )
{
   if (dFormat == 0)
   {
        iiMonth = (theInput.substring(0,2)*1)-1;
        iiDay = theInput.substring(2,4)*1;
        iiYear = theInput.substring(4,8)*1;
   }
   if (dFormat == 3)
   {
        iiMonth = (theInput.substring(0,2)*1)-1;
        iiDay = theInput.substring(2,4)*1;
        iiYear = theInput.substring(4,8)*1;
   }
   if (dFormat == 1)
   {
        iiDay = theInput.substring(0,2)*1;
        iiMonth = (theInput.substring(2,4)*1)-1;
        iiYear = theInput.substring(4,8)*1;
   }
   if (dFormat == 4)
   {
        iiDay = theInput.substring(0,2)*1;
        iiMonth = (theInput.substring(2,4)*1-1);
        iiYear = theInput.substring(4,8)*1;
   }
   if (dFormat == 2)
   {
        iiYear = theInput.substring(0,4)*1;
        iiMonth = (theInput.substring(4,6)*1)-1;
        iiDay = theInput.substring(6,8)*1;
   }
   if (dFormat == 5)
   {
        iiYear = theInput.substring(0,4)*1;
        iiMonth = (theInput.substring(4,6)*1)-1;
        iiDay = theInput.substring(6,8)*1;
   }

   if (theInput.length==12)
   {
        iiHour = theInput.substring(8,10)*1;
        iiMinute = theInput.substring(10,12)*1;
        sTodayIs = "Now";
   }
   else
   {
        sTodayIs = "Hoy";
   }

   if ( verifyInput_DateTime( iiDay, iiMonth, iiYear, iiHour, iiMinute )==0 )
   {
      setTimeNow();
   }
}

function verifyInput_DateTime( iiDay, iiMonth, iiYear, iiHour, iiMinute )
{
   returnBoolean = 0;
   iVal = parseInt(iiMonth);
   var num = ++iVal;

   switch ( num )
   {
       case  1:
       case  3:
       case  5:
       case  7:
       case  8:
       case 10:
       case 12:

       if (iiDay<=31)
       {
          returnBoolean = 1;
       }
       break;

       case  4:
       case  6:
       case  9:
       case 11:

       if (iiDay<=30)
       {
          returnBoolean = 1;
       }
       break;

       case  2:

       if (isLeapYear(iiYear))
       {
           if (iiDay<=29)
           {
              returnBoolean = 1;
           }
       }
       else
       {
           if (iiDay<=28)
           {
              returnBoolean = 1;
           }
       }
       break;
   }

   if (iiHour!="")
   {
      if (iiHour>23||iiMinute>59)
      {
        returnBoolean = 0;
      }
   }
   return returnBoolean;
}

function setTimeNow()
{
   d = new Date();
   iiDay = d.getDate();
   iiMonth = d.getMonth();
   iiYear = d.getYear();
   iiHour = d.getHours();
   iiMinute = d.getMinutes();
}

function onafterload_c( iiDay, iiMonth, iiYear, iiHour, iiMinute )
{
   iSelDay = iiDay;
   iMonth = iiMonth;
   iYear = iiYear;
   iHour = iiHour;
   iMinute = iiMinute;
   clearAllDays();
   setCurrentDate(iYear, iMonth, iSelDay, iHour, iMinute);
}

function onafterload(iNextMonthDayPressed)
{
   setCurrentDate(iYear, iMonth, iNextMonthDayPressed, iHour, iMinute);
}

function controlAndOpen_calendar(theObj,dFormat)
{
   if ( document.getElementById('calendar').style.visibility == 'hidden' )
   {
      showCalendar(theObj,'txtDate',dFormat);
   }
   else
   {
      hideCalendar();
   }
}

function controlAndOpen_DropDown(num)
{
   if (num==0)
   {
      if (isOpen_DropDownMonth == 1)
      {
         popDownYear(0);
         popUpMonth();
      }
      else
      {
         popDownMonth(0);
      }
   }
   else
   {
      if (isOpen_DropDownYear == 1)
      {
         popDownMonth(1);
         popUpYear();
      }
      else
      {
         popDownYear(1);
      }
   }
}

function isLeapYear(y)
{
   return (y%4!=0) ? false : (y%100!=0) ? true : (y%400!=0) ? false : true;
}

function addDay(iDay)
{
   if(iMaxY==6)
      {iMaxY = 0; iMaxX++;}
   else
      iMaxY ++;
   document.getElementById("cell_" + iMaxX + "_" + iMaxY).innerHTML = String(iDay);
   document.getElementById("cell_" + iMaxX + "_" + iMaxY).onclick = function(){tdclick(this)};
}

function makeDaySelected(iDay)
{
   for(var x=0; x<=5; x++)
      for(var y=0; y<=6; y++)
      {
         if(document.getElementById("cell_" + x + "_" + y).style.color=="")
            if(document.getElementById("cell_" + x + "_" + y).innerHTML==String(iDay))
               document.getElementById("cell_" + x + "_" + y).style.backgroundColor = "#FFAAFF";
      }
}

function getDaysNumberForMonth(iMonth, iYear)
{
   switch (iMonth+1)
   {
      case  1:
      case  3:
      case  5:
      case  7:
      case  8:
      case 10:
      case 12:
         return(31);
         break;
      case  4:
      case  6:
      case  9:
      case 11:
         return(30);
         break;
      case  2:
         if (isLeapYear(iYear))
            return(29)
         else
            return(28);
         break;
   }
}

function checkToday()
{
   if((todayDate.getUTCFullYear() == iYear)&&
      (todayDate.getUTCMonth()+1 == monthName[iMonth]))
   {
      for(var x=0; x<=5; x++)
         for(var y=0; y<=6; y++)
            if((document.getElementById("cell_" + x + "_" + y).innerHTML == String(todayDate.getUTCDate()))&&(document.getElementById("cell_" + x + "_" + y).style.color != "gray"))
            {
               document.getElementById("cell_" + x + "_" + y).innerHTML += "<img src='../images/select.gif'>";
               break;
            }
   }
}

function gotoToday()
{
   d = new Date();
   d.setUTCMonth(todayDate.getUTCMonth());
   d.setUTCFullYear(todayDate.getUTCFullYear());
   iSelDay = d.getUTCDate();
   iMonth = d.getUTCMonth();
   iYear = d.getUTCFullYear();
   iHour = d.getHours();
   iMinute = d.getMinutes();
   clearAllDays();
   onafterload(todayDate.getUTCDate());
}

function fnShowPic(obj, mode)
{
   if (mode == 1)
      document.getElementById(obj).style.filter=''
   else
      document.getElementById(obj).style.filter='gray(), alpha(opacity=50)';
}

function setCurrentDate(iYear, iMonth, iDay, iHour, iMinute)
{
   var s;
   var iLastDayOfMonth;
   var tempDateObj = new Date();
   document.getElementById("spanMonth").innerHTML = "&nbsp;" +   monthName[iMonth] + "&nbsp;<IMG id='changeMonth' style='filter: gray(), alpha(opacity=50);' SRC='../images/dropcal.gif' BORDER=0 onmouseover='fnShowPic(\"changeMonth\",1)' onmouseout='fnShowPic(\"changeMonth\",0)'>";
   document.getElementById("spanYear").innerHTML =                         "&nbsp;<IMG id='changeYear' style='filter: gray(), alpha(opacity=50);' SRC='../images/dropcal2.gif' BORDER=0 onmouseover='fnShowPic(\"changeYear\",1)' onmouseout='fnShowPic(\"changeYear\",0)'>" + "&nbsp;" + iYear;
   crossMonthObj=(dom)?document.getElementById("selectMonth").style : ie? document.all.selectMonth   : document.selectMonth;
   crossYearObj=(dom)?document.getElementById("selectYear").style : ie? document.all.selectYear : document.selectYear;
   tempDateObj.setUTCFullYear(iYear, iMonth, 1);
   iLastDayOfMonth = getDaysNumberForMonth(iMonth, iYear);
   document.getElementById("txtToday").innerHTML = "<img src=\"../images/select.gif\"><b><FONT size=1>" + sTodayIs + "</FONT></b>";
   document.getElementById("txtToday").onclick = function(){gotoToday()};
   var iDisabledDayBefore = 0;
   var iPrevMonth;
   var iPrevYear = iYear;
   var iDaysInPrevMonth;
   if(tempDateObj.getUTCDay()>0)
      for(var x=0; x<tempDateObj.getUTCDay(); x++)
      {
         iDisabledDayBefore++;
      }
   switch (iMonth)
   {
      case 0:
         iPrevMonth = 11;
         iPrevYear--;
         break;
      default:
         iPrevMonth = iMonth-1;
         break;
   }
   iDaysInPrevMonth = getDaysNumberForMonth(iPrevMonth, iPrevYear);
   var arrTemp = new Array();

   if(tempDateObj.getUTCDay()>0)
   {
      for(var i=iDaysInPrevMonth-iDisabledDayBefore+1; i<=iDaysInPrevMonth;i++)
      {
         arrTemp[arrTemp.length] = i;
      }
      for(var x=0; x<tempDateObj.getUTCDay(); x++)
      {
         document.getElementById("cell_0_" + x).innerHTML = arrTemp[x];
         document.getElementById("cell_0_" + x).onclick = function(){changeDate(2, this)};
         document.getElementById("cell_0_" + x).style.color = "gray";
         iMaxY++;
      }
   }
   else
   {
      for(var i=iDaysInPrevMonth-6; i<=iDaysInPrevMonth;i++)
      {
         arrTemp[arrTemp.length] = i;
      }
      for(var x=0; x<=6; x++)
      {
         document.getElementById("cell_0_" + x).innerHTML = arrTemp[x];
         document.getElementById("cell_0_" + x).onclick = function(){changeDate(2, this)};
         document.getElementById("cell_0_" + x).style.color = "gray";
      }

      iMaxX++;
      iMaxY = 0;
   }

   document.getElementById("cell_" + iMaxX + "_" + iMaxY).innerHTML = "1";
   document.getElementById("cell_" + iMaxX + "_" + iMaxY).onclick = function(){tdclick(this)};

   for(var iCurrentDay = 2; iCurrentDay <= iLastDayOfMonth; iCurrentDay++)
   {
      addDay(iCurrentDay)
   }
   makeDaySelected(iDay);

   var iNextDays = 1;
   for(var i=iMaxY+1; i<=6; i++)
   {
      document.getElementById("cell_" + iMaxX + "_" + i).innerHTML = iNextDays;
      document.getElementById("cell_" + iMaxX + "_" + i).onclick = function(){changeDate(3, this)};
      document.getElementById("cell_" + iMaxX + "_" + i).style.color = "gray";
      iNextDays++;
   }
   if(iMaxX<5)
   {
      iMaxX++;
      iMaxY=0;
      for(var i=iMaxY; i<=6; i++)
      {
         document.getElementById("cell_" + iMaxX + "_" + i).innerHTML = iNextDays;
         document.getElementById("cell_" + iMaxX + "_" + i).onclick = function(){changeDate(3, this)};
         document.getElementById("cell_" + iMaxX + "_" + i).style.color = "gray";
         iNextDays++;
      }
   }
   bIsLoaded = true;

   if (sTodayIs.indexOf("Now")!=-1)
   {

      if(iHour<10){
         self.document.frmCalendar.txt_hh.value="0"+iHour;
      }
      else{
         self.document.frmCalendar.txt_hh.value=iHour;
      }

      if(iMinute<10){
         self.document.frmCalendar.txt_mm.value="0"+iMinute;
      }
      else{
         self.document.frmCalendar.txt_mm.value=iMinute;
      }

      self.document.frmCalendar.txt_hh.focus();
   }
   else
   {
      self.document.frmCalendar.txt_hh.value="";
      self.document.frmCalendar.txt_mm.value="";
   }
   checkToday();
}


function changeDate(mode, obj)
{
   var iNextMonthDayPressed = null;
   if(bIsLoaded)
   {
      switch (mode)
      {
         case 0:
            d.setUTCMonth(obj);
            break;
         case 1:
            d.setUTCFullYear(obj);
            break;
         case 2:
            if(obj != null) iNextMonthDayPressed = obj.innerHTML;
            switch (d.getUTCMonth())
            {
               case 0:
                  d.setUTCMonth(11);
                  d.setUTCFullYear(d.getUTCFullYear()-1);
                  break;
               default:
                  d.setUTCMonth(d.getUTCMonth()-1);
                  break;
            }
            break;
         case 3:
            if(obj != null) iNextMonthDayPressed = obj.innerHTML;
            switch (d.getUTCMonth())
            {
               case 11:
                  d.setUTCMonth(0);
                  d.setUTCFullYear(d.getUTCFullYear()+1);
                  break;
               default:
                  d.setUTCMonth((d.getUTCMonth()+1));
                  break;
            }
            break;
      }
      iMonth = d.getUTCMonth();
      iYear = d.getUTCFullYear();
      clearAllDays();
      iSelDay = iNextMonthDayPressed;
      onafterload(iNextMonthDayPressed);
   }
}

function clearAllDays()
{
   setAllCellsNoColor();
   for(var x=0; x<=5; x++)
      for(var y=0; y<=6; y++)
      {
         document.getElementById("cell_" + x + "_" + y).innerHTML = "";
         document.getElementById("cell_" + x + "_" + y).onclick = "";
         document.getElementById("cell_" + x + "_" + y).style.color = "";
         document.getElementById("cell_" + x + "_" + y).background = "";
      }
   iMaxX = 0;
   iMaxY = 0;
}

function setAllCellsNoColor()
{
   for(var x=0; x<=5; x++)
      for(var y=0; y<=6; y++)
      {
         document.getElementById("cell_" + x + "_" + y).style.backgroundColor = "";
      }
}

function tdclick(obj)
{
   setAllCellsNoColor()
   if(obj.innerHTML!="")
   {
      obj.style.backgroundColor = "#FFAAFF";
      iSelDay = obj.innerHTML;
   }
   fnRetVal();hideCalendar();
}

function fnRetVal()
{
   var retval = "";
   var sSeparator, hourSeparator, separatorBoth;
   var data = document.frmCalendar;
   sSeparator = "/";
   hourSeparator = ":";
   separatorBoth = " ";
   if(iSelDay==null) iSelDay=0;
   var sMonth = String(iMonth+1);
   var sSelDay = iSelDay;
   if(String(iMonth+1).length==1) sMonth = "0" + sMonth;
   if(String(sSelDay).length==1) sSelDay = "0" + sSelDay;
   var sHH = document.getElementById("txt_hh").value+"";
   var sMM = document.getElementById("txt_mm").value+"";

   if ( !(sHH.indexOf(" ")!=-1 || sHH.indexOf("  ")!=-1 || sMM.indexOf(" ")!=-1 || sMM.indexOf("  ")!=-1) ){
      if(sHH.length==1)
      {
         sHH="0"+sHH;
      }

      if(sMM.length==1)
      {
         sMM="0"+sMM;
      }
   }
   else
   {
      sHH="";
      sMM="";
   }

   switch (lngFormat)
   {
      case 0:
         if(iSelDay!=0)
            retval += sMonth + sSeparator + sSelDay + sSeparator + iYear;
         else
            retval = -1;
         break;
      case 1:
         if(iSelDay!=0)
            retval += sSelDay + sSeparator + sMonth + sSeparator + iYear;
         else
            retval = -1;
         break;
      case 2:
         if(iSelDay!=0)
            retval += iYear + sSeparator + sMonth + sSeparator + sSelDay;
         else
            retval = -1;
         break;

      case 3:
         if(iSelDay!=0)
            retval += sMonth + sSeparator + sSelDay + sSeparator + iYear  + separatorBoth + sHH + hourSeparator + sMM;
         else
            retval = -1;
         break;
      case 4:
         if(iSelDay!=0)
            retval += sSelDay + sSeparator + sMonth + sSeparator + iYear + separatorBoth + sHH + hourSeparator + sMM;
         else
            retval = -1;
         break;
      case 5:
         if(iSelDay!=0)
            retval += iYear + sSeparator + sMonth + sSeparator + sSelDay + separatorBoth + sHH + hourSeparator + sMM;
         else
            retval = -1;
         break;
   }
   if(retval!=-1) {document.getElementById(objRetName).value = retval;}
}

function hideElement( elmID, overDiv )
{
   if(ie)
   {
      for( i = 0; i < document.all.tags(elmID).length; i++ )
      {
         obj = document.all.tags(elmID)[i];
         if( !obj || !obj.offsetParent )   continue;
         objLeft = obj.offsetLeft;
         objTop = obj.offsetTop;
         objParent = obj.offsetParent;
       while( objParent.tagName.toUpperCase() != "BODY" )
         {
            objLeft += objParent.offsetLeft;
            objTop  += objParent.offsetTop;
            objParent = objParent.offsetParent;
         }
       objHeight = obj.offsetHeight;
         objWidth = obj.offsetWidth;
       if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
         else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
         else if( overDiv.offsetTop >= ( objTop + objHeight ));
         else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
         else
         {
            if(obj.id!="selMonth"&&obj.id!="selYear") obj.style.visibility = "hidden";
         }
      }
   }
}

function swapImage(srcImg, destImg)
{
   if (ie)   { document.getElementById(srcImg).setAttribute("src",imgDir + destImg) }
}

function showElement( elmID )
{
   if(ie)
   {
      for( i = 0; i < document.all.tags(elmID).length; i++ )
      {
         obj = document.all.tags( elmID )[i];
       if( !obj || !obj.offsetParent ) continue;
          obj.style.visibility = "";
      }
   }
}

function showCalendar(obj, RetName, dFormat)
{
   isOpen_calendar = -isOpen_calendar;
   var leftpos = 0;
   var toppos = 0;
   aTag = new Object(obj);
   lngFormat = dFormat;
   objRetName = RetName;

   if (dFormat==3||dFormat==4) document.getElementById("div_time").style.display = "block";
   var crossobj = document.getElementById("calendar").style;

   do
   {
      aTag = aTag.offsetParent;
      leftpos += aTag.offsetLeft;
      toppos += aTag.offsetTop;
   }

   while(aTag.tagName!="BODY");

   crossobj.left =   fixedX==-1 ? obj.offsetLeft + leftpos :   fixedX;
   crossobj.top = fixedY==-1 ? obj.offsetTop + toppos + obj.offsetHeight +2 : fixedY;
   crossobj.visibility=(dom||ie)? "visible" : "show";
   hideElement( 'SELECT', document.getElementById("calendar") );
   hideElement( 'APPLET', document.getElementById("calendar") );

   var theInput = obj.value;

   if (theInput!="")
   {
      if ( (theInput.length==8||theInput.length==12) && verifyInput_allNumbers( theInput ) )
      {
         parseInput( theInput, dFormat );
      }
      else
      {
         setTimeNow();
      }
      onafterload_c( iiDay, iiMonth, iiYear, iiHour, iiMinute );
   }
   else
   {
      sTodayIs = "Hoy";
   }
}

function hideCalendar()
{
   isOpen_calendar = -isOpen_calendar;
   showElement( 'select' );
   showElement( 'APPLET' );
   crossMonthObj.visibility = "hidden";
   crossYearObj.visibility = "hidden";
   document.getElementById("calendar").style.visibility = "hidden";
}

function constructMonth()
{
   popDownYear(0);
   document.onselectstart=new Function ("return false")

   if (!monthConstructed)
   {
      sHTML =   ""
      for (i=0; i<12;   i++)
      {
         sName =   monthName[i];
         if (i==iMonth)
         {
            sName =   "<B>" +   sName +   "</B>"
         }
         sHTML += "<tr><td id='m" + i + "' style='cursor:default' onmouseout='this.style.backgroundColor=\"\";this.style.color=\"black\"' onclick='monthConstructed=false;monthSelected=" + i + ";popDownMonth(0);event.cancelBubble=true;changeDate(0, " + i + ");'>&nbsp;" + sName + "&nbsp;</td></tr>"
      }
      document.getElementById("selectMonth").innerHTML = "<table style='font-family:verdana; font-size:9px; border-width:1; border-style:solid; border-color:#000080;' bgcolor='#FFFFFF' cellspacing=0 onmouseover='clearTimeout(timeoutID2)' onmouseout='clearTimeout(timeoutID2);timeoutID2=setTimeout(\"popDownMonth(1)\",100)' " + sHTML + "</table>"
      monthConstructed=true
   }
}

function popUpMonth()
{
   isOpen_DropDownMonth=-1;
   var crossobj1 = document.getElementById("spanMonth");
   constructMonth()
   crossMonthObj.visibility = (dom||ie)? "visible" : "show";
   crossMonthObj.left = parseInt(crossobj1.offsetWidth);
   crossMonthObj.top = parseInt(crossobj1.offsetHeight);
   hideElement( 'select', document.getElementById("selectMonth") );
   hideElement( 'APPLET', document.getElementById("selectMonth") );
   fnShowPic("changeMonth",1);
}

function popDownMonth(fromWhere)
{
   if (fromWhere==1)
   {
      document.onselectstart=new Function ("return false");
   }
   else
   {
      document.onselectstart=new Function ("return true");
   }
   isOpen_DropDownMonth=1;
   crossMonthObj.visibility = "hidden";
   fnShowPic("changeMonth",0);
}

function incYear()
{
   for   (i=0; i<7; i++)
   {
      newYear   = (i+nStartingYear)+1
      if (newYear==iYear)
         txtYear = "&nbsp;<B>" + newYear + "</B>&nbsp;"
      else
         txtYear = "&nbsp;" + newYear + "&nbsp;";
      document.getElementById("y"+i).innerHTML = txtYear;
   }
   nStartingYear ++;
   bShow=true
}

function incYear10()
{
   for (i=0; i<7; i++)
   {
      newYear   = (i+nStartingYear)+10;
      if (newYear==iYear)
         txtYear = "&nbsp;<B>" + newYear + "</B>&nbsp;"
      else
         txtYear = "&nbsp;" + newYear + "&nbsp;";
      document.getElementById("y"+i).innerHTML = txtYear;
   }
   nStartingYear = nStartingYear + 10;
   bShow=true
}

function decYear()
{
   for (i=0; i<7; i++)
   {
      newYear = (i+nStartingYear)-1;
      if (newYear == iYear)
         txtYear = "&nbsp;<B>" + newYear + "</B>&nbsp;"
      else
         txtYear = "&nbsp;" + newYear + "&nbsp;"
      document.getElementById("y"+i).innerHTML = txtYear;
   }
   nStartingYear --;
   bShow=true
}

function decYear10()
{
   for (i=0; i<7; i++)
   {
      newYear = (i+nStartingYear)-5;
      if (newYear==iYear)
         txtYear = "&nbsp;<B>" + newYear + "</B>&nbsp;"
      else
         txtYear = "&nbsp;" + newYear + "&nbsp;"
      document.getElementById("y"+i).innerHTML = txtYear;
   }
   nStartingYear = nStartingYear - 5;
   bShow=true
}

function selectYear(nYear)
{
   yearSelected = parseInt(nYear+nStartingYear);
   yearConstructed = false;
   popDownYear(1);
   changeDate(1,yearSelected);
}

function popDownYear(fromWhere)
{
   if (fromWhere==0)
   {
      document.onselectstart=new Function ("return false");
   }
   else
   {
      document.onselectstart=new Function ("return true");
   }
   isOpen_DropDownYear=1;
   crossYearObj.visibility= "hidden";
}

function constructYear()
{
   popDownMonth(1);
   sHTML =   "";
   if (!yearConstructed)
   {
      sHTML =   "<tr><td align='center' style='cursor:default' onmouseout='clearInterval(intervalID1);this.style.backgroundColor=\"\"' onmousedown='clearInterval(intervalID1);intervalID1=setInterval(\"decYear()\",30)' onmouseup='clearInterval(intervalID1)'>-1</td>" +
      "<td align='center' style='cursor:default' onmouseout='clearInterval(intervalID1);this.style.backgroundColor=\"\"' onmousedown='clearInterval(intervalID1);intervalID1=setInterval(\"decYear10()\",1)' onmouseup='clearInterval(intervalID1)'>-10</td></tr>"
      j =   0;
      nStartingYear = iYear-3;
      for   (i=(iYear-3); i<=(iYear+3); i++)
      {
         sName =   i;
         if (i==iYear)
         {
            sName =   "<B>" +   sName +   "</B>";
         }
         sHTML += "<tr><td colspan=2 id='y" + j + "' style='cursor:default' onmouseout='this.style.backgroundColor=\"\";this.style.color=\"black\"' onclick='selectYear("+j+");event.cancelBubble=true'>&nbsp;" + sName + "&nbsp;</td></tr>";
         j ++;
      }
      sHTML += "<tr><td align='center' style='cursor:default' onmouseout='clearInterval(intervalID2);this.style.backgroundColor=\"\"' style='cursor:pointer' onmousedown='clearInterval(intervalID2);intervalID2=setInterval(\"incYear()\",30)'   onmouseup='clearInterval(intervalID2)'>+1</td>" +
         "<td align='center' style='cursor:default' onmouseout='clearInterval(intervalID2);this.style.backgroundColor=\"\"' style='cursor:pointer' onmousedown='clearInterval(intervalID2);intervalID2=setInterval(\"incYear10()\",1)'   onmouseup='clearInterval(intervalID2)'>+10</td></tr>"
      document.getElementById("selectYear").innerHTML   = "<table style='font-family:verdana; font-size:9px; border-width:1; border-style:solid; border-color:#000080;' bgcolor='#FFFFFF' onmouseover='clearTimeout(timeoutID2)' onmouseout='clearTimeout(timeoutID2);timeoutID2=setTimeout(\"popDownYear(1)\",100)' cellspacing=0>" + sHTML + "</table>"
      yearConstructed   = true;
   }
}

function popUpYear()
{
   isOpen_DropDownYear=-1;
   var crossobj2 = document.getElementById("spanYear");
   var leftOffset;
   constructYear();
   crossYearObj.visibility = (dom||ie)? "visible" : "show";
   leftOffset = parseInt(crossobj2.offsetWidth) + document.getElementById("spanYear").offsetLeft;
   if (ie)
   {
      leftOffset += 6;
   }
   crossYearObj.left = parseInt(crossobj2.offsetWidth) + 65;
   crossYearObj.top = parseInt(crossobj2.offsetHeight);
}

if(document.all && !document.getElementById)
{
   document.getElementById = function(id)
   {
      return document.all[id];
   }
}

var selRow;
var isOpen_calendar = 1;
var isOpen_DropDownMonth = 1;
var isOpen_DropDownYear = 1;

var iiDay = "";
var iiMonth = "";
var iiYear = "";
var iiHour = "";
var iiMinute = "";

var fixedX = -1
var fixedY = -1
var imgDir = "images"
var monthConstructed = false;
var yearConstructed = false;

var yearSelected;
var crossMonthObj, crossYearObj;
var intervalID1,timeoutID2,intervalID2,timeoutID1;
var nStartingYear;

var iMinYear = 1900;
var iMaxYear = 2100;
var iMaxX = 0;
var iMaxY = 0;
var bIsLoaded = false;
var iSelDay = 0;

var lngFormat = 1;
var objRetName;

var d = new Date();
var iMonth = d.getMonth();
var iYear = d.getFullYear();
var iHour = d.getHours();
var iMinute = d.getMinutes();
var todayDate = new Date();
var sTodayIs = "Hoy";

var ie=document.all;
var dom=document.getElementById;

var monthName = new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre")

document.write(""+

   "<div onclick='bShow=true' id='calendar' style='z-index:+999;position:absolute;visibility:hidden;'>"+
   "<FORM name=\"frmCalendar\" method=\"post\">" +
   "<TABLE width=180 cellSpacing=0 cellPadding=0 border=0 style='BORDER-RIGHT: #a0a0a0 1px solid; BORDER-TOP: #a0a0a0 1px solid; FONT-SIZE: 11px; BORDER-LEFT: #a0a0a0 1px solid; BORDER-BOTTOM: #a0a0a0 1px solid; FONT-FAMILY: arial' align=center valign=middle bgColor=white>" +
   "<TR>"+
      "<TD align=left class=\"buttons\" onclick=\"changeDate(2, null);\" onmouseover=\"document.getElementById('arL').style.filter='';\" onmouseout=\"document.getElementById('arL').style.filter='gray(), alpha(opacity=50)';\">&nbsp;&nbsp;<img id='arL' style=\"filter: 'gray(), alpha(opacity=50)'\" src='../images/left.gif'></TD>"+
       "<TD width=150><span id='spanMonth' style='cursor:pointer' onmouseover='fnShowPic(\"changeMonth\",1);window.status=\"Click to select a month.\"' onmouseout='fnShowPic(\"changeMonth\",0);window.status=\"\"' onclick='controlAndOpen_DropDown(0)'></span>&nbsp;<div id='selectMonth' style='z-index:+999;position:absolute;visibility:hidden;'></div></TD>"+
      "<TD nowrap><span id='spanYear' style='cursor:pointer' onmouseover='fnShowPic(\"changeYear\",1);window.status=\"Click to select a year.\"' onmouseout='fnShowPic(\"changeYear\",0);window.status=\"\"' onclick='controlAndOpen_DropDown(1)'></span><div id='selectYear' style='z-index:+999;position:absolute;visibility:hidden;'></div>&nbsp;</TD>"+
      "<TD nowrap class=\"buttons\" onclick=\"changeDate(3, null);\" onmouseover=\"document.getElementById('arR').style.filter='';\" onmouseout=\"document.getElementById('arR').style.filter='gray(), alpha(opacity=50)';\"><img id='arR' style=\"filter: 'gray(), alpha(opacity=50)'\" src='../images/right.gif'>&nbsp;</TD>"+
   "</TR>"+
   "<TR>"+
      "<TD colspan=4>"+
      "<TABLE style=\"WIDTH: 100%\" cellSpacing=0 cellPadding=0 width=\"100%\" align=center border=0>"+
      "<TR>"+
         "<TD class=\"weekend\">DO</TD>"+
         "<TD class=\"dayofweek\">LU</TD>"+
         "<TD class=\"dayofweek\">MA</TD>"+
         "<TD class=\"dayofweek\">MI</TD>"+
         "<TD class=\"dayofweek\">JU</TD>"+
         "<TD class=\"dayofweek\">VI</TD>"+
         "<TD class=\"weekend\">SA</TD>"+
      "</TR>"+
      "<TR>"+
         "<TD colspan=7><HR></TD>"+
      "</TR>");

for(var a = 0; a <=5; a++)
{
   document.write(""+"<TR id=\"cell_" + String(a) + "\">");
   for(var b = 0; b<=6; b++)
   {
      document.write("<TD id=\"cell_" + String(a) + "_" + String(b) + "\" class=\"alldays\" onmouseover=\"this.className='alldaysup'\" onmouseout=\"this.className='alldays'\" onclick=\"tdclick(this)\"></TD>");
   }
   document.write("</TR>");
}

document.write("</TABLE></TD></TR></TABLE><TABLE width=180 cellSpacing=0 cellPadding=0 border=0 style='BORDER-RIGHT: #a0a0a0 1px solid; BORDER-TOP: #a0a0a0 1px solid; FONT-SIZE: 11px; BORDER-LEFT: #a0a0a0 1px solid; BORDER-BOTTOM: #a0a0a0 1px solid; FONT-FAMILY: arial' align=center valign=middle bgColor=white>" +
   "<TR><TD colspan=2><div id=\"txtToday\" style='cursor:default'></div><div id='div_time' style='display:none'>HH<input type='text' class='hhmm' id='txt_hh' size='1' maxlength='2' onkeyup='if(isNaN(this.value)||this.value>23||this.value<0) this.value=\"\"' onchange='if(isNaN(this.value)||this.value>23||this.value<0) this.value=\"\"'>MM<input type='text' class='hhmm' id='txt_mm' size='1' maxlength='2' onkeyup='if(isNaN(this.value)||this.value>59||this.value<0) this.value=\"\"' onchange='if(isNaN(this.value)||this.value>59||this.value<0)  this.value=\"\"'></div></TD>"+
   "<TD class=\"alldays\"></TD><TD class=\"alldays\"><span onclick=\"hideCalendar();\" id='img_2'>Cancelar</span></TD>"+   "</TR></TABLE></FORM></DIV>");

onafterload(null);

<!--end:Script-->
