// JavaScript Document


    function ChangeColor(tableRow, highLighted)
    {
    if (highLighted)
    {
      tableRow.style.backgroundColor = '#eee';
    }
    else
    {
      tableRow.style.backgroundColor = 'transparent';
    }
  }

  function doJobLink(theUrl)
  {
  document.location.href = theUrl;
  }
  
  function DisplayAsLink(tableCell, highLighted){

    if (highLighted)
    {
      tableCell.style.cursor = 'pointer';
    }
    else
    {
      tableCell.style.cursor = 'default';
    }
	
  }
  


function setFormAction(action){

	if(action == "save")
	{

	if (document.form1.save_email_address.value.length == 0)
		{
		  document.form1.save_email_address.focus();
		  alert("In order to save this application and retreive at a later date, please enter your email address")
		  return (false);
		}
		  var zToCheck;
		  zToCheck = document.form1.save_email_address.value;
		  if (zToCheck.length < 7)
		  {
			alert("An email address must be supplied. Please enter at least 7 character in the email address field");
			document.form1.save_email_address.focus();
			return (false);
		  }

		  var zRegExp;
		  zRegExp = "^[A-Za-z0-9_-]+[A-Za-z0-9_.-]*@[A-Za-z0-9]+[A-Za-z0-9_-]+[.][A-Za-z0-9_-]+[A-Za-z0-9_.-]*[A-Za-z0-9]+$";

		  if (zToCheck.search(zRegExp) == -1)
		  {
			alert("An email address must be supplied. Please enter a VALID email address in the email address field");
			document.form1.save_email_address.focus();
			return (false);
		  }

		str = "Please confirm the email address that you have entered:\n\n"+document.form1.save_email_address.value+" \n\n  ";
		var emailconfirm = confirm(str);
		if (emailconfirm == false)
		{
			document.form1.save_email_address.focus();
			return false;
		}
	
}
	return (true);
}


/******************************************************************/

/******** FORM VALIDATOR ******************************************/

function FormValidator(theForm, refnum){

	var strForeName = theForm.forename.value;
	var strSurName = theForm.surname.value;
	var contactType = theForm.selContact.value;
	var strEmailAddress = theForm.emailaddress.value;
	var nTelephone_Home = theForm.tel_home.value;
	var nTelephone_Mobile = theForm.tel_mobile.value;
	var nTelephone_Work = theForm.tel_work.value;
	var strAddress = theForm.address.value;
	var strPostCode = theForm.postcode.value;

	if (refnum > 1){
	
		var chkSubVacs = document.forms[1].subrefs;
		var numSubVacs = 0;
		var valueSubVac;
		for (var i = 0; i < chkSubVacs.length; i++){
			if (chkSubVacs[i].checked == true){
				numSubVacs++;
				valueSubVac = chkSubVacs[i].value;

			}
		}
		if (numSubVacs < 1){
			alert("Please select a specific location\nYou can select more than one");
			return (false);
		}
	
	}
	
	
	if (strSurName == ""){
		alert("Please enter your Surname");
		theForm.surname.focus();
		return (false);
	}

	if (strForeName == ""){
		alert("Please enter your Forename");
		theForm.forename.focus();
		return (false);
	}

	if (strAddress == ""){
		alert("Please enter your Postal Address");
		theForm.address.focus();
		return (false);
	}	

	if (contactType == "*"){
		alert("Please select a method of contact from the drop down menu");
		theForm.selContact.focus();
		return (false);
	}

	if (contactType == "HomeTel"){
		if (nTelephone_Home == ""){
			alert("You have selected to be contacted by Home Telephone but have not completed the Home Telephone field");
			theForm.tel_home.focus();
			return (false);
		}
	}

	if (contactType == "MobileTel"){
		if (nTelephone_Mobile == ""){
			alert("You have selected to be contacted by Mobile Telephone but have not completed the Mobile Telephone field");
			theForm.tel_mobile.focus();
			return (false);
		}
	}

	if (contactType == "WorkTel"){
		if (nTelephone_Work == ""){
			alert("You have selected to be contacted by Work Telephone but have not completed the Work Telephone field");
			theForm.tel_work.focus();
			return (false);
		}
	}

	if (contactType == "Email"){
		var zToCheck;
		zToCheck = strEmailAddress;

		if (zToCheck.length < 7){
			alert("Please enter at least 7 character in the \"E-mail Address\" field");
			theForm.emailaddress.focus();
			return (false);
		}

		var zRegExp;
		zRegExp = "^[A-Za-z0-9_-]+[A-Za-z0-9_.-]*@[A-Za-z0-9]+[A-Za-z0-9_-]+[.][A-Za-z0-9_-]+[A-Za-z0-9_.-]*[A-Za-z0-9]+$";

		if (zToCheck.search(zRegExp) == -1){
			alert("Please enter a valid EMAIL ADDRESS in the \"E-mail Address\" field");
			theForm.emailaddress.focus();
			return (false);
		}
	}
	


	var zToCheck;
	zToCheck = strEmailAddress;

	  if (zToCheck.length < 7){
		  alert("Please enter at least 7 character in the \"E-mail Address\" field");
		  theForm.emailaddress.focus();
		  return (false);
	  }

	  var zRegExp;
	  zRegExp = "^[A-Za-z0-9_-]+[A-Za-z0-9_.-]*@[A-Za-z0-9]+[A-Za-z0-9_-]+[.][A-Za-z0-9_-]+[A-Za-z0-9_.-]*[A-Za-z0-9]+$";

	  if (zToCheck.search(zRegExp) == -1){
		  alert("Please enter a valid EMAIL ADDRESS in the \"E-mail Address\" field");
		  theForm.emailaddress.focus();
		  return (false);
	  }


	if (contactType == "Post"){
		if (strAddress == ""){
			alert("You have selected to be contacted by Post but have not completed the Postal Address field");
			theForm.address.focus();
			return (false);
		}

		if (strPostCode == ""){
			alert("Please enter your Post Code");
			theForm.postcode.focus();
			return (false);
		}
	}

	if (contactType == "Anymethod"){
		if ((strEmailAddress == "") && (theForm.tel_home.value == "") && (theForm.tel_mobile.value == "") && (theForm.tel_work.value == "")  && (theForm.address.value == "")){
			alert("You have selected to be contacted by ANY means provided, but you have not entered appropriate information - please correct");
			return (false);
		}
	}

	var radioWorkPermit = document.forms[1].workpermit;
	var numWorkPermit = 0;
	var valueWorkPermit;
	for (var i = 0; i < radioWorkPermit.length; i++){
		if (radioWorkPermit[i].checked == true){
			numWorkPermit++;
			valueWorkPermit = radioWorkPermit[i].value;
		}
	}

	if (numWorkPermit < 1){
		alert("Please state whether you require a work permit");
		return (false);
	}

	if (valueWorkPermit == "yes"){

		if (theForm.workpermitdetails.value == ""){
			alert("Please provide details of your Work Permit");
			theForm.workpermitdetails.focus();
			return (false);
		}

		var radioWorkPermitRequire = document.forms[1].require_permit;
		var numWorkPermitRequire = 0;
		var valueWorkPermitRequire;

		for (var i = 0; i < radioWorkPermitRequire.length; i++){
			if (radioWorkPermitRequire[i].checked == true){
				numWorkPermitRequire++;
				valueWorkPermitRequire = radioWorkPermitRequire[i].value;
			}
		}

		if (numWorkPermitRequire < 1){
			alert("Please state whether you hold a valid work permit");
			return (false);
		}

		if ((theForm.expiry_day.value == "") || (theForm.expiry_month.value == "") || (theForm.expiry_year.value == "")){
			alert("Please enter the full expiry date of your work permit");
			theForm.expiry_day.focus();
			return (false);
		}
	}

	return (true);
}













