// JavaScript Document

var READY_STATE_COMPLETE=4;
var peticion_http3 = null;

function inicializa_xhr3() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if (window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
}
}


/*
function valorcheckbox(){ 
    var i 	
    for (i=0;i<document.form2.sexo.length;i++){ 
       if (document.form2.sexo[i].checked)           		  
		  break;	  
    } 
    //document.bgColor = document.form2.sexo[i].value 
	return document.form2.sexo[i].value ;
} 
*/
/*
var checkboxes = document.getElementById("contacto").opcion;

var cont = 0;  
for (var x=0; x < checkboxes.length; x++) 
{ 
	if (checkboxes[x].checked) 
	{  
		//cont = cont + 1; 
		var op[x] = checkboxes[x].value ;
	}
}
*/

function crea_query_string3() {

//var checkboxes = document.getElementById("contacto").opcion;

/*var pro = document.getElementById("proxy");
var iplo = document.getElementById("iplocal");
var hosname1 = document.getElementById("hostname1");
var ippu = document.getElementById("ippublica");*/
var nom = document.getElementById("nombre2");
var celu = document.getElementById("cedula2");
var tel = document.getElementById("telefono2");
var tel_movil = document.getElementById("telefono_movil2");
var emai = document.getElementById("email2");
var ciu = document.getElementById("ciudad2");
var pai = document.getElementById("pais2");
var tip = document.getElementById("tipo");
var cant_p = document.getElementById("cantidad_p");
var cant_h = document.getElementById("cantidad_h");
var cam = document.getElementById("cama");
var  llegad_d = document.getElementById("llegada_dia");
var  llegad_m = document.getElementById("llegada_mes");
var salid_d = document.getElementById("salida_dia");
var salid_m = document.getElementById("salida_mes");
var pag = document.getElementById("pagina");
var pag2 = document.getElementById("pagina2");
var men = document.getElementById("mensaje2");




return "nombre2=" + encodeURIComponent(nom.value) + "&cedula2=" + encodeURIComponent(celu.value)  +
"&telefono_movil2=" + encodeURIComponent(tel_movil.value) + "&telefono2=" + encodeURIComponent(tel.value) +
"&email2=" + encodeURIComponent(emai.value) + "&ciudad2=" + encodeURIComponent(ciu.value) +
"&pais2=" + encodeURIComponent(pai.value) + "&tipo=" + encodeURIComponent(tip.value) +
"&cantidad_p=" + encodeURIComponent(cant_p.value) + "&cantidad_h=" + encodeURIComponent(cant_h.value) +
"&cama=" + encodeURIComponent(cam.value) + 
"&llegada_dia=" + encodeURIComponent(llegad_d.value) + "&llegada_mes=" + encodeURIComponent(llegad_m.value) +
"&salida_dia=" + encodeURIComponent(salid_d.value) + "&salida_mes=" + encodeURIComponent(salid_m.value) +
"&mensaje2=" + encodeURIComponent(men.value) +
"&pagina=" + encodeURIComponent(pag.value) + "&pagina2=" + encodeURIComponent(pag2.value) + "&nocache=" + Math.random();
}

function valida_reserva() {
peticion_http3 = inicializa_xhr3();
if(peticion_http3) {
peticion_http3.onreadystatechange = procesaRespuesta3;
peticion_http3.open("POST", "../../estandar/validareserva.php", true);
var query_string3 = crea_query_string3();
peticion_http3.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8849-1");
peticion_http3.send(query_string3);
}
}
/*
function enviar3() {
peticion_http3 = inicializa_xhr3();
if(peticion_http3) {
peticion_http3.onreadystatechange = procesaRespuesta4;
peticion_http3.open("POST", "mailer-contacto.php", true);
var query_string3 = crea_query_string3();
peticion_http3.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8849-1");
peticion_http3.send(query_string3);
}
}
*/
function procesaRespuesta3() {
if(peticion_http3.readyState == READY_STATE_COMPLETE) {
if (peticion_http3.status == 200) {
	var param4 = peticion_http3.responseText;
	if(param4=="exito")
	{
		//alert("Se ha registrado con exito.");
		//document.location.href = "contacto-rta.php";
		document.reserva.action = "../../estandar/mailer-reserva.php";
		document.getElementById("respuestareserva").innerHTML = "Procesando el envio ...";
		//enviar3();
		
		document.reserva.submit();
		//document.contacto.submit();
		//document.getElementById("respuesta").innerHTML = "Se ha registrado con exito. <br>";
		//document.getElementById("form2").reset();
	}
	else
	{
		document.getElementById("respuestareserva").innerHTML = peticion_http3.responseText;
	}
}
}
}

/*
function procesaRespuesta4() {
if(peticion_http3.readyState == READY_STATE_COMPLETE) {
if (peticion_http3.status == 200) {
	var param4 = peticion_http3.responseText;
	if(param4=="enviado")
	{
		//alert("Se ha registrado con exito.");
		//document.location.href = "contacto-rta.php";
		//document.getElementById("respuestas").innerHTML = "Procesando su envio ...";
		//enviar();
		//location.href = "rta.php?resultado=exito";
		document.getElementById("respuestaboletin").innerHTML = "<img src='images/icono-ok.gif' border='0' align='middle'/><br> Su suscripci&oacute;n ha sido enviada.";
		document.boletin.reset();
		//window.parent.img.location.reload();
		//window.close();
		//document.form1.submit();
		//document.getElementById("respuesta").innerHTML = "Se ha registrado con exito. <br>";
		//document.getElementById("form2").reset();
	}
	else
	{
		//location.href = "rta.php?resultado=exito";
		document.getElementById("respuestaboletin").innerHTML = "<img src='images/icono-ok.gif' border='0' align='middle'/><br> Su suscripci&oacute;n ha sido enviada.";
		document.boletin.reset();
		//window.parent.img.location.reload();
		//document.getElementById("respuestas").innerHTML = peticion_http.responseText;
	}
}
}
}
*/