function isEmpty (cadena){
   return (/^\s*$/.test(cadena))
 }
 
function validarEmail(direccion) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(direccion)){
    return (true);
  } else {
    return (false);
  }
}
function validarFormContact(){
	if (isEmpty(document.getElementById("from").value)){
		alert("Please, fill in your email address");
		document.getElementById("from").focus();
		return;
	}
	if (isEmpty(document.getElementById("subject").value)){
		alert("Please, fill in a subject");
		document.getElementById("subject").focus();
		return;
	}
	if (isEmpty(document.getElementById("body").value)){
		alert("Please, fill in the body field");
		document.getElementById("body").focus();
		return;
	}
	if (!validarEmail(document.getElementById("from").value)){
		alert("The email format is not correct");
		document.getElementById("from").focus();
		return;
	 }
	 
  new Ajax.Request('sendMail.php', {
  method: 'post',  
  parameters: $('contactForm').serialize(true),
  onSuccess: function(transport){
      alert("Your message has been sent. I will contact you as soon as possible");
	  Modalbox.hide();
    }
  });
}