function ShowObj(objMID) {
	document.getElementById(objMID).style.display='';
}
function HideObj(objMID) {
	document.getElementById(objMID).style.display='none';
}

function enableExpand(theForm, condition, expandid) {
	if(document.getElementById){
		//thisbrowser="NN6";
		bebacklayer = document.getElementById(expandid);
	}
	if (document.all) {
		//thisbrowser="ie"
		bebacklayer = document.all[expandid];
	}
	if (bebacklayer) {
		if (condition == true) {	
			bebacklayer.style.display = "block";
		} else {	
			bebacklayer.style.display = "none";
		}
	}
}

function initpage() {
	 selectJob(document.pt);
	 enableRegistered(document.pt);
	 enableTrading(document.pt);
	 enableIntend(document.pt);
	 enableApprovedSponsor(document.pt);
	 enableDuplicateLoginMessage(document.pt);
}

// Is your company currently registered as a business in Australia?
function enableRegistered(theForm) {
	if (theForm.registered_company[0].checked) {			//Yes
		 enableExpand(theForm, false, 'trading');
		 enableExpand(theForm, false, 'intend');
		 enableExpand(theForm, true, 'registered1');
		 enableExpand(theForm, true, 'registered2');
		 enableExpand(theForm, true, 'common1');
		 enableExpand(theForm, true, 'common2');
		 enableExpand(theForm, true, 'common3');
		 enableExpand(theForm, true, 'common4');
		 enableExpand(theForm, true, 'common5');
		 enableExpand(theForm, true, 'common6');
		 enableExpand(theForm, true, 'common7');
		 enableExpand(theForm, true, 'common8');
		 
		 enableExpand(theForm, true, 'approvedSponsor');
		 enableExpand(theForm, true, 'haveCandidate');
		 
		 enableExpand(theForm, false, 'intend_start1');
		 enableExpand(theForm, false, 'intend_start2');
		 enableExpand(theForm, false, 'intend_start3');
		 theForm.company_name.focus();
		 if (theForm.intend_to_start_company[0].checked) { 
		 		theForm.intend_to_start_company[0].checked=false;
		 }
		 if (theForm.intend_to_start_company[1].checked) { 
		 		theForm.intend_to_start_company[1].checked=false;
		 }
		 if (theForm.trading_australia[0].checked) { 
		 		theForm.trading_australia[0].checked=false;
		 }
		 if (theForm.trading_australia[1].checked) { 
		 		theForm.trading_australia[1].checked=false;
		 }		 
	}
	else if (theForm.registered_company[1].checked) {  // No
		 enableExpand(theForm, true, 'trading');
     enableExpand(theForm, false, 'registered1');
		 enableExpand(theForm, false, 'registered2');		 
		 enableExpand(theForm, false, 'common1');
		 enableExpand(theForm, false, 'common2');
		 enableExpand(theForm, false, 'common3');
		 enableExpand(theForm, false, 'common4');
		 enableExpand(theForm, false, 'common5');
		 enableExpand(theForm, false, 'common6');
		 enableExpand(theForm, false, 'common7');
		 enableExpand(theForm, false, 'common8');
		 
		 enableExpand(theForm, false, 'approvedSponsor');
		 enableExpand(theForm, false, 'sponsorApprovalNumber');
		 enableExpand(theForm, false, 'numberNominations');
		 enableExpand(theForm, false, 'haveCandidate');
		 
		 enableExpand(theForm, false, 'intend_start1');
		 enableExpand(theForm, false, 'intend_start2');
		 enableExpand(theForm, false, 'intend_start3');
		 
		 if (theForm.approved_sponsor[0].checked) { 
		 		theForm.approved_sponsor[0].checked=false;
		 }
		 if (theForm.approved_sponsor[1].checked) { 
		 		theForm.approved_sponsor[1].checked=false;
		 }
		 
		 if (theForm.have_candidate[0].checked) { 
		 		theForm.have_candidate[0].checked=false;
		 }
		 if (theForm.have_candidate[1].checked) { 
		 		theForm.have_candidate[1].checked=false;
		 }
	}
	else {
		 enableExpand(theForm, false, 'trading');
     enableExpand(theForm, false, 'registered1');
		 enableExpand(theForm, false, 'registered2');
		 enableExpand(theForm, false, 'common1');
		 enableExpand(theForm, false, 'common2');
		 enableExpand(theForm, false, 'common3');
		 enableExpand(theForm, false, 'common4');
		 enableExpand(theForm, false, 'common5');
		 enableExpand(theForm, false, 'common6');
		 enableExpand(theForm, false, 'common7');
		 enableExpand(theForm, false, 'common8');
		 
		 enableExpand(theForm, false, 'approvedSponsor');
		 enableExpand(theForm, false, 'sponsorApprovalNumber');
		 enableExpand(theForm, false, 'numberNominations');
		 enableExpand(theForm, false, 'haveCandidate');
		 
		 enableExpand(theForm, false, 'intend');
		 enableExpand(theForm, false, 'intend_start1');
		 enableExpand(theForm, false, 'intend_start2');
		 enableExpand(theForm, false, 'intend_start3');		 
	}
}

