function AbrirReserva()
{
	window.scrollTo(0,0);
	var capa = document.getElementById('cReserva');
	capa.style.left = window.screen.width*0.23 + "px";
	capa.style.top = window.screen.height*0.02 + "px";	
	PonerTransSalones();
	capa.style.visibility = 'visible';
}



function initPage()
{
	SelectFechaLle();
	SelectFechaSal();
	NDiasOnChange();		
}

function verifyDat()
{
	if (  CompruebaFechaLle() && CompruebaFechaSal() && CompDifFech1() ) 
	{
		document.F1.submit();
		//AbrirReserva();
	}
}

function FechaLleDiasOnChange(){ControlFecha();}	
function FechaLleMesOnChange(){ControlFecha();}	
function FechaLleAnioOnChange(){ControlFecha();}	
function FechaSalDiasOnChange(){ControlFechaSal();}	
function FechaSalMesOnChange(){ControlFechaSal();}	
function FechaSalAnioOnChange(){ControlFechaSal();}	
function NDiasOnChange(){ControlFecha();}	

            
function ControlFechaSal(){
   AnioL=parseInt(document.F1.FechaLleA.options[document.F1.FechaLleA.selectedIndex].text);
   MesL =parseInt(document.F1.FechaLleM.options[document.F1.FechaLleM.selectedIndex].text);
   DiaL =parseInt(document.F1.FechaLleD.options[document.F1.FechaLleD.selectedIndex].text);

   dtl=new Date(AnioL, MesL-1, DiaL);

   AnioS=parseInt(document.F1.FechaSalA.options[document.F1.FechaSalA.selectedIndex].text);
   MesS =parseInt(document.F1.FechaSalM.options[document.F1.FechaSalM.selectedIndex].text);
   DiaS =parseInt(document.F1.FechaSalD.options[document.F1.FechaSalD.selectedIndex].text);

   dts=new Date(AnioS, MesS-1, DiaS);
   document.F1.NumDias.value	=(((((dts-dtl)/1000)/24)/60)/60);
}
function ControlFecha(){
   Anio=parseInt(document.F1.FechaLleA.options[document.F1.FechaLleA.selectedIndex].text);
   Mes =parseInt(document.F1.FechaLleM.options[document.F1.FechaLleM.selectedIndex].text);
   Dia =parseInt(document.F1.FechaLleD.options[document.F1.FechaLleD.selectedIndex].text);

	dt=new Date(Anio, Mes-1, Dia);
    document.F1.FechaLleM.selectedIndex = dt.getMonth();
	document.F1.FechaLleD.selectedIndex = dt.getDate()-1;
	for( c=0;c<document.F1.FechaLleA.options.length;c++)
	{
		 if ( parseInt(document.F1.FechaLleA.options[c].text)==dt.getFullYear())
		 {
		 	document.F1.FechaLleA.selectedIndex = c;
			Found=true;
			break;
		 }
	}  
	if ( !Found )
	{
		o=document.createElement('<option></option>')
		o.text=dt.getFullYear();
		document.F1.FechaLleA.add(o,document.F1.FechaLleA.options.length);
		document.F1.FechaLleA.selectedIndex=document.F1.FechaLleA.options.length-1;
	}
	ND=1
	if ( document.F1.NumDias.value.length != 0)
	{
	   if ( !isNaN(parseInt(document.F1.NumDias.value)) )
          ND=document.F1.NumDias.value;
	}
	dt.setDate(dt.getDate()+parseInt(ND));
    document.F1.FechaSalM.selectedIndex = dt.getMonth();
	document.F1.FechaSalD.selectedIndex = dt.getDate()-1;
	Found=false;
	for( c=0;c<document.F1.FechaSalA.options.length;c++)
	{
		 if ( parseInt(document.F1.FechaSalA.options[c].text)==dt.getFullYear())
		 {
		 	document.F1.FechaSalA.selectedIndex = c;
			Found=true;
			break;
		 }
	}  
	if ( !Found )
	{
		o=document.createElement('<option></option>')
		o.text=dt.getFullYear();
		document.F1.FechaSalA.add(o,document.F1.FechaSalA.options.length);
		document.F1.FechaSalA.selectedIndex=document.F1.FechaSalA.options.length-1;
	}

}	

            function CompDifFech1() { 
   Selecta=1;
   Selecta=document.F1.FechaLleA;SelectIa=Selecta.selectedIndex;
   fechaSel=(Anio=parseInt(Selecta.options[SelectIa].text))*10000;
   Selectm=1;
   Selectm=document.F1.FechaLleM;SelectIm=Selectm.selectedIndex;
   fechaSel+=(Mes=parseInt(Selectm.options[SelectIm].text))*100;
   Selectd=1;
   Selectd=document.F1.FechaLleD;SelectId=Selectd.selectedIndex;
   fechaSel+=Dia=parseInt(Selectd.options[SelectId].text);   

   Selecta=document.F1.FechaSalA;SelectIa=Selecta.selectedIndex;
   fechaSel2=(Anio=parseInt(Selecta.options[SelectIa].text))*10000;
   Selectm=document.F1.FechaSalM;SelectIm=Selectm.selectedIndex;
   fechaSel2+=(Mes=parseInt(Selectm.options[SelectIm].text))*100;
   Selectd=document.F1.FechaSalD;SelectId=Selectd.selectedIndex;
   fechaSel2+=Dia=parseInt(Selectd.options[SelectId].text);   

   if ( fechaSel <= fechaSel2 ) 
   {
      return true; 
   }else
   {
      alert("La fecha de llegada debe ser mayor o igual a la fecha de salida");
      return false;
   }

}

