/**** form validation script ******/

/********** INSTRUCTIONS ******************

	This script can be used with any form to validate form fields. The syntax to check
	whether or not a field has a value is: 
	
	if(!<fieldName>.value){forgot += ' - Your message\n';}
	
	In the above example you would replace "<fieldName>" and "Your message" with the
	appropriate field name and message respectively.

	IMPORTANT NOTE: Make sure to uniquely name your form fields

******************************************/

	function validate(){
		
		var forgot = '';
		with(document.forms[0]){
			
					
			if(!first_name.value){forgot += ' - Your First Name\n';}
			if(!last_name.value){forgot += ' - Your Last Name\n';}
			
			
			// THIS LINE CHECKS FOR A VALID EMAIL ADDRESS
			// THIS CODE CHECKS FOR THE EXISTENCE OF THE "@" AND THE "."
			// EITHER NAME YOUR EMAIL FIELD "EmailAddress" OR
			// Change "EmailAddress" to whatever you have named your
			// email field
			//NOTE!!: IF YOU HAVE MORE THAN ONE EMAIL FIELD YOU WILL NEED TO 
			// COPY AND PASTE THIS LINE FOR EACH FORM FIELD
			// REMEMBER, FORM FIELDS MUST BE UNIQUE
			
			if(!email_address.value){forgot += ' - Your Email address\n';}
			else if((email_address.value.indexOf ('@', 0) == -1)||(email_address.value.indexOf ('.', 0) == -1))
						{forgot += ' - Invalid email address\n';}
			
			//THE FOLLOWING LINE SHOWS HOW TO CHECK A DROP DOWN
			//TO USE IT COPY AND UNCOMMENT (remove the "//") THIS LINE AND CHANGE "CCTYPE" to the 
			//name of your dropdown	
			
			//if(CCTYPE.selectedIndex == 0){forgot += ' - Your Credit Card type\n';}
							
			//THE FOLLOWING LINE SHOWS HOW TO CHECK FOR A SPECIFIC VALUE
			//if(subtotal.value == '$0.00'){forgot += ' - Select a ticket quantity\n';}
						
			
			//THE FOLLOWING LINE SHOWS HOW TO CHECK FOR A NUMERIC VALUE
			//if(!isNum(CCNUM1.value){forgot += ' - Invalid Credit Card\n';}
			
			if(!verification.value){forgot += ' - The verification letter\n';}
			else if(verification.value.toLowerCase() != 'hbl'){
				forgot += ' - Invalid verification letter\n';
			}

			if(forgot) alert("Please complete the following required fields:\n" + forgot);
			else submit();
		}
		return;	
	}


// PLACE THIS TAG WITHIN THE SUBMIT BUTTON
	// <input type="button" onClick="javascript:validate();" value="Submit" name="submit2">
	
	// IF USING AN IMAGE RATHER THAN BUTTON USE A LINK LIKE THIS:
	// <a href="javascript:validate();"><img src="_images/submit.gif" width="45" height="20" border="0"></a>
	