// JavaScript Document
// validateBooking.js
// (c) Edgedata 
// Written for Duckworth Land Rover
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 }

function validateBooking(form)
	{
	var errortext = '';
	if (document.frmBooking.Initials.value=='') {errortext = errortext + 'Your Initials\n';}
	if (document.frmBooking.Surname.value =='') {errortext = errortext + 'Your Surname\n';}
	if (document.frmBooking.TelephoneH.value + document.frmBooking.TelephoneW.value + document.frmBooking.TelephoneM.value =='') {errortext = errortext + 'Atleast one telephone number\n';}
	if (document.frmBooking.Address.value =='') {errortext = errortext + 'Your Full Postal Address\n';}
	if (document.frmBooking.PostCode.value =='') {errortext = errortext + 'Your Post Code\n';}
	if (isValidEmail(document.frmBooking.email.value)) 
		{
		} else {errortext = errortext + 'A valid email address\n';
		}
	if (document.frmBooking.RegNo.value=='') {errortext = errortext + 'Registration Number of your vehicle\n';}
	if (document.frmBooking.Mileage.value=='') {errortext = errortext + 'Current Mileage\n';}	
	if (document.frmBooking.PreferredDate.value=='') {errortext = errortext + 'Preferred date for work to be undertaken\n';}	
	if (document.frmBooking.alternativeDate1.value=='') {errortext = errortext + 'Alternative Date for work to be undertaken\n';}	
	if (document.frmBooking.WorkRequired.value =='') {errortext = errortext + 'Some details about your Booking.\n'}
	if (errortext != '') {
		errortext = 'Sorry but we need the following information before you can submit your booking.\n\n' + errortext + '\n\nPlease click the OK buttom below to return to the form and correct the problems and submit the form again.';
		alert(errortext);
		return false;
	} else {
		return true;
	}
}
