<!--
	function ValidateApplication(theForm) {
		// variable to hold the error message
		var strErrorMessage = "";
		// variable to hold flag values
		var flag = false;
		// variable to hold regular expression for email validation
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		// check for errors and set the error message
		if (theForm.PositionAppliedFor.value == "") {
			strErrorMessage += "Please enter position applied for\n";
			changeColour(theForm.PositionAppliedFor, true);
		} else changeColour(theForm.PositionAppliedFor, false);
		if (theForm.PositionNo.value == "") {
			strErrorMessage += "Please enter position number\n";
			changeColour(theForm.PositionNo, true);
		} else changeColour(theForm.PositionNo, false);
		for (var counter = 0; counter < theForm.ApplicantTitle.length; counter++) {
			if (theForm.ApplicantTitle[counter].checked) flag = true;
			if (counter == theForm.ApplicantTitle.length - 1 && theForm.ApplicantTitle[counter].checked && theForm.ApplicantTitleOther.value == "") {
				strErrorMessage += "Please enter your title\n";
				changeColour(theForm.ApplicantTitleOther, true);
			} else changeColour(theForm.ApplicantTitleOther, false);
		}
		if (!flag) strErrorMessage += "Please select your title\n";
		else flag = false;
		if (theForm.ApplicantFamilyName.value == "") {
			strErrorMessage += "Please enter your family name\n";
			changeColour(theForm.ApplicantFamilyName, true);
		} else changeColour(theForm.ApplicantFamilyName, false);
		if (theForm.ApplicantFirstNames.value == "") {
			strErrorMessage += "Please enter your first names\n";
			changeColour(theForm.ApplicantFirstNames, true);
		} else changeColour(theForm.ApplicantFirstNames, false);
		if (theForm.ApplicantFullPostalAddress.value == "") {
			strErrorMessage += "Please enter your postal address\n";
			changeColour(theForm.ApplicantFullPostalAddress, true);
		} else changeColour(theForm.ApplicantFullPostalAddress, false);
		if (theForm.ApplicantPhoneHome.value == "" && theForm.ApplicantPhoneBusiness.value == "" && theForm.ApplicantPhoneMobile.value == "") {
			strErrorMessage += "Please enter a phone number\n";
			changeColour(theForm.ApplicantPhoneHome, true);
			changeColour(theForm.ApplicantPhoneBusiness, true);
			changeColour(theForm.ApplicantPhoneMobile, true);
		} else {
			changeColour(theForm.ApplicantPhoneHome, false);
			changeColour(theForm.ApplicantPhoneBusiness, false);
			changeColour(theForm.ApplicantPhoneMobile, 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);
		}
		for (var counter = 0; counter < theForm.ApplicantEntitledToWorkInNZ.length; counter++) if (theForm.ApplicantEntitledToWorkInNZ[counter].checked) flag = true;
		if (!flag) strErrorMessage += "Please indicate whether you are entitled to work in New Zealand\n";
		else flag = false;
		for (var counter = 0; counter < theForm.EntitlementToWorkInNZ.length; counter++) if (theForm.EntitlementToWorkInNZ[counter].checked) flag = true;
		if (!flag) strErrorMessage += "Please indicate the entitlement you have for working in New Zealand\n";
		else flag = false;
		if (theForm.ReasonsForApplying.value == "") {
			strErrorMessage += "Please tell us your reasons for applying\n";
			changeColour(theForm.ReasonsForApplying, true);
		} else changeColour(theForm.ReasonsForApplying, false);
		for (var counter = 0; counter < theForm.ApplicantConsentsToMedicalExamination.length; counter++) if (theForm.ApplicantConsentsToMedicalExamination[counter].checked) flag = true;
		if (!flag) strErrorMessage += "Please indicate whether you consent to a medical examination\n";
		else flag = false;
		for (var counter = 0; counter < theForm.ApplicantConsentsToBiologicalMonitoringIfApplicable.length; counter++) if (theForm.ApplicantConsentsToBiologicalMonitoringIfApplicable[counter].checked) flag = true;
		if (!flag) strErrorMessage += "Please indicate whether you consent to biological monitoring\n";
		else flag = false;
		for (var counter = 0; counter < theForm.ApplicantHasMedicalConditions.length; counter++) if (theForm.ApplicantHasMedicalConditions[counter].checked) flag = true;
		if (!flag) strErrorMessage += "Please indicate if you have any injuries or medical conditions\n";
		else flag = false;
		if (theForm.ApplicantHasMedicalConditions[0].checked && theForm.ApplicantMedicalConditionDetails.value == "") {
			strErrorMessage += "Please state the details of your injury and/or medical condition\n";
			changeColour(theForm.ApplicantMedicalConditionDetails, true);
		} else changeColour(theForm.ApplicantMedicalConditionDetails, false);
		for (var counter = 0; counter < theForm.ApplicantHasConvicitions.length; counter++) if (theForm.ApplicantHasConvicitions[counter].checked) flag = true;
		if (!flag) strErrorMessage += "Please indicate if you have any criminal convictions\n";
		else flag = false;
		if (theForm.ApplicantHasConvicitions[0].checked && theForm.ApplicantConvictionDetails.value == "") {
			strErrorMessage += "Please state the details of your criminal convictions\n";
			changeColour(theForm.ApplicantConvictionDetails, true);
		} else changeColour(theForm.ApplicantConvictionDetails, false);
		for (var counter = 0; counter < theForm.ApplicantHasChargesPending.length; counter++) if (theForm.ApplicantHasChargesPending[counter].checked) flag = true;
		if (!flag) strErrorMessage += "Please indicate if you have any charges pending\n";
		else flag = false;
		if (theForm.ApplicantHasChargesPending[0].checked && theForm.ApplicantChargesPendingDetails.value == "") {
			strErrorMessage += "Please state the details of your charges pending\n";
			changeColour(theForm.ApplicantChargesPendingDetails, true);
		} else changeColour(theForm.ApplicantChargesPendingDetails, false);
		if (document.getElementById("Web_Site").checked && document.getElementById("Web_Site_detail").value == "") {
			strErrorMessage += "Please enter the details of the web site you read about this job on.";
			changeColour(document.getElementById("Web_Site_detail"), true);
		} else changeColour(document.getElementById("Web_Site_detail"), false);
		if (document.getElementById("Internal_Notice_Board").checked && document.getElementById("Internal_Notice_Board_detail").value == "") {
			strErrorMessage += "Please enter the details of the internal notice board you read about this job on.";
			changeColour(document.getElementById("Internal_Notice_Board_detail"), true);
		} else changeColour(document.getElementById("Internal_Notice_Board_detail"), false);
		if (document.getElementById("Newspaper").checked && document.getElementById("Newspaper_detail").value == "") {
			strErrorMessage += "Please enter the details of the newspaper you read about this job in.";
			changeColour(document.getElementById("Newspaper_detail"), true);
		} else changeColour(document.getElementById("Newspaper_detail"), false);
		if (document.getElementById("Institute_Publication").checked && document.getElementById("Institute_Publication_detail").value == "") {
			strErrorMessage += "Please enter the details of the institute publication you read about this job in.";
			changeColour(document.getElementById("Institute_Publication_detail"), true);
		} else changeColour(document.getElementById("Institute_Publication_detail"), false);
		if (document.getElementById("Radio").checked && document.getElementById("Radio_detail").value == "") {
			strErrorMessage += "Please enter the details of the radio station you heard about this job on.";
			changeColour(document.getElementById("Radio_detail"), true);
		} else changeColour(document.getElementById("Radio_detail"), false);
		if (document.getElementById("Referral_by_Staff_member").checked && document.getElementById("Referral_by_Staff_member_detail").value == "") {
			strErrorMessage += "Please enter the details of the staff member you heard about this job from.";
			changeColour(document.getElementById("Referral_by_Staff_member_detail"), true);
		} else changeColour(document.getElementById("Referral_by_Staff_member_detail"), false);
		if (document.getElementById("Other").checked && document.getElementById("Other_detail").value == "") {
			strErrorMessage += "Please enter the details of how heard about this job.";
			changeColour(document.getElementById("Other_detail"), true);
		} else changeColour(document.getElementById("Other_detail"), false);
		if (!theForm.ApplicantGivesConsent.checked) {
			strErrorMessage += "You must accept the declaration to submit your application\n";
			changeColour(theForm.ApplicantGivesConsent, true);
		} else changeColour(theForm.ApplicantGivesConsent, false);
		if (theForm.ConsentName.value == "") {
			strErrorMessage += "Please enter your name in the declaration\n";
			changeColour(theForm.ConsentName, true);
		} else changeColour(theForm.ConsentName, 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" : "";
	}
//-->
