function CheckForm(formname){
	
	var fieldsArray = new Array();
	
	/* ############### EDIT THESE VARIABLES... ########################################################### */
	if(formname == "application") { //name of the form
	
		/* list of names of all fields that need validating and their associated labels (as they should appear in alert box) */
		fieldsArray["company_name"] = "Company name";
		fieldsArray["postal_address"] = "Full postal address";
		fieldsArray["contact_name"] = "Contact name for account";
		fieldsArray["contact_email"] = "Contact email address";
		fieldsArray["telephone"] = "Contact telephone number";
		fieldsArray["password"] = "Password to be applied to your account";
		
		var emailfieldsArray = new Array(
			/* comma-separated list of names of all email fields that need validating */
			"contact_email"
		);
	}
	
	/* #################################################################################################### */
	
	
	/* ############### EDIT THESE VARIABLES... ########################################################### */
	
	else if(formname == "quote") { //name of the form
	
		/* list of names of all fields that need validating and their associated labels (as they should appear in alert box) */
		fieldsArray["your_name"] = "Your name";
		fieldsArray["telephone"] = "Your telephone number";
		fieldsArray["email_address"] = "Your email address";
		fieldsArray["date"] = "Date of travel";
		fieldsArray["time"] = "Time of travel";
		fieldsArray["pickup_address"] = "Pick-up address with postcode";
		fieldsArray["destination_address"] = "Destination address with postcode";
		fieldsArray["validate"] = "Validation code";
		//fieldsArray["vehicle"] = "Vehicle type required"; //see custom code added below
		
		// Also, need additional custom code added below to validate passenger numbers.
		
		var emailfieldsArray = new Array(
			/* comma-separated list of names of all email fields that need validating */
			""
		);
	}
	
	/* #################################################################################################### */

	/* ############### EDIT THESE VARIABLES... ########################################################### */
	
	else if(formname == "newsletter") { //name of the form
	
		/* list of names of all fields that need validating and their associated labels (as they should appear in alert box) */
		fieldsArray["email"] = "Email";
		fieldsArray["validate"] = "Validation code";
		
		var emailfieldsArray = new Array(
			/* comma-separated list of names of all email fields that need validating */
			"email"
		);
	}
	
	/* #################################################################################################### */
	
	/* ############### EDIT THESE VARIABLES... ########################################################### */
	
	else if(formname == "general") { //name of the form
	
		/* list of names of all fields that need validating and their associated labels (as they should appear in alert box) */
		fieldsArray["name"] = "Name";
		fieldsArray["company"] = "Company Name";
		fieldsArray["telephone"] = "Telephone";
		fieldsArray["email"] = "Email Address";
		fieldsArray["message"] = "Enquiry";
		fieldsArray["validate"] = "Validation Code";
		
		var emailfieldsArray = new Array(
			/* comma-separated list of names of all email fields that need validating */
			"email"
		);
	}
	
	else if (formname == "automated_booking") { //name of the form
	
		fieldsArray["full_name"] = "Full Name";
		fieldsArray["home_address"] = "Home Address";
		fieldsArray["email_address"] = "Email address";
		fieldsArray["pick_up_name_1"] = "Pick Up Name 1";
		fieldsArray["pick_up_1"] = "Pick Up Address 1";
		fieldsArray["validate_2"] = "Validation Field";
		
		var emailfieldsArray = new Array(
		/* comma-separated list of names of all email fields that need validating */
			"email_address"
		);
	}
	
	else if (formname == "advance_booking") {
	
		fieldsArray["booking_name"] = "Name";
		fieldsArray["booking_address"] = "Address";
		fieldsArray["booking_home_tel"] = "Home Tel No";
		fieldsArray["booking_mob"] = "Mobile Tel No";
		
		var emailfieldsArray = new Array(
		/* comma-separated list of names of all email fields that need validating */
			""
		);
		
	}
	/* #################################################################################################### */

	
	alertmessage = "";

	//Loop through each form field and for each field...
	for (var i=0; i < document.forms[formname].length; i++) {
				
		//...loop through each field in the array of fields to validate.	
		for (var array_item in fieldsArray) {
		
			//If the current form field is in the array of fields to validate... 
			if (document.forms[formname].elements[i].name == array_item) {
				
				//...check if field value is blank.
				if(document.forms[formname].elements[i].value == "") {
					
					alertmessage += '- ' + fieldsArray[array_item]  + '\n';
				
				}
				//If it's not blank...
				else {
					
					//...loop through the array of email fields.
					for (var j=0; j < emailfieldsArray.length; j++) {
				
						//If the current field exists in the array of email fields...
						if (emailfieldsArray[j] == array_item) {
							
							//...validate the email address.
							var email = document.forms[formname].elements[array_item].value;
							invalidChars = " /:,;?()"
							incorrect ='';
							for (k=0; k<invalidChars.length; k++){
								badChar = invalidChars.charAt(k)
								if(email.indexOf(badChar,0) > -1){
									incorrect += '- Invalid Email Address\n';
									break;
								}
							}
							atPos = email.indexOf("@",1)
							if(atPos == -1){
								incorrect += '- Invalid Email Address\n';
							}
							if(email.indexOf("@",atPos+1) > -1){
								incorrect += '- Invalid Email Address\n';
							}
							periodPos = email.indexOf(".",atPos)
							if(periodPos == -1){
								incorrect += '- Invalid Email Address\n';
							}
							if(periodPos+3 > email.length){
								incorrect += '- Invalid Email Address\n';
							}	
							if(incorrect != ''){
								alertmessage += '- Invalid Email Address\n';
							}
							
						}
							
					}	
						
				}
				
			}	
			
		}
		
	}
	
	if(formname == "quote") {
	//Check that a vehicle-type radio button is selected
		
		//Loop through all form elements again
		var valid = 0;
		for (var i=0; i < document.forms[formname].length; i++) {
			
			if (document.forms[formname].elements[i].name == 'vehicle') {
				if (document.forms[formname].elements[i].checked) {
					valid = 1;	
				}
			}
			
		}
		if (valid == 0) {
			alertmessage += '- Vehicle type required\n';
		}
		
	}
	
	if(alertmessage == ""){
		return true;
	}	
	else{
		TopMessage = "You have not entered the following form elements correctly: \n\n";
        BottomMessage = "\nPlease correct these fields to continue";
        alertmessage = TopMessage + alertmessage + BottomMessage;
        alert(alertmessage);
		return false;
	}
}