function validate(theform) {

	var requiredFields = new Array();
	var intCounter = 0;
	var strWarningMessage = "Please enter the following mandatory fields:\n";
	var bgColour = "#E9CDD0";

	if(theform.form_title != null) {
		if(theform.form_title.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Title";
			document.getElementById("form_title").style.backgroundColor = bgColour;
		}
	}
	
	if(theform.recipienttitle != null) {
		if(theform.recipienttitle.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Title";
			document.getElementById("recipienttitle").style.backgroundColor = bgColour;
		}
	}
	
	if(theform.recipientfirstname != null) {
		if(theform.recipientfirstname.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "First name";
			document.getElementById("recipientfirstname").style.backgroundColor = bgColour;
		}
	}
	
	if(theform.form_first_name != null) {
		if(theform.form_first_name.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "First name";
			document.getElementById("form_first_name").style.backgroundColor = bgColour;
		}
	}

	if(theform.form_surname != null) {
		if(theform.form_surname.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Surname";
			document.getElementById("form_surname").style.backgroundColor = bgColour;
		}
	}
	
	if(theform.recipientlastname != null) {
		if(theform.recipientlastname.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Surname";
			document.getElementById("recipientlastname").style.backgroundColor = bgColour;
		}
	}

	if (theform.form_email != null) {
		var strEmail = theform.form_email.value;
		var isEmail = ((strEmail.indexOf("@") != -1) && (strEmail.indexOf(".") != -1));
		
		if (theform.form_email.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Email address";
			document.getElementById("form_email").style.backgroundColor = bgColour;
		}
		if (!isEmail && theform.form_email.value.length > 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "A valid email address";
			document.getElementById("form_email").style.backgroundColor = bgColour;
		}
		if (theform.form_confirm_email.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Confirm Email address";
			document.getElementById("form_confirm_email").style.backgroundColor = bgColour;
		}
		if (theform.form_email.value != theform.form_confirm_email.value && theform.form_confirm_email.value.length > 0) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Confirm Email address doesnt match";
			document.getElementById("form_confirm_email").style.backgroundColor = bgColour;
		}
	}
	
	if (theform.recipientemailaddress != null) {
		var strEmail = theform.recipientemailaddress.value;
		var isEmail = ((strEmail.indexOf("@") != -1) && (strEmail.indexOf(".") != -1));
		
		if (theform.recipientemailaddress.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Email address";
			document.getElementById("recipientemailaddress").style.backgroundColor = bgColour;
		}
		if (!isEmail && theform.recipientemailaddress.value.length > 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "A valid email address";
			document.getElementById("recipientemailaddress").style.backgroundColor = bgColour;
		}
		if (theform.recipientconfirmemailaddress.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Confirm Email address";
			document.getElementById("recipientconfirmemailaddress").style.backgroundColor = bgColour;
		}
		if (theform.recipientemailaddress.value != theform.recipientconfirmemailaddress.value && theform.recipientconfirmemailaddress.value.length > 0) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Confirm Email address doesnt match";
			document.getElementById("recipientconfirmemailaddress").style.backgroundColor = bgColour;
		}
	}
	
	if(theform.form_contact_method != null) {
		if(theform.form_contact_method.selectedIndex == 0) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Contact method";
			document.getElementById("form_contact_method").style.backgroundColor = bgColour;
		}
		if(theform.form_contact_method.value == 'Post') {
			if(theform.form_address_1 != null) {
				if(theform.form_address_1.value.length < 1) {
					intCounter = intCounter + 1;
					requiredFields[intCounter] = "Address line 1";
					document.getElementById("form_address_1").style.backgroundColor = bgColour;
				}
			}
			if(theform.form_postcode != null) {
				if(theform.form_postcode.value.length < 1) {
					intCounter = intCounter + 1;
					requiredFields[intCounter] = "Post code";
					document.getElementById("form_postcode").style.backgroundColor = bgColour;
				}
			}
		}
		if(theform.form_contact_method.value == 'Phone') {
			if(theform.form_tel_home != null || theform.form_tel_mobile != null) {
				if(theform.form_tel_home.value.length < 1 || theform.form_tel_mobile.value.length < 1) {
					intCounter = intCounter + 1;
					requiredFields[intCounter] = "Home or mobile number";
					document.getElementById("form_tel_home").style.backgroundColor = bgColour;
					document.getElementById("form_tel_mobile").style.backgroundColor = bgColour;
				}
			}
		}
	}
	
	if(theform.form_hear_about_us != null) {
		if(theform.form_hear_about_us.selectedIndex == 0) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Hear about us";
			document.getElementById("form_hear_about_us").style.backgroundColor = bgColour;
		}
	}
	
	if(theform.enquiry != null) {
		if(theform.enquiry.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Your enquiry";
			document.getElementById("enquiry").style.backgroundColor = bgColour;
		}
	}
	
	if(theform.form_age != null) {
		if(theform.form_address_1 != null) {
			if(theform.form_address_1.value.length < 1) {
				intCounter = intCounter + 1;
				requiredFields[intCounter] = "Address line 1";
				document.getElementById("form_address_1").style.backgroundColor = bgColour;
			}
		}
		if(theform.form_town_city != null) {
			if(theform.form_town_city.value.length < 1) {
				intCounter = intCounter + 1;
				requiredFields[intCounter] = "Town/City";
				document.getElementById("form_town_city").style.backgroundColor = bgColour;
			}
		}
		if(theform.form_county != null) {
			if(theform.form_county.value.length < 1) {
				intCounter = intCounter + 1;
				requiredFields[intCounter] = "County";
				document.getElementById("form_county").style.backgroundColor = bgColour;
			}
		}
		if(theform.form_postcode != null) {
			if(theform.form_postcode.value.length < 1) {
				intCounter = intCounter + 1;
				requiredFields[intCounter] = "Post code";
				document.getElementById("form_postcode").style.backgroundColor = bgColour;
			}
		}
		if(theform.form_country != null) {
			if(theform.form_country.value.length < 1) {
				intCounter = intCounter + 1;
				requiredFields[intCounter] = "Country";
				document.getElementById("form_country").style.backgroundColor = bgColour;
			}
		}
		if(theform.form_card_name != null) {
			if(theform.form_card_name.value.length < 1) {
				intCounter = intCounter + 1;
				requiredFields[intCounter] = "Credit card name";
				document.getElementById("form_card_name").style.backgroundColor = bgColour;
			}
		}
		if(theform.form_card_number != null) {
			if(theform.form_card_number.value.length < 1) {
				intCounter = intCounter + 1;
				requiredFields[intCounter] = "Credit card number";
				document.getElementById("form_card_number").style.backgroundColor = bgColour;
			}
		}
		if(theform.form_expiry_month != null) {
			if(theform.form_expiry_month.value.length < 1) {
				intCounter = intCounter + 1;
				requiredFields[intCounter] = "Expiry month";
				document.getElementById("form_expiry_month").style.backgroundColor = bgColour;
			}
		}
		if(theform.form_expiry_year != null) {
			if(theform.form_expiry_year.value.length < 1) {
				intCounter = intCounter + 1;
				requiredFields[intCounter] = "Expiry year";
				document.getElementById("form_expiry_year").style.backgroundColor = bgColour;
			}
		}
		if(theform.form_secuirty_code != null) {
			if(theform.form_secuirty_code.value.length < 1) {
				intCounter = intCounter + 1;
				requiredFields[intCounter] = "Secuirty code";
				document.getElementById("form_secuirty_code").style.backgroundColor = bgColour;
			}
		}
		if(theform.form_travelled_before != null) {
			if(theform.form_travelled_before.value.length < 1) {
				intCounter = intCounter + 1;
				requiredFields[intCounter] = "Travelled before";
				document.getElementById("form_travelled_before").style.backgroundColor = bgColour;
			}
		}
	}
	
	//Add all booking form validation here
	if(theform.form_destination != null) {
		if(theform.form_tel_home.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Home phone number";
			document.getElementById("form_tel_home").style.backgroundColor = bgColour;
		}
		
		if(theform.form_address_1.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Address line 1";
			document.getElementById("form_address_1").style.backgroundColor = bgColour;
		}
		
		if(theform.form_town_city.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Town";
			document.getElementById("form_town_city").style.backgroundColor = bgColour;
		}
		
		if(theform.form_county.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "County";
			document.getElementById("form_county").style.backgroundColor = bgColour;
		}
		
		if(theform.form_postcode.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Postcode";
			document.getElementById("form_postcode").style.backgroundColor = bgColour;
		}
		
		if(theform.form_country.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Country";
			document.getElementById("form_country").style.backgroundColor = bgColour;
		}
		
		if(theform.form_no_passengers.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Number of passengers";
			document.getElementById("form_no_passengers").style.backgroundColor = bgColour;
		}
		
		for(var i=1;i<=theform.form_no_passengers.value;i++) {
			if (eval("theform.form_title_" + i + ".value;") == '') {
				intCounter = intCounter + 1;
				requiredFields[intCounter] = 'Passenger ' + i + ' title';
				document.getElementById('form_title_' + i).style.backgroundColor = bgColour;
			}
			
			if (eval("theform.form_first_name_" + i + ".value;") == '') {
				intCounter = intCounter + 1;
				requiredFields[intCounter] = 'Passenger ' + i + ' name';
				document.getElementById('form_first_name_' + i).style.backgroundColor = bgColour;
			}
			
			if (eval("theform.form_Surname_" + i + ".value;") == '') {
				intCounter = intCounter + 1;
				requiredFields[intCounter] = 'Passenger ' + i + ' surname';
				document.getElementById('form_Surname_' + i).style.backgroundColor = bgColour;
			}
			
			/*if (eval("theform.form_dob_" + i + "_day.value;") == '' || eval("theform.form_dob_" + i + "_month.value;") == '' || eval("theform.form_dob_" + i + "_year.value;") == '') {
				intCounter = intCounter + 1;
				requiredFields[intCounter] = 'Passenger ' + i + ' date of birth';
				document.getElementById('form_dob_' + i + '_day').style.backgroundColor = bgColour;
				document.getElementById('form_dob_' + i + '_month').style.backgroundColor = bgColour;
				document.getElementById('form_dob_' + i + '_year').style.backgroundColor = bgColour;
			}*/
		}
		
		/*if(theform.form_card_type.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Creditcard Type";
			document.getElementById("form_card_type").style.backgroundColor = bgColour;
		}*/
		
		if(theform.form_card_name.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Creditcard Name";
			document.getElementById("form_card_name").style.backgroundColor = bgColour;
		}
		
		if(theform.form_card_number.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Creditcard Number";
			document.getElementById("form_card_number").style.backgroundColor = bgColour;
		}
		
		if(theform.form_card_number.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Creditcard Number";
			document.getElementById("form_card_number").style.backgroundColor = bgColour;
		}
		
		if(theform.form_card_start_date_month.value.length < 1 || theform.form_card_start_date_year.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Creditcard Start Date";
			document.getElementById("form_card_start_date_month").style.backgroundColor = bgColour;
			document.getElementById("form_card_start_date_year").style.backgroundColor = bgColour;
		}
		
		if(theform.form_card_expiry_date_month.value.length < 1 || theform.form_card_expiry_date_year.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Creditcard Expiry Date";
			document.getElementById("form_card_expiry_date_month").style.backgroundColor = bgColour;
			document.getElementById("form_card_expiry_date_year").style.backgroundColor = bgColour;
		}
		
		if(theform.form_card_security_code.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Creditcard Security Code";
			document.getElementById("form_card_security_code").style.backgroundColor = bgColour;
		}
		
		if(theform.form_cardholder_title.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Creditcard Holder Title";
			document.getElementById("form_cardholder_title").style.backgroundColor = bgColour;
		}
		
		if(theform.form_cardholder_first_name.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Creditcard Holder First Name";
			document.getElementById("form_cardholder_first_name").style.backgroundColor = bgColour;
		}
		
		if(theform.form_cardholder_surname.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Creditcard Holder Surname";
			document.getElementById("form_cardholder_surname").style.backgroundColor = bgColour;
		}
		
		if(theform.form_cardholder_address_1.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Creditcard Holder Address 1";
			document.getElementById("form_cardholder_address_1").style.backgroundColor = bgColour;
		}
		
		if(theform.form_cardholder_town_city.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Creditcard Town/City";
			document.getElementById("form_cardholder_town_city").style.backgroundColor = bgColour;
		}
		
		if(theform.form_cardholder_county.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Creditcard Holder Country";
			document.getElementById("form_cardholder_county").style.backgroundColor = bgColour;
		}
		
		if(theform.form_cardholder_postcode.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Creditcard Holder Postcode";
			document.getElementById("form_cardholder_postcode").style.backgroundColor = bgColour;
		}
		
		if(theform.form_cardholder_country.value.length < 1) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Creditcard Holder Country";
			document.getElementById("form_cardholder_country").style.backgroundColor = bgColour;
		}
		
		switch(theform.form_travel_method.value) {
			case 'Air': {
				if(theform.form_air_class.value.length < 1) {
					intCounter = intCounter + 1;
					requiredFields[intCounter] = "Travel Options Class";
					document.getElementById("form_air_class").style.backgroundColor = bgColour;
				}
				break;
			}
			case 'Rail': {
				if(theform.form_rail_class.value.length < 1) {
					intCounter = intCounter + 1;
					requiredFields[intCounter] = "Travel Options Class";
					document.getElementById("form_rail_class").style.backgroundColor = bgColour;
				}
				if(theform.form_rail_lille_stopover.value.length < 1) {
					intCounter = intCounter + 1;
					requiredFields[intCounter] = "Travel Options Stopover";
					document.getElementById("form_rail_lille_stopover").style.backgroundColor = bgColour;
				}
				break;
			}
			/*case 'Self Drive': {
				if(theform.form_self_drive_operator.value.length < 1) {
					intCounter = intCounter + 1;
					requiredFields[intCounter] = "Travel Options Operator";
					document.getElementById("form_self_drive_operator").style.backgroundColor = bgColour;
				}
				
				var outbound_route = false;
				if(theform.brittany_ferries_options.value.length < 1) {
					var outbound_route = true;
				}
				if(theform.transmanche_options.value.length < 1) {
					var outbound_route = true;
				}
				if(theform.eurotunnel_options.value.length < 1) {
					var outbound_route = true;
				}
				if(theform.p_and_o_options.value.length < 1) {
					var outbound_route = true;
				}*/
				
				//brittany_ferries_options,transmanche_options,eurotunnel_options,p_and_o_options

				/*if(theform.form_outbound_route.value.length < 1 || theform.form_homebound_route.value.length < 1) {
					intCounter = intCounter + 1;
					requiredFields[intCounter] = "Travel Options Route";
					document.getElementById("form_outbound_route").style.backgroundColor = bgColour;
					document.getElementById("form_homebound_route").style.backgroundColor = bgColour;
				}
				if(theform.form_outbound_date.value.length < 1 || theform.form_homebound_date.value.length < 1) {
					intCounter = intCounter + 1;
					requiredFields[intCounter] = "Travel Options Date";
					document.getElementById("form_outbound_date").style.backgroundColor = bgColour;
					document.getElementById("form_homebound_date").style.backgroundColor = bgColour;
				}
				if(theform.form_outbound_time.value.length < 1 || theform.form_homebound_time.value.length < 1) {
					intCounter = intCounter + 1;
					requiredFields[intCounter] = "Travel Options Time";
					document.getElementById("form_outbound_time").style.backgroundColor = bgColour;
					document.getElementById("form_homebound_time").style.backgroundColor = bgColour;
				}
				
				if(theform.form_self_drive_operator.value.length < 1) {
					intCounter = intCounter + 1;
					requiredFields[intCounter] = "Travel Options Operator";
					document.getElementById("form_self_drive_operator").style.backgroundColor = bgColour;
				}
				*/
				/*break;
			}*/
		}
		
		if(!theform.form_booking_conditions.checked) {
			intCounter = intCounter + 1;
			requiredFields[intCounter] = "Accept Booking Conditions";
			document.getElementById("form_booking_conditions").style.backgroundColor = bgColour;
		}		
	}
	
	//Display warning message
	if (intCounter > 0) {
		for (i = 1; i <= intCounter; i++) {
			strWarningMessage = strWarningMessage + "\n" + requiredFields[i];
		}
		alert(strWarningMessage);
		return false;
	}

	return true;
}

function updateotherpleasestate(vselect)  {
	var cellindex;
	cellindex=vselect.selectedIndex;
	thevalue=vselect.options[cellindex].value;
//	alert(cellindex);
	if (thevalue=="Other")  {
		document.getElementById("otherpleasestate").style.display="block";
		}
	else  {
		document.getElementById("otherpleasestate").style.display="none";
		document.getElementById("otherpleasestate").value="";		
		}
	}
	

