
function wait(theForm){

theForm.CurrentTime.value = new Date()
//alert(theForm.CurrentTime.value);

if (theForm.name.value == "")
  {
    alert("Please enter Name.");
    theForm.name.focus();
    return (false);
  }

if (theForm.Telephone.value == "")
  {
    alert("Please enter Telephone Number.");
    theForm.Telephone.focus();
    return (false);
  }

  if (theForm.emailaddress.value == "")
  {
    alert("Please enter a Valid Email address.");
    theForm.emailaddress.focus();
    return (false);
  }
  else
  {
  return checkEmail(theForm, theForm.emailaddress.value)
  }
  return (true);
}

function checkEmail(theForm, checkString)
{
    var newstr = "";
    var at = false;
    var dot = false;

    // DO SOME PRELIMINARY CHECKS ON THE DATA

    // IF EMAIL ADDRESS HAS A '@' CHARACTER
    if (checkString.indexOf("@") != -1) {
      at = true;

    // IF EMAIL ADDRESS HAS A '.' CHARACTER
    } else if (checkString.indexOf(".") != -1) {
      dot = true;
    }
    // PARSE REMAINDER OF STRING
    for (var i = 0; i < checkString.length; i++) {
        ch = checkString.substring(i, i + 1)
        if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
                || (ch == "@") || (ch == ".") || (ch == "_")
                || (ch == "-") || (ch >= "0" && ch <= "9")) {
                newstr += ch;
                if (ch == "@") {
                    at=true;
                }
                if (ch == ".") {
                    dot=true;
                }
        }
    }
    if ((at == true) && (dot == true)) {
        return newstr;
    }
    else {
      // DISPLAY ERROR MESSAGE
      alert ("Please, Enter a Valid Email Address.");
	  theForm.emailaddress.focus();
      return false;
    }
}