function FormValidatorOnlineAppPersonal(theForm, refnum){

	var strForeName = theForm.forename.value;
	var strSurName = theForm.surname.value;
	var contactType = theForm.selContact.value;
	var strEmailAddress = theForm.emailaddress.value;
	var nTelephone_Home = theForm.tel_home.value;
	var nTelephone_Mobile = theForm.tel_mobile.value;
	var nTelephone_Work = theForm.tel_work.value;
	var strAddress = theForm.address.value;
	var strPostCode = theForm.postcode.value;

	if (refnum > 1){
	
		var chkSubVacs = document.forms[1].subrefs;
		var numSubVacs = 0;
		var valueSubVac;
		for (var i = 0; i < chkSubVacs.length; i++){
			if (chkSubVacs[i].checked == true){
				numSubVacs++;
				valueSubVac = chkSubVacs[i].value;
			}
		}
		if (numSubVacs < 1){
			alert("Please select a specific location\nYou can select more than one");
			return (false);
		}
	
	}
	
	
	if (strSurName == ""){
		alert("Please enter your Surname");
		theForm.surname.focus();
		return (false);
	}

	if (strForeName == ""){
		alert("Please enter your Forename");
		theForm.forename.focus();
		return (false);
	}

	if (strAddress == ""){
		alert("Please enter your Postal Address");
		theForm.address.focus();
		return (false);
	}	

	if (contactType == "*"){
		alert("Please select a method of contact from the drop down menu");
		theForm.selContact.focus();
		return (false);
	}

	if (contactType == "HomeTel"){
		if (nTelephone_Home == ""){
			alert("You have selected to be contacted by Home Telephone but have not completed the Home Telephone field");
			theForm.tel_home.focus();
			return (false);
		}
	}

	if (contactType == "MobileTel"){
		if (nTelephone_Mobile == ""){
			alert("You have selected to be contacted by Mobile Telephone but have not completed the Mobile Telephone field");
			theForm.tel_mobile.focus();
			return (false);
		}
	}

	if (contactType == "WorkTel"){
		if (nTelephone_Work == ""){
			alert("You have selected to be contacted by Work Telephone but have not completed the Work Telephone field");
			theForm.tel_work.focus();
			return (false);
		}
	}

	if (contactType == "Email"){
		var zToCheck;
		zToCheck = strEmailAddress;

		if (zToCheck.length < 7){
			alert("Please enter at least 7 character in the \"E-mail Address\" field");
			theForm.emailaddress.focus();
			return (false);
		}

		var zRegExp;
		zRegExp = "^[A-Za-z0-9_-]+[A-Za-z0-9_.-]*@[A-Za-z0-9]+[A-Za-z0-9_-]+[.][A-Za-z0-9_-]+[A-Za-z0-9_.-]*[A-Za-z0-9]+$";

		if (zToCheck.search(zRegExp) == -1){
			alert("Please enter a valid EMAIL ADDRESS in the \"E-mail Address\" field");
			theForm.emailaddress.focus();
			return (false);
		}
	}
	


	var zToCheck;
	zToCheck = strEmailAddress;

	  if (zToCheck.length < 7){
		  alert("Please enter at least 7 character in the \"E-mail Address\" field");
		  theForm.emailaddress.focus();
		  return (false);
	  }

	  var zRegExp;
	  zRegExp = "^[A-Za-z0-9_-]+[A-Za-z0-9_.-]*@[A-Za-z0-9]+[A-Za-z0-9_-]+[.][A-Za-z0-9_-]+[A-Za-z0-9_.-]*[A-Za-z0-9]+$";

	  if (zToCheck.search(zRegExp) == -1){
		  alert("Please enter a valid EMAIL ADDRESS in the \"E-mail Address\" field");
		  theForm.emailaddress.focus();
		  return (false);
	  }


	if (contactType == "Post"){
		if (strAddress == ""){
			alert("You have selected to be contacted by Post but have not completed the Postal Address field");
			theForm.address.focus();
			return (false);
		}

		if (strPostCode == ""){
			alert("Please enter your Post Code");
			theForm.postcode.focus();
			return (false);
		}
	}

	if (contactType == "Anymethod"){
		if ((strEmailAddress == "") && (theForm.tel_home.value == "") && (theForm.tel_mobile.value == "") && (theForm.tel_work.value == "")  && (theForm.address.value == "")){
			alert("You have selected to be contacted by ANY means provided, but you have not entered appropriate information - please correct");
			return (false);
		}
	}


	var radioEmployeeButton = theForm.currentemployee;
	var numValid = 0;
	var valueCurrentemployee;
	for (var i = 0; i < radioEmployeeButton.length; i++){
		if (radioEmployeeButton[i].checked == true){
			numValid++;
			valueCurrentemployee = radioEmployeeButton[i].value;
		}
	}

	if (numValid < 1){
		document.form1.currentemployee[0].focus();
		alert("Please state whether you are a current employee");
		return (false);
	}
	

		if(valueCurrentemployee == "yes")
		{

			var radioRedundancy = theForm.redundancy;
			var numValid = 0;
			var valueRedundancy;
			for (var i = 0; i < radioRedundancy.length; i++){
				if (radioRedundancy[i].checked == true){
					numValid++;
					valueRedundancy = radioRedundancy[i].value;

				}
			}
	
			if (numValid < 1){
				document.form1.currentemployee[0].focus();
				alert("Please state whether you are at risk from redundancy");
				return (false);
			}
			
		}
		
		
	var radioDisabilityButton = theForm.havedisability;
	var numValid = 0;
	var valueDisability;
	for (var i = 0; i < radioDisabilityButton.length; i++){
		if (radioDisabilityButton[i].checked == true){
			numValid++;
			valueDisability = radioDisabilityButton[i].value;

		}
	}

	if (numValid < 1){
		document.form1.havedisability[0].focus();
		alert("Please state whether you consider yourself to have a disability");
		return (false);
	}
	


		






var radioWorkPermit = theForm.workpermit;
	var numWorkPermit = 0;
	var valueWorkPermit;
	for (var i = 0; i < radioWorkPermit.length; i++){
		if (radioWorkPermit[i].checked == true){
			numWorkPermit++;
			valueWorkPermit = radioWorkPermit[i].value;
		}
	}

	if (numWorkPermit < 1){
		document.form1.workpermit[0].focus();
		alert("Please state whether you require a work permit");
		return (false);
	}
	
	if(valueWorkPermit == "yes")
	{
		var radioWorkPermitValid = theForm.require_permit;
		var numWorkPermitValid = 0;
		var valueWorkPermitValid;
		for (var i = 0; i < radioWorkPermitValid.length; i++){
			if (radioWorkPermitValid[i].checked == true){
				numWorkPermitValid++;
				valueWorkPermitValid = radioWorkPermitValid[i].value;
			}
		}
	
		if (numWorkPermitValid < 1){
			document.form1.require_permit[0].focus();
			alert("Please state whether your work permit is valid");
			return (false);
		}
	}



if((valueWorkPermit == "yes") && (valueWorkPermitValid == "no"))
{
			document.form1.require_permit[0].focus();
			alert("To apply for a vacancy at Turning Point candidates must possess a valid work permit.");
			return (false);
}





	return (true);
}








