// JavaScript validation for Conference Enquiry Form.
// Rewritten on 18.04.2008
		
function validateForm() {
	var msg = "";
	emailValue = document.enquiryBARYNZ.email_address.value;
	var sel = document.enquiryBARYNZ.seating_style;
	if (document.enquiryBARYNZ.contact_name.value == '') { msg = "Please enter a Contact Name"; document.enquiryBARYNZ.contact_name.select(); }
	if (document.enquiryBARYNZ.email_address.value == '') { msg = "Please enter a Email Address"; document.enquiryBARYNZ.email_address.select(); }
	if (document.enquiryBARYNZ.phone_number.value == '') { msg = "Please enter a Phone Number"; document.enquiryBARYNZ.phone_number.select(); }
	if (document.enquiryBARYNZ.address1.value == "") { msg = "Please enter a Address 1"; document.enquiryBARYNZ.address1.select(); }
	if (document.enquiryBARYNZ.address2.value == "") { msg = "Please enter a Address 2"; document.enquiryBARYNZ.address2.select(); }
	if (sel.options[sel.selectedIndex].value  == "Please select") { msg = "Please select a Seating Style";  document.enquiryBARYNZ.seating_style.focus(); }
	if (document.enquiryBARYNZ.from_month.value == '') { msg = "Please enter a right format dd/mm/yyyy or not leave blank"; document.enquiryBARYNZ.from_month.select(); }
	if (document.enquiryBARYNZ.to_month.value == '') { msg = "Please enter a Right Format dd/mm/yyyy or not leave blank"; document.enquiryBARYNZ.to_month.select(); }
	if (document.enquiryBARYNZ.time_from.value == '') { msg = "Please enter a Time From"; document.enquiryBARYNZ.time_from.select(); }
	if (document.enquiryBARYNZ.time_to.value == '') { msg = "Please enter a Time To"; document.enquiryBARYNZ.time_to.select(); }
	if (document.enquiryBARYNZ.numbers_attending.value == '') { msg = "Please enter Number Attending"; document.enquiryBARYNZ.numbers_attending.select(); }
	if (document.enquiryBARYNZ.numbers_catering.value == '') { msg = "Please enter a Number for Catering "; document.enquiryBARYNZ.numbers_catering.select(); }
	if (document.enquiryBARYNZ.password.value == '') { msg = "Please enter the security code. "; document.enquiryBARYNZ.password.select(); }
	if (echeck(emailValue) == false) { msg = "Please enter a valid email address"; document.enquiryBARYNZ.email_address.select(); }
	if (msg.length != 0) { alert(msg); return false; }
}
	
function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if ( (str.indexOf(at)==-1) || (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) || (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) || (str.indexOf(at,(lat+1))!=-1) || (str.substring(lat-1,lat)==dot || 	str.substring(lat+1,lat+2)==dot) || (str.indexOf(dot,(lat+2))==-1) || (str.indexOf(" ")!=-1) ) { return false }
	else { return true }
}
