<!--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);

//Habilita Campos  para Facturación
function CheckFac() {   
if(document.frmMain.checkval.value==1)
 {
  document.frmMain.x_FTB10.disabled=false;
  document.frmMain.x_FTB11.disabled=false;
  document.frmMain.x_FTB12.disabled=false;
  document.frmMain.x_FTB13.disabled=false;
  document.frmMain.x_FTB14.disabled=false;
  document.frmMain.x_FTB10.focus();  
  document.frmMain.checkval.value=0
  }
  else  
  {
  document.frmMain.x_FTB10.disabled=true;
  document.frmMain.x_FTB10.value="";
  document.frmMain.x_FTB11.disabled=true;
  document.frmMain.x_FTB11.value="";
  document.frmMain.x_FTB12.disabled=true;
  document.frmMain.x_FTB12.value="";
  document.frmMain.x_FTB13.disabled=true;
  document.frmMain.x_FTB13.value="";
  document.frmMain.x_FTB14.disabled=true;
  document.frmMain.x_FTB14.value="";  
  document.frmMain.checkval.value=1
  }
}

//Habilita Campos  para Facturación 2
function CheckFac1() {   
if(document.frmMain.checkval.value==1)
 {
  location.href="account.asp?a=I&key="+document.frmMain.key.value+"&fac=1";
  document.frmMain.x_FTB10.focus();
  }
  else  
  {
  document.frmMain.x_FTB10.disabled=true;
  document.frmMain.x_FTB10.value="";
  document.frmMain.x_FTB11.disabled=true;
  document.frmMain.x_FTB11.value="";
  document.frmMain.x_FTB12.disabled=true;
  document.frmMain.x_FTB12.value="";
  document.frmMain.x_FTB13.disabled=true;
  document.frmMain.x_FTB13.value="";
  document.frmMain.x_FTB14.disabled=true;
  document.frmMain.x_FTB14.value="";  
  document.frmMain.checkval.value=1
  }
}

//Checa etstaus
function estatusCheck1() {      
var estatus
var wrt_sts = document.frmMain.estatus.value
switch(wrt_sts)
{
 case "A":
    estatus = "No Asignado"
    break
 case "B":
    estatus = "Enviado"
    break
 case "C":
    estatus = "Terminado"
    break
 case "D":
    estatus = "Cancelado"
    break
 case " ":
    estatus = false
    break
}
if (document.frmMain.estatus.value == false)
   {
   alert('Seleccione Estatus!');
   document.frmMain.estatus.focus();
   }
   else
   {
    
	//No Enviado
	if (document.frmMain.x_FTB14b.value == "A")
	   {
		 if (document.frmMain.estatus.value == "A" | document.frmMain.estatus.value == "C")
            {  
 			alert('Seleccione otro estatus diferente!');
            document.frmMain.estatus.focus();		
	        }
		    else
			   {				 
	            document.frmMain.x_FTB14.value=document.frmMain.estatus.value;
		        document.frmMain.x_FTB14a.value=estatus;				
				return
		        }              
	    }
    //Enviado
	if (document.frmMain.x_FTB14b.value == "B")
	   {
		 if (document.frmMain.estatus.value == "B")
            {  
 			alert('Seleccione otro estatus diferente!');
            document.frmMain.estatus.focus();			
	        }
			 else
			    {				 
	            document.frmMain.x_FTB14.value=document.frmMain.estatus.value;
		        document.frmMain.x_FTB14a.value=estatus;
				return
		        }
    }
	//Terminado
	if (document.frmMain.x_FTB14b.value == "C")
	   {		 
 		alert('Este Servicio ha sido terminado!');
        document.frmMain.estatus.focus();			
	   }	
	//Cancelado
	if (document.frmMain.x_FTB14b.value == "D")
	   {
		alert('Este Servicio ha sido Cancelado!');
        document.frmMain.estatus.focus();			
       }	
  }
}


//Checa campo de busqueda vacio
function check_search() {      
if (document.Busqueda.pSearch.value == "")
   {
   document.Busqueda.pSearch.value="x"
   }
}