function FormValidatorPreviousEmp(theForm){

	if ((theForm.one_emp_jobtitle.value != "") || (theForm.one_emp_details.value != "") || (theForm.one_emp_duties.value != "") || (theForm.one_emp_from_day.value != "") || (theForm.one_emp_from_month.value != "") || (theForm.one_emp_from_year.value != "") || (theForm.one_emp_to_day.value != "") || (theForm.one_emp_to_month.value != "") || (theForm.one_emp_to_year.value != "")){

		if (theForm.one_emp_jobtitle.value == ""){
			alert("Please supply the job title");
			theForm.one_emp_jobtitle.focus();
			return (false);
		}

		if (theForm.one_emp_details.value == ""){
			alert("Please supply the employers name, address and nature of business");
			theForm.one_emp_details.focus();
			return (false);
		}

		if (theForm.one_emp_duties.value == ""){
			alert("Please supply your main duties and responsibilities");
			theForm.one_emp_duties.focus();
			return (false);
		}

		if (theForm.one_emp_reason.value == ""){
			alert("Please state your reason for leaving");
			theForm.one_emp_reason.focus();
			return (false);
		}

		if (theForm.one_emp_salary.value == ""){
			alert("Please state your final salary");
			theForm.one_emp_salary.focus();
			return (false);
		}

		if ((theForm.one_emp_from_day.value == "") || (theForm.one_emp_from_month.value == "") || (theForm.one_emp_from_year.value == "")){
			alert("Please supply the from date in full");
			theForm.one_emp_from_day.focus();
			return (false);
		}

		if ((theForm.one_emp_to_day.value == "") || (theForm.one_emp_to_month.value == "") || (theForm.one_emp_to_year.value == "")){
			alert("Please supply the to date in full");
			theForm.one_emp_to_day.focus();
			return (false);
		}
	}

	if ((theForm.two_emp_jobtitle.value != "") || (theForm.two_emp_details.value != "") || (theForm.two_emp_duties.value != "") || (theForm.two_emp_from_day.value != "") || (theForm.two_emp_from_month.value != "") || (theForm.two_emp_from_year.value != "") || (theForm.two_emp_to_day.value != "") || (theForm.two_emp_to_month.value != "") || (theForm.two_emp_to_year.value != "")){

		if (theForm.two_emp_jobtitle.value == ""){
			alert("Please supply the job title");
			theForm.two_emp_jobtitle.focus();
			return (false);
		}

		if (theForm.two_emp_details.value == ""){
			alert("Please supply the employers name, address and nature of business");
			theForm.two_emp_details.focus();
			return (false);
		}

		if (theForm.two_emp_duties.value == ""){
			alert("Please supply your main duties and responsibilities");
			theForm.two_emp_duties.focus();
			return (false);
		}

		if (theForm.two_emp_reason.value == ""){
			alert("Please state your reason for leaving");
			theForm.two_emp_reason.focus();
			return (false);
		}

		if (theForm.two_emp_salary.value == ""){
			alert("Please state your final salary");
			theForm.two_emp_salary.focus();
			return (false);
		}

		if ((theForm.two_emp_from_day.value == "") || (theForm.two_emp_from_month.value == "") || (theForm.two_emp_from_year.value == "")){
			alert("Please supply the from date in full");
			theForm.two_emp_from_day.focus();
			return (false);
		}

		if ((theForm.two_emp_to_day.value == "") || (theForm.two_emp_to_month.value == "") || (theForm.two_emp_to_year.value == "")){
			alert("Please supply the to date in full");
			theForm.two_emp_to_day.focus();
			return (false);
		}
	}

	if ((theForm.three_emp_jobtitle.value != "") || (theForm.three_emp_details.value != "") || (theForm.three_emp_duties.value != "") || (theForm.three_emp_from_day.value != "") || (theForm.three_emp_from_month.value != "") || (theForm.three_emp_from_year.value != "") || (theForm.three_emp_to_day.value != "") || (theForm.three_emp_to_month.value != "") || (theForm.three_emp_to_year.value != "")){

		if (theForm.three_emp_jobtitle.value == ""){
			alert("Please supply the job title");
			theForm.three_emp_jobtitle.focus();
			return (false);
		}

		if (theForm.three_emp_details.value == ""){
			alert("Please supply the employers name, address and nature of business");
			theForm.three_emp_details.focus();
			return (false);
		}

		if (theForm.three_emp_duties.value == ""){
			alert("Please supply your main duties and responsibilities");
			theForm.three_emp_duties.focus();
			return (false);
		}

		if (theForm.three_emp_reason.value == ""){
			alert("Please state your reason for leaving");
			theForm.three_emp_reason.focus();
			return (false);
		}

		if (theForm.three_emp_salary.value == ""){
			alert("Please state your final salary");
			theForm.three_emp_salary.focus();
			return (false);
		}

		if ((theForm.three_emp_from_day.value == "") || (theForm.three_emp_from_month.value == "") || (theForm.three_emp_from_year.value == "")){
			alert("Please supply the from date in full");
			theForm.three_emp_from_day.focus();
			return (false);
		}

		if ((theForm.three_emp_to_day.value == "") || (theForm.three_emp_to_month.value == "") || (theForm.three_emp_to_year.value == "")){
			alert("Please supply the to date in full");
			theForm.three_emp_to_day.focus();
			return (false);
		}
	}
	return (true);
}












function FormValidatorEducation(theForm){

	if ((theForm.one_education_date_from.value != "") || (theForm.one_education_date_to.value != "") || (theForm.one_education_establishment.value != "") || (theForm.one_education_qualifications.value != "") || (theForm.one_education_levelattained.value != "")){

		if (theForm.one_education_date_from.value == ""){
			alert("Please supply the from date");
			theForm.one_education_date_from.focus();
			return (false);
		}

		if (theForm.one_education_date_to.value == ""){
			alert("Please supply the to date");
			theForm.one_education_date_to.focus();
			return (false);
		}

		if (theForm.one_education_establishment.value == ""){
			alert("Please supply the School/College/University");
			theForm.one_education_establishment.focus();
			return (false);
		}

		if (theForm.one_education_qualifications.value == ""){
			alert("Please supply the qualification gained");
			theForm.one_education_qualifications.focus();
			return (false);
		}

		if (theForm.one_education_levelattained.value == ""){
			alert("Please supply the level attained");
			theForm.one_education_levelattained.focus();
			return (false);
		}
	}

	if ((theForm.two_education_date_from.value != "") || (theForm.two_education_date_to.value != "") || (theForm.two_education_establishment.value != "") || (theForm.two_education_qualifications.value != "") || (theForm.two_education_levelattained.value != "")){

		if (theForm.two_education_date_from.value == ""){
			alert("Please supply the from date");
			theForm.two_education_date_from.focus();
			return (false);
		}

		if (theForm.two_education_date_to.value == ""){
			alert("Please supply the to date");
			theForm.two_education_date_to.focus();
			return (false);
		}

		if (theForm.two_education_establishment.value == ""){
			alert("Please supply the School/College/University");
			theForm.two_education_establishment.focus();
			return (false);
		}

		if (theForm.two_education_qualifications.value == ""){
			alert("Please supply the qualification gained");
			theForm.two_education_qualifications.focus();
			return (false);
		}

		if (theForm.two_education_levelattained.value == ""){
			alert("Please supply the level attained");
			theForm.two_education_levelattained.focus();
			return (false);
		}
	}

	if ((theForm.three_education_date_from.value != "") || (theForm.three_education_date_to.value != "") || (theForm.three_education_establishment.value != "") || (theForm.three_education_qualifications.value != "") || (theForm.three_education_levelattained.value != "")){

		if (theForm.three_education_date_from.value == ""){
			alert("Please supply the from date");
			theForm.three_education_date_from.focus();
			return (false);
		}

		if (theForm.three_education_date_to.value == ""){
			alert("Please supply the to date");
			theForm.three_education_date_to.focus();
			return (false);
		}

		if (theForm.three_education_establishment.value == ""){
			alert("Please supply the School/College/University");
			theForm.three_education_establishment.focus();
			return (false);
		}

		if (theForm.three_education_qualifications.value == ""){
			alert("Please supply the qualification gained");
			theForm.three_education_qualifications.focus();
			return (false);
		}

		if (theForm.three_education_levelattained.value == ""){
			alert("Please supply the level attained");
			theForm.three_education_levelattained.focus();
			return (false);
		}
	}

	if ((theForm.four_education_date_from.value != "") || (theForm.four_education_date_to.value != "") || (theForm.four_education_establishment.value != "") || (theForm.four_education_qualifications.value != "") || (theForm.four_education_levelattained.value != "")){

		if (theForm.four_education_date_from.value == ""){
			alert("Please supply the from date");
			theForm.four_education_date_from.focus();
			return (false);
		}

		if (theForm.four_education_date_to.value == ""){
			alert("Please supply the to date");
			theForm.four_education_date_to.focus();
			return (false);
		}

		if (theForm.four_education_establishment.value == ""){
			alert("Please supply the School/College/University");
			theForm.four_education_establishment.focus();
			return (false);
		}

		if (theForm.four_education_qualifications.value == ""){
			alert("Please supply the qualification gained");
			theForm.four_education_qualifications.focus();
			return (false);
		}

		if (theForm.four_education_levelattained.value == ""){
			alert("Please supply the level attained");
			theForm.four_education_levelattained.focus();
			return (false);
		}
	}
	return (true);
}







