function isValidEmail(s) {
  
  var firstPeriodLocation = s.indexOf('.');
  var firstAtLocation = s.indexOf('@');
  var secondAtLocation = s.indexOf('@', firstAtLocation+1);
  var periodAfterAtLocation = s.indexOf('.', firstAtLocation);
  
  if (!s || s.length == 0) {
    return false;
  } else if (s.length < 5) {
    // not at least five characters
    return false;
  } else if (secondAtLocation != -1) {
    // more than one @
    return false;
  } else if (firstPeriodLocation == -1) {
    // there is no .
    return false;
  } else if (periodAfterAtLocation == -1) {
    // a . does not follow the @
    return false;
  } else if (periodAfterAtLocation-firstAtLocation < 2) {
    // there isn't at least one character between @ and .
    return false;
  } else if (firstAtLocation == 0) {
    // there is not at least one character before @
    return false;
  } else if (s.charAt(s.length-1) ==  '.') {
    // it ends with a .
    return false;
  }
  return true;
}

function doEmailCheck(formObj)
{
  var n = formObj.elements["email"].value;
  if (!isValidEmail(n))
  {
    return false;
  } else
  {
    return true;
  }
}

