<!--
	function validateForm(theForm) {
		// variable to hold the error message
		var strErrorMessage = "";
		// variable to hold regular expression for email validation
		var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		// variable to hold flag values
		var flag = false;
		// variable to hold radio button lists
		var rbList;
		// check for errors and set the error message
		if (theForm.Given_Names.value == "") {
			strErrorMessage += "Please enter your given names\n";
			changeColour(theForm.Given_Names, true);
		} else changeColour(theForm.Given_Names, false);
		if (theForm.Family_Name.value == "") {
			strErrorMessage += "Please enter your family name\n";
			changeColour(theForm.Family_Name, true);
		} else changeColour(theForm.Family_Name, false);
		if (theForm.Address.value == "") {
			strErrorMessage += "Please enter your address\n";
			changeColour(theForm.Address, true);
		} else changeColour(theForm.Address, false);
		if (theForm.email_from.value == "") {
			strErrorMessage += "Please enter your email address\n";
			changeColour(theForm.email_from, true);
		} else {
			if (!filter.test(theForm.email_from.value)) {
				strErrorMessage += "The email address you entered is invalid\n";
				changeColour(theForm.email_from, true);
			} else changeColour(theForm.email_from, false);
		}
		/* if (theForm.email_confirm.value == "") {
			strErrorMessage += "Please enter your email address\n";
			changeColour(theForm.email_confirm, true);
		} else {
			if (!filter.test(theForm.email_confirm.value)) {
				strErrorMessage += "The email address you entered is invalid\n";
				changeColour(theForm.email_confirm, true);
			} else changeColour(theForm.email_confirm, false);
		} */
		if (theForm.Daytime_Phone.value == "") {
			strErrorMessage += "Please enter your daytime phone number\n";
			changeColour(theForm.Daytime_Phone, true);
		} else changeColour(theForm.Daytime_Phone, false);
		rbList = document.getElementById("tdCareerInterest").getElementsByTagName("INPUT");
		for (i = 0; i < rbList.length; i++)
			if (rbList[i].checked) {
				flag = true;
				break;
			}
		if (!flag) strErrorMessage += "Please specify your career of interest\n";
		else flag = false;
		if (rbList[rbList.length - 2].checked && theForm.Other_Career_of_Interest.value == "") {
			strErrorMessage += "Please enter details of your career of interest\n";
			changeColour(theForm.Other_Career_of_Interest, true);
		} else changeColour(theForm.Other_Career_of_Interest, false);
		rbList = document.getElementById("tdCitizen").getElementsByTagName("INPUT");
		for (i = 0; i < rbList.length; i++)
			if (rbList[i].checked) {
				flag = true;
				break;
			}
		if (!flag) strErrorMessage += "Please enter your legal work status\n";
		else flag = false;
		if (rbList[rbList.length - 1].checked && theForm.Other_Entitlement_to_Work_in_NZ.value == "") {
			strErrorMessage += "Please enter details of your legal work status\n";
			changeColour(theForm.Other_Entitlement_to_Work_in_NZ, true);
		} else changeColour(theForm.Other_Entitlement_to_Work_in_NZ, false);
		rbList = document.getElementById("tdCriminalOffence").getElementsByTagName("INPUT");
		for (i = 0; i < rbList.length; i++)
			if (rbList[i].checked) {
				flag = true;
				break;
			}
		if (!flag) strErrorMessage += "Please state whether you have had criminal convictions\n";
		else flag = false;
		if (rbList[0].checked && theForm.Details_of_Convictions.value == "") {
			strErrorMessage += "Please enter the details of your criminal convictions\n";
			changeColour(theForm.Details_of_Convictions, true);
		} else changeColour(theForm.Details_of_Convictions, false);
		rbList = document.getElementById("tdCriminalCharges").getElementsByTagName("INPUT");
		for (i = 0; i < rbList.length; i++)
			if (rbList[i].checked) {
				flag = true;
				break;
			}
		if (!flag) strErrorMessage += "Please state whether you are awaiting the hearing of charges\n";
		else flag = false;
		if (rbList[0].checked && theForm.Details_of_Awaiting_Hearings.value == "") {
			strErrorMessage += "Please enter the details of the charges\n";
			changeColour(theForm.Details_of_Awaiting_Hearings, true);
		} else changeColour(theForm.Details_of_Awaiting_Hearings, false);
		rbList = document.getElementById("tdOngoingMedicalProblems").getElementsByTagName("INPUT");
		for (i = 0; i < rbList.length; i++)
			if (rbList[i].checked) {
				flag = true;
				break;
			}
		if (!flag) strErrorMessage += "Please state whether you have any ongoing medical problems\n";
		else flag = false;
		if (rbList[0].checked && theForm.Details_of_Medical_Problem.value == "") {
			strErrorMessage += "Please enter the details of your medical problems\n";
			changeColour(theForm.Details_of_Medical_Problem, true);
		} else changeColour(theForm.Details_of_Medical_Problem, false);
		rbList = document.getElementById("tdBackOrNeckPainInjury").getElementsByTagName("INPUT");
		for (i = 0; i < rbList.length; i++)
			if (rbList[i].checked) {
				flag = true;
				break;
			}
		if (!flag) strErrorMessage += "Please state whether you have back or neck pain or injuries\n";
		else flag = false;
		if (rbList[0].checked && theForm.Details_of_neck_or_back_injury.value == "") {
			strErrorMessage += "Please enter the details of your back or neck pain or injuries\n";
			changeColour(theForm.Details_of_neck_or_back_injury, true);
		} else changeColour(theForm.Details_of_neck_or_back_injury, false);
		rbList = document.getElementById("tdAccInjury").getElementsByTagName("INPUT");
		for (i = 0; i < rbList.length; i++)
			if (rbList[i].checked) {
				flag = true;
				break;
			}
		if (!flag) strErrorMessage += "Please state whether you have had any ACC work related compensation\n";
		else flag = false;
		if (rbList[0].checked && theForm.Details_of_ACC_injury.value == "") {
			strErrorMessage += "Please enter the details of your ACC work related compensation\n";
			changeColour(theForm.Details_of_ACC_injury, true);
		} else changeColour(theForm.Details_of_ACC_injury, false);
		if (theForm.Referee_1_Name.value == "" || theForm.Referee_1_Address.value == "" || theForm.Referee_2_Name.value == "" || theForm.Referee_1_Address.value == "")
			strErrorMessage += "Please enter all the details of your referees\n";
		if (theForm.Referee_1_Name.value == "") changeColour(theForm.Referee_1_Name, true);
		else changeColour(theForm.Referee_1_Name, false);
		if (theForm.Referee_1_Address.value == "") changeColour(theForm.Referee_1_Address, true);
		else changeColour(theForm.Referee_1_Address, false);
		if (theForm.Referee_2_Name.value == "") changeColour(theForm.Referee_2_Name, true);
		else changeColour(theForm.Referee_2_Name, false);
		if (theForm.Referee_2_Address.value == "") changeColour(theForm.Referee_2_Address, true);
		else changeColour(theForm.Referee_2_Address, false);
		if (theForm.Signed_Declaration.value == "") {
			strErrorMessage += "You must enter your name in the declaration\n";
			changeColour(theForm.Signed_Declaration, true);
		}
		else changeColour(theForm.Signed_Declaration, false);
		rbList = document.getElementById("pRefereePermission").getElementsByTagName("INPUT");
		for (i = 0; i < rbList.length; i++)
			if (rbList[i].checked) {
				flag = true;
				break;
			}
		if (!flag) strErrorMessage += "Please enter whether you give us permission to contact your referees\n";
		else flag = false;
		if (theForm.Covering_Letter.value == "" && theForm.File.value == "") {
			strErrorMessage += "Please enter your covering letter or attach your CV\n";
			changeColour(theForm.Covering_Letter, true);
			changeColour(theForm.File, true);
		} else {
			changeColour(theForm.Covering_Letter, false);
			changeColour(theForm.File, false);
		}
		rbList = document.getElementById("pAcceptDeclaration").getElementsByTagName("INPUT");
		for (i = 0; i < rbList.length; i++)
			if (rbList[i].checked) {
				flag = true;
				break;
			}
		if (!flag) strErrorMessage += "Please accept or reject the declaration\n";
		else flag = false;

		// check if there are errors, output error message and return appropriate value
		if(String(strErrorMessage) != "") {
			alert(strErrorMessage);
			return false;
		}
		return true;
	}
	function changeColour(el, blColour) {
		el.style.backgroundColor = blColour ? "#FFCECE" : "";
	}
	