// Do you have any company trading in Australia?
function enableTrading(theForm) {	
	if (theForm.trading_australia[0].checked) {   //Yes
		 enableExpand(theForm, false, 'intend');
		 enableExpand(theForm, true, 'registered1');
		 enableExpand(theForm, true, 'registered2');
		 enableExpand(theForm, true, 'common1');
		 enableExpand(theForm, true, 'common2');
		 enableExpand(theForm, true, 'common3');
		 enableExpand(theForm, true, 'common4');
		 enableExpand(theForm, true, 'common6');
		 enableExpand(theForm, true, 'common7');
		 enableExpand(theForm, true, 'common8');
		 enableExpand(theForm, true, 'common5');
		 enableExpand(theForm, false, 'intend_start1');
		 enableExpand(theForm, false, 'intend_start2');
		 enableExpand(theForm, false, 'intend_start3');
		 theForm.company_name.focus();
		 if (theForm.intend_to_start_company[0].checked) { 
		 		theForm.intend_to_start_company[0].checked=false;
		 }
		 if (theForm.intend_to_start_company[1].checked) { 
		 		theForm.intend_to_start_company[1].checked=false;
		 }
	}
	else if (theForm.trading_australia[1].checked) {   //No
		 enableExpand(theForm, true, 'intend');
		 enableExpand(theForm, false, 'registered1');
		 enableExpand(theForm, false, 'registered2');
		 enableExpand(theForm, false, 'common1');
		 enableExpand(theForm, false, 'common2');
		 enableExpand(theForm, false, 'common3');
		 enableExpand(theForm, false, 'common4');
		 enableExpand(theForm, false, 'common5');
		 enableExpand(theForm, false, 'common6');
		 enableExpand(theForm, false, 'common7');
		 enableExpand(theForm, false, 'common8');
	}
}
//Do you intend to start a company in Australia?
function enableIntend(theForm) {
	if (theForm.intend_to_start_company[0].checked) { //Yes
		 enableExpand(theForm, true, 'intend_start1');
		 enableExpand(theForm, true, 'intend_start2');
		 enableExpand(theForm, true, 'intend_start3');
		 enableExpand(theForm, true, 'common1');
		 enableExpand(theForm, true, 'common2');
		 enableExpand(theForm, true, 'common3');
		 enableExpand(theForm, true, 'common4');
		 enableExpand(theForm, true, 'common5');
		 enableExpand(theForm, true, 'common6');
		 enableExpand(theForm, true, 'common7');
		 enableExpand(theForm, true, 'common8');
	}
	else if (theForm.intend_to_start_company[1].checked) { //No
		 enableExpand(theForm, false, 'intend_start1');
		 enableExpand(theForm, false, 'intend_start2');
		 enableExpand(theForm, false, 'intend_start3');
		 enableExpand(theForm, false, 'common1');
		 enableExpand(theForm, false, 'common2');
		 enableExpand(theForm, false, 'common3');
		 enableExpand(theForm, false, 'common4');
		 enableExpand(theForm, false, 'common5');
		 enableExpand(theForm, false, 'common6');
		 enableExpand(theForm, false, 'common7');
		 enableExpand(theForm, false, 'common8');
	}
}

//Are you currently an approved sponsor by the Department of Immigration and Multicultural Affairs?
function enableApprovedSponsor(theForm) {
	if (theForm.approved_sponsor[0].checked) { //Yes
		 enableExpand(theForm, true, 'sponsorApprovalNumber');
		 enableExpand(theForm, true, 'numberNominations');
	}
	else if (theForm.approved_sponsor[1].checked) { //No
		 enableExpand(theForm, false, 'sponsorApprovalNumber');
		 enableExpand(theForm, false, 'numberNominations');
	}
}

