// CopyRight Grupo Hispaworks S.L Tel. 902.190.123 //


//// Crear el Objeto Xmlhttp //

function creaXmlhttp (){
	var xmlhttp = false;
 	//Comprobar si estamos usando IE.
	try {
 		//Si la versión de JavaScript es superior a 5.
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e1) {
		//Si no, utilizar el tradicional objeto ActiveX.
		try {
			// Si estamos usando Internet Explorer.
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e2) {
			//En caso contrario debe tratarse de un navegador que no es IE.
			xmlhttp = false;
		}	
	}

	//Si no estamos usando IE, creamos una instancia JavaScript del objeto.
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	
	return xmlhttp;
}

function sendForm (){

	var ok = validarForm ();
	if (ok){

	
	document.getElementById("btnEnviar").style.display == "none";
	var palla_empresa = document.getElementById("palla_empresa").value;
	var palla_asistentes = document.getElementById ('palla_asistentes').options[document.getElementById ('palla_asistentes').selectedIndex].value;
	var palla_nombres = document.getElementById("palla_nombres").value;
	var palla_cursa = document.getElementById ('palla_cursa').options[document.getElementById ('palla_cursa').selectedIndex].value;
	var palla_uala = document.getElementById ('palla_uala').options[document.getElementById ('palla_uala').selectedIndex].value;
	if (palla_uala == "SI"){
	var palla_asistuala = document.getElementById("palla_asistuala").value;
	}else{
	palla_asistuala = "0";	
	}
	var palla_contact = document.getElementById("palla_contact").value;
	var palla_mail = document.getElementById("palla_mail").value;
	var palla_tel = document.getElementById("palla_tel").value;
	
	document.getElementById("form").style.display = "none";

		serverPage="sendform.php?palla_empresa=" + palla_empresa + "&palla_asistentes=" + palla_asistentes + "&palla_nombres=" + palla_nombres + "&palla_cursa=" + palla_cursa + "&palla_uala=" + palla_uala + "&palla_asistuala=" + palla_asistuala + "&palla_contact=" + palla_contact + "&palla_mail=" + palla_mail + "&palla_tel=" + palla_tel;
		xmlhttp = creaXmlhttp();
		var obj = document.getElementById("result");
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState != 4){
				obj.innerHTML = '<img src="images/loading.gif">';
			}
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
				//alert (xmlhttp.responseText);
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);	
		
		document.getElementById("form").style.display = "block";

		document.getElementById("palla_empresa").value = "";
		document.getElementById ('palla_asistentes').options[document.getElementById ('palla_asistentes').selectedIndex].value = "";
		document.getElementById("palla_nombres").value = "";
		document.getElementById ('palla_cursa').options[document.getElementById ('palla_cursa').selectedIndex].value = "";
		document.getElementById ('palla_uala').options[document.getElementById ('palla_uala').selectedIndex].value = "";
		document.getElementById ("asistuala").style.display = "none";
		document.getElementById("palla_contact").value = "";
		document.getElementById("palla_mail").value = "";
		document.getElementById("palla_tel").value = "";
		
		document.getElementById("btnEnviar").style.display == "block";
		
	
	}
}

// Activar asistentes uala//
function asistUala (){
	var palla_uala;
	palla_uala = document.getElementById ("palla_uala").value;
	if (palla_uala == "SI"){
	document.getElementById ("palla_asistuala").value = "";	
	document.getElementById ("asistuala").style.display = "block";
	}else{
	document.getElementById ("palla_asistuala").value = "";
	document.getElementById ("asistuala").style.display = "none";
	}
}

/// Limpiar Background de input //

function limpiarBg (campo){
	campo.style.background = "#ffffff";	
}