// JavaScript Document



<!--

function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}

//-->

function mmLoadMenus() {

  if (window.mm_menu_0613103805_0) return;

        window.mm_menu_0613103805_0 = new Menu("root",179,18,"Arial, Helvetica, sans-serif",12,"#C9C6BE","#FFFFFF","#373121","#996600","left","middle",3,0,1000,-5,7,true,true,true,0,true,true);

  mm_menu_0613103805_0.addMenuItem("Restaurant&nbsp;Quevedo&nbsp;Real","location='html/restaurant.html'");

  mm_menu_0613103805_0.addMenuItem("Salas&nbsp;de&nbsp;Conferencias","location='html/salas.html'");

  mm_menu_0613103805_0.addMenuItem("Piscina&nbsp;y&nbsp;Spa","location='html/piscina.html'");

   mm_menu_0613103805_0.hideOnMouseOut=true;

   mm_menu_0613103805_0.bgColor='#999999';

   mm_menu_0613103805_0.menuBorder=1;

   mm_menu_0613103805_0.menuLiteBgColor='#FFFFFF';

   mm_menu_0613103805_0.menuBorderBgColor='#383025';



mm_menu_0613103805_0.writeMenus();

} // mmLoadMenus()



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}



function MM_controlShockwave(objStr,x,cmdName,frameNum) { //v3.0

  var obj=MM_findObj(objStr);

  if (obj) eval('obj.'+cmdName+'('+((cmdName=='GotoFrame')?frameNum:'')+')');

}



function validaFormulario(opcion){

var forma = document.frmUser;

	if(opcion==0){

	    if(forma.nombre.value == ""){

		  alert("Por favor ingrese un nombre");

		  forma.nombre.focus();

		  return false;

		}

		if(forma.email.value == ""){

		  alert("Por favor ingrese un correo");

		  forma.email.focus();

		  return false;

		}

		if(forma.country.value == ""){

		  alert("Por favor ingrese un pais");

		  forma.country.focus();

		  return false;

		}

		if(forma.phone.value == ""){

		  alert("Por favor ingrese un telefono");

		  forma.phone.focus();

		  return false;

		}

		val = forma.email.value;

		p= val.indexOf('@');

		if (p<1 || p==(val.length-1)) {

			alert("Correo electronico es invalido");

			forma.email.select();	 

			return false;

		}

		if(forma.contenido.value == ""){

		  alert("Por favor ingrese un comentario");

		  forma.contenido.focus();

		  return false;

		}

		

		forma.action = "../html/finish.php";

		forma.submit();	

	}else{

		forma.nombre.value = "";

		forma.email.value = "";

		forma.contenido.value = "";

		forma.country.value  = "";

		forma.phone.value = "";

	}	

}



var pong;

function makeArray(n){

  this.length = n;

  for (i=1;i<=n;i++){

    this[i]=0;

  }

  return this;

}



// standard date display function with y2k compatibility

function displayDate() {

  var this_month = new makeArray(12);

  this_month[0]  = "Enero";

  this_month[1]  = "Febrero";

  this_month[2]  = "Marzo";

  this_month[3]  = "Abril";

  this_month[4]  = "Mayo";

  this_month[5]  = "Junio";

  this_month[6]  = "Julio";

  this_month[7]  = "Agosto";

  this_month[8]  = "Septiembre";

  this_month[9]  = "Octubre";

  this_month[10] = "Noviembre";

  this_month[11] = "Diciembre";



  var this_day_e = new makeArray(7);

  this_day_e[0]  = "Domingo";

  this_day_e[1]  = "Lunes";

  this_day_e[2]  = "Martes";

  this_day_e[3]  = "Miércoles";

  this_day_e[4]  = "Jueves";

  this_day_e[5]  = "Viernes";

  this_day_e[6]  = "Sábado";



  var today = new Date();

  var day   = today.getDate();

  var month = today.getMonth();

  var year  = today.getYear();

  var dia = today.getDay();

    if (year < 1000) {

       year += 1900; }

  return( " " + this_day_e[dia] + ", " + day + " de " + this_month[month] + " " + year);

}



function ObtenerMesListado(){

  var this_month = new makeArray(12);

  this_month[0]  = "Enero";

  this_month[1]  = "Febrero";

  this_month[2]  = "Marzo";

  this_month[3]  = "Abril";

  this_month[4]  = "Mayo";

  this_month[5]  = "Junio";

  this_month[6]  = "Julio";

  this_month[7]  = "Agosto";

  this_month[8]  = "Septiembre";

  this_month[9]  = "Octubre";

  this_month[10] = "Noviembre";

  this_month[11] = "Diciembre";

  var ls_cadena = new String;

  

  ls_cadena = "<option value='0' selected='selected'>Mes</option>";

  

  for (i=0;i<12;i++){

	  if((i+1)<10){

	    numero = "0"+(i+1);

	  }else{

		numero = (i+1);  

	  }

      ls_cadena += "<option value='"+numero+"' ";

	  ls_cadena +=  ">"+this_month[i]+"</option>";

  } 	

  return ls_cadena;

}



