function check_form1 ()
{
  valid = true; // assume valid

  if (document.giving1.lname.value.length == 0)
     { valid = false; alert('Your Last Name Must be Filled In!');
      document.giving1.lname.focus();return false; }
  if (document.giving1.fname.value.length == 0)
     { valid = false; alert('Your First Name Must be Filled In!');
      document.giving1.fname.focus();return false; }
	if (!document.giving1.gender[0].checked && 
	    !document.giving1.gender[1].checked)
     { valid = false; alert('Your Gender Must be Checked!');
      document.giving1.gender[0].focus();return false; }

	if (document.giving1.address.value.length == 0)
	  { valid = false; alert('Address Must be Filled In!');
		document.giving1.address.focus();return false; }
	if (document.giving1.city.value.length == 0)
	 { valid = false; alert('City Must be Filled In!');
		document.giving1.city.focus();return false; }
//	if (document.giving1.state.selectedIndex == false )
	if (document.giving1.state.value.length == 0)
	 { valid = false; alert('State Must be Filled In!');
		document.giving1.state.focus();return false; }
	if (document.giving1.zip.value.length == 0)
	 { valid = false; alert('Zip Code Must be Filled In!');
		document.giving1.zip.focus();return false; }
	if (document.giving1.country.value.length == 0)
	 { valid = false; alert('Country Must be Filled In!');
		document.giving1.country.focus();return false; }

	if (document.giving1.phone_number1.value.length == 0)
	 { valid = false; alert('Phone Number Must be Filled In!');
		document.giving1.phone_number1.focus();return false; }

	if (!document.giving1.phonet[0].checked &&
		  !document.giving1.phonet[1].checked)
	 { valid = false; alert('Phone Type (H)=Home (C)=Cell Must be checked! ');
		   document.giving1.phonet[0].focus();return false; }

	if (document.giving1.email.value.length == 0)
	 { valid = false; alert('E-mail address Must be Filled In!');
		document.giving1.email.focus();return false; }

  if (document.giving1.email.value.length > 0)
	 { valid = VerifyEmailAddress(document.giving1.email.value);
	    if (valid==false)
	    {document.giving1.email.focus(); return false;}
	 }

	if (document.giving1.amount_a3.value < 1  ||
		  document.giving1.amount_a3.value > 1000000 ||
		  isNaN(document.giving1.amount_a3.value))
		{ valid = false; alert('TOTAL is zero or is an invalid value!');
	    document.giving1.amount_a3.value = 0.00;
			document.giving1.of.focus();return false; }

 //To eliminate form spam and hijacking by automated bots we use Human Intelligence Identification Test 
	if (document.giving1.amount_a3.value != document.giving1.hii.value)
		{ valid = false; alert('Provide the Required ANSWER to the IDENTIFICATION QUESTION!');
	    document.giving1.hii.value="";
	    document.giving1.hii.focus();return false; }

	if (valid)
        {
    //alert("Please be patient while your application is processed. \n" +
				//"Processing can take up to few minutes depending on network traffic.\n\n" + 
				//"DO NOT CLICK SUBMIT AGAIN, it can result in a duplicate information." +
				//"\n\n CLICK OK BUTTON TO CONTINUE.");

			document.giving1.gender_m.value = "";
			document.giving1.gender_f.value = "";
			document.giving1.phone_h.value = "";
			document.giving1.phone_c.value = "";

			if (document.giving1.gender[0].checked == true){document.giving1.gender_m.value = "checked";}
			if (document.giving1.gender[1].checked == true){document.giving1.gender_f.value = "checked";}
			if (document.giving1.phonet[0].checked == true){document.giving1.phone_h.value = "checked";}
			if (document.giving1.phonet[1].checked == true){document.giving1.phone_c.value = "checked";}

			if (document.giving1.newa.checked == true){document.giving1.newa.value = "checked";}

			// Building paypal form data for ONE TIME GIFT
			//==================================================================
			document.paypal1.item_number.value= document.giving1.item_number.value;
			document.paypal1.amount.value= document.giving1.amount_a3.value;

			document.giving1.submit();
			document.paypal1.submit();

			return true;

        }

	 document.giving1.email.focus();
   return false;
}

//========================================================================
// FORM #2
//========================================================================

