//Contact functions
 
//Copyright 1997-2009 Brad Scott
//Written: 23May2009
//Author: Brad Scott


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



//Validate the whole contact form on Submit
function validateContactSubmit() 
{
   var intErrorCount;
   
   intErrorCount = 0;
   
   // execute all validations in reverse order, so focus gets
   // set to the first one in error.
   if (validatedivBasic(document.forms.contact.Organization, 'idOrganizationError', true, 'Please enter your business name') == false) intErrorCount += 1; 
   if (!validatedivEmailAddress(document.forms.contact.ContactEmailAddress, 'idContactEmailAddressError', true, 'Please enter a valid email address.', 'Please enter your email address')) intErrorCount += 1;
   if (!validatedivPhone(document.forms.contact.ContactPhone, 'idContactPhoneError', 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 (!validatedivName(document.forms.contact.NameLast, 'idNameLastError', true, 'Please enter a valid last name.', 'Please enter your last name')) intErrorCount += 1;
   if (!validatedivName(document.forms.contact.NameFirst, 'idNameFirstError', 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);
}