//Script de Enfoque Body
function IniFocus() {
var win=null;
var frmMain=document.getElementById('user'); 
document.user.usr.focus();   
}

// Visivilidad para colonia en Solicitud de Taxi
function change_visibility(mod) {

var dir = document.frmMain.x_FTB10.value 

if (mod == 1) {
//Col.style.visibility = "visible";}
document.frmMain.x_FTB8.style.visibility = "visible";
document.frmMain.x_FTB9.style.visibility = "hidden";
document.frmMain.x_FTB10.value = dir
document.frmMain.x_FTB10.readOnly = "true";}
 else{
//Col.style.visibility = "hidden";
document.frmMain.x_FTB8.style.visibility = "hidden";
document.frmMain.x_FTB9.style.visibility = "visible";
document.frmMain.x_FTB10.style.value = "";}
document.frmMain.x_FTB10.readOnly = "false"
}



//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;
	 } 
}

// para chequeo
function check(){
alert("hola");	
}
//Validación de Inicio
function FieldValidIni() {

if (document.user.usr.value == false)
   {
     alert("Registre Nombre de Usuario!");
	 document.user.usr.focus();  	 
	 return false;
   }
if (document.user.psw.value == false)
   {
     alert("Registre Contraseña!");
	 document.user.psw.focus();  	 
	 return false;
   }

return true;

}
//Validación de Asignaciones
function FieldValidSer() {

if (document.frmMain.x_FTB14b.value == "A")
   {
	if (document.frmMain.x_FTB14.value == "B")
	   {
	    if (document.frmMain.unidades.value == false)
 	       {
	       alert("Registre Unidad!");
           document.frmMain.unidades.focus();  	 
	       return false;   
	       }	   
        if (document.frmMain.tarifas.value == false)
 	       {
	       alert("Registre Tarifa!");
           document.frmMain.tarifas.focus();  	 
	       return false;   
	       }    	
	   }
   }

if (document.frmMain.x_FTB14.value == document.frmMain.x_FTB14b.value)
   {
   alert("Estatus no valido!");
   document.frmMain.estatus.focus();  	 
   return false;   
   }

if (document.frmMain.estatus.value == false)
   {
   alert("Registre Estatus!");
   document.frmMain.estatus.focus();  	 
   return false;   
   }

//No Enviado
if (document.frmMain.x_FTB14b.value == "A")
   {
    if (document.frmMain.x_FTB14.value == "A" | document.frmMain.x_FTB14.value == "C")
       {  
 		alert('Seleccione otro estatus diferente!');
        document.frmMain.estatus.focus();
		return false;
       }
   }
//Enviado
if (document.frmMain.x_FTB14b.value == "B")
   {
   if (document.frmMain.x_FTB14.value == "B")
      {  
   	  alert('Seleccione otro estatus diferente!');
      document.frmMain.estatus.focus();			
	  return false;
      }
  }
//Terminado
if (document.frmMain.x_FTB14b.value == "C")
   {		 
   if (document.frmMain.x_FTB14.value != "C")
      {
	  alert('Este Servicio ha sido terminado!');
      document.frmMain.estatus.focus();			
      return false;
	  }
   }	
//Cancelado
if (document.frmMain.x_FTB14b.value == "D")
   {
   if (document.frmMain.x_FTB14.value != "D")
      {
	  alert('Este Servicio ha sido Cancelado!');
      document.frmMain.estatus.focus();			
      return false;
	  }
   }	
var confirmar = confirm('¿Deseas Modificar esta Solicitud?');
if (confirmar == true)
   {
    return true;	
   }
    else
   {
    return false; 
   }    	      
}

//Validación Operadores
function fieldValidOpeTur(fld) {
var fldVal=document.getElementById(fld);
var fldVal1=document.getElementById(fld+1);
var fldVal2=document.getElementById(fld+2);
var fldVal3 = ""
if (fldVal1.value == false)
   {
     alert("Registre Hora!");
	 fldVal1.focus();  	 
	 return false;
   }
if (fldVal2.value == "")
   {
     alert("Registre Minutos!");
	 fldVal2.focus();  	 
	 return false;
   }   
if (fldVal1.value >= 12)
   {fldVal3 = " PM"}
   else
   {fldVal3 = " AM"}
fldVal.value = fldVal1.value+":"+fldVal2.value+fldVal3   
}