function ObtenerDiaListado(){



ls_cadena = "<option value='0' selected='selected'>Dia</option>";

  

  for (i=0;i<31;i++){

	  if((i+1)<10){

	    numero = "0"+(i+1);

	  }else{

		numero = (i+1);  

	  }

      ls_cadena += "<option value='"+numero+"' ";

	  ls_cadena +=  ">"+numero+"</option>";

  } 	

  return ls_cadena;

}



function fg_objetus() {

      var http_request = false;

      if (window.XMLHttpRequest) { // Mozilla, Safari,...

         http_request = new XMLHttpRequest();

      } else if (window.ActiveXObject) { // IE

         try {

            http_request = new ActiveXObject("Msxml2.XMLHTTP");

         } catch (e) {

            try {

               http_request = new ActiveXObject("Microsoft.XMLHTTP");

            } catch (e) {}

         }

      }

      if (!http_request) {

         alert('Cannot create XMLHTTP instance');

         return false;

      }

	  if (http_request.overrideMimeType) {

            http_request.overrideMimeType('text/xml');

      }

      return http_request;

   }



function ObtenerAnoListado(){



ls_cadena = "<option value='0' selected='selected'>A&ntilde;o</option>";

  var today = new Date();

  var year  = today.getFullYear();

  for (i=year;i<(year+10);i++){

	  ls_cadena += "<option value='"+i+"' ";

	  ls_cadena +=  ">"+i+"</option>";

  } 	

  return ls_cadena;

}



function ObtenerCantidadListado(){



ls_cadena = "<option value='0' selected='selected'>0</option>";

 

  for (i=1;i<11;i++){

	  ls_cadena += "<option value='"+i+"' ";

	  ls_cadena +=  ">"+i+"</option>";

  } 	

  return ls_cadena;

}



function ObtenerHabitacionListado(){



ls_cadena = "<option value='0' selected='selected'>0</option>";

 

  for (i=1;i<11;i++){

	  ls_cadena += "<option value='"+i+"' ";

	  ls_cadena +=  ">"+i+"</option>";

  } 	

  return ls_cadena;

}



