// 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 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("nombre");
var emai = document.getElementById("email");
var men = document.getElementById("mensaje");


return "nombre=" + encodeURIComponent(nom.value) + 
"&email=" + encodeURIComponent(emai.value)  +
"&mensaje=" + encodeURIComponent(men.value)  + 
"&nocache=" + Math.random();
}
function valida_mensaje() {
peticion_http3 = inicializa_xhr3();
if(peticion_http3) {
peticion_http3.onreadystatechange = procesaRespuesta3;
peticion_http3.open("POST", "valida_mensaje.php", true);
var query_string3 = crea_query_string3();
peticion_http3.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-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-8859-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.contacto.action = "mailer-mensaje.php";
		document.getElementById("respuestacontacto").innerHTML = "Procesando el envio ...";
		//enviar3();
		
		document.contacto.submit();
		//document.contacto.submit();
		//document.getElementById("respuesta").innerHTML = "Se ha registrado con exito. <br>";
		//document.getElementById("form2").reset();
	}
	else
	{
		document.getElementById("respuestacontacto").innerHTML = peticion_http3.responseText;
	}
}
}
}

/*
function procesaRespuesta4() {
if(peticion_http3.readyState == READY_STATE_COMPLETE) {
if (peticion_http3.status == 200) {
	var param5 = peticion_http3.responseText;
	if(param5=="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;
	}
}
}
}
*/