//Validación Operadores
function FieldValidOpe() {

if (document.mod_ate.x_FTB1.value == false)
   {
     alert("Registre Nombre de Operador!");
	 document.mod_ate.x_FTB1.focus();  	 
	 return false;
   }
if (document.mod_ate.x_FTB2.value == false)
   {
     alert("Registre Colonia!");
	 document.mod_ate.x_FTB2.focus();  	 
	 return false;
   }
if (document.mod_ate.x_FTB3.value == false)
   {
     alert("Registre Dirección!");
	 document.mod_ate.x_FTB3.focus();  	 
	 return false;
   }
if (document.mod_ate.x_FTB4.value == false)
   {
     alert("Registre Tel!");
	 document.mod_ate.x_FTB4.focus();  	 
	 return false;
   }
if (document.mod_ate.x_FTB5.value == false)
   {
     alert("Registre Cel!");
	 document.mod_ate.x_FTB5.focus();  	 
	 return false;
   }   
if (document.mod_ate.x_FTB6.value == false)
   {
     alert("Registre Número de Unidad!");
	 document.mod_ate.x_FTB6.focus();  	 
	 return false;
   }   
if (document.mod_ate.x_FTB71.value == false)
   {
     alert("Registre Hora de Horario de Entrada del Turno!");
	 document.mod_ate.x_FTB71.focus();  	 
	 return false;
   } 
if (document.mod_ate.x_FTB72.value == "")
   {
     alert("Registre Minutos de Horario de Entrada del Turno!");
	 document.mod_ate.x_FTB72.focus();  	 
	 return false;
   }    
if (document.mod_ate.x_FTB81.value == false)
   {
     alert("Registre Hora de Horario de Salida del Turno");
	 document.mod_ate.x_FTB81.focus();  	 
	 return false;
   }    
if (document.mod_ate.x_FTB82.value == "")
   {
     alert("Registre Minutos de Minutos de Salida del Turno");
	 document.mod_ate.x_FTB82.focus();  	 
	 return false;
   }   
//if (document.mod_ate.x_FTB71.value > document.mod_ate.x_FTB81.value)
//   {
//     alert("La Hora de Entrada es Mayor a la de Salida!");
//	 document.mod_ate.x_FTB71.focus();  	 
//	 return false;
//   }   
//if (document.mod_ate.x_FTB81.value < document.mod_ate.x_FTB71.value)
//   {
//     alert("La Hora de Salida es Menor a la de Salida!");
//	 document.mod_ate.x_FTB81.focus();  	 
//	 return false;
//   }      
if (document.mod_ate.x_FTB10.value == false)
   {
     alert("Registre Número de Operador!");
	 document.mod_ate.x_FTB10.focus();  	 
	 return false;
   }   
if (document.mod_ate.x_FTB11.value == false)
   {
     alert("Registre Antiguedad!");
	 document.mod_ate.x_FTB11.focus();  	 
	 return false;
   }   
if (document.mod_ate.x_FTB9.value == false)
   {
     alert("Registre Imágen!");
	 document.mod_ate.x_FTB9.focus();  	 
	 return false;
   }      
var confirmar = confirm('¿Deseas Registrar Operador?');
if (confirmar == true)
   {
    return true;
   }
    else
   {
    return false; 
   }    	      
}


