
function isEmailValid(element)
{
  good = 0;
  email = element.value
  var tld = email.substring(email.length-7, email.length)
  var host = email.substring(email.indexOf("@")+1, email.indexOf(".",email.lastIndexOf("@")))
  var user = email.substring(0, email.indexOf("@"))

  if (email.indexOf("@") == -1 || email.indexOf("@") != email.lastIndexOf("@")) { good = 1; }
  if (email.indexOf(".") == -1) { good = 1; }
  if (host.length == 0) { good = 1; }
  if (user.length == 0) { good = 1; }
  if (email.indexOf(" ") != -1) { good = 1; }
  if (email.indexOf(",") != -1) { good = 1; }
  if (good == 0)
  {
    return true;
  }
  if (good == 1)
  {
    alert("The email address you have given appears to be incorrect. Please check that you have entered it correctly.")
    element.focus()
    return false;
  }
}