//----------------------- Drop-down Select Option Validation  -----------------------------

function validateForm(theForm)
{
	// check if no drop down or first drop down is selected, if so, invalid selection
	if (document.forms.theForm.Locator.value == 0)
	{
	alert("Please select a choice from - How did you hear about our company?");
	document.forms.theForm.Locator.focus();
	return false;
	}
	
	if (document.forms.theForm.Event.value == 0)
	{
	alert("Please select a choice from - Why are you submitting an application for vending space?");
	document.forms.theForm.Event.focus();
	return false;
	}

	if (document.forms.theForm.Salutation.value == 0)
	{
	alert("Please select a choice from - How do you want like to be address (Salutation)?");
	document.forms.theForm.Salutation.focus();
	return false;
	}

//------------------------------- First Name Validation ------------------------------- 	

// only allow alpha - no numbers, no symbols, no punctuation, etc.
	if (document.forms.theForm.FirstName.value == '') 
		{
   		alert('Please enter your First Name');
		document.forms.theForm.FirstName.focus();
   		return false;
		}

	var invalidLetter = '1234567890\/\'\\ ";:?!()[]\{\}^|@#$%&*+=';
	for (j=0; j<invalidLetter.length; j++) {
   		if (document.forms.theForm.FirstName.value.indexOf(invalidLetter.charAt(j),0) > -1) {
    	  alert('Your First Name contains invalid characters.  Please recheck your entry.');
          document.forms.theForm.FirstName.focus();
		  return false;
		  						 }
										  }
	// require at least 3 characters be entered
		if (document.forms.theForm.FirstName.value.length < 3)
		{
		alert("Please enter at least 3 characters in the - First Name - field.");
		document.forms.theForm.FirstName.focus();
		return false;
		}

//------------------------------- Last Name Validation ------------------------------- 	

// only allow alpha - no numbers, no symbols, no punctuation, etc.
	if (document.forms.theForm.LastName.value == '') 
		{
   		alert('Please enter your Last Name');
		document.forms.theForm.LastName.focus();
   		return false;
		}

	var invalidLetter = '1234567890\/\'\\ ";:?!()[]\{\}^|@#$%&*+=';
	for (j=0; j<invalidLetter.length; j++) {
   		if (document.forms.theForm.LastName.value.indexOf(invalidLetter.charAt(j),0) > -1) {
    	  alert('Your Last Name contains invalid characters.  Please recheck your entry.');
          document.forms.theForm.LastName.focus();
		  return false;
		  						 }
										  }
	// require at least 3 characters be entered
		if (document.forms.theForm.LastName.value.length < 3)
		{
		alert("Please enter at least 3 characters in the - Last Name - field.");
		document.forms.theForm.LastName.focus();
		return false;
		}

//------------------------------- Email Address Validation ------------------------------- 	
	if (document.forms.theForm.UserEmail.value == '') 
		{
   		alert('Your Email address is mandatory.  Please enter one.');
		document.forms.theForm.UserEmail.focus();
   		return false;
		}
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
   		if (document.forms.theForm.UserEmail.value.indexOf(invalidChars.charAt(i),0) > -1) {
    	  alert('Your Email address contains invalid characters (use lower case for domain name, please recheck your entry.');
          document.forms.theForm.UserEmail.focus();
		  return false;
  	 													 }
										  }
	for (i=0; i<document.forms.theForm.UserEmail.length; i++) {
   		if (document.forms.theForm.UserEmail.value.charCodeAt(i)>127) {
      		alert("Your Email address contains invalid ASCII characters.  Please recheck your entry.");
      		document.forms.theForm.UserEmail.focus();
			return false;
 	 								}
								  }
	var atPos = document.forms.theForm.UserEmail.value.indexOf('@',0);
	if (atPos == -1) {
 	  alert('Your Email address must contain an @.  Please recheck your entry.');
  	  document.forms.theForm.UserEmail.focus();
	  return false;
	 				 }
	if (atPos == 0) {
   	    alert('Your Email address must not start with @.  Please recheck your entry.');
   		document.forms.theForm.UserEmail.focus();
		return false;
	 				}
	if (document.forms.theForm.UserEmail.value.indexOf('@', atPos + 1) > - 1) {
   	    alert('Your Email address must contain only one @.  Please recheck your entry.');
   		document.forms.theForm.UserEmail.focus();
		return false;
	 										}
	if (document.forms.theForm.UserEmail.value.indexOf('.', atPos) == -1) {
 		alert('Your Email address must contain at least a period in the domain name.  Please recheck your entry.');
   		document.forms.theForm.UserEmail.focus();
		return false;
	 									}
	if (document.forms.theForm.UserEmail.value.indexOf('@.',0) != -1) {
	    alert('A period must not immediately follow @ your email address.  Please recheck your entry.');
   		document.forms.theForm.UserEmail.focus();
		return false;
	 								}
	if (document.forms.theForm.UserEmail.value.indexOf('.@',0) != -1){
 	    alert('A period must not immediately precede @ your Email address.  Please recheck your entry.');
 		document.forms.theForm.UserEmail.focus();
		return false;
	 								}
	if (document.forms.theForm.UserEmail.value.indexOf('..',0) != -1) {
 		alert('Two periods must not be adjacent in your Email address.  Please recheck your entry.');
  		document.forms.theForm.UserEmail.focus();
		return false;
	 								}
	var suffix = document.forms.theForm.UserEmail.value.substring(document.forms.theForm.UserEmail.value.lastIndexOf('.')+1);
		if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' 
			&& suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' 
			&& suffix != 'pro' && suffix != 'museum') {
   			alert('Invalid primary domain in Email address.  Please recheck your entry.');
   			document.forms.theForm.UserEmail.focus();
			return false;
	 												  }
	