//Validación Propietarios
function FieldValidPro() {

if (document.mod_ate.x_FTB1.value == false)
   {
     alert("Registre Nombre de Propietario!");
	 document.mod_ate.x_FTB1.focus();  	 
	 return false;
   }
if (document.mod_ate.x_FTB2.value == false)
   {
     alert("Registre RFC!");
	 document.mod_ate.x_FTB2.focus();  	 
	 return false;
   }
if (document.mod_ate.x_FTB2.value.length < 10)
   {
     alert("RFC no puede ser menor de 10 caracteres!");
	 document.mod_ate.x_FTB2.focus();  	 
	 return false;
   }

if (document.mod_ate.x_FTB2.value.length > 13)
   {
     alert("RFC no puede ser mayor de 13 caracteres!");
	 document.mod_ate.x_FTB2.focus();  	 
	 return false;
   }   
if (document.mod_ate.x_FTB3.value == false)
   {
     alert("Registre Colonia!");
	 document.mod_ate.x_FTB3.focus();  	 
	 return false;
   }
if (document.mod_ate.x_FTB4.value == false)
   {
     alert("Registre Dirección!");
	 document.mod_ate.x_FTB4.focus();  	 
	 return false;
   }
if (document.mod_ate.x_FTB5.value == false)
   {
     alert("Registre Tel!");
	 document.mod_ate.x_FTB5.focus();  	 
	 return false;
   }   
if (document.mod_ate.x_FTB6.value == false)
   {
     alert("Registre Tel Opcional!");
	 document.mod_ate.x_FTB6.focus();  	 
	 return false;
   }   
if (document.mod_ate.x_FTB7.value == false)
   {
     alert("Registre Celular!");
	 document.mod_ate.x_FTB7.focus();  	 
	 return false;
   }   
if (document.mod_ate.x_FTB8.value == false)
   {
     alert("Registre Celular Opcional!");
	 document.mod_ate.x_FTB8.focus();  	 
	 return false;
   }   
if (document.mod_ate.x_FTB10.value == false)
   {
     alert("Registre Cuidad!");
	 document.mod_ate.x_FTB10.focus();  	 
	 return false;
   }   
if (document.mod_ate.x_FTB11.value == false)
   {
     alert("Registre Estado!");
	 document.mod_ate.x_FTB11.focus();  	 
	 return false;
   }   
if (document.mod_ate.x_FTB9.value == false)
   {
     alert("Registre Imágen!");
	 document.mod_ate.x_FTB9.focus();  	 
	 return false;
   }      
var confirmar = confirm('¿Deseas Registrar Propietario?');
if (confirmar == true)
   {
    return true;
   }
    else
   {
    return false; 
   }    	      
}

//Validación Unidades
function FieldValidUni() {

if (document.mod_ate.x_FTB1.value == false)
   {
     alert("Registre Nombre de Unidad!");
	 document.mod_ate.x_FTB1.focus();  	 
	 return false;
   }
if (document.mod_ate.x_FTB2.value == false)
   {
     alert("Registre Placas!");
	 document.mod_ate.x_FTB2.focus();  	 
	 return false;
   }
if (document.mod_ate.x_FTB3.value == false)
   {
     alert("Registre Marca!");
	 document.mod_ate.x_FTB3.focus();  	 
	 return false;
   }
if (document.mod_ate.x_FTB4.value == false)
   {
     alert("Registre Modelo!");
	 document.mod_ate.x_FTB4.focus();  	 
	 return false;
   }
if (document.mod_ate.x_FTB5.value == false)
   {
     alert("Registre Año!");
	 document.mod_ate.x_FTB5.focus();  	 
	 return false;
   }   
if (document.mod_ate.x_FTB6.value == false)
   {
     alert("Registre Color!");
	 document.mod_ate.x_FTB6.focus();  	 
	 return false;
   }   
if (document.mod_ate.x_FTB7.value == false)
   {
     alert("Registre Número de Unidad!");
	 document.mod_ate.x_FTB7.focus();  	 
	 return false;
   }   
if (document.mod_ate.x_FTB8.value == false)
   {
     alert("Registre Propietario!");
	 document.mod_ate.x_FTB8.focus();  	 
	 return false;
   }   
if (document.mod_ate.x_FTB9.value == false)
   {
     alert("Registre Imágen!");
	 document.mod_ate.x_FTB9.focus();  	 
	 return false;
   }   
var confirmar = confirm('¿Deseas Registrar Unidad?');
if (confirmar == true)
   {
    return true;
   }
    else
   {
    return false; 
   }    	      
}

