function highlightField(field) {
	field.style.background = 'LemonChiffon';
}

function checkEnquiryForm(enquiryForm) {
	var afterHoursPhoneCheck = enquiryForm.afterHoursPhone;
	var subscribeCheck = enquiryForm.subscribe;

//var smallEnquiry = "";
	enquiryForm.firstName.style.background = 'White';
	enquiryForm.lastName.style.background = 'White';
	enquiryForm.dayPhone.style.background = 'White';
	if (afterHoursPhoneCheck != null) {
		enquiryForm.afterHoursPhone.style.background = 'White';
	}
	enquiryForm.postcode.style.background = 'White';
	enquiryForm.email.style.background = 'White';
	enquiryForm.departureDay.style.background = 'White';
	enquiryForm.departureMonthYear.style.background = 'White';
	//enquiryForm.returnDay.style.background = 'White';
	enquiryForm.returnMonthYear.style.background = 'White'; 
	
	

	if (enquiryForm.firstName.value.length == 0) {
		alert("Please enter your first name.");
		highlightField(enquiryForm.firstName);
		return false;
	}

	if (enquiryForm.lastName.value.length == 0) {
		alert("Please enter your surname.");
		highlightField(enquiryForm.lastName);
		return false;
	}

	// Daytime phone number must be provided.
	if (enquiryForm.dayPhone.value.length == 0) {
		alert("Please enter your phone (daytime).");
		highlightField(enquiryForm.dayPhone);
		return false;
	}

	if (!isValidPostcode(enquiryForm.postcode.value)) {
		highlightField(enquiryForm.postcode);
		return false;
	}
	
	if (afterHoursPhoneCheck != null) {
		// Afterhours phone number must be provided.
		if (enquiryForm.afterHoursPhone.value.length == 0) {
			alert("Please enter your phone (afterhours)");
			highlightField(enquiryForm.afterHoursPhone);
			return false;
		}
	}

	

	if (!isValidEmail(enquiryForm.email.value)) {
		highlightField(enquiryForm.email);
		return false;
	}

	// Assume that month and year will be a string in the format of MM/yyyy
	// Also remember that months range from 0..11
	month = new Number(enquiryForm.departureMonthYear.value.substring(0,2))-1;
	year = enquiryForm.departureMonthYear.value.substring(3,7);

	// Assume that day is an integer in the form of a string
	day = enquiryForm.departureDay.value;
	if (!isValidDate(year, month, day)) {
		highlightField(enquiryForm.departureDay);
		highlightField(enquiryForm.departureMonthYear);
		return false;
	}
	departureDate = new Date(year, month, day, 11, 59, 59);

	// Departure date must be after today.
	var todaysDate = stringToDate(enquiryForm.todaysDate.value);
	if (departureDate <= todaysDate) {
		alert('The departure date must be after today.');
		highlightField(enquiryForm.departureDay);
		highlightField(enquiryForm.departureMonthYear);
		return false;
	}

	// If a return date has been given, check its validity.
	if (enquiryForm.returnMonthYear != null) {

		// Assume that month and year will be a string in the format of MM/yyyy
		// Also remember that months range from 0..11
		month = new Number(enquiryForm.returnMonthYear.value.substring(0,2))-1;
		year = enquiryForm.returnMonthYear.value.substring(3,7);

		// Assume that day is an integer in the form of a string
		day = enquiryForm.returnDay.value;
		if (!isValidDate(year, month, day)) {
			highlightField(enquiryForm.returnDay);
			highlightField(enquiryForm.returnMonthYear);
			return false;
		}
		returnDate = new Date(year, month, day, 11, 59, 59);

		// Return date must be AFTER departure date
		if (returnDate <= departureDate) {
			alert('The return date must be after the departure date.');
			highlightField(enquiryForm.returnDay);
			highlightField(enquiryForm.returnMonthYear);
			return false;
		}
	}
	
	if (subscribeCheck != null) {
		if ((! enquiryForm.subscribe[0].checked) && (! enquiryForm.subscribe[1].checked)){
			alert('Please select whether or not you would like to receive our email newsletter.');
			return false;	
		}
	}
	

	//return true;
}