function FormValidatorStatement(theForm){

  	if (theForm.statement.value == ""){
		alert("Please enter some text for your statement");
		theForm.statement.focus();
		return (false);
	}

	arrStatement = theForm.statement.value.split(" ");

	if (arrStatement.length > 850){
		alert("Please enter a maximum of 850 words");
		theForm.statement.focus();
		return (false);
	}

	return (true);
}



function FormValidatorReferees(theForm)

{

  	if (theForm.one_referee_name.value == "")
	{
		alert("Please enter the referees name");
		theForm.one_referee_name.focus();
		return (false);
	}

  	if (theForm.one_referee_position.value == "")
	{
		alert("Please enter the referees position");
		theForm.one_referee_position.focus();
		return (false);
	}


  	if (theForm.one_referee_company.value == "")
	{
		alert("Please enter the organisation name");
		theForm.one_referee_company.focus();
		return (false);
	}

  	if (theForm.one_referee_companyaddress1.value == "")
	{
		alert("Please enter address line 1 for this referee");
		theForm.one_referee_companyaddress1.focus();
		return (false);
	}

  	if (theForm.one_referee_companyaddress2.value == "")
	{
		alert("Please enter address line 2 for this referee");
		theForm.one_referee_companyaddress2.focus();
		return (false);
	}

  	if (theForm.one_referee_knowthem.value == "")
	{
		alert("Please state how you know this referee");
		theForm.one_referee_knowthem.focus();
		return (false);
	}

  	if (theForm.one_referee_tel.value == "")
	{
		alert("Please supply the referees telephone number");
		theForm.one_referee_tel.focus();
		return (false);
	}


	var zToCheck;
	zToCheck = theForm.one_referee_email.value;
	
	if (zToCheck.length != 0 )
	{
	
		if (zToCheck.length < 7)
		{
		  alert("Please enter at least a 7 character address in the first referees e-mail address field");
		  theForm.one_referee_email.focus();
		  return (false);
		}
		
		var zRegExp;
		zRegExp = "^[A-Za-z0-9_-]+[A-Za-z0-9_.-]*@[A-Za-z0-9]+[A-Za-z0-9_-]+[.][A-Za-z0-9_-]+[A-Za-z0-9_.-]*[A-Za-z0-9]+$";
		
		if (zToCheck.search(zRegExp) == -1)
		{
		  alert("Please enter a valid EMAIL ADDRESS in the first referees e-mail address field");
		  theForm.one_referee_email.focus();
		  return (false);
		}
		  
	}
	
	

  	if (theForm.two_referee_name.value == "")
	{
		alert("Please enter the referees name");
		theForm.two_referee_name.focus();
		return (false);
	}

  	if (theForm.two_referee_position.value == "")
	{
		alert("Please enter the referees position");
		theForm.two_referee_position.focus();
		return (false);
	}


  	if (theForm.two_referee_company.value == "")
	{
		alert("Please enter the organisation name");
		theForm.two_referee_company.focus();
		return (false);
	}

  	if (theForm.two_referee_companyaddress1.value == "")
	{
		alert("Please enter address line 1 for this referee");
		theForm.two_referee_companyaddress1.focus();
		return (false);
	}

  	if (theForm.two_referee_companyaddress2.value == "")
	{
		alert("Please enter address line 2 for this referee");
		theForm.two_referee_companyaddress2.focus();
		return (false);
	}

  	if (theForm.two_referee_knowthem.value == "")
	{
		alert("Please state how you know this referee");
		theForm.two_referee_knowthem.focus();
		return (false);
	}

  	if (theForm.two_referee_tel.value == "")
	{
		alert("Please supply the referees telephone number");
		theForm.two_referee_tel.focus();
		return (false);
	}

	var zToCheck;
	zToCheck = theForm.two_referee_email.value;

	if (zToCheck.length != 0)
	{
		
		if (zToCheck.length < 7)
		{
		  alert("Please enter at least a 7 character address in the second referees e-mail address field");
		  theForm.two_referee_email.focus();
		  return (false);
		}
		
		var zRegExp;
		zRegExp = "^[A-Za-z0-9_-]+[A-Za-z0-9_.-]*@[A-Za-z0-9]+[A-Za-z0-9_-]+[.][A-Za-z0-9_-]+[A-Za-z0-9_.-]*[A-Za-z0-9]+$";
		
		if (zToCheck.search(zRegExp) == -1)
		{
		  alert("Please enter a valid EMAIL ADDRESS in the second referees e-mail address field");
		  theForm.two_referee_email.focus();
		  return (false);
		}
	
	}
	



  //rehabilitation act details

	var totalPart1numCount = 0;
	var totalPart2numCount = 0;

	var radio1Name = theForm.convictions;
	var num1Count = 0;
	var radio2Name = theForm.enquiries;
	var num2Count = 0;
	var radio3Name = theForm.disqualified;
	var num3Count = 0;
	var radio4Name = theForm.convictions_office;
	var num4Count = 0;

	for (var i = 0; i < radio1Name.length; i++)
	{
		if (radio1Name[i].checked == true){
			num1Count++;
			totalPart1numCount++;
		}
	}

	for (var i = 0; i < radio2Name.length; i++)
	{
		if (radio2Name[i].checked == true){
			num2Count++;
			totalPart1numCount++;			
		}
	}

	for (var i = 0; i < radio3Name.length; i++)
	{
		if (radio3Name[i].checked == true){
			num3Count++;
			totalPart1numCount++;			
		}
	}
	


	for (var i = 0; i < radio4Name.length; i++)
	{
		if (radio4Name[i].checked == true){
			num4Count++;
			totalPart2numCount ++;			
		}
	}
		
//if no answers then error- done
//if they answer one of the 3 questions they must answer all
//then
//if they answer none of these questions they must answer the other one
	

	if (totalPart1numCount == 0 && totalPart2numCount == 0) 
	{
	
		alert("You must answer the required questions relating to the Rehabilitation of offenders act 1974");
		document.form1.convictions[0].focus();
		return (false);
	}
	
	
	
	if (totalPart1numCount > 0 && totalPart1numCount < 3) 
	{
		if (num1Count < 1){
			alert("Please state whether you have ever been convicted of a criminal offence by the courts, cautioned, reprimanded or given a final warning by the police (‘spent’ or unspent’)?");
			document.form1.convictions[0].focus();
			return (false);}
	
		if (num2Count < 1){
			alert("Please state whether you have any police enquiries undertaken following allegations made against you");
			theForm.enquiries[0].focus();
			return (false);}
	
		if (num3Count < 1){
			alert("Please state whether you are disqualified from working with vulnerable adults or children");
			theForm.disqualified[0].focus();
			return (false);}
	

	}

	if (totalPart1numCount == 0 && totalPart2numCount != 1)
	{

			alert("Please state whether you have ever been convicted of a criminal offence (‘unspent’ only)?");
			document.form1.convictions_office[0].focus();

	}



	if (totalPart1numCount == 3 && totalPart2numCount == 1)
	{

		alert("You only need to answer the questions relating to working with vulnerable adults and children OR general post, but not both");
		document.form1.convictions_office[0].focus();
	    return (false);

	}
	
	
	




  if (theForm.declaration.checked == false)
  {
    alert("You must agree to the declaration to submit this application");
    theForm.declaration.focus();
    return (false);
  }


		if (theForm.selMediaSources.value == "")
		{
			alert("Please select where you saw this vacancy advertised");
			theForm.selMediaSources.focus();
			return (false);
		}

return (true);
}



