// JavaScript Document
function isEmail(strValue) 
{
 var objRegExp = /^[a-z]\w*([.\-]\w+)*@[a-z]\w*([.\-]\w+)*\.[a-z]{2,4}$/i;

 return objRegExp.test(strValue);

}

function validate_regist()
{
	
	
	var why1 = "";
	
	var frm		= document.ChronoContact_self_assessment;
	
	if((frm.title[0].checked == false) && (frm.title[1].checked == false) && (frm.title[2].checked == false) && (frm.title[3].checked == false) && (frm.title[4].checked == false))
	{
 		why1+='You have not filled in question 1<br/>';	 
 	}
	
	if(frm.name.value == ""){
 		why1+='You have not filled in question 2<br/>';	 
 	}
	
	if(frm.surname.value == ""){
 		why1+='You have not filled in question 3<br/>';	 
 	}

	if(isEmail(frm.email.value)==''){

		why1+='You have not filled in question 4<br/>';
		
	}
	
	if(isEmail(frm.re_email.value)==''){

		why1+='You have not filled in question 5<br/>';
		
	}
	
	
	if((frm.re_email.value) != (frm.email.value))
	{

		why1+='Email address not matching<br/>';
		
	}
	
	
	if(frm.dobDay.value==0 || frm.dobMonth.value==0 || frm.dobYear.value==0)
	{

		why1+='You have not filled in question 6<br/>';
		
	}
	
	
	if(frm.country_residence.value=='')
	{
		why1+='You have not filled in question 7<br/>';		
	}
	
	if(frm.country_citizen.value=='')
	{
		why1+='You have not filled in question 8<br/>';		
	}
	
	if((frm.passport[0].checked == false) && (frm.passport[1].checked == false))
	{
		why1+='You have not filled in question 9<br/>';		
	}
	
	if(frm.english_ability.value=='')
	{
		why1+='You have not filled in question 10<br/>';		
	}

	
 	if(why1!="")
	{
	showDialog('Alert',why1,'warning');
	return false;
	}
 
}

function  gotofocus()
{
	var frm		= document.ChronoContact_self_assessment;
	
		
	if((frm.title[0].checked == false) && (frm.title[1].checked == false) && (frm.title[2].checked == false) && (frm.title[3].checked == false) && (frm.title[4].checked == false))
	{
		document.getElementById('title0').focus(); 
	}
	
	else if(frm.name.value == ""){
		frm.name.focus(); 
	}
	
	else if(frm.surname.value == "")
	{
		frm.surname.focus();
	}
	
	else if(isEmail(frm.email.value)==''){

		frm.email.focus();
		
	}
	
	else if(isEmail(frm.re_email.value)==''){

		frm.re_email.focus();
		
	}
	
	else if((frm.re_email.value) != (frm.email.value))
	{
		frm.re_email.focus();
		
	}
	
	else if(frm.dobDay.value==0 || frm.dobMonth.value==0 || frm.dobYear.value==0)
	{

		frm.dobDay.focus();
		
	}
	else if(frm.country_residence.value=='')
	{
		frm.country_residence.focus();
	}
	else if(frm.country_citizen.value=='')
	{
		frm.country_citizen.focus();	
	}
	
	else if((frm.passport[0].checked == false) && (frm.passport[1].checked == false))
	{
		document.getElementById('passport0').focus();
	}
	
	
	
	else if(frm.english_ability.value=='')
	{
		frm.english_ability.focus();
	}	
}



