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 contactar(){
	
	if (Spry.Widget.Form.validate(document.contacto) == false) {
			return false;
	}
	c = document.getElementById('rescon');

	nom=document.contacto.nombre2.value;
	asu=document.contacto.asunto.value;
	mai=document.contacto.email2.value;
	msg=document.contacto.mensaje.value;
	ajax=nuevoAjax();
	c.innerHTML = '<p style="text-align:center;"><img src="../images/loadingAnimation.gif" /></p>'; 
	ajax.open("POST", "../php/contacto.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("nombre="+nom+"&asunto="+asu+"&email="+mai+"&mensaje="+msg)
}

function borrarCampos(){
	document.contacto.nombre2.value="";
	document.contacto.asunto.value="";
	document.contacto.email2.value="";
	document.contacto.mensaje.value="";
	document.contacto.nombre2.focus();
}
