
function fFecha()
{
    var mydate=new Date();
    var year=mydate.getYear();
    if (year < 1000)
    year+=1900;
    var day=mydate.getDay();
    var month=mydate.getMonth();
    month=month+1;
    var daym=mydate.getDate();
    if (daym<10)
    daym="0"+daym;
    if(month<10)
    month="0"+month;
    document.getElementById("idDate").value=daym+"/"+month+"/"+year;
    document.getElementById("idLDate").value=daym+"/"+month+"/"+year;
    document.getElementById("idDDate").value=daym+"/"+month+"/"+year;
}

function make_menu(i)
{
    if(i==0)
    {
        var obj=document.getElementById("idVuelo");
        obj.style.display=(obj.style.display=="none")?"block":"";
        obj=document.getElementById("idHotel");
        obj.style.display=(obj.style.display=="block")?"none":"none";        
    }
    else
    {
        if(i==1)
        {
            var obj=document.getElementById("idHotel");
            obj.style.display=(obj.style.display=="none")?"block":"";
            obj=document.getElementById("idVuelo");
            obj.style.display=(obj.style.display=="block")?"none":"none";        
        }
        else
        {
            var obj=document.getElementById("idVuelo");
            obj.style.display=(obj.style.display=="none")?"block":"";
            obj=document.getElementById("idHotel");
            obj.style.display=(obj.style.display=="block")?"none":"none";        
        }
    }
}

function fServicios()
{
    
    if(document.getElementById("h1").checked==true)
    {
      var obj=document.getElementById("idServicios1");
      obj.style.display=(obj.style.display=="block")?"none":"none";
      obj=document.getElementById("idServicios2");
      obj.style.display=(obj.style.display=="block")?"none":"none";
      document.getElementById("idButton").style.display="block";
    }
    else
    {
      var obj=document.getElementById("idServicios1");
      obj.style.display=(obj.style.display=="none")?"block":"";
      obj=document.getElementById("idServicios2");
      obj.style.display=(obj.style.display=="none")?"block":"";        
      document.getElementById("idButton").style.display="none";
    }    
}
function validarV(){  
    if(document.formEnviarV.idName.value==""){ //si el largo de nombre es menor a 2 caracteres 
        alert("Put your name"); //mensaje a la pantalla 
        document.formEnviarV.idName.focus(); //el puntero del mouse queda en nombre 
        return 0; //devolvemos un cero para dejar de validar 
    } 
    if(document.formEnviarV.idEmail.value==""){ //si el largo de marca es menor a 2 caracteres 
        alert("Put your Email"); //mensaje a la pantalla 
        document.formEnviarV.idEmail.focus(); //el puntero del mouse queda en marca 
        return 0; //devolvemos un cero para dejar de validar 
    } 
    if((document.formEnviarV.idAdulto.value=="0")&&(document.formEnviarV.idNino.value=="0")&&(document.formEnviarV.idBebe.value=="0"))
    {
        alert("put at least one Person");        
        document.formEnviarV.idAdulto.focus();
        return 0;
    }
    if(document.formEnviarV.idDate.value=="")
    {
        alert("put at Flight Date");        
        document.formEnviarV.idDate.focus();
        return 0;        
    }
    else{ //sino enviamos el formulario 
        document.formEnviarV.submit(); //enviamos formulario     
    } 
}  
function validarH(){  
    if(document.formEnviarH.idFullN.value==""){ //si el largo de nombre es menor a 2 caracteres 
        alert("Put your name"); //mensaje a la pantalla 
        document.formEnviarH.idFullN.focus(); //el puntero del mouse queda en nombre 
        return 0; //devolvemos un cero para dejar de validar 
    } 
    if(document.formEnviarH.idHEmail.value==""){ //si el largo de marca es menor a 2 caracteres 
        alert("Put your Email"); //mensaje a la pantalla 
        document.formEnviarH.idHEmail.focus(); //el puntero del mouse queda en marca 
        return 0; //devolvemos un cero para dejar de validar 
    } 
    else{ //sino enviamos el formulario 
        document.formEnviarH.submit(); //enviamos formulario     
    } 
}  
function validarHV(){  
    if(document.formEnviarH.idFullN.value==""){ //si el largo de nombre es menor a 2 caracteres 
        alert("Put your name"); //mensaje a la pantalla 
        document.formEnviarH.idFullN.focus(); //el puntero del mouse queda en nombre 
        return 0; //devolvemos un cero para dejar de validar 
    } 
    if(document.formEnviarH.idHEmail.value==""){ //si el largo de marca es menor a 2 caracteres 
        alert("Put your Email"); //mensaje a la pantalla 
        document.formEnviarH.idHEmail.focus(); //el puntero del mouse queda en marca 
        return 0; //devolvemos un cero para dejar de validar 
    } 
    else{ //sino enviamos el formulario 
        document.formEnviarH.submit(); //enviamos formulario     
    } 
}
  