function validarReserva(){

	

	var forma = document.reserva;

	

	if(forma.nombres.value==""){

		alert("Nombre es requerido");

		forma.nombres.focus();

	    return false;

	}

	

	if(forma.phone.value==""){

		alert("Telefono es requerido");

		forma.phone.focus();

	    return false;

	}

	

	if(forma.country.value==""){

		alert("Pais es requerido");

		forma.country.focus();

	    return false;

	}

	

	if(forma.email.value==""){

		alert("Email es requerido");

		forma.email.focus();

		return false;

	}

	

	val = forma.email.value;

	p= val.indexOf('@');

	if (p<1 || p==(val.length-1)) {

		alert("Correo electronico es invalido");

		forma.email.select();	 

		return false;

	}

	

	if((forma.dia_entrada.value!="0")||(forma.mes_entrada.value!="0")||(forma.anio_entrada.value!="0")){

	   if(forma.dia_entrada.value=="0"){

		  alert("Dia de ingreso es requerido");

		  forma.dia_entrada.focus();	 

		  return false;

	   }

	   if(forma.mes_entrada.value=="0"){

	      alert("Mes de ingreso es requerido");

		  forma.mes_entrada.focus();	

		  return false;

	   }

	   if(forma.anio_entrada.value=="0"){

	      alert("Anio de ingreso es requerido");

		  forma.anio_entrada.focus();	

		  return false;

	   }

	   

	   var d = new Date();

	   var currYear = d.getFullYear();

       var currMonth = d.getMonth() + 1;

       var curate = d.getDate();



       time = currYear + "-" +(currMonth < 10 ? "0" : "") + currMonth + "-" +(curate < 10 ? "0" : "") + curate;

    

	   if (forma.anio_entrada.value+"-"+forma.mes_entrada.value+"-"+forma.dia_entrada.value<time){

		 alert('Por favor, seleccione una fecha superior a la actual');

		 forma.dia_entrada.focus();

		 return false;

	   }

	   

	   if(forma.dia_salida.value=="0"){

	      alert("Dia de salida es requerido");

		  forma.dia_salida.focus();	

		  return false;

	   }

	   if(forma.mes_salida.value=="0"){

	      alert("Mes de salida es requerido");

		  forma.mes_salida.focus();	

		  return false;

	   }

	   if(forma.anio_salida.value=="0"){

	      alert("Anio de salida es requerido");

		  forma.anio_salida.focus();	

		  return false;

	   }

	   

	   if (forma.anio_entrada.value+"-"+forma.mes_entrada.value+"-"+forma.dia_entrada.value>=forma.anio_salida.value+"-"+forma.mes_salida.value+"-"+forma.dia_salida.value){

		 alert('Por favor, seleccione una fecha superior a la fecha de entrada');

		 forma.dia_salida.focus();

		 return false;

	   }

	   

	}

	

	if(forma.cant_sencilla.value!="0"){

	   if(forma.adultos_sencilla.value=="0"){

		 alert('Cantidad de adultos es requerida');

		 forma.adultos_sencilla.focus();

		 return false;   

	   }

	}

	if(forma.cant_doble.value!="0"){

	  if(forma.adultos_doble.value=="0"){

		 alert('Cantidad de adultos es requerida');

		 forma.adultos_doble.focus();

		 return false;     

	   }

	}

	if(forma.cant_extra.value!="0"){

	   if(forma.adultos_extra.value=="0"){

		 alert('Cantidad de adultos es requerida');

		 forma.adultos_extra.focus();

		 return false;     

	   }

	}

	

	var lo_container = document.getElementById('mensaje');

	var lo_campos = document.getElementById('campos');

	var lo_boton = document.getElementById('btn_enviar');

	var ps_pagehtml = "sendmail.php?nombres="+forma.nombres.value+"&email="+forma.email.value;

	ps_pagehtml += "&observaciones="+forma.observaciones.value+"&dia_entrada="+forma.dia_entrada.value;

	ps_pagehtml += "&mes_entrada="+forma.mes_entrada.value+"&anio_entrada="+forma.anio_entrada.value;

	ps_pagehtml += "&dia_salida="+forma.dia_salida.value+"&mes_salida="+forma.mes_salida.value;

	ps_pagehtml += "&anio_salida="+forma.anio_salida.value+"&cant_sencilla="+forma.cant_sencilla.value;

	ps_pagehtml += "&adultos_sencilla="+forma.adultos_sencilla.value+"&ninos_sencilla="+forma.ninos_sencilla.value;

	ps_pagehtml += "&cant_doble="+forma.cant_doble.value+"&adultos_doble="+forma.adultos_doble.value;

	ps_pagehtml += "&ninos_doble="+forma.ninos_doble.value+"&cant_extra="+forma.cant_extra.value;

	ps_pagehtml += "&adultos_extra="+forma.adultos_extra.value+"&ninos_extra="+forma.ninos_extra.value+"&phone="+forma.phone.value+"&country="+forma.country.value; 

	//alert(ps_pagehtml);

	

	var lo_ajax=fg_objetus();

	lo_container.innerHTML = "Procesando...";

	lo_ajax.open("GET", ps_pagehtml,true);

	lo_ajax.onreadystatechange=function() {

			if (lo_ajax.readyState==4) {

			   if(lo_ajax.status==200){

					  ls_contenido = lo_ajax.responseText;

					  //alert(ls_contenido);

					  if(ls_contenido==1){

					  lo_container.innerHTML = "<b>Su solicitud de reserva ha sido enviada satisfactoriamente.</b>";

					  lo_campos.innerHTML = "<a href='#' onclick='restablecer();'>Continuar</a>";

					  lo_boton.innerHTML = "";

					  }else{

					   lo_container.innerHTML = "Su solicitud de reserva <b>NO</b> se ha enviado."; 	  

					  }

			   }else {

					  alert("Sorry, try again later"); 

			   }

			} else {

			   lo_container.innerHTML = "Processing.....";

			}

	}

	lo_ajax.send(null);

}



function restablecer(){

	var lo_container = document.getElementById('mensaje');

	var lo_campos = document.getElementById('campos');

	var lo_boton = document.getElementById('btn_enviar');

  

    lo_container.innerHTML = "";

	lo_campos.innerHTML = "<em>(*) Campos Obligatorios</em>";

    lo_boton.innerHTML = "";
	
	lo_boton.innerHTML = "<table width='100%' cellpadding='1' cellspacing='0' bgcolor='#D4CCA5'><tr><td><table width='100%' cellpadding='0' cellspacing='0' bgcolor='#D4CCA5'><tr><td height='26' align='center' valign='middle' bgcolor='#D4CCA5'><input onclick='validarReserva();' type='button' value='Enviar' name='send' /></td></tr></table></td></tr></table>";
	
	//alert(lo_boton.innerHTML);

	var forma = document.reserva;

	forma.nombres.value="";

	forma.email.value = "";

	forma.observaciones.value = "";

	forma.country.value = "";

	forma.phone.value = "";

	forma.dia_entrada.options[0].selected=true;

	forma.mes_entrada.options[0].selected=true;

	forma.anio_entrada.options[0].selected=true;

	forma.dia_salida.options[0].selected=true;

	forma.mes_salida.options[0].selected=true;

	forma.anio_salida.options[0].selected=true;

	forma.cant_sencilla.options[0].selected=true;

	forma.adultos_sencilla.options[0].selected=true;

	forma.ninos_sencilla.options[0].selected=true;

	forma.cant_doble.options[0].selected=true;

	forma.adultos_doble.options[0].selected=true;

	forma.ninos_doble.options[0].selected=true;

	forma.cant_extra.options[0].selected=true;

	forma.adultos_extra.options[0].selected=true;

	forma.ninos_extra.options[0].selected=true;

}

//-->