function isEmailAddr (s){ 
	var rv = false
	if ((s == null) || (s.length == 0)) 
       	rv = false;
 	 else {
		var reEmail =/([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		//reEmail = /.+\@.+\..+$/
		
		rv = reEmail.test(s)
    }
	if(rv){
		return rv
	}else{
		return false
	}
}
 
function loylatyClub(theForm){
	if (theForm.First_name.value == ""){
    	alert("Please enter your name.");
    	theForm.First_name.focus();
    	return (false);
  	}
	if (theForm.Last_name.value == ""){
    	alert("Please enter your surname.");
    	theForm.Last_name.focus();
    	return (false);
  	}
	if (theForm.Address.value == ""){
    	alert("Please enter your address.");
    	theForm.Address.focus();
    	return (false);
  	}
	if (theForm.City.value == ""){
    	alert("Please enter your city.");
    	theForm.City.focus();
    	return (false);
  	}
	if (theForm.Postcode.value == ""){
    	alert("Please enter your postcode.");
    	theForm.Postcode.focus();
    	return (false);
  	}
	if (theForm.Country.value == ""){
    	alert("Please enter your country.");
    	theForm.Country.focus();
    	return (false);
  	}
  	if (!isEmailAddr(theForm.email_from.value)){
    	alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    	theForm.email_from.focus();
    	return (false);
 	}
	if (!isEmailAddr(theForm.email_from.value) || (theForm.email_confirm.value != theForm.email_from.value)){
    	alert("Please confirm your email again");
    	theForm.email_confirm.focus();
    	return (false);
 	}
	if (!theForm.terms.checked){
    	alert("Please read the terms and conditions.");
    	theForm.terms.focus();
    	return (false);
  	}
	return (true);
}

function updateDetails(theForm){
	
	if (theForm.Membership_Number.value == ""){
    	alert("Please enter your membership number.");
    	theForm.First_name.focus();
    	return (false);
  	}
	if (theForm.First_name.value == ""){
    	alert("Please enter your name.");
    	theForm.First_name.focus();
    	return (false);
  	}
	if (theForm.Last_name.value == ""){
    	alert("Please enter your surname.");
    	theForm.Last_name.focus();
    	return (false);
  	}
	if (theForm.Address.value == ""){
    	alert("Please enter your address.");
    	theForm.Address.focus();
    	return (false);
  	}
	if (theForm.City.value == ""){
    	alert("Please enter your city.");
    	theForm.City.focus();
    	return (false);
  	}
	if (theForm.Postcode.value == ""){
    	alert("Please enter your postcode.");
    	theForm.Postcode.focus();
    	return (false);
  	}
	if (theForm.Country.value == ""){
    	alert("Please enter your country.");
    	theForm.Country.focus();
    	return (false);
  	}
  	if (!isEmailAddr(theForm.email_from.value)){
    	alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    	theForm.email_from.focus();
    	return (false);
 	}
	if (!isEmailAddr(theForm.email_from.value) || (theForm.email_confirm.value != theForm.email_from.value)){
    	alert("Please confirm your email again");
    	theForm.email_confirm.focus();
    	return (false);
 	}
	if (!theForm.terms.checked){
    	alert("Please read the terms and conditions.");
    	theForm.terms.focus();
    	return (false);
  	}
	return (true);
}

//-->