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

function validateSalesenq(form)
	{
	var errortext = '';
	if (document.frmSalesenq.Initials.value=='') {errortext = errortext + 'Your Initials\n';}
	if (document.frmSalesenq.Surname.value =='') {errortext = errortext + 'Your Surname\n';}
	if (document.frmSalesenq.TelephoneH.value + document.frmSalesenq.TelephoneW.value + document.frmSalesenq.TelephoneM.value =='') {errortext = errortext + 'Atleast one telephone number\n';}
	if (document.frmSalesenq.Address.value =='') {errortext = errortext + 'Your Address\n';}
	if (document.frmSalesenq.PostCode.value =='') {errortext = errortext + 'Your Post Code\n';}
	if (isValidEmail(document.frmSalesenq.email.value)) 
		{
		} else {errortext = errortext + 'A valid email address\n';
		}

	if (document.frmSalesenq.SalesEnquiry.value =='') {errortext = errortext + 'Some details about your enquiry.\n'}
	if (errortext != '') {
		errortext = 'Sorry but we need the following information before you can submit your enquiry.\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;
	}
}