function checkOtherOccupation(theForm){
	if (theForm.monthsofemployment[1].checked){
			enableExpand(theForm, true, 'Out1details31');
		}
		
	else{
			enableExpand(theForm, false, 'Out1details31');
		}
}//function

/*function selectJob(theForm) {
	if (theForm.occupationCategoryHidden.value != "" && theForm.occupationHidden.value != "") {
		selectSelection(theForm.occupationCategory, theForm.occupationCategoryHidden.value);
		selectOccupation(theForm);
		selectSelection(theForm.occupation, theForm.occupationHidden.value);
	}
}*/

function isValidEmailAddr(inputStr){
		// check for the @ char
			var atPos=inputStr.indexOf("@",0);
			var spacePos=inputStr.indexOf(" ",0);
		
			if (spacePos>0)
			{ // no spaces allow
				return false;
			}	
			else if (atPos<0)
			{ // invalid or no @
				return false;
			}
			else
			{
				var pointPos=inputStr.indexOf(".",atPos);
			 	if (pointPos==-1){// not found
				return false;
			}
			else if (pointPos==inputStr.length-1)
			{ // last position
				return false;
			}
		}
		return true;
}

//Validate personal details (name, username, password, email)
function validatePersonalDetails(theForm) {
	 if (theForm.contact_firstname.value == "") {
		alert("Please specify your first name.");
		theForm.contact_firstname.focus();
		return false;
	}
	else {			
		firstname = theForm.contact_firstname.value;		
		for (i=0;i<firstname.length;i++) {
			c = firstname.substring(i,i+1);
			if (c == ";") {
				  alert("First name cannot have ';'");
				  theForm.contact_firstname.focus();
				  return false;
			 }
			 if (c == ",") {
			 		alert("First name cannot have ','");
					theForm.contact_firstname.focus();
					return false;
			 }
	  }
	}
	
	if (theForm.contact_surname.value == ""){
			alert("Please specify your last name.");
			theForm.contact_surname.focus();
			return false;
	}
	else {
		surname = theForm.contact_surname.value;		
		for (i=0;i<surname.length;i++) {
			c = surname.substring(i,i+1);
			if (c == ";") {
			   alert("Last name cannot have ';'");
			   theForm.contact_surname.focus();
			   return false;
		 	}
		 	if (c == ",") {
		 		 alert("Last name cannot have ','");
				 theForm.contact_surname.focus();
				 return false;
		 	}
	  }
	}

	if (theForm.email.value == ""){
			alert("Please specify your email address.");
			theForm.email.focus();
			return false;
	} 
		else if (!isValidEmailAddr(theForm.email.value)){
			alert("Your first email address does not seem to be correct.");
			theForm.email.focus();
			theForm.email.select();
			return false;
	}

	login = theForm.customerLogin.value;
	if (login.length < 6 || login.length > 20) {
		alert("Username has to be 6 - 20 characters");
		theForm.customerLogin.focus();
		return false;
		} else {
			for (i=0;i<login.length;i++) {
				c = login.substring(i,i+1);
				if (c == " ") {
					alert("Login cannot have any spaces");
					theForm.customerLogin.focus();
					return false;
				}
				if (c == "'") {
					alert("Login cannot have '");
					theForm.customerLogin.focus();
					return false;
				}
			}			
		}
		password = theForm.customerPassword.value;
		password2 = theForm.customerPasswordConfirmation.value;
		if (password.length < 6 || password.length > 12) {
			alert("Password has to be 6 - 12 characters");
			theForm.customerPassword.focus();
			return false;
		} else {
			for (i=0;i<password.length;i++) {
				c = password.substring(i,i+1);
				if (c == " ") {
					alert("Password can't have any spaces");
					theForm.customerPassword.focus();
					return false;
				}
				if (c == "'") {
					alert("Password cannot have '");
					theForm.customerPassword.focus();
					return false;
				}
			}
		}
		if (password != password2) {
			alert("Password and retype have to be the same");
			theForm.customerPasswordConfirmation.focus();
			return false;
		}
		return true;
}

		 
// Validate form when submitted (for new assessment)
// for retaking assessment, use validateFormRetake
function validateForm(theForm){
	if ((theForm.registered_company[0].checked == false) && (theForm.registered_company[1].checked == false)) {
		alert("Please specify if your company is currently registered as a business in Australia");
		theForm.registered_company[0].focus();
		return false;
	}
	// If registered company, or not registered company but has company trading in Australia
	if ((theForm.registered_company[0].checked) || (theForm.registered_company[1].checked && theForm.trading_australia[0].checked)) {		 
		 if (theForm.company_name.value=="") {
		 		alert("Please provide the name of the sponsoring company");
				theForm.company_name.focus();
				return false;
		 }		 
		 if (theForm.abn.value.length<14) {
		 		alert("ABN should be 14 digits including spaces");
				theForm.abn.focus();
				return false;
		 }
		 if (theForm.number_employee.value=="0") {
		 		alert("Please specify how many employees do you have");
				theForm.number_employee.focus();
				return false;
		 }	
		 if (theForm.trading_period.value=="0") {
		 		alert("Please specify how long the company has been trading");
				theForm.trading_period.focus();
				return false;
		 }
		 if (theForm.turnover.value=="0") {
		 		alert("Please provide the annual Turn over of the company");
				theForm.turnover.focus();
				return false;
		 } 
		 if (theForm.training[0].checked==false && theForm.training[1].checked==false) {
		 		alert("Please state if the company has a formal Training Procedure Documented");
				theForm.training[0].focus();
				return false;
		 } 
		 if (theForm.training_cost.value=="0") {
		 		alert("Please specify how much did you spend in Training last financial year");
				theForm.training_cost.focus();
				return false;
		 }
		 if (theForm.occupationCategory.value == "-1") {
		 		alert("Please select the occupation category");
		 		theForm.occupationCategory.focus();
		 		return false;
		 }
	
		 var index=theForm.occupation.options[theForm.occupation.selectedIndex].value.indexOf("|");
		 if (index<0){
		 		alert("Please select the occupation");
				theForm.occupation.focus();
				return false;
		 }
		 
		 if (theForm.approved_sponsor[0].checked==false && theForm.approved_sponsor[1].checked==false) {
		 		alert("Please specify whether you are currently an approved sponsor by the Department of Immigration and Multicultural Affairs");
				theForm.approved_sponsor[1].focus();
				return false;
		 }
		 
		 if (theForm.approved_sponsor[0].checked==true) {
		 		if (theForm.sponsor_approval_number.value=="") {
					 alert("Please provide your sponsorship approval number");
					 theForm.sponsor_approval_number.focus();
					 return false;
				}
				if (theForm.number_nominations.value=="") {
					 alert("Please provide how many nomitations you have left to use");
					 theForm.number_nominations.focus();
					 return false;
				}		 
		 }
		 
		 if (theForm.intend_number_employees.value=="0") {
		 		alert("Please specify how many employees are you looking at sponsoring in the next two (2) years");
				theForm.intend_number_employees.focus();
				return false;
		 }
		 
		 if (theForm.have_candidate[0].checked==false && theForm.have_candidate[1].checked==false) {
		 		alert("Please specify if you already have someone in mind to fill a position in your company");
				theForm.have_candidate[1].focus();
				return false;
		 }
		 
		 if (theForm.intend_industry_sector.value=="0") {
		 		alert("Please specify what industry sector will you be involved in");
				theForm.intend_industry_sector.focus();
				return false;
		 }		 
	}
	
	if ((theForm.registered_company[1].checked) && (theForm.trading_australia[0].checked==false && theForm.trading_australia[1].checked==false)) {
		alert("Please state if you have any company trading in Australia");
		theForm.registered_company[1].focus();
		return false;
	}
	
	if ((theForm.trading_australia[1].checked) && (theForm.intend_to_start_company[0].checked==false && theForm.intend_to_start_company[1].checked==false)) {
		alert("Please state if are intending to start a company in Australia");
		theForm.trading_australia[1].focus();
		return false;
	}
	
	// If intending to register a company in Australia
	if (theForm.intend_to_start_company[0].checked) {
		 if (theForm.when_intend_to_register_company.value=="0") {
		 		alert("Please specify when do you intend on registering the company");
				theForm.when_intend_to_register_company.focus();
				return false;
		 }
		 if (theForm.intend_company_location.value=="") {
		 		alert("Please specify where are you looking at locating the company");
				theForm.intend_company_location.focus();
				return false;
		 }
		 // Validate questions related to the Offshore company
		 if (theForm.number_employee.value=="0") {
		 		alert("Please specify how many employees do you have");
				theForm.number_employee.focus();
				return false;
		 }	
		 if (theForm.trading_period.value=="0") {
		 		alert("Please specify how long the company has been trading");
				theForm.trading_period.focus();
				return false;
		 }
		 if (theForm.turnover.value=="0") {
		 		alert("Please provide the annual Turn over of the company");
				theForm.turnover.focus();
				return false;
		 } 
		 if (theForm.training[0].checked==false && theForm.training[1].checked==false) {
		 		alert("Please state if the company has a formal Training Procedure Documented");
				return false;
		 } 
		 if (theForm.training_cost.value=="0") {
		 		alert("Please specify how much did you spend in Training last financial year");
				theForm.training_cost.focus();
				return false;
		 }
		 if (theForm.occupationCategory.value == "-1") {
		 		alert("Please select the occupation category");
		 		theForm.occupationCategory.focus();
		 		return false;
		 }
	
		 var index=theForm.occupation.options[theForm.occupation.selectedIndex].value.indexOf("|");
		 if (index<0){
		 		alert("Please select the occupation");
				theForm.occupation.focus();
				return false;
		 }
		 
		 if (theForm.approved_sponsor[0].checked==false && theForm.approved_sponsor[1].checked==false) {
		 		alert("Please specify whether you are currently an approved sponsor by the Department of Immigration and Multicultural Affairs");
				theForm.approved_sponsor[1].focus();
				return false;
		 }
		 
		 if (theForm.approved_sponsor[0].checked==true) {
		 		if (theForm.sponsor_approval_number.value=="") {
					 alert("Please provide your sponsorship approval number");
					 theForm.sponsor_approval_number.focus();
					 return false;
				}
				if (theForm.number_nominations.value=="") {
					 alert("Please provide how many nomitations you have left to use");
					 theForm.number_nominations.focus();
					 return false;
				}		 
		 }
		 
		 if (theForm.intend_number_employees.value=="0") {
		 		alert("Please specify how many employees are you looking at sponsoring in the next two (2) years");
				theForm.intend_number_employees.focus();
				return false;
		 }
		 
		 if (theForm.have_candidate[0].checked==false && theForm.have_candidate[1].checked==false) {
		 		alert("Please specify if you already have someone in mind to fill a position in your company");
				theForm.have_candidate[1].focus();
				return false;
		 }
		 
		 if (theForm.intend_industry_sector.value=="0") {
		 		alert("Please specify what industry sector will you be involved in");
				theForm.intend_industry_sector.focus();
				return false;
		 }
	}
	
	return validatePersonalDetails(theForm);
	return true;
} //validateForm(theForm)