function FormValidatorCurrentEmp(theForm){

	if ((theForm.current_emp_details.value != "") || (theForm.current_job_title.value != "") || (theForm.current_mainduties.value != "")){
		if (theForm.current_emp_details.value == ""){
			alert("Please supply the employee name, address and nature of business");
			theForm.current_emp_details.focus();
			return (false);
		}

		if (theForm.current_job_title.value == ""){
			alert("Please supply the job title");
			theForm.current_job_title.focus();
			return (false);
		}

		if (theForm.current_mainduties.value == ""){
			alert("Please enter your main duties and responsibilities");
			theForm.current_mainduties.focus();
			return (false);
		}
	}
	return (true);
}












function formValidatorCVSubmit(theForm, refnum)
{

	if (refnum > 1){

		var chkSubVacs = document.forms[0].subrefs;
		var numSubVacs = 0;
		var valueSubVac;
		for (var i = 0; i < chkSubVacs.length; i++){
			if (chkSubVacs[i].checked == true){
				numSubVacs++;
				valueSubVac = chkSubVacs[i].value;
			}
		}
		if (numSubVacs < 1){
			alert("Please select a specific location\nYou can select more than one");
			return (false);
		}
	}


		
	var radioDisabilityButton = theForm.havedisability;
	var numValid = 0;
	var valueDisability;
	for (var i = 0; i < radioDisabilityButton.length; i++){
		if (radioDisabilityButton[i].checked == true){
			numValid++;
			valueDisability = radioDisabilityButton[i].value;

		}
	}

	if (numValid < 1){
		
		alert("Please state whether you consider yourself to have a disability");
		document.form1.havedisability[0].focus();
		return (false);
	}
	


		
  if (theForm.title.value == "")
  {
    alert("Please enter a value for the \"Title\" field.");
    theForm.title.focus();
    return (false);
  }

  if (theForm.forename.value == "")
  {
    alert("Please enter a value for the \"Forename\" field.");
    theForm.forename.focus();
    return (false);
  }

  if (theForm.surname.value == "")
  {
    alert("Please enter a value for the \"Surname\" field.");
    theForm.surname.focus();
    return (false);
  }

  if (theForm.address.value == "")
  {
    alert("Please enter a value for the \"Address\" field.");
    theForm.address.focus();
    return (false);
  }

  if (theForm.telephone.value == "")
  {
    alert("Please enter a value for the \"Telephone\" field.");
    theForm.telephone.focus();
    return (false);
  }

  var zToCheck;
  zToCheck = theForm.email.value;
  if (zToCheck.length < 7)
  {
    alert("An email address must be supplied. Please enter at least 7 character in the \"Contact E-mail\" field.");
    theForm.email.focus();
    return (false);
  }

  var zRegExp;
  zRegExp = "^[A-Za-z0-9_-]+[A-Za-z0-9_.-]*@[A-Za-z0-9]+[A-Za-z0-9_-]+[.][A-Za-z0-9_-]+[A-Za-z0-9_.-]*[A-Za-z0-9]+$";

  if (zToCheck.search(zRegExp) == -1)
  {
    alert("An email address must be supplied. Please enter a valid EMAIL ADDRESS in the \"Contact E-mail\" field.");
    theForm.email.focus();
    return (false);
  }





	var radioEmployeeButton = theForm.currentemployee;
	var numValid = 0;
	var valueCurrentemployee;
	for (var i = 0; i < radioEmployeeButton.length; i++){
		if (radioEmployeeButton[i].checked == true){
			numValid++;
			valueCurrentemployee = radioEmployeeButton[i].value;
		}
	}

	if (numValid < 1){

		alert("Please state whether you are a current employee");
		document.form1.currentemployee[0].focus();
		return (false);
	}
	


		if(valueCurrentemployee == "yes")
		{

			var radioRedundancy = theForm.redundancy;
			var numValid = 0;
			var valueRedundancy;
			for (var i = 0; i < radioRedundancy.length; i++){
				if (radioRedundancy[i].checked == true){
					numValid++;
					valueRedundancy = radioRedundancy[i].value;

				}
			}
	
			if (numValid < 1){
				
				alert("Please state whether you are at risk from redundancy");
				document.form1.currentemployee[0].focus();
				return (false);
			}
			
		}
		

		
		
	var radioWorkPermit = theForm.workpermit;
	var numWorkPermit = 0;
	var valueWorkPermit;
	for (var i = 0; i < radioWorkPermit.length; i++){
		if (radioWorkPermit[i].checked == true){
			numWorkPermit++;
			valueWorkPermit = radioWorkPermit[i].value;
		}
	}

	if (numWorkPermit < 1){
		document.form1.workpermit[0].focus();
		alert("Please state whether you require a work permit");
		return (false);
	}
	
	if(valueWorkPermit == "yes")
	{
		var radioWorkPermitValid = theForm.require_permit;
		var numWorkPermitValid = 0;
		var valueWorkPermitValid;
		for (var i = 0; i < radioWorkPermitValid.length; i++){
			if (radioWorkPermitValid[i].checked == true){
				numWorkPermitValid++;
				valueWorkPermitValid = radioWorkPermitValid[i].value;
			}
		}
	
		if (numWorkPermitValid < 1){
			document.form1.require_permit[0].focus();
			alert("Please state whether your work permit is valid");
			return (false);
		}
	}



if((valueWorkPermit == "yes") && (valueWorkPermitValid == "no"))
{
			document.form1.require_permit[0].focus();
			alert("To apply for a vacancy at Turning Point candidates must possess a valid work permit.");
			return (false);
}

  //rehabilitation act details

	var totalPart1numCount = 0;
	var totalPart2numCount = 0;

	var radio1Name = theForm.convictions;
	var num1Count = 0;
	var radio2Name = theForm.enquiries;
	var num2Count = 0;
	var radio3Name = theForm.disqualified;
	var num3Count = 0;
	var radio4Name = theForm.convictions_office;
	var num4Count = 0;

	for (var i = 0; i < radio1Name.length; i++)
	{
		if (radio1Name[i].checked == true){
			num1Count++;
			totalPart1numCount++;
		}
	}

	for (var i = 0; i < radio2Name.length; i++)
	{
		if (radio2Name[i].checked == true){
			num2Count++;
			totalPart1numCount++;
		}
	}

	for (var i = 0; i < radio3Name.length; i++)
	{
		if (radio3Name[i].checked == true){
			num3Count++;
			totalPart1numCount++;
		}
	}



	for (var i = 0; i < radio4Name.length; i++)
	{
		if (radio4Name[i].checked == true){
			num4Count++;
			totalPart2numCount ++;
		}
	}

//if no answers then error- done
//if they answer one of the 3 questions they must answer all
//then
//if they answer none of these questions they must answer the other one


	if (totalPart1numCount == 0 && totalPart2numCount == 0)
	{

		alert("You must answer the required questions relating to the Rehabilitation of offenders act 1974");
		document.form1.convictions[0].focus();
		return (false);
	}



	if (totalPart1numCount > 0 && totalPart1numCount < 3)
	{
		if (num1Count < 1){
			alert("Please state whether you have ever been convicted of a criminal offence by the courts, cautioned, reprimanded or given a final warning by the police (‘spent’ or unspent’)?");
			theForm.convictions[0].focus();
			return (false);}

		if (num2Count < 1){
			alert("Please state whether you have any police enquiries undertaken following allegations made against you");
			theForm.enquiries[0].focus();
			return (false);}

		if (num3Count < 1){
			alert("Please state whether you are disqualified from working with vulnerable adults or children");
			theForm.disqualified[0].focus();
			return (false);}


	}

	if (totalPart1numCount == 0 && totalPart2numCount != 1)
	{

			alert("Please state whether you have ever been convicted of a criminal offence (‘unspent’ only)?");
			document.form1.convictions_office[0].focus();

	}



	if (totalPart1numCount == 3 && totalPart2numCount == 1)
	{

		alert("You only need to answer the questions relating to working with vulnerable adults and children OR general post, but not both");
		document.form1.convictions_office[0].focus();
	    return (false);

	}


  if (theForm.statement.value == "")
  {
    alert("Please enter your supporting statememt.");
    theForm.statement.focus();
    return (false);
  }

  //media source

	if (theForm.selMediaSources.value == "")
	{
		alert("Please select where you saw this vacancy advertised");
		theForm.selMediaSources.focus();
		return (false);
	}

  //cv submit


  if (theForm.fileCV.value == "")
  {
    alert("Please select your CV by clicking on the browse button.");
    theForm.fileCV.focus();
    return (false);
  }

	var cvUpload = theForm.fileCV.value;
	var cvUploadlength =  theForm.fileCV.value.length;

	if (cvUploadlength > 0 )
	{
	var startPos = cvUploadlength - 4
	strCVExtension=cvUpload.slice(startPos,cvUploadlength)
		if ((strCVExtension != ".txt") && (strCVExtension != ".doc") && (strCVExtension != ".pdf") && (strCVExtension != ".rtf") && (strCVExtension != "docx"))
			{
				alert("Please upload plain text, rich text format, PDF or Word documents only for your CV")
				theForm.fileCV.focus()
				return false
			}
		}


  if (theForm.declaration.checked == false)
  {
    alert("You must agree to the declaration to submit this application");
    theForm.declaration.focus();
    return (false);
  }


  return (true);
}








