function proceed(){
	return isEmpty( "application", new Array('App1SName','App1GName','App1DOB'), new Array('Surname Name','Given Name','Date of Birth') );	
}
function isEmpty(szFormName,arElements,arDisplay){
	var szEmptyError = "";
	var nFirstErrorIndex = 0;
	try{
		for(var i=0; i<arElements.length; i++){
			if(document.forms[szFormName].elements[ arElements[i] ].value==""){
				szEmptyError 		+= "- "+arDisplay[i]+"\n";
				nFirstErrorIndex = i;
			}
		}
	}catch(E){
		alert( "Form Validation Error: isEmpty()" );	
	}
	if(szEmptyError!=""){
		alert( 	"Please Fill in the following(s)\n"+
						"==================\n"+
						szEmptyError);
		try{
			document.forms[szFormName].elements[ arElements[nFirstErrorIndex] ].focus();
		}catch(E){}
		return false;
	}
	return true;
}
function hide_previous_address(nApp) {
	try{
		years = document.forms["application"].elements["App"+nApp+"HomeAddressPeriod"].value;
		pos1=years.indexOf(".")
		if( years!="" && pos1==-1) {
			years = years+".0";
			document.forms["application"].elements["App"+nApp+"HomeAddressPeriod"].value = years;
		}
		if( years=="" ){
			document.forms["application"].elements["App"+nApp+"HomeAddressPeriod"].value = "";
			document.getElementById("prevaddress"+nApp).style.display="none";
		}else{
			document.forms["application"].elements["App"+nApp+"HomeAddressPeriod"].value = years;
			if(years >= "2.0") {
				document.getElementById("prevaddress"+nApp).style.display="none";
			} else {
				document.getElementById("prevaddress"+nApp).style.display="block";
			}
		}
	}catch(E){}
}
function hide_previous_employee() {
	try{
		length1 = document.forms["application"].elements["LengthofService"].value;
		pos1=length1.indexOf(".")
		if( length1!="" && pos1==-1) {
			length1 = length1+".0";
			document.forms["application"].elements["LengthofService"].value = length1;
		}
		if( length1=="" ){
				document.getElementById("exemployee1").style.display="none";
		}else{
			if(length1 >= "2.0") {
				document.getElementById("exemployee1").style.display="none";
			} else {
				document.getElementById("exemployee1").style.display="block";
			}
		}
	}catch(E){}
}
function hide_app2_previous_employee() {
	try{
		length1 = document.forms["application"].elements["App2LengthofService"].value;
		pos1=length1.indexOf(".")
		if( length1!="" && pos1==-1) {
			length1 = length1+".0";
			document.forms["application"].elements["LengthofService"].value = length1;
		}
		if( length1=="" ){
			document.forms["application"].elements["App2LengthofService"].value = "";
		}else{
			document.forms["application"].elements["App2LengthofService"].value = length1;
			if(length1 >= "2.0") {
				document.getElementById("exemployee2").style.display="none";
			} else {
				document.getElementById("exemployee2").style.display="block";
			}
		}
	}catch(E){}
}
function selectborrower(intNumBorrower, strHash){
	if(intNumBorrower == 1 ){
		borrower2(false);
	}else if(intNumBorrower==2){
		borrower2(true);
	}else{
		if(confirm('Are you sure the number of borrower is '+intNumBorrower+'?\nIf you click OK, you will be logged out from current application form and redirected to another application form')){
		self.location = 'http://application.trustar.com.au/online/index.php?page=A1';
		}
	}
}
function borrower2(bShow) {
	if(bShow) {
		document.getElementById("borrower2").style.display="block";
	} else {
		document.getElementById("borrower2").style.display="none";
	}
}
function copyAddress(){
	try{
		document.forms["application"].elements["App2HomeAddressStreet"].value = document.forms["application"].elements["App1HomeAddressStreet"].value
		document.forms["application"].elements["App2HomeAddressSuburb"].value = document.forms["application"].elements["App1HomeAddressSuburb"].value
		document.forms["application"].elements["App2HomeAddressState"].value = document.forms["application"].elements["App1HomeAddressState"].value
		document.forms["application"].elements["App2HomeAddressPostCode"].value = document.forms["application"].elements["App1HomeAddressPostCode"].value
		document.forms["application"].elements["App2HomeAddressPeriod"].value = document.forms["application"].elements["App1HomeAddressPeriod"].value
		document.forms["application"].elements["App2PreviousAddressStreet"].value = document.forms["application"].elements["App1PreviousAddressStreet"].value
		document.forms["application"].elements["App2PreviousAddressSuburb"].value = document.forms["application"].elements["App1PreviousAddressSuburb"].value
		document.forms["application"].elements["App2PreviousAddressState"].value = document.forms["application"].elements["App1PreviousAddressState"].value
		document.forms["application"].elements["App2PreviousAddressSuburb"].value = document.forms["application"].elements["App1PreviousAddressSuburb"].value
		document.forms["application"].elements["App2PreviousAddressPostCode"].value = document.forms["application"].elements["App1PreviousAddressPostCode"].value
		document.forms["application"].elements["App2PreviousAddressPeriod"].value = document.forms["application"].elements["App1PreviousAddressPeriod"].value
		hide_previous_address(2);
	}catch(E){}
}
function set( FormElementName, FormElementValue ){
	try{
		document.application.elements[FormElementName].value = FormElementValue;
	}catch(E){}
}