

function emailAddressCheck(address)
{
  // First check the length
  var len = address.length;
  if (len == 0)
  {
    return false;
  }

  // Next check that there are no spaces or tabs
  if (address.indexOf(" ") >= 0 || address.indexOf("\t") >= 0)
  {
    return false;
  }

  // Next check that there is an @ but only one and that it is not at the
  // beginning or end of the string
  var indexAt = address.indexOf("@");
  if (indexAt <= 0 || indexAt == (len - 1) || address.indexOf("@", indexAt + 1) >= 0)
  {
    return false;
  }

  // Check for a dot after the @, but not the first character after the 
  // @ and not the last character
  var indexDot = address.indexOf(".", indexAt + 1);
  if (indexDot < 0 || indexDot == (indexAt + 1) || indexDot == (len - 1))
  {
    return false;
  }

  return true;
}


function checkQuickEmailForm()
{
  if (!emailAddressCheck(document.quickEmailForm.address.value))
  {
    alert("Please enter a valid email address");
    document.quickEmailForm.address.focus();
    return false;
  }
  return true;
}


