function ShowObj(objMID) {
	document.getElementById(objMID).style.display='';
}
function HideObj(objMID) {
	document.getElementById(objMID).style.display='none';
}
function initpage() {
	checkBusinessCatagory(document.bu);
	}
function pageReloadCheckAll() {
	checkBusinessCatagory(document.bu);
	enableKeyDrivers(document.bu);
	showQuestion(document.bu.intentionality.value);
	checkServiceSelectionReason(document.bu);
}
function writeSpouseOrPartnerDescriptor(theForm) {
	if ((theForm.marital_status.value == "single") ||(theForm.marital_status.value == "separated") ||(theForm.marital_status.value == "divorced") ||(theForm.marital_status.value == "widowed") ) {
		document.getElementById('spouseOrPartnerDescriptor').innerHTML='your ';
	} else {
		if (theForm.marital_status.value == "married") {
			document.getElementById('spouseOrPartnerDescriptor').innerHTML='you and your spouse`s ' ;
		} else {
			document.getElementById('spouseOrPartnerDescriptor').innerHTML='you and your partner`s ';
		}
	}
}

function writeSpousOrPartnerDescriptor(theForm) {
	if ((theForm.marital_status.value == "single") ||(theForm.marital_status.value == "separated") ||(theForm.marital_status.value == "divorced") ||(theForm.marital_status.value == "widowed") ) {
		document.getElementById('spousOrPartnerDescriptor').innerHTML='your ';
	} else {
		if (theForm.marital_status.value == "married") {
			document.getElementById('spousOrPartnerDescriptor').innerHTML='you and your spouse`s ';
		} else {
			document.getElementById('spousOrPartnerDescriptor').innerHTML='you and your partner`s ';
		}
	}
}


function writePartnerDescriptor(theForm) {
	if ((theForm.marital_status.value == "single") ||(theForm.marital_status.value == "separated") ||(theForm.marital_status.value == "divorced") ||(theForm.marital_status.value == "widowed") ) {
		document.getElementById('partnerDescriptor').innerHTML='your ';
	} else {
		if (theForm.marital_status.value == "married") {
			document.getElementById('partnerDescriptor').innerHTML='you and your spouse`s ';
		} else {
			document.getElementById('partnerDescriptor').innerHTML='you and your partner`s ';
		}
	}
}

function checkBusinessCatagory(theForm) {

	if(theForm.business_category[0].checked) {
		ShowObj('8b');
		ShowObj('9b');
		ShowObj('10b');
		ShowObj('11ba');
		ShowObj('11bb');
		ShowObj('5a');
		ShowObj('6a');
		HideObj('8e');
		HideObj('9e');
		HideObj('10e');
		HideObj('8i');
		HideObj('9i');
		HideObj('5ea');
		HideObj('5eb');
		HideObj('6eb');

	}
		
	if(theForm.business_category[1].checked){
		ShowObj('8e');
		ShowObj('9e');
		ShowObj('10e');
		ShowObj('5a');
		ShowObj('6a');
		HideObj('8i');
		HideObj('9i');
		HideObj('8b');
		HideObj('9b');
		HideObj('10b');
		HideObj('11ba');
		HideObj('11bb');
		HideObj('5ea');
		HideObj('5eb');
		HideObj('6eb');
	}
	
	if(theForm.business_category[2].checked){
		ShowObj('8i');
		ShowObj('9i');
		ShowObj('5a');
		ShowObj('6a');
		HideObj('8e');
		HideObj('9e');
		HideObj('10e');
		HideObj('8b');
		HideObj('9b');
		HideObj('10b');
		HideObj('11ba');
		HideObj('11bb');
		HideObj('5ea');
		HideObj('5eb');
		HideObj('6eb');

	}

if(theForm.business_category[3].checked){

		ShowObj('5ea');
		ShowObj('5eb');
		ShowObj('6eb');
		HideObj('8i');
		HideObj('9i');
		HideObj('8e');
		HideObj('9e');
		HideObj('10e');
		HideObj('8b');
		HideObj('9b');
		HideObj('10b');
		HideObj('11ba');
		HideObj('11bb');
		HideObj('5a');
		HideObj('6a');
}


if (theForm.business_category[4].checked){
		HideObj('8i');
		HideObj('9i');
		HideObj('8e');
		HideObj('9e');
		HideObj('10e');
		HideObj('8b');
		HideObj('9b');
		HideObj('10b');
		HideObj('11ba');
		HideObj('11bb');
		HideObj('5a');
		HideObj('6a');
		HideObj('5ea');
		HideObj('5eb');
		HideObj('6eb');
	}

}