function formValidatorVolunteers(theForm)
{

  if (theForm.name.value == "")
  {
    alert("Please enter a value in the name field.");
    theForm.name.focus();
    return (false);
  }

  if (theForm.cboHours.value == "*")
  {
    alert("Please select available hours from the drop down menu.");
    theForm.cboHours.focus();
    return (false);
  }

var checkboxWork = document.forms[1].areasofwork;
var numWorkSelected = 0;

for (var i = 0; i < checkboxWork.length; i++)
	{
		if (checkboxWork[i].checked == true){
		numWorkSelected++;}
	}

	if (numWorkSelected < 1){
		alert("Please select an area of work from the list provided");
		checkboxWork[0].focus();		
		return (false);}


var checkboxCategory = document.forms[1].category;
var numCategorySelected = 0;

for (var i = 0; i < checkboxCategory.length; i++)
	{
		if (checkboxCategory[i].checked == true){
		numCategorySelected++;}
	}

	if (numCategorySelected < 1){
		alert("Please select a job category from the list provided");
		checkboxCategory[0].focus();		
		return (false);}		

var checkboxRegion= document.forms[1].location;
var numRegionSelected = 0;

for (var i = 0; i < checkboxRegion.length; i++)
	{
		if (checkboxRegion[i].checked == true){
		numRegionSelected++;}
	}

	if (numRegionSelected < 1){
		alert("Please select a location from the list provided");
		checkboxRegion[0].focus();		
		return (false);}

return (true);
}








/*===========================================================================================================================*/


/*===========================================================================================================================*/

















function frmResetSelections()
{


$('input[name=convictions]').attr('checked',false);
$('input[name=enquiries]').attr('checked',false);
$('input[name=disqualified]').attr('checked',false);
$('input[name=convictions_office]').attr('checked',false);

}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}









function formValidatorJBEReg(theForm)
{



  if (theForm.name.value == "")
  {
    alert("Please enter your name in to the text field provided.");
    theForm.name.focus();
    return (false);
  }

  if (theForm.cbopermcontract.value == "0")
  {
    alert("Please select the type from the list provided.");
    theForm.cbopermcontract.focus();
    return (false);
  }
  
  if (theForm.cboSalaryRange.value == "0")
  {
    alert("Please select the salary range from the list provided.");
    theForm.cboSalaryRange.focus();
    return (false);
  }

var checkboxWork = theForm.areasofwork;
var numWorkSelected = 0;

for (var i = 0; i < checkboxWork.length; i++)
	{
		if (checkboxWork[i].checked == true){
		numWorkSelected++;}
	}

	if (numWorkSelected < 1){
		alert("Please select an area of work from the list provided");
		return (false);}


var checkboxCategory = theForm.category;
var numCategorySelected = 0;

for (var i = 0; i < checkboxCategory.length; i++)
	{
		if (checkboxCategory[i].checked == true){
		numCategorySelected++;}
	}

	if (numCategorySelected < 1){
		alert("Please select a job category from the list provided");
		return (false);}		

var checkboxRegion= theForm.region;
var numRegionSelected = 0;

for (var i = 0; i < checkboxRegion.length; i++)
	{
		if (checkboxRegion[i].checked == true){
		numRegionSelected++;}
	}

	if (numRegionSelected < 1){
		alert("Please select a location from the list provided");
		return (false);}
 
 return (true);
}









function formValidatorVolunteerLogon(theForm)
{

  if (theForm.txtEmail.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.txtEmail.focus();
    return (false);
  }
return (true);
}




function loadPage (location){

	window.location.href=location;

}