//Validación Tarifas
function FieldValidTar() {

if (document.mod_ate.x_FTB1.value == false)
   {
     alert("Registre Nombre de Tarifa!");
	 document.mod_ate.x_FTB1.focus();  	 
	 return false;
   }
if (document.mod_ate.x_FTB2.value == false)
   {
     alert("Registre Costo!");
	 document.mod_ate.x_FTB2.focus();  	 
	 return false;
   }

var confirmar = confirm('¿Deseas Registrar Tarifa?');
if (confirmar == true)
   {
    return true;
   }
    else
   {
    return false; 
   }    	      
}

//Validación de Campos de Solicitud 
function FieldValidSol() {

if (document.frmMain.x_FTB8.value == false)
   {
     alert("Registre Colonia de Envio!");
	 document.frmMain.x_FTB8.focus();  	 
	 return false;
   }
if (document.frmMain.x_FTB9.value == false)
   {
     alert("Registre Direccion de Envio!");
	 document.frmMain.x_FTB9.focus();  	 
	 return false;
   }
if (document.frmMain.x_FTB10.value == false)
   {
     alert("Registre Colonia de Destino!");
	 document.frmMain.x_FTB10.focus();  	 
	 return false;
   }
if (document.frmMain.x_FTB10.value == "Seleccione Colonia")
   {
     alert("Registre Colonia de Destino!");
	 document.frmMain.x_FTB10.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB11.value == false)
   {
     alert("Registre Direccion de Destino!");
	 document.frmMain.x_FTB11.focus();  	 
	 return false;
   }
if (document.frmMain.x_FTB12.value == false)
   {
     alert("Registre Número de Pasajeros!");
	 document.frmMain.x_FTB12.focus();  	 
	 return false;
   }
if (document.frmMain.x_FTB13.value == false)
   {
     alert("Registre Fecha!");
	 document.frmMain.x_FTB13.focus();  	 
	 return false;
   }

var fecha,mes,dia,ann,hrs,mns,tms
    fecha = document.frmMain.hora.value;
    dia = fecha.substr(8,2);
    mes = fecha.substr(5,2);
    ann = fecha.substr(0,4);
    hrs = fecha.substr(11,2);
    mns = fecha.substr(14,2);
    tms = fecha.substr(17,4);
   if(tms=="p.m.")
     {
	 if(hrs==1){hrs=13}
	 if(hrs==2){hrs=14}
	 if(hrs==3){hrs=15}
	 if(hrs==4){hrs=16}
	 if(hrs==5){hrs=17}
	 if(hrs==6){hrs=18}
	 if(hrs==7){hrs=19}
	 if(hrs==8){hrs=20}
	 if(hrs==9){hrs=21}
	 if(hrs==10){hrs=22}
	 if(hrs==11){hrs=23}	 
	 } 
   if (hrs==12 & tms=="a.m."){hrs=24}
   fecha=ann+"/"+mes+"/"+dia+" "+hrs+":"+mns;               
   
var fecha1,mes1,dia1,ann1,hrs1,mns1,tms1   
   fecha1 = document.frmMain.x_FTB13.value;
   dia1 = fecha1.substr(0,2);
   mes1 = fecha1.substr(3,2);
   ann1 = fecha1.substr(6,4);
   hrs1 = document.frmMain.x_FTB14.value;
   mns1 = document.frmMain.x_FTB15.value;
   tms1 = document.frmMain.x_FTB16.value;
 
   if(tms1=="PM")
     {
	 if(hrs1==1){hrs1=13}
	 if(hrs1==2){hrs1=14}
	 if(hrs1==3){hrs1=15}
	 if(hrs1==4){hrs1=16}
	 if(hrs1==5){hrs1=17}
	 if(hrs1==6){hrs1=18}
	 if(hrs1==7){hrs1=19}
	 if(hrs1==8){hrs1=20}
	 if(hrs1==9){hrs1=21}
	 if(hrs1==10){hrs1=22}
	 if(hrs1==11){hrs1=23}		 
	 } 
   if (hrs1==12 & tms1=="AM"){hrs1=24} 
   fecha1=ann1+"/"+mes1+"/"+dia1+" "+hrs1+":"+mns1;     
   
//alert("fecha1="+fecha1+" < fecha="+fecha)

if(document.frmMain.envio0.value == 2)
{
  if (fecha1 < fecha)
     {
      alert("Registre Fecha/Hora Correcta! \n \n Fechas/Horas anteriores no son permitidas");
      document.frmMain.x_FTB13.focus();  
	  return false;
     }
}
if (document.frmMain.x_FTB14.value == false)
   {
     alert("Registre Hora!");
	 document.frmMain.x_FTB14.focus();  	 
	 return false;
   }
if (document.frmMain.x_FTB15.value == "Min")
   {
     alert("Registre Minutos!");
	 document.frmMain.x_FTB15.focus();  	 
	 return false;
   }
if (document.frmMain.x_FTB16.value == false)
   {
     alert("Registre Tiempo a.m./p.m.!");
	 document.frmMain.x_FTB16.focus();  	 
	 return false;
   }

var confirmar = confirm('¿Deseas Registrar esta Solicitud?');
if (confirmar == true)
   {
    return true;
   }
    else
   {
    return false; 
   }    	      
}

