var cnn;
function start_ajaxCONTACTO()
{  //alert(datosFrmDatosCONTACTO());

   cnn=createXMLHttpRequest();
   cnn.open("POST","Contacto.ajax.php",true);
   cnn.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
   cnn.send(datosFrmDatosCONTACTO());

   cnn.onreadystatechange=function()
   {  if(cnn.readyState==4 && cnn.status==200)
      {  var respuesta=cnn.responseText;
         document.getElementById("respuestaCONTACTO").innerHTML=respuesta;
         document.getElementById("dataFormCONTACTO").style.display="none";
         document.getElementById("completedCONTACTO").style.display="inline";

         //alert(cnn.responseText);
	  }
   }
}

function datosFrmDatosCONTACTO()
{  var datos="";
   datos="nombre="+encodeURIComponent(document.getElementById("frmDatosCONTACTO").txtNombre.value);
   datos=datos+"&email="+encodeURIComponent(document.getElementById("frmDatosCONTACTO").txtEmail.value);
   datos=datos+"&asunto="+encodeURIComponent(document.getElementById("frmDatosCONTACTO").txtAsunto.value);
   datos=datos+"&mensaje="+encodeURIComponent(document.getElementById("frmDatosCONTACTO").txtMensaje.value);

   return(datos);
}

function validateFrmDatos()
{  var msg="Faltan datos por ingresar:\n\n";
   var sw=1;
   var nombre=document.getElementById("frmDatosCONTACTO").txtNombre.value;
   var email=document.getElementById("frmDatosCONTACTO").txtEmail.value;
   var asunto=document.getElementById("frmDatosCONTACTO").txtAsunto.value;
   var mensaje=document.getElementById("frmDatosCONTACTO").txtMensaje.value;

   if(nombre=="")
   {  msg=msg+"El Nombre no ha sido proporcionado\n";
      sw=0;
   }
   if(email=="")
   {  msg=msg+"El Correo no ha sido proporcionado\n";
      sw=0;
   }
   if(asunto=="")
   {  msg=msg+"El Asunto no ha sido proporcionado\n";
      sw=0;
   }
   if(mensaje=="")
   {  msg=msg+"El Mensaje no ha sido proporcionado";
      sw=0;
   }
   if(sw==1)
   {  if(testEmail.test(email))
      { start_ajaxCONTACTO();
	  }
	  else
	  { alert("El Correo no es valido");
	    document.getElementById("frmDatosCONTACTO").txtEmail.focus();
	  }
   }
   else
   {  alert(msg);
   }
}