function formValidatorRegInterest(theForm)
{

  if (theForm.name.value == "")
  {
    alert("Please enter your name");
    theForm.name.focus();
    return (false);
  }



  var zToCheck;
  zToCheck = theForm.email.value;
  if (zToCheck.length < 7)
  {
    alert("An email address must be supplied. Please enter at least 7 character ");
    theForm.email.focus();
    return (false);
  }

  var zRegExp;
  zRegExp = "^[A-Za-z0-9_-]+[A-Za-z0-9_.-]*@[A-Za-z0-9]+[A-Za-z0-9_-]+[.][A-Za-z0-9_-]+[A-Za-z0-9_.-]*[A-Za-z0-9]+$";

  if (zToCheck.search(zRegExp) == -1)
  {
    alert("An email address must be supplied - please enter a valid EMAIL");
    theForm.email.focus();
    return (false);
  }



var checkboxCategory = theForm.whichrole;
var numCategorySelected = 0;

for (var i = 0; i < checkboxCategory.length; i++)
	{
		if (checkboxCategory[i].checked == true){
		numCategorySelected++;}
	}

	if (numCategorySelected < 1){
		alert("Please select a job role from the list provided");
		return (false);}		


  if (theForm.coveringletter.value == "")
  {
    alert("Please supply your covering letter");
    theForm.coveringletter.focus();
    return (false);
  }


//cv submit

  if (theForm.fileCV.value == "")
  {
    alert("Please select your CV by clicking on the browse button");
    theForm.fileCV.focus();
    return (false);
  }

	var cvUpload = theForm.fileCV.value;
	var cvUploadlength =  theForm.fileCV.value.length;

	if (cvUploadlength > 0 )
	{
	var startPos = cvUploadlength - 4
	strCVExtension=cvUpload.slice(startPos,cvUploadlength)
		if ((strCVExtension != ".txt") && (strCVExtension != ".doc") && (strCVExtension != ".pdf") && (strCVExtension != ".rtf") && (strCVExtension != "docx"))
			{
				alert("Please upload plain text, rich text format, PDF or Word documents only for your CV")
				theForm.fileCV.focus()
				return false
			}
		}


  return (true);
}



function formValidatorCVSubmitEqualOpp(theForm)
{
	
  //question one

		var checkboxName = theForm.ethnicgroup;
		var numEthicGroupselected = 0;
		var valEthicGroupselected = 0;
		
		for (var i = 0; i < checkboxName.length; i++)
			{
				if (checkboxName[i].checked == true){
				numEthicGroupselected++;
				valEthicGroupselected = checkboxName[i].value;
				}
			}
		



if (numEthicGroupselected == 0)
	{
			alert("Please state your ethinc group, or specify that you do not want to answer");
			theForm.ethnicgroup[0].focus();
			return (false);

	}

//now check the other fields
//if any of them is checked, and nothing entered into text field then alert



if ((valEthicGroupselected == "white_other") && (theForm.ethnicgroup_otherwhite.value == ""))
	{
			alert("You have selected 'other white' as your ethic group but have not specified, please correct");
			theForm.ethnicgroup_otherwhite.focus();
			return (false);		
	}

if ((valEthicGroupselected == "other_mixed") && (theForm.ethnicgroup_othermixed.value == ""))
	{
			alert("You have selected 'other mixed' as your ethic group but have not specified, please correct");
			theForm.ethnicgroup_othermixed.focus();
			return (false);		
	}

if ((valEthicGroupselected == "other_asian") && (theForm.ethnicgroup_otherasian.value == ""))
	{
			alert("You have selected 'other asian' as your ethic group but have not specified, please correct");
			theForm.ethnicgroup_otherasian.focus();
			return (false);		
	}

if ((valEthicGroupselected == "other_black") && (theForm.ethnicgroup_otherblack.value == ""))
	{
			alert("You have selected 'other black' as your ethic group but have not specified, please correct");
			theForm.ethnicgroup_otherblack.focus();
			return (false);		
	}

if ((valEthicGroupselected == "other_ethicgroup") && (theForm.ethnicgroup_other.value == ""))
	{
			alert("You have selected 'other ethic group' but have not specified, please correct");
			theForm.ethnicgroup_other.focus();
			return (false);		
	}


		var checkboxName = theForm.religiousgroup;
		var numReligiousGroupselected = 0;
		var valReligiousGroupselected = 0;
		
		for (var i = 0; i < checkboxName.length; i++)
			{
				if (checkboxName[i].checked == true){
				numReligiousGroupselected++;
				valReligiousGroupselected = checkboxName[i].value;
				}
			}


if (numReligiousGroupselected == 0)
	{
			alert("Please state your religious group, or specify that you do not want to answer");
			theForm.religiousgroup[0].focus();	
			return (false);		
	}


		var checkboxName = theForm.have_disability;
		var numDisabilityGroupselected = 0;
		var valDisabilityGroupselected = 0;
		
		for (var i = 0; i < checkboxName.length; i++)
			{
				if (checkboxName[i].checked == true){
				numDisabilityGroupselected++;
				valDisabilityGroupselected = checkboxName[i].value;
				}
			}



if ((valDisabilityGroupselected == "yes") && (theForm.disability_nature.value == ""))
	{
			alert("Please state the nature of your disability");
			theForm.disability_nature.focus();				
			return (false);		
	}




if (numDisabilityGroupselected == 0)
	{
			alert("Please state whether you have a disability, or specify that you do not want to answer");
			theForm.have_disability[0].focus();	
			return (false);		
	}



		var checkboxName = theForm.gender;
		var numGenderGroupselected = 0;
		var valGenderGroupselected = 0;
		
		for (var i = 0; i < checkboxName.length; i++)
			{
				if (checkboxName[i].checked == true){
				numGenderGroupselected++;
				valGenderGroupselected = checkboxName[i].value;
				}
			}


if (numGenderGroupselected == 0)
	{
			alert("Please state your gender, or specify that you do not want to answer");
			theForm.gender[0].focus();	
			return (false);		
	}


		var checkboxName = theForm.sexualorientation;
		var numSexualGroupselected = 0;
		var valSexualGroupselected = 0;
		
		for (var i = 0; i < checkboxName.length; i++)
			{
				if (checkboxName[i].checked == true){
				numSexualGroupselected++;
				valSexualGroupselected = checkboxName[i].value;
				}
			}


if (numSexualGroupselected == 0)
	{
			alert("Please state your sexual orientation, or decline to specify");
			theForm.sexualorientation[0].focus();
			return (false);		
	}





		var checkboxName = theForm.nationalidentity;
		var numNationlGroupselected = 0;
		var valNationalGroupselected = 0;
		
		for (var i = 0; i < checkboxName.length; i++)
			{
				if (checkboxName[i].checked == true){
				numNationlGroupselected++;
				valNationalGroupselected = checkboxName[i].value;
				}
			}


if (numNationlGroupselected == 0)
	{
			alert("Please state your national identity, or decline to specify");
			theForm.nationalidentity[0].focus();
			return (false);		
	}
	
	
	
if ((valNationalGroupselected == "national_other") && (theForm.othernationality.value == ""))
	{
			alert("Please specify your nationality");
			theForm.othernationality.focus();
			return (false);		
	}




		var checkboxName = theForm.maritalstatus;
		var numMaritalGroupselected = 0;
		var valMaritalGroupselected = 0;
		
		for (var i = 0; i < checkboxName.length; i++)
			{
				if (checkboxName[i].checked == true){
				numMaritalGroupselected++;
				valMaritalGroupselected = checkboxName[i].value;
				}
			}




if (numMaritalGroupselected == 0)
	{
			alert("Please state your marital status, or decline to specify");
			theForm.maritalstatus[0].focus();
			return (false);		
	}
	

	return true;
}



