String.prototype.trim = function() {
  return (this.replace(/^[\s.]+/, "").replace(/[\s.]+$/, ""));
}

function isValidEmail(str) {
   validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;

   if (str.search(validRegExp) == -1) {
      return false;
   } else {
      return true;
   }
}

function checkfields(which){
   var pass=true;
   var name = which.elements[0].value.trim();
   var setemail = which.elements[2].value.trim();
   var answer = which.elements[3].value.trim();

   if (name == "" || !isValidEmail(setemail)) {
	alert("Please provide your name and enter a valid email address in order for us to respond to your query.");
        return false;
   }
   if (answer != "14") {
	alert("Apologies, we are receiving far too much spam, so please add the 2 numbers and respond correctly.");
        return false;
   }
   return true;
}