// for retaking assessment, use validateFormRetake
function validateFormRetake(theForm){		
	// do not validate firstname, lastname, username, password, email	
	if ((theForm.registered_company[0].checked == false) && (theForm.registered_company[1].checked == false)) {
		alert("Please specify if your company is currently registered as a business in Australia");
		theForm.registered_company[0].focus();
		return false;
	}
	// If registered company, or not registered company but has company trading in Australia
	if ((theForm.registered_company[0].checked) || (theForm.registered_company[1].checked && theForm.trading_australia[0].checked)) {		 
		 if (theForm.company_name.value=="") {
		 		alert("Please provide the name of the sponsoring company");
				theForm.company_name.focus();
				return false;
		 }		 
		 if (theForm.abn.value.length<14) {
		 		alert("ABN should be 14 digits including spaces");
				theForm.abn.focus();
				return false;
		 }
		 if (theForm.number_employee.value=="0") {
		 		alert("Please specify how many employees do you have");
				theForm.number_employee.focus();
				return false;
		 }	
		 if (theForm.trading_period.value=="0") {
		 		alert("Please specify how long the company has been trading");
				theForm.trading_period.focus();
				return false;
		 }
		 if (theForm.turnover.value=="0") {
		 		alert("Please provide the annual Turn over of the company");
				theForm.turnover.focus();
				return false;
		 } 
		 if (theForm.training[0].checked==false && theForm.training[1].checked==false) {
		 		alert("Please state if the company has a formal Training Procedure Documented");
				theForm.training[0].focus();
				return false;
		 } 
		 if (theForm.training_cost.value=="0") {
		 		alert("Please specify how much did you spend in Training last financial year");
				theForm.training_cost.focus();
				return false;
		 }
		 if (theForm.occupationCategory.value == "-1") {
		 		alert("Please select the occupation category");
		 		theForm.occupationCategory.focus();
		 		return false;
		 }
	
		 var index=theForm.occupation.options[theForm.occupation.selectedIndex].value.indexOf("|");
		 if (index<0){
		 		alert("Please select the occupation");
				theForm.occupation.focus();
				return false;
		 }
		 
		 if (theForm.approved_sponsor[0].checked==false && theForm.approved_sponsor[1].checked==false) {
		 		alert("Please specify whether you are currently an approved sponsor by the Department of Immigration and Multicultural Affairs");
				theForm.approved_sponsor[1].focus();
				return false;
		 }
		 
		 if (theForm.approved_sponsor[0].checked==true) {
		 		if (theForm.sponsor_approval_number.value=="") {
					 alert("Please provide your sponsorship approval number");
					 theForm.sponsor_approval_number.focus();
					 return false;
				}
				if (theForm.number_nominations.value=="") {
					 alert("Please provide how many nomitations you have left to use");
					 theForm.number_nominations.focus();
					 return false;
				}		 
		 }
		 
		 if (theForm.intend_number_employees.value=="0") {
		 		alert("Please specify how many employees are you looking at sponsoring in the next two (2) years");
				theForm.intend_number_employees.focus();
				return false;
		 }
		 
		 if (theForm.have_candidate[0].checked==false && theForm.have_candidate[1].checked==false) {
		 		alert("Please specify if you already have already located someone to fill the required position in your company");
				theForm.have_candidate[1].focus();
				return false;
		 }
		 
		 if (theForm.intend_industry_sector.value=="0") {
		 		alert("Please specify what industry sector will you be involved in");
				theForm.intend_industry_sector.focus();
				return false;
		 }		 
	}
	
	if ((theForm.registered_company[1].checked) && (theForm.trading_australia[0].checked==false && theForm.trading_australia[1].checked==false)) {
		alert("Please state if you have any company trading in Australia");
		theForm.registered_company[1].focus();
		return false;
	}
	
	if ((theForm.trading_australia[1].checked) && (theForm.intend_to_start_company[0].checked==false && theForm.intend_to_start_company[1].checked==false)) {
		alert("Please state if are intending to start a company in Australia");
		theForm.trading_australia[1].focus();
		return false;
	}
	
	// If intending to register a company in Australia
	if (theForm.intend_to_start_company[0].checked) {
		 if (theForm.when_intend_to_register_company.value=="0") {
		 		alert("Please specify when you intend to register the company");
				theForm.when_intend_to_register_company.focus();
				return false;
		 }
		 if (theForm.intend_company_location.value=="") {
		 		alert("Please specify where are you intending to locate the company");
				theForm.intend_company_location.focus();
				return false;
		 }
		 // Validate questions related to the Offshore company
		 if (theForm.number_employee.value=="0") {
		 		alert("Please specify how many employees do you have");
				theForm.number_employee.focus();
				return false;
		 }	
		 if (theForm.trading_period.value=="0") {
		 		alert("Please specify how long the company has been trading");
				theForm.trading_period.focus();
				return false;
		 }
		 if (theForm.turnover.value=="0") {
		 		alert("Please indicate the annual turnover of the company");
				theForm.turnover.focus();
				return false;
		 } 
		 if (theForm.training[0].checked==false && theForm.training[1].checked==false) {
		 		alert("Please state if the company has a formal Training Procedure Documented");
				return false;
		 } 
		 if (theForm.training_cost.value=="0") {
		 		alert("Please estimate how much you spent on training and/ or staff development during the last financial year");
				theForm.training_cost.focus();
				return false;
		 }
		 if (theForm.occupationCategory.value == "-1") {
		 		alert("Please select the occupation category");
		 		theForm.occupationCategory.focus();
		 		return false;
		 }
	
		 var index=theForm.occupation.options[theForm.occupation.selectedIndex].value.indexOf("|");
		 if (index<0){
		 		alert("Please select the occupation");
				theForm.occupation.focus();
				return false;
		 }
		 
		 if (theForm.approved_sponsor[0].checked==false && theForm.approved_sponsor[1].checked==false) {
		 		alert("Please specify whether you are currently an approved sponsor by the Department of Immigration and Multicultural Affairs");
				theForm.approved_sponsor[1].focus();
				return false;
		 }
		 
		 if (theForm.approved_sponsor[0].checked==true) {
		 		if (theForm.sponsor_approval_number.value=="") {
					 alert("Please provide your sponsorship approval number");
					 theForm.sponsor_approval_number.focus();
					 return false;
				}
				if (theForm.number_nominations.value=="") {
					 alert("Please tell us how many nominations you still have available");
					 theForm.number_nominations.focus();
					 return false;
				}		 
		 }
		 
		 if (theForm.intend_number_employees.value=="0") {
		 		alert("Please specify how many employees do you expect to sponsor in the next two (2) years");
				theForm.intend_number_employees.focus();
				return false;
		 }
		 
		 if (theForm.have_candidate[0].checked==false && theForm.have_candidate[1].checked==false) {
		 		alert("Please specify if you already have already located someone to fill the required position in your company");
				theForm.have_candidate[1].focus();
				return false;
		 }
		 
		 if (theForm.intend_industry_sector.value=="0") {
		 		alert("Please specify which industry sector will you be involved in");
				theForm.intend_industry_sector.focus();
				return false;
		 }
	}	
	return true;
} //validateFormRetake(theForm)