function validateRegInterest(theForm)
{
	
	
if (theForm.name.value == "")
	{
			alert("Please enter your name");
			theForm.name.focus();
			return (false);

	}
	
var zToCheck;
		  zToCheck = theForm.email.value;
		  if (zToCheck.length < 7)
		  {
			alert("An email address must be supplied. Please enter a VALID email address in the email address field");
			theForm.email.focus();
			return (false);
		  }

		  var zRegExp;
		  zRegExp = "^[A-Za-z0-9_-]+[A-Za-z0-9_.-]*@[A-Za-z0-9]+[A-Za-z0-9_-]+[.][A-Za-z0-9_-]+[A-Za-z0-9_.-]*[A-Za-z0-9]+$";

		  if (zToCheck.search(zRegExp) == -1)
		  {
			alert("An email address must be supplied. Please enter a VALID email address in the email address field");
			theForm.email.focus();
			return (false);
		  }
  //question one

  if (theForm.coveringletter.value == "")
  {
    alert("Please supply your covering letter");
    theForm.coveringletter.focus();
    return (false);
  }


//cv submit

  if (theForm.fileCV.value == "")
  {
    alert("Please select your CV by clicking on the browse button");
    theForm.fileCV.focus();
    return (false);
  }

	var cvUpload = theForm.fileCV.value;
	var cvUploadlength =  theForm.fileCV.value.length;

	if (cvUploadlength > 0 )
	{
	var startPos = cvUploadlength - 4
	strCVExtension=cvUpload.slice(startPos,cvUploadlength)
		if ((strCVExtension != ".txt") && (strCVExtension != ".doc") && (strCVExtension != ".pdf") && (strCVExtension != ".rtf") && (strCVExtension != "docx"))
			{
				alert("Please upload plain text, rich text format, PDF or Word documents only for your CV")
				theForm.fileCV.focus()
				return false
			}
		}


		var checkboxName = theForm.ethnicgroup;
		var numEthicGroupselected = 0;
		var valEthicGroupselected = 0;
		
		for (var i = 0; i < checkboxName.length; i++)
			{
				if (checkboxName[i].checked == true){
				numEthicGroupselected++;
				valEthicGroupselected = checkboxName[i].value;
				}
			}



if (numEthicGroupselected == 0)
	{
			alert("Please state your ethinc group, or specify that you do not want to answer");
			theForm.ethnicgroup[0].focus();
			return (false);

	}

//now check the other fields
//if any of them is checked, and nothing entered into text field then alert



if ((valEthicGroupselected == "white_other") && (theForm.ethnicgroup_otherwhite.value == ""))
	{
			alert("You have selected 'other white' as your ethic group but have not specified, please correct");
			theForm.ethnicgroup_otherwhite.focus();
			return (false);		
	}

if ((valEthicGroupselected == "other_mixed") && (theForm.ethnicgroup_othermixed.value == ""))
	{
			alert("You have selected 'other mixed' as your ethic group but have not specified, please correct");
			theForm.ethnicgroup_othermixed.focus();
			return (false);		
	}

if ((valEthicGroupselected == "other_asian") && (theForm.ethnicgroup_otherasian.value == ""))
	{
			alert("You have selected 'other asian' as your ethic group but have not specified, please correct");
			theForm.ethnicgroup_othermixed.focus();
			return (false);		
	}

if ((valEthicGroupselected == "other_black") && (theForm.ethnicgroup_otherblack.value == ""))
	{
			alert("You have selected 'other black' as your ethic group but have not specified, please correct");
			theForm.ethnicgroup_othermixed.focus();
			return (false);		
	}

if ((valEthicGroupselected == "other_ethicgroup") && (theForm.ethnicgroup_other.value == ""))
	{
			alert("You have selected 'other ethic group' but have not specified, please correct");
			theForm.ethnicgroup_other.focus();
			return (false);		
	}


		var checkboxName = theForm.religiousgroup;
		var numReligiousGroupselected = 0;
		var valReligiousGroupselected = 0;
		
		for (var i = 0; i < checkboxName.length; i++)
			{
				if (checkboxName[i].checked == true){
				numReligiousGroupselected++;
				valReligiousGroupselected = checkboxName[i].value;
				}
			}


if (numReligiousGroupselected == 0)
	{
			alert("Please state your religious group, or specify that you do not want to answer");
			theForm.religiousgroup[0].focus();	
			return (false);		
	}


		var checkboxName = theForm.have_disability;
		var numDisabilityGroupselected = 0;
		var valDisabilityGroupselected = 0;
		
		for (var i = 0; i < checkboxName.length; i++)
			{
				if (checkboxName[i].checked == true){
				numDisabilityGroupselected++;
				valDisabilityGroupselected = checkboxName[i].value;
				}
			}



if ((valDisabilityGroupselected == "yes") && (theForm.disability_nature.value == ""))
	{
			alert("Please state the nature of your disability");
			theForm.disability_nature.focus();				
			return (false);		
	}




if (numDisabilityGroupselected == 0)
	{
			alert("Please state whether you have a disability, or specify that you do not want to answer");
			theForm.have_disability[0].focus();	
			return (false);		
	}



		var checkboxName = theForm.gender;
		var numGenderGroupselected = 0;
		var valGenderGroupselected = 0;
		
		for (var i = 0; i < checkboxName.length; i++)
			{
				if (checkboxName[i].checked == true){
				numGenderGroupselected++;
				valGenderGroupselected = checkboxName[i].value;
				}
			}


if (numGenderGroupselected == 0)
	{
			alert("Please state your gender, or specify that you do not want to answer");
			theForm.gender[0].focus();	
			return (false);		
	}


		var checkboxName = theForm.sexualorientation;
		var numSexualGroupselected = 0;
		var valSexualGroupselected = 0;
		
		for (var i = 0; i < checkboxName.length; i++)
			{
				if (checkboxName[i].checked == true){
				numSexualGroupselected++;
				valSexualGroupselected = checkboxName[i].value;
				}
			}


if (numSexualGroupselected == 0)
	{
			alert("Please state your sexual orientation, or decline to specify");
			theForm.sexualorientation[0].focus();
			return (false);		
	}





		var checkboxName = theForm.nationalidentity;
		var numNationlGroupselected = 0;
		var valNationalGroupselected = 0;
		
		for (var i = 0; i < checkboxName.length; i++)
			{
				if (checkboxName[i].checked == true){
				numNationlGroupselected++;
				valNationalGroupselected = checkboxName[i].value;
				}
			}


if (numNationlGroupselected == 0)
	{
			alert("Please state your national identity, or decline to specify");
			theForm.nationalidentity[0].focus();
			return (false);		
	}
	
	
	
if ((valNationalGroupselected == "national_other") && (theForm.othernationality.value == ""))
	{
			alert("Please specify your nationality");
			theForm.othernationality.focus();
			return (false);		
	}




		var checkboxName = theForm.maritalstatus;
		var numMaritalGroupselected = 0;
		var valMaritalGroupselected = 0;
		
		for (var i = 0; i < checkboxName.length; i++)
			{
				if (checkboxName[i].checked == true){
				numMaritalGroupselected++;
				valMaritalGroupselected = checkboxName[i].value;
				}
			}




if (numMaritalGroupselected == 0)
	{
			alert("Please state your marital status, or decline to specify");
			theForm.maritalstatus[0].focus();
			return (false);		
	}
	

	return true;	
}
