function checkForm(theForm) {
	
	var why = "";
	var message ="Por favor, rellena todos los campos";

	if (theForm.email.value.length == 0){
	alert(message);
	theForm.email.focus();
	return false;	
	}

	if (theForm.email.value.length != 0){
    why += checkEmail(theForm.email.value);
		if (why != ""){
		alert(why);
		return false;
		}
	}
	
	if (theForm.subject.value.length == 0){
	alert(message);
	theForm.subject.focus();
	return false;	
	}
  
    if (theForm.body.value.length == 0){
	alert(message);
	theForm.body.focus();
	return false;
	}			
}

function checkEmail (strng) {
	var error="";
    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Por favor, entra un email valido.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "Por favor, entra un email valido.\n";
      	 }
	}
	return error;    
}