function ValidDate(){
var fecha,mes,dia,ann
   fecha=new Date();
   mes = (fecha.getMonth() + 1);
   dia =fecha.getDate();
   ann = fecha.getYear();             
   if(dia < 10){dia="0"+dia;}
   if(mes < 10){mes="0"+mes;}     
   fecha=ann+"/"+mes+"/"+dia;
   
var fecha1,mes1,dia1,ann1   
   fecha1 = document.frmMain.x_FTB13.value;
   dia1 = fecha1.substr(0,2);
   mes1 = fecha1.substr(3,2);
   ann1 = fecha1.substr(6,4);         
   fecha1=ann1+"/"+mes1+"/"+dia1;  

if (fecha1 < fecha)
   {
    alert("Registre Fecha Correcta! \n \n Fechas anteriores no son permitidas");
    document.frmMain.x_FTB13.focus();  	
   }
}


//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.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 Tipo de Convenio!");
	 document.forma.tipo.focus();  	 
	 return false;
   }
if (document.forma.convenio.value == false)
   {
     alert("Registre Convenio!");
	 document.forma.convenio.focus();  	 
	 return false;
   }
var confirmar = confirm('¿Deseas Registrar esta Solicitud?');
if (confirmar == true)
   {
    return true;
   }
    else
   {
    return false; 
   }    	      
}

//Validación email()
function emailValid() {

var mail = document.frmMain.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!");
     document.frmMain.email.focus();  	 
	 return false;
   }
if (pore == -1)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.frmMain.email.focus();  	 
	 return false;
   }

var total = resu + 2;
if (total == size)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.frmMain.email.focus();  	 
	 return false;
   }

var confirmar = confirm('¿Deseas Continuar?');
if (confirmar == true)
   {
    return true;
   }
    else
   {
    return false; 
   }   
	
}
	
//Validación de Campos
function FieldValid(frm) {

if (document.frmMain.x_FTB1.value == false)
   {
     alert("Registre Nombre!");
	 document.frmMain.x_FTB1.focus();  	 
	 return false;
   }

var mail = document.frmMain.x_FTB2.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.frmMain.x_FTB2.focus();  	 
	 return false;
   }
if (pore == -1)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.frmMain.x_FTB2.focus();  	 
	 return false;
   }

var total = resu + 2;
if (total == size)
   {
     alert("Escriba corectamente el Correo Electronico!");
     document.frmMain.x_FTB2.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB3.value == false)
   {
     alert("Registre Telefonos!");
	 document.frmMain.x_FTB3.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB4.value == false)
   {
     alert("Registre Fax!");
	 document.frmMain.x_FTB4.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB5.value == false)
   {
     alert("Registre Colonia!");
	 document.frmMain.x_FTB5.focus();  	 
	 return false;
   }
   