//------------------------------- Event Sponsor Interest Validation ------------------------------- 	

	if (document.forms.theForm.Sponsor.value == 0)
	{
	alert("Error --- Please select your answer (Event Sponsorship)");
	document.forms.theForm.Sponsor.focus();
	return false;
	}

//------------------------------- Business Name Validation --------------------------------------- 	

	if (document.forms.theForm.Business.value == '') 
		{
   		alert('Please enter your Business Name');
		document.forms.theForm.Business.focus();
   		return false;
		}
	
	var invalidChars =  '\";:?!()[]\{\}^|!@#$%^&*+=<>?~';
	for (k=0; k<invalidChars.length; k++) {
   		if (document.forms.theForm.Business.value.indexOf(invalidChars.charAt(k),0) > -1) {
    	  alert('Your Business Name contains invalid characters.  Please recheck your entry.');
          document.forms.theForm.Business.focus();
		  return false;
 										  			}
										  }
	
//------------------------------- Phone Number Validation ------------------------------------------ 	

	if (document.forms.theForm.Phone.value == '') 
		{
   		alert('Please enter your Phone Number with area code in the following format xxx-xxxx-xxxx!');
		document.forms.theForm.Phone.focus();
   		return false;
		}
	
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*+=<,>?~';
	for (m=0; m<invalidChars.length; m++) {
   		if (document.forms.theForm.Phone.value.indexOf(invalidChars.charAt(m),0) > -1) {
    	  	alert('Your Phone Number contains invalid characters.  Please recheck your entry.');
          	document.forms.theForm.Phone.focus();
		  return false;
 										  			}
										  }
	