function checkPointSubmit(theForm, showLogin) {
	if (showLogin) {
		if (theForm.first_name.value==""){
			alert("Question 1: Please specify your first name.");
			theForm.first_name.focus();
			return false;
		}
		if (theForm.sur_name.value==""){
			alert("Question 3: Please specify your surname.");
			theForm.sur_name.focus();
			return false;
		}		
		
		//Q3 E-mail address
			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;
			}
		
		email = theForm.email.value;
		email2 = theForm.emailConfirmation.value;
		
		if (email2=="") {
			alert("Please verify your e-mail address.");
			theForm.emailConfirmation.focus();
			return false;
		}
		else {
			if (email != email2) {
				alert("Your e-mail address do not match.");
				theForm.emailConfirmation.focus();
				return false;
			}
		}
		
		//Q4 Username	
		customer_login = theForm.customer_login.value;
		if (customer_login.length < 6 || customer_login.length > 20) {
			alert("Username has to be 6 - 20 characters");
			theForm.customer_login.focus();
			return false;
			} else {
				for (i=0;i<customer_login.length;i++) {
					c = customer_login.substring(i,i+1);
					if (c == " ") {
						alert("Login can't have any spaces");
						theForm.customer_login.focus();
						return false;
					}
					if (c == "'") {
						alert("Login can't have '");
						theForm.customer_login.focus();
						return false;
					}
				}			
			}
			password = theForm.customer_password.value;
			password2 = theForm.customer_password_confirmation.value;
			if (password.length < 6 || password.length > 12) {
				alert("Password has to be 6 - 12 characters");
				theForm.customer_password.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.customer_password.focus();
						return false;
					}
					if (c == "'") {
						alert("Password can't have '");
						theForm.customer_password.focus();
						return false;
					}
				}
			}
			if (password != password2) {
				alert("Password and retype have to be the same");
				theForm.customer_password_confirmation.focus();
				return false;
			}
		}
		
		
//Q7 Date of Birth
/*
		if (theForm.age.value==""){
			alert("Please select your age.");
			theForm.age.focus();
			return false;
		}
*/		
		if (theForm.dobDay.value==0) {
			 alert("Please select your date of birth.");
			 theForm.dobDay.focus();
			 return false;
		}
		
		if (theForm.dobMonth.value==0) {
			 alert("Please select the month of your birthday.");
			 theForm.dobMonth.focus();
			 return false;
		}
		
		if (theForm.dobYear.value==0) {
			 alert("Please select the year of your birthday.");
			 theForm.dobYear.focus();
			 return false;
		}
		
		switch(parseInt(theForm.dobMonth.value,10))
		{
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:
				if(parseInt(theForm.dobDay.value,10) < 1 || parseInt(theForm.dobDay.value,10) > 31)
				{
					alert("Please enter a valid date of birth.");
					theForm.dobDay.focus();
					return false;
				}
				break;
			case 4:
			case 6:
			case 9:
			case 11:
				if(parseInt(theForm.dobDay.value,10) < 1 || parseInt(theForm.dobDay.value,10) > 30)
				{
					alert("Please enter a valid date of birth.");
					theForm.dobDay.focus();
					return false;
				}
				break;
			case 2:
				maxDobDay = 28;
				if(parseInt(theForm.dobYear.value,10) % 4 == 0)
				{
					maxDobDay = 29;
				}
				if(parseInt(theForm.dobDay.value,10) < 1 || parseInt(theForm.dobDay.value,10) > maxDobDay)
				{
					alert("Please enter a valid date of birth.");
					theForm.dobDay.focus();
					return false;
				}
				break;
		}
	
