//***********************************************************************************************
// validarFecha(dia,mes, año)
//
// Valida que el día y el mes introducidos sean correctos. Además valida que el año introducido
// sea o no bisiesto
//
//***********************************************************************************************
function validarFecha(dia,mes,anio)
{
var elMes = parseInt(mes);

if(elMes>12)
return 1;
// MES FEBRERO
if(elMes == 02){
if(esBisiesto(anio)){
if(parseInt(dia) > 29){
return 1;
}
else
return 0;
}
else{
if(parseInt(dia) > 28){
return 1;
}
else
return 0;
}
}
//RESTO DE MESES

if(elMes== 04 || elMes==06 || elMes==09 || elMes==11){
if(parseInt(dia) > 30){
return 1;
}
}
return 0;

}
//*****************************************************************************************
// esBisiesto(anio)
//
// Determina si el año pasado com parámetro es o no bisiesto
//*****************************************************************************************
function esBisiesto(anio)
{
var BISIESTO;
if(parseInt(anio)%4==0){
if(parseInt(anio)%100==0){
if(parseInt(anio)%400==0){
BISIESTO=true;
}
else{
BISIESTO=false;
}
}
else{
BISIESTO=true;
}
}
else
BISIESTO=false;

return BISIESTO;
}

//*****************************************************************************************
// compare_dates(fecha, fecha2) 
//
// Determina que si dos fechas son iguales
//*****************************************************************************************


function compare_dates(fecha, fecha2)  
   {  
     var xMonth=fecha.substring(3, 5);  
     var xDay=fecha.substring(0, 2);  
     var xYear=fecha.substring(6,10);  
     var yMonth=fecha2.substring(3, 5);  
     var yDay=fecha2.substring(0, 2);  
     var yYear=fecha2.substring(6,10);  
     if (xYear> yYear)  
     {  
         return(true)  
     }  
     else  
     {  
       if (xYear == yYear)  
       {   
         if (xMonth> yMonth)  
         {  
             return(true)  
         }  
         else  
         {   
           if (xMonth == yMonth)  
           {  
             if (xDay> yDay)  
               return(true);  
             else  
               return(false);  
           }  
           else  
             return(false);  
         }  
       }  
       else  
         return(false);  
     }  
 }  

