// JavaScript Validation for Contact Form
function CheckForm () { 

	//Initialise variables
	var errorMsg = "";

	//Check for a Title
	if (document.frm01.lstTitle.value == ""){
		errorMsg += "\n\tTitle \t\t- Enter your Title";	
	}
	//Check for a first name
	if (document.frm01.txtFirstName.value == ""){
		errorMsg += "\n\tFirst Name \t- Enter your First Name";	
	}
		
	//Check for a last name
	if (document.frm01.txtLastName.value == ""){
		errorMsg += "\n\tLast Name \t- Enter your Last Name";
	}
	//Check for a Telephone Number
	if (document.frm01.txtTel.value == ""){
		errorMsg += "\n\tTelephone Number \t- Enter your Telephone Number";
	}
	 	
	//Check for an e-mail address and that it is valid
	if ((document.frm01.txtEmail.value == "") || (document.frm01.txtEmail.value.length > 0 && (document.frm01.txtEmail.value.indexOf("@",0) == - 1 || document.frm01.txtEmail.value.indexOf(".",0) == - 1))) { 
		errorMsg += "\n\tE-mail Address \t- Enter your valid e-mail address";
	}
			
	//Check for Enquiry
	if (document.frm01.txtEnquiry.value == "") { 
 		errorMsg += "\n\tEnquiry \t\t- Enter your Enquiry";
	}
		
	//If there is a problem with the form then display an error
	if (errorMsg != ""){
		msg = "______________________________________________________________\n\n";
		msg += "Your enquiry has not been sent because there are problem(s) with the form.\n";
		msg += "Please correct the problem(s) and re-submit the form.\n";
		msg += "______________________________________________________________\n\n";
		msg += "The following field(s) need to be corrected: -\n";
		
		errorMsg += alert(msg + errorMsg + "\n\n");
		return false;
	}
	
	return true;
}