//Q8
	if (theForm.english.value == "") {
		alert("Question 9: Please specify your engilsh ability.");
		theForm.english.focus();
		return false;
	}
//Q9
	if (theForm.marital_status.value == "") {
		alert("Question 10: Please specify your marital status.");
		theForm.marital_status.focus();
		return false;
	}
//Q9 for business owner
if ((theForm.personal_assets.value == "")&& (theForm.business_category[0].checked)) {
		alert("Question 13: Please specify your personal assets.");
		theForm.personal_assets.focus();
		return false;
	}
	//Q9 for executive
if ((theForm.personal_assets.value == "")&& (theForm.business_category[1].checked)) {
		alert("Question 13: Please specify your personal assets.");
		theForm.personal_assets.focus();
		return false;
	}//Q9 for investor
if ((theForm.personal_assets.value == "")&& (theForm.business_category[2].checked)) {
		alert("Question 13: Please specify your personal assets.");
		theForm.personal_assets.focus();
		return false;
	}

	//Q11 Business Personal
	if ((theForm.approximate_turnover_business.value == "") && (theForm.business_category[0].checked)) {
		alert("Question 15: Please specify your approximate turnover of your business(es).");
		theForm.approximate_turnover_business.focus();
		return false;
	}
	//Q14 Business Personal
	if ((theForm.statement_suits.value == "") && (theForm.business_category[0].checked)) {
		alert("Question 18: Please specify your statement that best suits you.");
		theForm.statement_suits.focus();
		return false;
	}

	//Q11 Executive Personal
	if ((theForm.company_turnover.value == "") && (theForm.business_category[1].checked)) {
		alert("Question 15: Please specify your company turnover.");
		theForm.company_turnover.focus();
		return false;
	}
	//Q12 Executive Personal
	if ((theForm.senior_position.value == "") && (theForm.business_category[1].checked)) {
		alert("Question 16: Please specify your senior position in company.");
		theForm.senior_position.focus();
		return false;
		if (theForm.senior_position.value=="other"){
			alert("Question 16: Please specify your other senior position in company.");
			theForm.othersenior_position.focus();
			return false;
			}
	}
	
	//Q11

	if((theForm.business_category[0].checked) || (theForm.business_category[1].checked) || (theForm.business_category[2].checked)){
		if((!theForm.business_in_australia[0].checked) && (!theForm.business_in_australia[1].checked) && (!theForm.business_in_australia[2].checked)) {
			alert("Question 11: Please specify if you are committed to start business in Australia.");
			theForm.business_in_australia[0].focus();
			return false;
		}
	}
	
		if((!theForm.business_category[0].checked) && (!theForm.business_category[1].checked) && (!theForm.business_category[2].checked)&& (!theForm.business_category[3].checked)&& (!theForm.business_category[4].checked)) {
			alert("Question 10: Please specify your business category.");
			theForm.business_category[0].focus();
			return false;
	}
	
	if (theForm.business_category[3].checked){
		if((!theForm.business_preestablished[0].checked) && (!theForm.business_preestablished[1].checked) && (!theForm.business_preestablished[2].checked)) {
			alert("Question 11: Please specify if your business details.");
			theForm.business_preestablished[0].focus();
			return false;
		}
	}
	
	if (theForm.business_category[0].checked){
		if((!theForm.involved_inoverall_performance[0].checked) && (!theForm.involved_inoverall_performance[1].checked)) {
			alert("Question 11: Please specify if you were involved in overall performance of your business.");
			theForm.involved_inoverall_performance[0].focus();
			return false;
		}
		else{
		if((!theForm.approximate_netvalue[0].checked) && (!theForm.approximate_netvalue[1].checked)){
			alert("Question 15: Please specify approximate net value of your business assets");
			theForm.approximate_netvalue[0].focus();
			return false;
		}
		}

	}
	//Q13 Executive Personal
	if ((theForm.management_above.value == "") && (theForm.business_category[1].checked)) {
		alert("Question 17: Please specify management levels above you.");
		theForm.management_above.focus();
		return false;
	}

	//Q11 Investor level
	if ((theForm.directly_managing_business.value == "") && (theForm.business_category[2].checked)) {
		alert("Question 15: Please specify your business investments.");
		theForm.directly_managing_business.focus();
		return false;
	}
	
	//Q12 Investor level
	if ((theForm.ownership_interest.value == "") && (theForm.business_category[2].checked)) {
		alert("Question 16: Please specify your ownership interest of business.");
		theForm.ownership_interest.focus();
		return false;
	}
	if((theForm.net_value.value == "") && (theForm.business_category[2].checked)){
		alert("Question 16: Please specify net Value of your business assets.");
		theForm.net_value.focus();
		return false;
	}
	if (theForm.intentionality.value == "0") {
		alert("Please tell us how far into the immigration process you are currently.");
		theForm.intentionality.focus();
		return false;
	}
	
	
	/*
	if (theForm.intentionality.value="10" && theForm.intentionality_other.value=="") {
		alert("Please tell us how far into the immigration process you are currently.");
		theForm.intentionality_other.focus();
		return false;
	}
	*/	
	
	if (theForm.txt_key_drivers.value == "0") {
		alert("Please specify what key factor would allow you to proceed further.");
		theForm.txt_key_drivers.focus();
		return false;
	}
	
	/*
	if (theForm.txt_key_drivers.value="12" && theForm.key_drivers_other.value=="") {
		alert("Please specify what key factor would allow you to proceed further.");
		theForm.key_drivers_other.focus();
		return false;
	}
	*/
	
	if (!(theForm.help_prepare_visa.checked || theForm.prepare_on_behalf.checked || theForm.specific_aspects.checked || theForm.help_moving.checked || theForm.help_job.checked || theForm.info_life.checked || theForm.service_guide_other.checked)) {
		alert("Please specify in what key way(s) would you like us to assist you.");
		return false;
	}
	
	if (theForm.service_guide_other.checked && theForm.service_guide_other_text.value=="") {
		alert("Please specify in what key way(s) would you like us to assist you.");
		theForm.service_guide_other_text.focus();
		return false;
	}
	return true;
}

