function submitForm()
{
  var valid = true;
  if(!isEmail(document.getElementById("email").value))
  {
    alert("Invalid email address");
    valid = false;
  }
  else if(document.getElementById("name").value == "" ||
          document.getElementById("email").value == "" ||
          document.getElementById("query").value == "")
  {
    alert("Please fill in all form values");
    valid = false;
  }
  
  return valid;
  
  function isEmail(str)
  {
    var validEmail = /^[-A-Za-z_.0-9]+\@([-A-Za-z_0-9]+\.)+[A-Za-z0-9]+$/;
    return (str.search(validEmail) > -1);
  }
}
