function nuevoAjax(){
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 enviarMail(){
	
	if (Spry.Widget.Form.validate(document.suscripcion) == false) {
			return false;
	}
	c = document.getElementById('resusc');
	nom=document.suscripcion.nombre.value;
	ape=document.suscripcion.apellido.value;
	mai=document.suscripcion.email.value;
	ajax=nuevoAjax();
	c.innerHTML = '<p style="text-align:center;"><img src="../images/esperando.gif" /></p>'; 
	ajax.open("POST", "../php/suscripcion.php",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			c.innerHTML = ajax.responseText
		}
		borrarCampos()
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("email="+mai+"&nombre="+nom+"&apellido="+ape);
}

function borrarCampos(){
	document.suscripcion.nombre.value="";
	document.suscripcion.apellido.value="";
	document.suscripcion.email.value="";
	document.suscripcion.nombre.focus();
}