//Signup Organization functions
 
//Copyright 1997-2008 Brad Scott
//Written: 10Nov2008
//Modified 26Nov2008 bug fixes
//Author: Brad Scott


//Set the error font
setClassError("fontError");

//clearGoal clears out the goal field on entry so user can enter their own text
// ----------------------------------------------------------------------------
function clearGoal(frmForm)
{
   var strGoal;
   var strMatch;
   
   strGoal = frmForm.Goal.value;
   strMatch = "Please list your dollar goal here";
  
   strGoal = strGoal.substr(0,strMatch.length);

   if (strGoal == strMatch)
   {
      frmForm.Goal.value = "";
   }
}


//Validate the whole signup form on Submit
function validateSignupOrgSubmit() 
{
   var intErrorCount;
   
   intErrorCount = 0;
   
   // execute all validations in reverse order, so focus gets
   // set to the first one in error.
   if (!validatetblCheckbox(document.forms.contact.AgreementAcknowledged, 'idtblTerms', 'idAgreementAcknowledgedError', 2, 'Please indicate that you accept the agreement terms by checking the Agreement box.', 'Please indicate that you accept the agreement terms by checking the above box')) intErrorCount += 1; 
   if (!validatetblCheckbox(document.forms.contact.Authority, 'idtblAuthority', 'idAuthorityError', 2, 'Please indicate that you have the authority to represent this church for this fundraising program by checking the above box.', 'Please indicate that you have the authority to represent this church for this fundraising program by checking the above box.')) intErrorCount += 1; 
   if (!validatetblPhone(document.forms.contact.OrganizationPhone, 'idtblOrganizationPhone', 'idOrganizationPhoneError', 1, true, 'Please enter a phone number in the format nnn-nnn-nnnn xnnnn where n is a number from 0 to 9.', 'Please enter your church phone number')) intErrorCount += 1;
   if (!validatetblNumeric(document.forms.contact.ZipCode, 'idtblCityStateZip', 'idZipCodeError', 3, true, 5, 5, 'Please enter a valid 5 digit Zip Code.', 'Please enter a Zip Code')) intErrorCount += 1;
   if (!validatetblName(document.forms.contact.City, 'idtblCityStateZip', 'idCityError', 3, true, 'Please enter a valid city.', 'Please enter a city')) intErrorCount += 1;
   if (validatetblBasic(document.forms.contact.Address1, 'idtblAddress', 'idAddress1Error', 1, true, 'Please enter your church address') == false) intErrorCount += 1;
   if (validatetblBasic(document.forms.contact.Organization, 'idtblOrganization', 'idOrganizationError', 1, true, 'Please enter your church name') == false) intErrorCount += 1; 
   if (!validatetblEmailAddress(document.forms.contact.ContactEmailAddress, 'idtblContactEmailAddress', 'idContactEmailAddressError', 1, true, 'Please enter a valid email address.', 'Please enter your email address')) intErrorCount += 1;
   if (!validatetblPhone(document.forms.contact.ContactPhone, 'idtblContactPhone', 'idContactPhoneError', 1, true, 'Please enter your phone number in the format nnn-nnn-nnnn xnnnn where n is a number from 0 to 9.', 'Please enter your phone number')) intErrorCount += 1;
   if (validatetblBasic(document.forms.contact.Title, 'idtblTitle', 'idTitleError', 1, true, 'Please enter your title') == false) intErrorCount += 1; 
   if (!validatetblName(document.forms.contact.NameLast, 'idtblName', 'idNameLastError', 2, true, 'Please enter a valid last name.', 'Please enter your last name')) intErrorCount += 1;
   if (!validatetblName(document.forms.contact.NameFirst, 'idtblName', 'idNameFirstError', 2, true, 'Please enter a valid first name.', 'Please enter your first name')) intErrorCount += 1; 
 
   //if errors, alert the user
   if (intErrorCount > 1)
   {
      alert('Please correct the highlighted fields before submitting.');
   }
   
   if (intErrorCount==1)
   {
      alert('Please correct the highlighted field before submitting.');
   }
   
   return (intErrorCount === 0);
}





//Validate the whole signup form on Submit
function validateSignupNewspaperSubmit() 
{
   //Start by validating the credit card expiration month/year
   var intErrorCount;
   
   intErrorCount = 0;
   
   // execute all validations in reverse order, so focus gets
   // set to the first one in error.
   if (!validatetblNumeric(document.forms.contact.ZipCode, 'idtblCityStateZip', 'idZipCodeError', 3, true, 5, 5, 'Please enter a valid 5 digit Zip Code.', 'Please enter your Zip Code')) intErrorCount += 1;
   if (!validatetblName(document.forms.contact.City, 'idtblCityStateZip', 'idCityError', 3, true, 'Please enter a valid city.', 'Please enter your city')) intErrorCount += 1;
   if (validatetblBasic(document.forms.contact.Organization, 'idtblOrganization', 'idOrganizationError', 1, true, 'Please enter your newspaper name') == false) intErrorCount += 1; 
   if (!validatetblEmailAddress(document.forms.contact.ContactEmailAddress, 'idtblContactEmailAddress', 'idEmailContactAddressError', 1, false, 'Please enter a valid email address.', 'Please enter your email address')) intErrorCount += 1;
   if (!validatetblPhone(document.forms.contact.ContactPhone, 'idtblContactPhone', 'idContactPhoneError', 1, true, 'Please enter a phone number in the format nnn-nnn-nnnn xnnnn where n is a number from 0 to 9.', 'Please enter your phone number')) intErrorCount += 1;
   if (validatetblBasic(document.forms.contact.Title, 'idtblTitle', 'idTitleError', 1, true, 'Please enter your title') == false) intErrorCount += 1; 
   if (!validatetblName(document.forms.contact.NameLast, 'idtblName', 'idNameLastError', 2, true, 'Please enter a valid last name.', 'Please enter your last name')) intErrorCount += 1;
   if (!validatetblName(document.forms.contact.NameFirst, 'idtblName', 'idNameFirstError', 2, true, 'Please enter a valid first name.', 'Please enter your first name')) intErrorCount += 1; 
 
   //if errors, alert the user
   if (intErrorCount > 1)
   {
      alert('Please correct the highlighted fields before submitting.');
   }
   
   if (intErrorCount==1)
   {
      alert('Please correct the highlighted field before submitting.');
   }
   
   return (intErrorCount === 0);
}