function AjaxFunction(email)
{
var httpxml;
try
{
// Firefox, Opera 8.0+, Safari
httpxml=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
httpxml=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
httpxml=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
function stateck()
{
if(httpxml.readyState==4)
{
document.getElementById("msg").innerHTML=httpxml.responseText;

}
}
var url="email-ajax.php";
url=url+"?email="+email;
url=url+"&sid="+Math.random();
httpxml.onreadystatechange=stateck;
httpxml.open("GET",url,true);
httpxml.send(null);
}


function AjaxFunction1(email)
{
var httpxml;
try
{
// Firefox, Opera 8.0+, Safari
httpxml=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
httpxml=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
httpxml=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
function stateck()
{
if(httpxml.readyState==4)
{
document.getElementById("msg1").innerHTML=httpxml.responseText;

}
}
var url="email-ajax.php";
url=url+"?email="+email;
url=url+"&sid="+Math.random();
httpxml.onreadystatechange=stateck;
httpxml.open("GET",url,true);
httpxml.send(null);
}





function validate_qualification()
{
	
	var why1 = "";
	
	var frm		= document.self_assessment_qualification;
	
	//alert(frm.marital_status.selectedIndex);
	
	if(frm.industry.selectedIndex == 0)
	{
		why1+='You have not filled in question 11<br/>';		
	}
	
	if(frm.occupation.selectedIndex == 0)
	{
		why1+='You have not filled in question 12<br/>';		
	}
	
	if((frm.related_occupation[0].checked == false) && (frm.related_occupation[1].checked == false))
	{
		why1+='You have not filled in question 13<br/>';	
	}
	
	if((frm.job_offer[0].checked == false) && (frm.job_offer[1].checked == false))
	{
		why1+='You have not filled in question 14<br/>';	
	}
	
	if((frm.lastyears[0].checked == false) && (frm.lastyears[1].checked == false) && (frm.lastyears[2].checked == false))
	{
		why1+='You have not filled in question 15<br/>';		
	}
	
	if(frm.nominate_refer.selectedIndex == 0)
	{
		why1+='You have not filled in question 16<br/>';		
	}
	
	if(frm.marital_status.selectedIndex == 0)
	{
		why1+='You have not filled in question 17<br/>';		
	}

	if(frm.marital_status.selectedIndex == 2 || frm.marital_status.selectedIndex == 6 || frm.marital_status.selectedIndex == 7 || frm.marital_status.selectedIndex == 8 || frm.marital_status.selectedIndex == 9) 
	{
		if(frm.dobDay.value==0 || frm.dobMonth.value==0 || frm.dobYear.value==0)
		{	
			why1+='You have not filled in question 17a<br/>';					
		}
		if(frm.spouse_language.value == 0)
		{
			why1+='You have not filled in question 17b<br/>';		
		}
		if(frm.spouse_industry.value == 0)
		{
			why1+='You have not filled in question 17c<br/>';		
		}
		if(frm.spouse_occupation.selectedIndex == 0)
		{
			why1+='You have not filled in question 17d<br/>';		
		}
		if((frm.spouse_skilled[0].checked == false) && (frm.spouse_skilled[1].checked == false))
		{
			why1+='You have not filled in question 17e<br/>';		
		}
	}
	
	if(frm.marital_status.selectedIndex != 1 && frm.marital_status.selectedIndex != 0)
	{
		if((frm.children_details[0].checked == false) && (frm.children_details[1].checked == false))
		{
			why1+='You have not filled in question 17f<br/>';		
		}
	}

	
	
 	if(why1!="")
	{
	showDialog1('Alert',why1,'warning');
	return false;
	}
 
}

function  gotofocus1()
{
	var frm		= document.self_assessment_qualification;
	
	if(frm.industry.selectedIndex == 0)
	{
		frm.industry.focus();
	}
	
	else if(frm.occupation.selectedIndex == 0)
	{
		frm.occupation.focus();	
	}
	
	else if((frm.related_occupation[0].checked == false) && (frm.related_occupation[1].checked == false))
	{
		document.getElementById('related_occupation1').focus(); 
	}
	
	else if((frm.job_offer[0].checked == false) && (frm.job_offer[1].checked == false))
	{
		document.getElementById('job_offer0').focus(); 	
	}
	
	else if((frm.lastyears[0].checked == false) && (frm.lastyears[1].checked == false) && (frm.lastyears[2].checked == false))
	{
		document.getElementById('lastyears0').focus(); 
	}
	
	else if(frm.nominate_refer.selectedIndex == 0)
	{
		document.getElementById('nominate_refer').focus(); 
	}
	
	else if(frm.marital_status.selectedIndex == 0)
	{
		document.getElementById('marital_status').focus(); 
	}
	
	else if(frm.marital_status.selectedIndex == 2 || frm.marital_status.selectedIndex == 6 || frm.marital_status.selectedIndex == 7 || frm.marital_status.selectedIndex == 8 || frm.marital_status.selectedIndex == 9) 
	{
		if(frm.dobDay.value==0 || frm.dobMonth.value==0 || frm.dobYear.value==0)
		{
			frm.dobDay.focus();			
		}
		else if(frm.spouse_language.value == 0)
		{
			frm.spouse_language.focus();	
		}
		else if(frm.spouse_industry.value == 0)
		{
			frm.spouse_industry.focus();		
		}
		else if(frm.spouse_occupation.selectedIndex == 0)
		{
			frm.spouse_occupation.focus();		
		}
		else if((frm.spouse_skilled[0].checked == false) && (frm.spouse_skilled[1].checked == false))
		{
			document.getElementById('spouse_skilled0').focus();	
		}
	}
	
	else if(frm.marital_status.selectedIndex != 1)
	{
		if((frm.children_details[0].checked == false) && (frm.children_details[1].checked == false))
		{
			document.getElementById('children_details0').focus();	
		}
	}

	
}











function validate_general()
{
	
	var why1 = "";
	
	var frm		= document.self_assessment_qualification;


	if(frm.australia_study_details[0].checked == false && frm.australia_study_details[1].checked == false)
	{
		why1+='You have not filled in question 18<br/>';		
	}
	if(frm.australia_study_details[0].checked == true)
	{
		if(frm.highest_qualification.value == '0')
		{
			why1+='You have not filled in question 18a<br/>';		
		}
		if(frm.study_australia.value == '0')
		{
			why1+='You have not filled in question 18b<br/>';		
		}
		if(frm.dobMonth.value==0 || frm.dobYear.value==0)
		{
			why1+='You have not filled in question 18c<br/>';	
		}
		if(frm.regional_area.value == '0')
		{
			why1+='You have not filled in question 18d<br/>';		
		}
	}
	
	if(frm.australia_occupation[0].checked == false && frm.australia_occupation[1].checked == false)
	{
		why1+='You have not filled in question 19<br/>';		
	}
	
	if(frm.fluent_english[0].checked == false && frm.fluent_english[1].checked == false)
	{
		why1+='You have not filled in question 20<br/>';		
	}
	
	if(frm.fluent_english[0].checked == true && frm.fluent_english[1].checked == false)
	{
		if(document.getElementById('other_language').value == '')
		{
			why1+='You have not filled in question 20a<br/>';		
		}
		
		if(frm.NAATI[0].checked == false && frm.NAATI[1].checked == false && frm.NAATI[2].checked == false)
		{
			why1+='You have not filled in question 20b<br/>';		
		}
	}
	
	
	
	
	if(frm.nominate_region.value == "")
	{
		why1+="You have not filled in question 21<br/>";		
	}
	
	if(frm.nominate_region.value != "Not Applicable")
	{	
		if(frm.sponsor.value == "")
		{
			why1+='You have not filled in question 22<br/>';		
		}	
	}
	
	if(frm.spouse_dob.value != '0/0/0')
	{	
		if(frm.spouse_sponsor.value == "")
		{
			why1+='You have not filled in question 23<br/>';		
		}
	}

	if(frm.spouse_sponsor.value != "Not Applicable")
	{
		if(frm.sponsor_statement.value == "")
		{
			why1+='You have not filled in question 24<br/>';		
		}
	}
	
	
	if(frm.read_agree.checked == false)
	{
		why1+='You have not read and agreed<br/>';		
	}
	

 	if(why1!="")
	{
	showDialog2('Alert',why1,'warning');
	return false;
	}
 
}

function  gotofocus2()
{
	var frm		= document.self_assessment_qualification;
	
	if(frm.australia_study_details[0].checked == false && frm.australia_study_details[1].checked == false)
	{
		document.getElementById('australia_study_details1').focus();	
	}
	
	
	else if(frm.australia_study_details[0].checked == true)
	{
		if(frm.highest_qualification.value == '0')
		{
			frm.highest_qualification.focus();	
		}
		else if(frm.study_australia.value == '0')
		{
			frm.study_australia.focus();	
		}	
		else if(frm.dobMonth.value==0 || frm.dobYear.value==0)
		{
			frm.dobMonth.focus();	
		}
		else if(frm.regional_area.value == '0')
		{
			frm.regional_area.focus();	
		}
	}
	
	else if(frm.fluent_english[0].checked == false && frm.fluent_english[1].checked == false)
	{
		document.getElementById('fluent_english0').focus();
	}
	
	else if(frm.fluent_english[0].checked == true && frm.fluent_english[1].checked == false)
	{
		if(document.getElementById('other_language').value == '')
		{
			document.getElementById('other_language').focus();	
		}
		
		else if(frm.NAATI[0].checked == false && frm.NAATI[1].checked == false && frm.NAATI[2].checked == false)
		{
			document.getElementById('NAATI').focus();
		}
	
	}
	
	
	
	
	else if(frm.nominate_region.value == "")
	{
		frm.nominate_region.focus();	
	}
	else if(frm.nominate_region.value != "Not Applicable")
	{
	
		if(frm.sponsor.value == "")
		{
			frm.sponsor.focus();	
		}
		else if(frm.spouse_dob.value != '0/0/0')
		{	
			if(frm.spouse_sponsor.value == "")
			{
				frm.spouse_sponsor.focus();	
			}
		}	
		else if(frm.sponsor_statement.value == "")
		{
			frm.sponsor_statement.focus();	
		}
	}
	
	else if(frm.read_agree.checked == false)
	{
		frm.read_agree.focus();	
	}
	
	
	
}

function showLanguage()
{
	document.getElementById('language_other').style.display = 'block';
}
function hideLanguage()
{
	document.getElementById('language_other').style.display = 'none';
}



function selectMaritalstatus(statusVal)
{

	if(statusVal == "Married" || statusVal == "De Facto (living together but not married)" || statusVal == "Interdependent relationship" || statusVal == "Engaged to be married & not living together" || statusVal == "Engaged to be married & living together")
	{
		document.getElementById('marital1').style.display = "block";
	}
	else
	{
		document.getElementById('marital1').style.display = "none";
	}
	
	if(statusVal == "Single/Never Married" || statusVal == 0)
	{
		document.getElementById('children_handle').style.display = "none";
	}
	else
	{
		document.getElementById('children_handle').style.display = "block";
	}
	
}


function displayQualification()
{
	document.getElementById('qualification').style.display = "block";

}
function displayQualification1()
{
	document.getElementById('qualification').style.display = "none";

}

function setValidation(setValue)
{
	if(setValue == "Not Applicable")
	{
		document.self_assessment_qualification.sponsor.disabled  = true;
		document.self_assessment_qualification.sponsor.value = "";
	}
	else
	{
		document.self_assessment_qualification.sponsor.disabled  = false;
	}
	
	
}

function setValidationSponsor(setValue)
{

	var sponsorVal = document.self_assessment_qualification.sponsor.value;

	//alert(sponsorVal);

	if(setValue == "Not Applicable" && sponsorVal == "Not Applicable")
	{
		document.self_assessment_qualification.sponsor_statement.disabled  = true;
		document.self_assessment_qualification.sponsor_statement.value = "";
	}
	else
	{		
		document.self_assessment_qualification.sponsor_statement.disabled  = false;
	}
	
	
}