// JavaScript Validation for Contact Form
//Check the enquiry form is filled in correctly
function CheckForm () { 

	//Initialise variables
	var errorMsg = "";
			 	
	//Check for an e-mail address and that it is valid
	if ((document.frmEnquiry.txtEmail.value == "") || (document.frmEnquiry.txtEmail.value.length > 0 && (document.frmEnquiry.txtEmail.value.indexOf("@",0) == - 1 || document.frmEnquiry.txtEmail.value.indexOf(".",0) == - 1))) { 
		errorMsg += "\nE-mail Address \t- Enter your valid e-mail address";
	}
	
	//Check for a Name
	if (document.frmEnquiry.txtName.value == ""){
		errorMsg += "\nName \t\t- Please enter your name";	
	}
	
	
	//Check for a message
	if (document.frmEnquiry.txtMessage.value == "") {
		errorMsg += "\nMessage type \t- Please type your message in the space provided";	
	}


					
	//If there is a problem with the form then display an error
	if (errorMsg != ""){
		msg = "______________________________________________________________\n\n";
		msg += "Your message has not been submitted because the required information\n";
		msg += "has not been completed.\n\n";
		msg += "Please complete the information and re-submit your message.\n";
		msg += "______________________________________________________________\n\n";
		
		errorMsg += alert(msg + errorMsg + "\n\n");
		return false;
	}
	
	return true;
}