if (document.frmMain.x_FTB6.value == false)
   {
     alert("Registre Direccion!");
	 document.frmMain.x_FTB6.focus();  	 
	 return false;
   }

var pssw0 = document.frmMain.x_FTB7.value;
var pssw1 = document.frmMain.x_FTB8.value;
var pssw2 = document.frmMain.x_FTB9.value;
var size0 = pssw0.length;
var size1 = pssw1.length;
var size2 = pssw2.length;

if (size0 > 8 | size0 < 6)
   {
	 alert("Su Nombre de Usuario tienen que ser menor de 8 caracteres o cuando menos de 6 caracteres!");
	 document.frmMain.x_FTB7.focus();  	 
	 return false;  
   }
   
if (size1 > 8 | size1 < 6)
   {
	 alert("Su Contraseña tienen que ser menor de 8 caracteres o cuando menos de 6 caracteres!");
	 document.frmMain.x_FTB8.focus();  	 
	 return false;  
   }

if (size2 > 8 | size2 < 6)
   {
	 alert("Su Contraseña tienen que ser menor de 8 caracteres o cuando menos de 6 caracteres!");
	 document.frmMain.x_FTB9.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB7.value == false)
   {
     alert("Registre Usuario!");
	 document.frmMain.x_FTB7.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB8.value == false)
   {
     alert("Registre Contraseña!");
	 document.frmMain.x_FTB8.focus();  	 
	 return false;
   }

if (document.frmMain.x_FTB9.value == false)
   {
     alert("Confirme Contraseña!");
	 document.frmMain.x_FTB9.value="";  	 
	 document.frmMain.x_FTB9.focus();  	 
	 return false;
   }

if (document.frmMain.checkval.value == 0)
   {
	   
   if (document.frmMain.x_FTB10.value == false)
      {
       alert("Registre Número de RFC!");
	   document.frmMain.x_FTB10.focus();  	 
	   return false;
      }

   if (document.frmMain.x_FTB10.value.length < 10)
     {
       alert("RFC no puede ser menor de 10 caracteres!");
	   document.frmMain.x_FTB10.focus();  	 
	   return false;
     }

  if (document.frmMain.x_FTB10.value.length > 13)
     {
       alert("RFC no puede ser mayor de 13 caracteres!");
	   document.frmMain.x_FTB10.focus();  	 
	   return false;
     }

  if (document.frmMain.x_FTB11.value == false)
     {
       alert("Registre Nombre o Razón Social!");
	   document.frmMain.x_FTB11.focus();  	 
	   return false;
     }
   
  if (document.frmMain.x_FTB12.value == false)
     {
       alert("Registre Domicilio!");
	   document.frmMain.x_FTB12.focus();  	 
	   return false;
     }

  if (document.frmMain.x_FTB13.value == false)
     {
       alert("Registre Cuidad!");
       document.frmMain.x_FTB13.focus();  	 
	   return false;
     }

  if (document.frmMain.x_FTB14.value == false)
     {
       alert("Registre Estado !");
       document.frmMain.x_FTB14.focus();  	 
	   return false;
     }
 }
if (document.frmMain.x_FTB8.value == document.frmMain.x_FTB9.value)
  {
  if (frm == 1){
     var confirmar = confirm('¿Deseas Modificar sus Datos? \n \n verifique su información posteriormente');  
  }else{
  var confirmar = confirm('¿Deseas Registrar sus Datos? \n \n Si su correo es incorrecto su confirmación no será recibida');
  }
  if (confirmar == true)
     {
      return true;
     }
      else
     {
 	   return false; 
     }   	   
  }
  else 
    {
     alert("Confirme Contraseña Correctamente!");
	 document.frmMain.x_FTB9.focus();  	 
	 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 = -175;
   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'>Cerrar</span></TD>"+   "</TR></TABLE></FORM></DIV>");

onafterload(null);

<!--end:Script-->
