function checkForm(){
	var hasError = 0;
	var hasError2 = 0;
	var hasError3 = 0;
	var missingFields = "";

	highlightColor = "#96ADB5";
	defaultColor = "#ffffff";
	thisForm = document.contactForm

	var arrFields = new Array("Title", "FirstName",  "Surname", "Address1",       "Town", "PostCode",  "Phone",                "Email", "whatcar",                      "Dealership", "route", "PreferredTime");
	var arrTitles = new Array("Title", "First Name", "Surname", "Address Line 1", "Town", "Post Code", "Daytime Phone Number", "Email", "What car do you want to try?", "Dealership", "Preferred route", "Preferred Time");

	for(i=0; i<arrFields.length; i++){
		theField = arrFields[i]
		theTitle = arrTitles[i]

		if(isNaN(thisForm[theField].length) || ! isNaN(thisForm[theField].selectedIndex)){
			if(thisForm[theField].value == ""){
				missingFields += theTitle + "\n";
				thisForm[theField].style.background = highlightColor;
				if(hasError == 0){thisForm[theField].focus()}
				hasError = 1;
			}else{
				thisForm[theField].style.background = defaultColor;
			}
		}else{
			var hasNodeSelected = 0;
			for(j=0; j<thisForm[theField].length; j++){
				if(thisForm[theField][j].checked){
					hasNodeSelected++;
				}
			}
			if(hasNodeSelected == 0){
				hasError = 1;
				missingFields += theTitle + "\n";
			}
		}
	}


	if(thisForm["PreferredTestDriveDateD"].value=="" || thisForm["PreferredTestDriveDateM"].value=="" || thisForm["PreferredTestDriveDateY"].value=="" ){
			hasError = 1;
			missingFields += "Preferred Date" + "\n";
			thisForm["PreferredTestDriveDateD"].style.background = highlightColor;
			thisForm["PreferredTestDriveDateM"].style.background = highlightColor;
			thisForm["PreferredTestDriveDateY"].style.background = highlightColor;
	}else{
			thisForm["PreferredTestDriveDateD"].style.background = defaultColor;
			thisForm["PreferredTestDriveDateM"].style.background = defaultColor;
			thisForm["PreferredTestDriveDateY"].style.background = defaultColor;
	}

	if(hasError == 1){
		alert('Please complete the following fields:\n' + missingFields)
		return false;
	}else{
		return true;
	}

}
