function check_form ()
{
  valid = true; // assume valid

	if (document.EmailLogin.email.value.length == 0)
	 { valid = false; alert('E-mail address must be filled in!');
		document.EmailLogin.email.focus();return false; }

	if (document.EmailLogin.email.value.length > 0)
	{ valid = VerifyEmailAddress();
				if (valid==false)
				{document.EmailLogin.email.focus(); return false;}
	}

	if (document.EmailLogin.pass.value.length == 0)
		{ valid = false; alert('Password is not correct, please try again.');
	    document.EmailLogin.pass.value="";
					document.EmailLogin.pass.focus();return false; }

	if (document.EmailLogin.pass.value != "2707")
		{ valid = false; alert('Password is not correct, please try again.');
	    document.EmailLogin.pass.value="";
					document.EmailLogin.pass.focus();return false; }

	
	if (valid)
        {
			
						
						document.EmailLogin.submit();

						return true;

        }

	 document.EmailLogin.email.focus();
   return false;
}


function VerifyEmailAddress()
{
  var Reason  = "Your Email Address appears incorrect.  \n\nPlease check. \n\nREASON:"
  var Success = "Email Address entered Correctly!"
  var checkStr = document.EmailLogin.email.value;
  checkStr = checkStr.toLowerCase();

  var ix = (checkStr.length - 4)
  var RC = true;
  var x = AtSignValid = DoublePeriod = PeriodValid = SpaceValid = ExtValid = RL = 0;

  for (i = 0;  i < checkStr.length;  i++)
  {
    if (checkStr.charAt(i) == '@')
      AtSignValid++;
    else if (checkStr.charAt(i) == '.')
    {
      if (x == (i-1))
        DoublePeriod++;
      else
      {
        x = i;
        PeriodValid++;
      }
    }
    else if (checkStr.charAt(i) == ' ')
      SpaceValid ++;
  }
  if (checkStr.indexOf(".com", ix) > -1) ExtValid++;
  else if (checkStr.indexOf(".edu", ix) > -1) ExtValid++;
  else if (checkStr.indexOf(".net", ix) > -1)  ExtValid++;
  else if (checkStr.indexOf(".biz", ix) > -1)  ExtValid++;
  else if (checkStr.indexOf(".org", ix) > -1) ExtValid++;
  else if (checkStr.indexOf(".gov", ix) > -1) ExtValid++;
  else if (checkStr.indexOf(".mil", ix) > -1) ExtValid++;
  else if (checkStr.indexOf(".cc", ix) > -1) ExtValid++;
 
	RL = Reason.length;
  if (AtSignValid != 1)    Reason += "\nOnly one '@' allowed, " + AtSignValid + " found.";
  if (PeriodValid == 0)   Reason += "\nAddress must contain at least one period.";
  if (SpaceValid > 0)     Reason += "\nNo Spaces allowed. Address contains " + SpaceValid + " space";
  if (SpaceValid > 1)     Reason += "s.";
  if (ExtValid == 0)       Reason += "\nAddress must contain at least one valid extension like: ";
  if (ExtValid == 0)       Reason += "\n\t.com\n\t.edu\n\t.net\n\t.biz\n\t.org\n\t.gov\n\t.mil\n\t.cc ";
  if (checkStr.length > 120) Reason += "\nPlease limit the Email Address to 120 characters.";

  if (RL != Reason.length)
  {
 alert(Reason);
 return false;
  }
  return true;
}
