var a=String.fromCharCode(225); 
var e=String.fromCharCode(233); 
var i=String.fromCharCode(237); 
var o=String.fromCharCode(243); 
var u=String.fromCharCode(250);
var n=String.fromCharCode(241);
var N=String.fromCharCode(209);
var intro=String.fromCharCode(10);

function objetoAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
  		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
	{
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function ComprobarMailPresencial()
{
	document.getElementById('denegado').style.display = 'none'; 
	document.getElementById('noaparece').style.display = 'none'; 
	document.getElementById('confirmado').style.display = 'none'; 
    document.getElementById('aprobado').style.display = 'none'; 
	document.getElementById('confirmadoretorno').style.display = 'none'; 
	
	url = "/virtual/comprobarmailpresencial.php?mail=" + document.getElementById('mail').value + "&nocache=" + Math.random(); ;
	ajax=objetoAjax();
	ajax.open("GET", url);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) 
		{
			entra = false;
			if (ajax.responseText == 'noesta')
			{
				document.getElementById('noaparece').style.display = 'block'; 
				entra = true;
			}
			if (ajax.responseText == 'denegado')
			{
				document.getElementById('denegado').style.display = 'block'; 
				entra = true;
			}
			if (ajax.responseText.indexOf('aprobado') > -1) 
			{
				trozos = ajax.responseText.split ("-");
				document.getElementById('sede').innerHTML = trozos[1]; 
				document.getElementById('aprobado').style.display = 'block'; 
				entra = true;
			}
			if (ajax.responseText.indexOf('confirmado') > -1) 
			{
				trozos = ajax.responseText.split ("-");
				document.getElementById('sedeconfirmado').innerHTML = trozos[1]; 
				document.getElementById('confirmado').style.display = 'block'; 
				entra = true;
			}
				
			if (!(entra))
				alert(ajax.responseText);

		}
	}
	
	ajax.send(null)
}

function ConfirmarInscripcionPresencial()
{
	
	url = "/virtual/confirmarmailpresencial.php?mail=" + document.getElementById('mail').value;
	ajax=objetoAjax();
	ajax.open("GET", url);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) 
		{
			entra = false;
			if (ajax.responseText == 'noesta')
			{
				alert("Por favor vuelva a escribir su mail");
				entra = true;
			}
			if (ajax.responseText == 'ok')
			{			
				document.getElementById('confirmadoretorno').style.display = 'block'; 
			    document.getElementById('aprobado').style.display = 'none'; 
				entra = true;
			}
				
			if (!(entra))
				alert(ajax.responseText);

		}
	}
	
	ajax.send(null)
}