function check_form2 ()
{
  valid = true; // assume valid

  if (document.giving2.lname.value.length == 0)
     { valid = false; alert('Your Last Name Must be Filled In!');
      document.giving2.lname.focus();return false; }
  if (document.giving2.fname.value.length == 0)
     { valid = false; alert('Your First Name Must be Filled In!');
      document.giving2.fname.focus();return false; }
	if (!document.giving2.gender[0].checked && 
	    !document.giving2.gender[1].checked)
     { valid = false; alert('Your Gender Must be Checked!');
      document.giving2.gender[0].focus();return false; }

	if (document.giving2.address.value.length == 0)
	  { valid = false; alert('Address Must be Filled In!');
		document.giving2.address.focus();return false; }
	if (document.giving2.city.value.length == 0)
	 { valid = false; alert('City Must be Filled In!');
		document.giving2.city.focus();return false; }
//	if (document.giving2.state.selectedIndex == false )
	if (document.giving2.state.value.length == 0)
	 { valid = false; alert('State Must be Filled In!');
		document.giving2.state.focus();return false; }
	if (document.giving2.zip.value.length == 0)
	 { valid = false; alert('Zip Code Must be Filled In!');
		document.giving2.zip.focus();return false; }
	if (document.giving2.country.value.length == 0)
	 { valid = false; alert('Country Must be Filled In!');
		document.giving2.country.focus();return false; }

	if (document.giving2.phone_number1.value.length == 0)
	 { valid = false; alert('Phone Number Must be Filled In!');
		document.giving2.phone_number1.focus();return false; }

	if (!document.giving2.phonet[0].checked &&
		  !document.giving2.phonet[1].checked)
	 { valid = false; alert('Phone Type (H)=Home (C)=Cell Must be checked! ');
		   document.giving2.phonet[0].focus();return false; }

	if (document.giving2.email.value.length == 0)
	 { valid = false; alert('E-mail address Must be Filled In!');
		document.giving2.email.focus();return false; }

  if (document.giving2.email.value.length > 0)
	 { valid = VerifyEmailAddress(document.giving2.email.value);
	    if (valid==false)
	    {document.giving2.email.focus(); return false;}
	 }

	if (document.giving2.amount_a3.value < 1  ||
		  document.giving2.amount_a3.value > 1000000 ||
		  isNaN(document.giving2.amount_a3.value))
		{ valid = false; alert('GIFT AMOUNT is zero or is an invalid value!');
	    document.giving2.amount_a3.value = 0.00;
			document.giving2.amount_a3.focus();return false; }

	var how_many = document.giving2.how_many_srt.value;

	if (document.giving2.billing_cycle_t3.value == "M"  &&
	     how_many > 12)
		{ valid = false; alert('(For:) INSTALLMENTS must be a number between 1 to 12, if payments are based on "Monthly" terms.');  
	    document.giving2.how_many_srt.value = 1;
	    document.giving2.how_many_srt.focus();return false; }

 //To eliminate form spam and hijacking by automated bots we use Human Intelligence Identification Test 
	if (document.giving2.total_a3.value != document.giving2.hiii.value)
		{ valid = false; alert('Provide the Required ANSWER to the IDENTIFICATION QUESTION!');
	    document.giving2.hiii.value="";
	    document.giving2.hiii.focus();return false; }


	if (valid)
        {
    //  alert("Please be patient while your application is processed. \n" +
				//"Processing can take up to few 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.");

			if (document.giving2.newa.checked == true){document.giving2.newa.value = "checked";}
 
			document.giving2.gender_m.value = "";
			document.giving2.gender_f.value = "";
			if (document.giving2.gender[0].checked == true){document.giving2.gender_m.value = "checked";}
			if (document.giving2.gender[1].checked == true){document.giving2.gender_f.value = "checked";}

			document.giving2.phone_h.value = "";
			document.giving2.phone_c.value = "";
			if (document.giving2.phonet[0].checked == true){document.giving2.phone_h.value = "checked";}
			if (document.giving2.phonet[1].checked == true){document.giving2.phone_c.value = "checked";}


			// Building paypal form data for AUTOMATIC RECURRING GIFT: (Regular Billing Cycle)
			//==================================================================
			document.paypal2.item_number.value= document.giving2.item_number.value;
			document.paypal2.a3.value= document.giving2.amount_a3.value;
			document.paypal2.p3.value= document.giving2.billing_cycle_p3.value;
			document.paypal2.t3.value= document.giving2.billing_cycle_t3.value;
			document.paypal2.srt.value= document.giving2.how_many_srt.value;


			document.giving2.submit();
			document.paypal2.submit();

			return true;

        }

	 document.giving2.email.focus();
   return false;
}


function VerifyEmailAddress(email)
{
  var Reason  = "Your Email Address appears incorrect.  \n\nPlease check. \n\nREASON:"
  var Success = "Email Address entered Correctly!"
  var checkStr =email;
  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;
}