function IsNumeric(valor) 
{ 
var log=valor.length; var sw="S"; 
for (x=0; x<log; x++) 
{ v1=valor.substr(x,1); 
v2 = parseInt(v1); 
//Compruebo si es un valor numérico 
if (isNaN(v2)) { sw= "N";} 
} 
if (sw=="S") {return true;} else {return false; } 
} 
var primerslap=false; 
var segundoslap=false; 
function formateafecha(fecha) 
{ 
var long = fecha.length; 
var dia; 
var mes; 
var ano; 
if ((long>=2) && (primerslap==false)) { dia=fecha.substr(0,2); 
if ((IsNumeric(dia)==true) && (dia<=31) && (dia!="00")) { fecha=fecha.substr(0,2)+"/"+fecha.substr(3,7); primerslap=true; } 
else { fecha=""; primerslap=false;} 
} 
else 
{ dia=fecha.substr(0,1); 
if (IsNumeric(dia)==false) 
{fecha="";} 
if ((long<=2) && (primerslap=true)) {fecha=fecha.substr(0,1); primerslap=false; } 
} 
if ((long>=5) && (segundoslap==false)) 
{ mes=fecha.substr(3,2); 
if ((IsNumeric(mes)==true) &&(mes<=12) && (mes!="00")) { fecha=fecha.substr(0,5)+"/"+fecha.substr(6,4); segundoslap=true; } 
else { fecha=fecha.substr(0,3);; segundoslap=false;} 
} 
else { if ((long<=5) && (segundoslap=true)) { fecha=fecha.substr(0,4); segundoslap=false; } } 
if (long>=7) 
{ ano=fecha.substr(6,4); 
if (IsNumeric(ano)==false) { fecha=fecha.substr(0,6); } 
else { if (long==10){ if ((ano==0) || (ano<1900) || (ano>2100)) { fecha=fecha.substr(0,6); } } } 
} 
if (long>=10) 
{ 
fecha=fecha.substr(0,10); 
dia=fecha.substr(0,2); 
mes=fecha.substr(3,2); 
ano=fecha.substr(6,4); 
// Año no viciesto y es febrero y el dia es mayor a 28 
if ( (ano%4 != 0) && (mes ==02) && (dia > 28) ) { fecha=fecha.substr(0,2)+"/"; } 
var mydate=new Date();
var year=mydate.getYear();
if (year < 1000)
year+=1900;
var day=mydate.getDay();
var month=mydate.getMonth();
var daym=mydate.getDate();
month=month+1;
if(ano<year)
{ 
  fecha=fecha.substr(0,6);
}
else
{
     if(mes<month){fecha=fecha.substr(0,2)+"/";}     
     else
     {
         if((dia<daym) && (mes==month) && (ano==year)){fecha=fecha.substr(0,0);}
     }
}

} 
return (fecha); 
}
