// JavaScript Document
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 !='undefined'){
   if (typeof XMLHttpRequest!='undefined') {
      xmlhttp = new XMLHttpRequest();
   }}
   return xmlhttp;
}
 
 
function enviaMail(){
   var asunto,mensaje,nombreAp,email,fono,celular,contenedor;
   contenedor = document.getElementById('procesos');
   contenedor.innerHTML="<img src='cargando/anim2.gif' id='cargando' name='cargando' width='30px' height='30px'>";
   
   asunto = document.getElementById('asunto').value;
   mensaje = document.getElementById('mensaje').value;
   nombreAp = document.getElementById('nombreAp').value;
   email = document.getElementById('email').value;
   fono = document.getElementById('fono').value;
   celular = document.getElementById('celular').value;
   
   ajax=nuevoAjax();
   ajax.open("POST", "envia_mail/enviaMail.php",true);
   ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   ajax.send("mensaje="+mensaje+"&nombreAp="+nombreAp+"&email="+email+"&fono="+fono+"&celular="+celular+"&asunto="+asunto);
   ajax.onreadystatechange=function() {
      if (ajax.readyState==4) {
         contenedor.innerHTML =ajax.responseText
      }
   }
}
 
function Validar(x){   

		if(x.asunto.value=="1")
		{
			alert("El campo <--Asunto--> esta vacia");
			x.asunto.focus();
			return false;
		}
		if(x.mensaje.value=="")
		{
			alert("El campo <--Comentario--> esta vacia");
			x.mensaje.focus();
			return false;
		}
		if(x.nombreAp.value=="")
		{
			alert("El campo <--Nombre/apellidos--> esta vacia");
			x.nombreAp.focus();
			return false;
		}
		if(x.email.value=="")
		{
			alert("El campo <--E-mail--> esta vacio");
			x.email.focus();
			return false;
		}
	enviaMail();
	return true;
}