function SelectFechaLle()
{
	fechaActual= new Date();
	
	var navegador = navigator.appName;
 
 	if (navegador == "Microsoft Internet Explorer")
 	{
		document.getElementById("FechaLleD").selectedIndex = fechaActual.getDate();
		document.getElementById("FechaLleM").selectedIndex = fechaActual.getMonth();
		document.getElementById("FechaLleA").selectedIndex = fechaActual.getFullYear()-2005;
	}
	else
	{
		document.F1.FechaLleD.value = fechaActual.getDate()+1;
		document.F1.FechaLleM.value = fechaActual.getMonth()+1;
		document.F1.FechaLleA.value = fechaActual.getFullYear();
	}
}

function CompruebaFechaLle()
{
   Selecta=1;
   Selecta=document.F1.FechaLleA;SelectIa=Selecta.selectedIndex;
   fechaSel=(Anio=parseInt(Selecta.options[SelectIa].text))*10000;
   Selectm=1;
   Selectm=document.F1.FechaLleM;SelectIm=Selectm.selectedIndex;
   fechaSel+=(Mes=parseInt(Selectm.options[SelectIm].text))*100;
   Selectd=1;
   Selectd=document.F1.FechaLleD;SelectId=Selectd.selectedIndex;
   fechaSel+=Dia=parseInt(Selectd.options[SelectId].text);
   fechaCom=new Date(Anio, Mes-1, Dia);
   
   fechaCom=(Anio*10000)+((fechaCom.getMonth() + 1)*100)+fechaCom.getDate();

   if ( fechaCom != fechaSel ) { alert("Fecha no valida(Llegada)");return false;}
if ( 20060122 <= fechaSel )return true; else alert("Fecha no valida(Llegada)");return false;
}

function SelectFechaSal()
{
	fechaActual= new Date();
	
	var navegador = navigator.appName;
 
 	if (navegador == "Microsoft Internet Explorer")
 	{
		document.getElementById("FechaSalD").selectedIndex = fechaActual.getDate()-1;
		document.getElementById("FechaSalM").selectedIndex = fechaActual.getMonth();
		document.getElementById("FechaSalA").selectedIndex = fechaActual.getFullYear()-2005;
	}
	else
	{
		document.F1.FechaSalD.value = fechaActual.getDate();
		document.F1.FechaSalM.value = fechaActual.getMonth()+1;
		document.F1.FechaSalA.value = fechaActual.getFullYear();
	}
}

function CompruebaFechaSal()
{
   Selecta=1;
   Selecta=document.F1.FechaSalA;SelectIa=Selecta.selectedIndex;
   fechaSel=(Anio=parseInt(Selecta.options[SelectIa].text))*10000;
   Selectm=1;
   Selectm=document.F1.FechaSalM;SelectIm=Selectm.selectedIndex;
   fechaSel+=(Mes=parseInt(Selectm.options[SelectIm].text))*100;
   Selectd=1;
   Selectd=document.F1.FechaSalD;SelectId=Selectd.selectedIndex;
   fechaSel+=Dia=parseInt(Selectd.options[SelectId].text);
   fechaCom=new Date(Anio, Mes-1, Dia);
   
   fechaCom=(Anio*10000)+((fechaCom.getMonth() + 1)*100)+fechaCom.getDate();

   if ( fechaCom != fechaSel ) { alert("Fecha no valida(Salida)");return false;}
if ( 20060122 <= fechaSel )return true; else alert("Fecha no valida(Salida)");return false;
}

function SelectHab1()
{
	document.F1.elements(document.F1.elements.length-7).selectedIndex = 0;
}