var intSubmitCount=0;
function trim(strVar) {
	while(strVar.charAt(0)==" ") {
		strVar=strVar.substring(1,strVar.length);
	}
	while(strVar.charAt(strVar.length-1)==" ") {
		strVar=strVar.substring(0,strVar.length-1);
	}
	return strVar;
}
function CheckSoleTrader() {
	if(document.getElementById("cboCompanyType").value == "1001") {
		if(trim(document.getElementById("txtPDHFirstName").value)!="") {
			if(trim(document.getElementById("txtQSFN1").value)=="") {
				document.getElementById("txtQSFN1").value=document.getElementById("txtPDHFirstName").value
			}
	}
		if(trim(document.getElementById("txtPDHLastName").value)!="") {
			if(trim(document.getElementById("txtQSLN1").value)=="") {
				document.getElementById("txtQSLN1").value=document.getElementById("txtPDHLastName").value
			}
		}
	}
}

function GetAddress(sectionvar){
	var redirect;
	var strValue;
	if ( sectionvar=='1') {
		redirect="postcodeclear.asp";
		redirect=redirect+"?BusinessAddress=" + document.getElementById("txtaddress1").value;
		redirect=redirect+"&BusinessPostcode=" + document.getElementById("txtPostCode").value;
	} else {
		var strcINVALID_POSTCODE_CHARACTERS="[^A-Za-z0-9 ]" // \x20 equates to char(32) in hex
		if (trim(document.getElementById("txtPostCodeSearch").value) == "") {
			alert("Please enter a postcode");
			document.getElementById("txtPostCodeSearch").focus();
			return(false);
		} else {
			strValue=new String(trim(document.getElementById("txtPostCodeSearch").value));
			if (strValue.search(new RegExp(strcINVALID_POSTCODE_CHARACTERS))!=-1) {
				alert("The Postcode must only contain the following: Letters (a..z), Numbers (0..9), Spaces ( )");
				document.getElementById("txtPostCodeSearch").focus();
				return(false);
			}
		}
		redirect="postcodesearch.asp";
		redirect=redirect+"?BusinessAddress=" + document.getElementById("txtAddressSearch").value;
		redirect=redirect+"&BusinessPostcode=" + document.getElementById("txtPostCodeSearch").value;
	}
	document.location=redirect;
	return (false);
}
function checklimited(control){    
	if(control.value=="1000") {
		document.getElementById("txtCompanyRegNoText").style.display = "block";
	} else {
		document.getElementById("txtCompanyRegNoText").style.display = "none";
	}
}

function checkHowFoundOut(control){
	if(control.value=="{178C6579-04A4-4119-892A-9A86001ECA08}") {
		document.getElementById("div_txt_how_found_out").style.display = "block";
	} else {
		document.getElementById("div_txt_how_found_out").style.display = "none";
	}
}

//--------------------------------------------------------------------------------------------//
// COPY COMPANY NAME TO ON BEHALF OF FIELD IN AUTHORISATION SECTION                           //
//--------------------------------------------------------------------------------------------//
//	function CopyCompany(){
//		document.getElementById("txtAuthCompanyName").value = document.getElementById("txtCompanyName").value;
//	}
