function check_form ()
{
  valid = true; // assume valid

//  if (!document.contact.type.checked)
//     { valid = false; alert('Type of Request Must be Filled In!');
//      document.contact.type.focus();return false; }
  if (document.contact.request.value.length == 0)
     { valid = false; alert('Request Must be Filled In!');
      document.contact.request.focus();return false; }

	if (document.contact.realname.value.length == 0)
     { valid = false; alert('Name Must be Filled In!');
      document.contact.realname.focus();return false; }
  
  if (document.contact.address.value.length == 0)
     { valid = false; alert('Address Must be Filled In!');
      document.contact.address.focus(); return false;}
	if (document.contact.city.value.length == 0)
		 { valid = false; alert('City Must be Filled In!');
			document.contact.city.focus();return false; }
//if (document.contact.state.selectedIndex == false )
	if (document.contact.state.value.length == 0)
		 { valid = false; alert('State or Province Must be Filled In!');
			document.contact.state.focus();return false; }
	if (document.contact.zip.value.length == 0)
	   { valid = false; alert('Postal Code Must be Filled In!');
		  document.contact.zip.focus();return false; }
//if (document.contact.country.selectedIndex == false)
	if (document.contact.country.value.length == 0)
	   { valid = false; alert('Country Must be Filled In!');
		  document.contact.country.focus();return false; }

	if (document.contact.phone.value.length == 0)
	   { valid = false; alert('Phone Must be Filled In!');
		  document.contact.phone.focus();return false; }

//  if (!document.contact.contact.checked)
//     { valid = false; alert('Prayer Partners Contact You Must be Filled In!');
//      document.contact.contact.focus();return false; }

  if (!valid)
	{
        document.contact.method="POST";
        document.contact.action="mailto:sales@ffmwoc.org ? SUBJECT=DTD Prayer Request Problem";
        alert ("There is a problem with the completion of this form. \n" +
				  "David T. Demola Ministries has been notified. \n");
	}

  if (document.contact.email.value.length > 0)
			{valid = VerifyEmailAddress();}
	 else
			{document.contact.email.value = "none@none.com";
			 valid = true;}

  if (valid)
        {
      alert("Please be patient while your form is processed. \n" +
				"Processing can take up to several minutes depending on network traffic.\n\n" + 
				"DO NOT CLICK SUBMIT AGAIN, it can result in a duplicate information." +
				"\n\n Click OK to Continue.");
      document.contact.submit();
      return true;

        }
   document.contact.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.contact.email.value;
  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(".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 (checkStr.length > 120)
    Reason += "\nPlease limit the Email Address to 120 characters.";

  if (RL != Reason.length)
  {
 alert(Reason);
 return false;
  }
  return true;
}