function selectSelection(s, v) {
	if (v != "") {
        for(var i=0; i<s.length; i++) {
			if (s.options[i].value == v) {
				s[i].selected = true;
			} else {
				s[i].selected = false;
			}
        }
	}
}
// Check for duplicate username once the login input text is out of focus
function validateLogin(suserid, firstname, surname) {

if(suserid=="") {
  //alert("Please specify a username.");
	return false;  // blank username, stop processing
}

document.body.style.cursor='wait';

// Create an instance of the XML HTTP Request object
var oXMLHTTP = new ActiveXObject( "Microsoft.XMLHTTP" );
	
// Prepare the XMLHTTP object for a HTTP POST to our validation ASP page
var sURL = "../../../validateLogin.asp?login=" + suserid + "&contact_firstname=" + firstname + "&contact_surname=" + surname
oXMLHTTP.open( "POST", sURL, false );

// Execute the request
oXMLHTTP.send();

if (oXMLHTTP.responseText == "exists") {
	 	 //alert("Login " + suserid + " already exists.");
	 	 ShowObj('duplicateLogin');
		 HideObj('duplicateLoginSameUser');
	 }
else if (oXMLHTTP.responseText == "exists_same_user") {
 	 	 //alert("You have already created an account");
	 	 ShowObj('duplicateLoginSameUser');
		 HideObj('duplicateLogin');
	 }
else {
	 	 HideObj('duplicateLogin');
	 	 HideObj('duplicateLoginSameUser');
	 }
document.body.style.cursor='auto';
}