// functions used for intentionality, key drivers and service selection guide question at the end of assessment page

function checkIntentionalityReason(theForm)
{
	if(theForm.intentionality.value == "10")
	{
		ShowObj("intentionality_other");
		theForm.intentionality_other.focus();
	}
	else
	{
		HideObj("intentionality_other");
	}
}

function checkKeyDriversReason(theForm)
{
	if(theForm.txt_key_drivers.value == "12")
	{
		ShowObj("key_drivers_other");
		theForm.key_drivers_other.focus();
	}
	else
	{
		HideObj("key_drivers_other");
	}
}

function checkServiceSelectionReason(theForm)
{
	if(theForm.service_guide_other.checked)
	{
		ShowObj("service_guide_other_text");
		theForm.service_guide_other_text.focus();
	}
	else
	{		
		HideObj("service_guide_other_text");
	}
}

function showQuestion(str)
{ 
	checkIntentionalityReason(document.bu);	
	enableKeyDrivers(document.bu);	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="/onlineassessments/include/getKeyDrivers.asp"
	url=url+"?q="+str
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}	
	
function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("txt_key_drivers").innerHTML=xmlHttp.responseText 
	} 
} 
	
function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}			
	return objXMLHttp
}

function enableKeyDrivers(theForm) {
	var str = new String() ;

	if(document.getElementById){
		//thisbrowser="NN6";
		bebacklayer = document.getElementById("key_drivers");
	}
	if (document.all) {
		//thisbrowser="ie"
		bebacklayer = document.all["key_drivers"];
	}

	if (bebacklayer) {
		if (theForm.intentionality.value != "0") {	
			bebacklayer.style.display = "block";
		} else {	
			bebacklayer.style.display = "none";
		}
	}
}

// end function for intentionality and key drivers question at the end of assessment page