//------------------------------- Mailing Address Validation ------------------------------------------ 	

	if (document.forms.theForm.Street.value == '') 
		{
   		alert('Please enter your Street Address!');
		document.forms.theForm.Street.focus();
   		return false;
		}

	var invalidChars = '\";:?!()[]\{\}^|!@#$%^&*+=<>?~';
	for (m=0; m<invalidChars.length; m++) {
   		if (document.forms.theForm.Street.value.indexOf(invalidChars.charAt(m),0) > -1) {
    	  	alert('The Street Address field contains invalid characters.  Please recheck your entry.');
          	document.forms.theForm.Street.focus();
		  return false;
 										  			}
										  }
										  
	if (document.forms.theForm.City.value == '') 
		{
   		alert('Please enter your City or Town!');
		document.forms.theForm.City.focus();
   		return false;
		}

	var invalidChars = '\";:?!()[]\{\}^|!@#$%^&*+=<>?~';
	for (m=0; m<invalidChars.length; m++) {
   		if (document.forms.theForm.City.value.indexOf(invalidChars.charAt(m),0) > -1) {
    	  	alert('The City or Town field contains invalid characters.  Please recheck your entry.');
          	document.forms.theForm.City.focus();
		  return false;
 										  			}
										  }									  
										  
	if (document.forms.theForm.State.value == '') 
		{
   		alert('Please enter your State (Parish or Providence)!');
		document.forms.theForm.State.focus();
   		return false;
		}

	var invalidChars = '\";:?!()[]\{\}^|!@#$%^&*+=<>?~';
	for (m=0; m<invalidChars.length; m++) {
   		if (document.forms.theForm.State.value.indexOf(invalidChars.charAt(m),0) > -1) {
    	  	alert('The Parish or Providence field contains invalid characters.  Please recheck your entry.');
          	document.forms.theForm.State.focus();
		  return false;
 										  			}
										  }											  
										  
	if (document.forms.theForm.Zip.value == '') 
		{
   		alert('Please enter your Zip or Postal Code!');
		document.forms.theForm.Zip.focus();
   		return false;
		}

	if (document.forms.theForm.Country.value == '') 
		{
   		alert('Please enter the name of your Country!');
		document.forms.theForm.Country.focus();
   		return false;
		}



//------------------------------- Vending Space Validation ------------------------------------------ 

	if (document.forms.theForm.Size.value == 0)
	{
	alert("Error --- Please select your answer - Size of Vending Space!");
	document.forms.theForm.Size.focus();
	return false;
	}

//------------------------------- Description of Display Validation -------------------------------- 

	if (document.forms.theForm.Display.value == '') 
		{
   		alert('Please enter a Description of your Vending Display!');
		document.forms.theForm.Display.focus();
   		return false;
		}

	var invalidChars =  '\";:?!()[]\{\}^|!@#$%^&*+=<>?~';
	for (n=0; n<invalidChars.length; n++) {
   		if (document.forms.theForm.Display.value.indexOf(invalidChars.charAt(n),0) > -1) {
    	  	alert('Your Vending Display Description contains invalid characters.  Please recheck your entry.');
          	document.forms.theForm.Display.focus();
		  return false;
 										  			}
										  }
	// require at least 35 characters be entered
		if (document.forms.theForm.Display.value.length < 15)
		{
		alert("The Description of Display field requires at least 15 characters - hit ENTER for new line!");
		document.forms.theForm.Display.focus();
		return false;
		}

//------------------------------- Products Intend to Sell Validation -------------------------------- 

	if (document.forms.theForm.Products.value == '') 
		{
   		alert('Please enter the Products you intend to sell or display!');
		document.forms.theForm.Products.focus();
   		return false;
		}

	var invalidChars =  '\";:?!()[]\{\}^|!@#$%^&*+=<>?~';
	for (p=0; p<invalidChars.length; p++) {
   		if (document.forms.theForm.Products.value.indexOf(invalidChars.charAt(p),0) > -1) {
    	  	alert('The Products field contains invalid characters.  Please recheck your entry.');
          	document.forms.theForm.Products.focus();
		  return false;
 										  			}
										  }
	// require at least 60 characters be entered
		if (document.forms.theForm.Products.value.length < 15)
		{
		alert("The Products field requires at least 15 characters - hit ENTER for new line!");
		document.forms.theForm.Products.focus();
		return false;
		}

//------------------------------- Business References Validation ------------------------------------ 

	if (document.forms.theForm.References.value == '') 
		{
   		alert('Please enter your References - 1 entry per line - Hit ENTER twice after each completed contact!');
		document.forms.theForm.References.focus();
   		return false;
		}

	var invalidChars =  '\";:?!()[]\{\}^|!@#$%^&*+=<>?~';
	for (q=0; q<invalidChars.length; q++) {
   		if (document.forms.theForm.References.value.indexOf(invalidChars.charAt(q),0) > -1) {
    	  	alert('The Reference field contains invalid characters.  Please recheck your entry.');
          	document.forms.theForm.References.focus();
		  return false;
 										  			}
										  }
	// require at least 60 characters be entered
		if (document.forms.theForm.References.value.length < 15)
		{
		alert("The Reference field requires at least 15 characters - hit ENTER for new line!");
		document.forms.theForm.References.focus();
		return false;
		}



//------------------------------- Questions Validation --------------------------------------------- 

	return true;


}