// Check for duplicate email once the email input text is out of focus
function validateEmail(emailaddress, firstname, surname) {

if(emailaddress=="") {
  //alert("Please specify your e-mail address.");
	return false;  // blank email, stop processing
}

document.body.style.cursor='wait';

// Create an instance of the XML HTTP Request object
var oXMLHTTP = new ActiveXObject( "Microsoft.XMLHTTP" );
	
// Prepare the XMLHTTP object for a HTTP POST to our validation ASP page
var sURL = "../../../validateEmail.asp?email=" + emailaddress + "&contact_firstname=" + firstname + "&contact_surname=" + surname

oXMLHTTP.open( "POST", sURL, false );

// Execute the request
oXMLHTTP.send();

if (oXMLHTTP.responseText == "exists") {
	 	 //alert("Email " + emailaddress + " already exists.");
	 	 ShowObj('duplicateEmail');
		 HideObj('duplicateEmailSameUser');
	 }
else if (oXMLHTTP.responseText == "exists_same_user") {
 	 	 //alert("You have already created an account");
	 	 ShowObj('duplicateEmailSameUser');
		 HideObj('duplicateEmail');
	 }
else {
	 	 HideObj('duplicateEmail');
	 	 HideObj('duplicateEmailSameUser');
	 }

document.body.style.cursor='auto';
}

function enableDuplicateLoginMessage(theForm) {
	HideObj('duplicateLogin');
	HideObj('duplicateLoginSameUser');
	HideObj('duplicateEmail');
	HideObj('duplicateEmailSameUser');
}

