// JavaScript Document


function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function ChangeHIPType(){
	
	//Get the selected value
	
	sltHipType = document.getElementById("HipType");
	
	//Get the Values
	strHipType = sltHipType.value;
	
	
	//Showhide the sections
	if (strHipType == "1"){
		ShowHide('HIP_Link','');
		ShowHide('HIP_Upload','none');
	}else{
		ShowHide('HIP_Link','none');
		ShowHide('HIP_Upload','');
	}
	
	
}

function ChangeEPCType(){
	
	//Get the selected value
	
	sltEpcType = document.getElementById("EpcType");
	
	//Get the Values
	strEpcType = sltEpcType.value;
	
	
	//Showhide the sections
	if (strEpcType == "1"){
		ShowHide('EPC_Link','');
		ShowHide('EPC_Upload','none');
	}else{
		ShowHide('EPC_Link','none');
		ShowHide('EPC_Upload','');
	}
	
	
}

function ChangeGasCertType(){
	
	//Get the selected value
	
	sltGasCertType = document.getElementById("GasCertType");
	
	//Get the Values
	strGasCertType = sltGasCertType.value;
	
	
	//Showhide the sections
	if (strGasCertType == "1"){
		ShowHide('GasCert_Link','');
		ShowHide('GasCert_Upload','none');
	}else{
		ShowHide('GasCert_Link','none');
		ShowHide('GasCert_Upload','');
	}
	
	
}

function ChangeElecCertType(){
	
	//Get the selected value
	
	sltElecCertType = document.getElementById("ElecCertType");
	
	//Get the Values
	strElecCertType = sltElecCertType.value;
	
	
	//Showhide the sections
	if (strElecCertType == "1"){
		ShowHide('ElecCert_Link','');
		ShowHide('ElecCert_Upload','none');
	}else{
		ShowHide('ElecCert_Link','none');
		ShowHide('ElecCert_Upload','');
	}
	
	
}

function ElementAvailability(){
	
	chkUnavailable = document.getElementById("Unavailable");
	
	if (chkUnavailable.checked){
		
		ShowHide('UnavailableNotes','');
		ShowHide('ElementContent','');
	
	}else{
				
		ShowHide('UnavailableNotes','none');
		ShowHide('ElementContent','');
		
	}
		

	
}

function IncludeElement(strElement,fltPrice,VatNeeded) { 
 		
		 	
		 	strElement = document.getElementById(strElement);
			
			
			SubTotal = document.getElementById("SubTotal");
			AdminFee = document.getElementById("AdminFee");
			AdminFeeValue = document.getElementById("AdminFeeValue");
			Vat = document.getElementById("Vat");
			Total = document.getElementById("Total");
			
			
					
			if (strElement.checked ) {
			
				SubTotalTmp = parseFloat(SubTotal.value) + parseFloat(fltPrice);
				
			
			}else{
				
				SubTotalTmp = parseFloat(SubTotal.value) - parseFloat(fltPrice);
				
			}
			
			SubTotalTmp = SubTotalTmp.toFixed(2);
				
				if (SubTotalTmp > 0){
					AdminFeeTmp = parseFloat(AdminFeeValue.value);
				}else{
					AdminFeeTmp = 0;
				}
				AdminFeeTmp = AdminFeeTmp.toFixed(2);
				
				if (VatNeeded == "True") {
					VatTmp = (parseFloat(SubTotalTmp) + parseFloat(AdminFeeTmp)) * 0.175 ;
				
				}else{
					VatTmp = 0;
					
				}
				VatTmp = VatTmp.toFixed(2);
				
				TotalTmp = parseFloat(SubTotalTmp) + parseFloat(AdminFeeTmp) +  parseFloat(VatTmp);
				TotalTmp = TotalTmp.toFixed(2);
				
				
				SubTotal.value = SubTotalTmp;
				AdminFee.value = AdminFeeTmp;
				Vat.value = VatTmp;
				Total.value = TotalTmp;
		 
		 }
		 
		 
		 function IncludeAmmendment(strAddElement,fltAddPrice,strRemoveElement,fltRemovePrice,VatNeeded) { 
		 
			strAddElement = document.getElementById(strAddElement);
			
			
			
			SubTotal = document.getElementById("SubTotal");
			AdminFee = document.getElementById("AdminFee");
			AdminFeeValue = document.getElementById("AdminFeeValue");
			Vat = document.getElementById("Vat");
			Total = document.getElementById("Total");
			
			
			if (strAddElement.checked ) {
			
				
				
				if (strRemoveElement != "") {
					strRemoveElement = document.getElementById(strRemoveElement);
					
					if (strRemoveElement.checked ) {
					
						strRemoveElement.checked = false;
					
					}else{
						fltRemovePrice = 0;
					
					}
					
					
				}
				
				SubTotalTmp = parseFloat(SubTotal.value) + parseFloat(fltAddPrice) - parseFloat(fltRemovePrice);
				
			}else{
				
				SubTotalTmp = parseFloat(SubTotal.value) - parseFloat(fltAddPrice);
				
			}
			
			SubTotalTmp = SubTotalTmp.toFixed(2);
				
				if (SubTotalTmp > 0){
					AdminFeeTmp = parseFloat(AdminFeeValue.value);
				}else{
					AdminFeeTmp = 0;
				}
				AdminFeeTmp = AdminFeeTmp.toFixed(2);
				
				if (VatNeeded == "True") {
					VatTmp = (parseFloat(SubTotalTmp) + parseFloat(AdminFeeTmp)) * 0.175 ;
				
				}else{
					VatTmp = 0;
					
				}
				VatTmp = VatTmp.toFixed(2);
				
				TotalTmp = parseFloat(SubTotalTmp) + parseFloat(AdminFeeTmp) +  parseFloat(VatTmp);
				TotalTmp = TotalTmp.toFixed(2);
				
				
				SubTotal.value = SubTotalTmp;
				AdminFee.value = AdminFeeTmp;
				Vat.value = VatTmp;
				Total.value = TotalTmp;
		 
		 
		 }
		 
		 
function GenerateSaleStatement_Land(){
	
	//Element Holding the statement
	txtStatement = document.getElementById("Statement");
	
	//Elements providing the values
	sltBlockType = document.getElementById("BlockType");
	sltBlockTypeOther = document.getElementById("BlockTypeOther");
	sltType = document.getElementById("Type");
	sltTotalPropertyLandArea = document.getElementById("TotalPropertyLandArea");
	sltPlanningApproval = document.getElementById("PlanningApprovalText");
	sltPropertyType = document.getElementById("PropertyType");
	sltPropertyTypeOther = document.getElementById("PropertyTypeOther");
	sltAspect = document.getElementById("Aspect");
	sltNoParcels = document.getElementById("NoParcels");
	sltParcelEqual = document.getElementById("ParcelsEqual");
	
	//Get the Values
	strBlockType = sltBlockType.options[sltBlockType.selectedIndex].value;
	strBlockTypeOther = sltBlockTypeOther.value;
	strType = sltType.options[sltType.selectedIndex].value;
	strTotalPropertyLandArea = sltTotalPropertyLandArea.value;
	strPlanningApproval = sltPlanningApproval.options[sltPlanningApproval.selectedIndex].value;
	strPropertyType = sltPropertyType.options[sltPropertyType.selectedIndex].value;
	strPropertyTypeOther = sltPropertyTypeOther.value;
	strAspect = sltAspect.value;
	strNoParcels = sltNoParcels.value;
	
	if (sltParcelEqual.checked){
		strParcelEqual = "equal";
	}else{
		strParcelEqual = "unequal";
	}
	
	strStatementValue = "A ";
	
	if (strBlockType == "Other"){
		if (strBlockTypeOther != ""){
			strStatementValue += "" + strBlockTypeOther +  "";
		}

	}else{
		strStatementValue += "" + strBlockType +  "";

	}
	
	
	strStatementValue += " block of ";	
	
	strStatementValue +=  "" + strType;
	
	if (strTotalPropertyLandArea != ""){
		strStatementValue +=  " measuring " + strTotalPropertyLandArea;
	}
	strStatementValue += " with ";
	
	strStatementValue += strPlanningApproval;
	
	strStatementValue += " planning approval, suitable for ";
	
	
	if (strPropertyType == "Other"){
		if (strPropertyTypeOther != ""){
			strStatementValue += "" + strPropertyTypeOther +  "";
		}

	}else{
		strStatementValue += "" + strPropertyType +  "";

	}
	
	strStatementValue += " use offered in ";
	
	if (strNoParcels > 1){
		
		strStatementValue += "" + strNoParcels +  " lots of " + strParcelEqual +  " parcels";

	}else{
		strStatementValue += "" + strNoParcels +  " lot";

	}
	
	strStatementValue += " with ";
	
	strStatementValue += strAspect;
	
	strStatementValue += " aspect.";	

	txtStatement.value = strStatementValue;
	
}
		 
		 
function GenerateSaleStatement(){

	//Initially set the additonal fields as hidden
	ShowHide('BasementFields','none');

	//Element Holding the statement
	txtStatement = document.getElementById("Statement");
	
	//Elements providing the values
	sltYearBuilt = document.getElementById("YearBuilt");
	sltFloors = document.getElementById("Floors");
	sltBasement = document.getElementById("Basement");
	sltBuild = document.getElementById("Build");
	sltBuildOther = document.getElementById("BuildOther");
	sltCovered = document.getElementById("Covered");
	sltCoveredOther = document.getElementById("CoveredOther");
	sltTypeCont = document.getElementById("TypeCont");
	sltTypeContOther = document.getElementById("TypeContOther");
	sltType = document.getElementById("Type");
	sltFlatFloor = document.getElementById("FlatFloor");
	sltBedrooms = document.getElementById("Bedrooms");
	sltRoomsInRoof = document.getElementById("RoomsInRoof");
	
	sltPrimaryHeating = document.getElementById("PrimaryHeating");
	sltSecondaryHeating = document.getElementById("SecondaryHeating");
	
	sltTownAspect = document.getElementById("Aspect");
	
	//Get the Values
	strYearBuilt = sltYearBuilt.value;
	strFloors = sltFloors.options[sltFloors.selectedIndex].value;
	strBasement = sltBasement.options[sltBasement.selectedIndex].value;
	strBuild = sltBuild.options[sltBuild.selectedIndex].value;
	strBuildOther = sltBuildOther.value;
	strCovered = sltCovered.options[sltCovered.selectedIndex].value;
	strCoveredOther = sltCoveredOther.value;
	strTypeCont = sltTypeCont.options[sltTypeCont.selectedIndex].value;
	strTypeContOther = sltTypeContOther.value;
	strType = sltType.options[sltType.selectedIndex].value;
	strFlatFloor = sltFlatFloor.value;
	strBedrooms = sltBedrooms.options[sltBedrooms.selectedIndex].value;
	strRoomsInRoof = sltRoomsInRoof.options[sltRoomsInRoof.selectedIndex].value;
	
	strTownAspect = sltTownAspect.options[sltTownAspect.selectedIndex].value;
	
	strPrimaryHeating = sltPrimaryHeating.options[sltPrimaryHeating.selectedIndex].value;
	strSecondaryHeating = sltSecondaryHeating.options[sltSecondaryHeating.selectedIndex].value;
	
	
	//Set the string
	if (strFloors == "1"){
		strStatementValue = strFloors + ' Floor';
	}else{
		strStatementValue = strFloors + ' Floors';
	}
	
	if (strBasement == "1"){
		strStatementValue +=  ', plus Basement';
	
	}

	if (strBuild == "Other"){
		if (strBuildOther != ""){
			strStatementValue += ", " + strBuildOther +  " built";
		}
		ShowHide('BuildOther','');
		ShowHide('BuildOtherTitle','');
	}else{
		strStatementValue += ", " + strBuild +  " built";
		ShowHide('BuildOther','none');
		ShowHide('BuildOtherTitle','none');
	}
	
	
	if (strCovered == "Other"){
		if (strCoveredOther != ""){
			strStatementValue += ", " + strCoveredOther +  " covered";
		}
		ShowHide('CoveredOther','');
		ShowHide('CoveredOtherTitle','');
	}else{
		strStatementValue += ", " + strCovered +  " covered";
		ShowHide('CoveredOther','none');
		ShowHide('CoveredOtherTitle','none');
	}
	

	if (strTypeCont == "Other"){
		if (strTypeContOther != ""){
			strStatementValue += ", " + strTypeContOther;
		}
		ShowHide('TypeContOther','');
		ShowHide('TypeContOtherTitle','');
	}else{
		strStatementValue += ", " + strTypeCont;
		ShowHide('TypeContOther','none');
		ShowHide('TypeContOtherTitle','none');
	}
	
	strStatementValue +=  " " + strType;
	
	if (strType == "Flat"){
		
		ShowHide('FlatFloor','');
		ShowHide('FlatFloorTitle','');
		
		if (strFlatFloor != ""){
			strStatementValue += " (Floor: " + strFlatFloor + ")" ;
		}

	}else{
		ShowHide('FlatFloor','none');
		ShowHide('FlatFloorTitle','none');
	}
	
	if (strBedrooms == "1"){
		strStatementValue += ", with " + strBedrooms + ' Bedroom';
	}else{
		strStatementValue += ", with " + strBedrooms + ' Bedrooms';
	}
	
	if (strRoomsInRoof != "0"){
	
		if (strRoomsInRoof == "1"){
			strStatementValue += " and " + strRoomsInRoof + ' room in the roof';
		}else{
			strStatementValue += " and " + strRoomsInRoof + ' rooms in the roof';
		}
		
	}
	
	if (strYearBuilt != ""){
		
		strStatementValue += ", built in " + strYearBuilt;
	}
	
	if (strTownAspect != ""){
		strStatementValue += ", with " + strTownAspect + " aspect";
	}
		
	strStatementValue += ".";	

	txtStatement.value = strStatementValue;
	
	
	//Show/Hide Elements
	
	//Floors
	if (strFloors == "6+"){
		
		ShowHide('FirstFloorWrap','');
		ShowHide('SecondFloorWrap','');
		ShowHide('ThirdFloorWrap','');
		ShowHide('FourthFloorWrap','');		
		ShowHide('OtherFloorsWrap','');
		
		
	}else if (strFloors == "5"){
		
		ShowHide('FirstFloorWrap','');
		ShowHide('SecondFloorWrap','');
		ShowHide('ThirdFloorWrap','');
		ShowHide('FourthFloorWrap','');		
		ShowHide('OtherFloorsWrap','none');
		
		
	}else if (strFloors == "4"){
		
		ShowHide('FirstFloorWrap','');
		ShowHide('SecondFloorWrap','');
		ShowHide('ThirdFloorWrap','');
		ShowHide('FourthFloorWrap','none');		
		ShowHide('OtherFloorsWrap','none');
		
		
	}else if (strFloors == "3"){
		
		ShowHide('FirstFloorWrap','');
		ShowHide('SecondFloorWrap','');
		ShowHide('ThirdFloorWrap','none');
		ShowHide('FourthFloorWrap','none');		
		ShowHide('OtherFloorsWrap','none');
		
		
	}else if (strFloors == "2"){
		
		ShowHide('FirstFloorWrap','');
		ShowHide('SecondFloorWrap','none');
		ShowHide('ThirdFloorWrap','none');
		ShowHide('FourthFloorWrap','none');		
		ShowHide('OtherFloorsWrap','none');
		
		
	}else{
		
		ShowHide('FirstFloorWrap','none');
		ShowHide('SecondFloorWrap','none');
		ShowHide('ThirdFloorWrap','none');
		ShowHide('FourthFloorWrap','none');		
		ShowHide('OtherFloorsWrap','none');
		
		
	}
	
	//Basement	
	if (strBasement == "1"){
				
		//Show the BasementFields
		ShowHide('BasementFields','');
	}else{
		
		//Hide the BasementFields
		ShowHide('BasementFields','none');
	}


	if (strPrimaryHeating == "Other"){
		
		ShowHide('PrimaryHeatingOther','');
		ShowHide('PrimaryHeatingOtherTitle','');

	}else{
		ShowHide('PrimaryHeatingOther','none');
		ShowHide('PrimaryHeatingOtherTitle','none');
	}
	
	if (strSecondaryHeating == "Other"){
		
		ShowHide('SecondaryHeatingOther','');
		ShowHide('SecondaryHeatingOtherTitle','');

	}else{
		ShowHide('SecondaryHeatingOther','none');
		ShowHide('SecondaryHeatingOtherTitle','none');
	}

}


function ShowHide(strTarget,strDisplayValue){

	var elementmode = document.getElementById(strTarget).style;
	elementmode.display = strDisplayValue;

}

function ShowRooms(strFloor){

	// Get the number of rooms needed
	sltNoRooms = document.getElementById(strFloor+"NoRooms");
	strNoRooms = sltNoRooms.options[sltNoRooms.selectedIndex].value;
	
	
	ShowHide(strFloor+'Room2','none');
	ShowHide(strFloor+'Room3','none');
	ShowHide(strFloor+'Room4','none');
	ShowHide(strFloor+'Room5','none');
	ShowHide(strFloor+'Room6','none');
	ShowHide(strFloor+'Room7','none');
	ShowHide(strFloor+'Room8','none');

	if (strNoRooms == "8") {
		
		ShowHide(strFloor+'Room2','');
		ShowHide(strFloor+'Room3','');
		ShowHide(strFloor+'Room4','');
		ShowHide(strFloor+'Room5','');
		ShowHide(strFloor+'Room6','');
		ShowHide(strFloor+'Room7','');
		ShowHide(strFloor+'Room8','');
		
	}else if (strNoRooms == "7") {
		
		ShowHide(strFloor+'Room2','');
		ShowHide(strFloor+'Room3','');
		ShowHide(strFloor+'Room4','');
		ShowHide(strFloor+'Room5','');
		ShowHide(strFloor+'Room6','');
		ShowHide(strFloor+'Room7','');
		
	}else if (strNoRooms == "6") {
		
		ShowHide(strFloor+'Room2','');
		ShowHide(strFloor+'Room3','');
		ShowHide(strFloor+'Room4','');
		ShowHide(strFloor+'Room5','');
		ShowHide(strFloor+'Room6','');
		
	}else if (strNoRooms == "5") {
		
		ShowHide(strFloor+'Room2','');
		ShowHide(strFloor+'Room3','');
		ShowHide(strFloor+'Room4','');
		ShowHide(strFloor+'Room5','');
		
	}else if (strNoRooms == "4") {
		
		ShowHide(strFloor+'Room2','');
		ShowHide(strFloor+'Room3','');
		ShowHide(strFloor+'Room4','');
		
	}else if (strNoRooms == "3") {
		
		ShowHide(strFloor+'Room2','');
		ShowHide(strFloor+'Room3','');
		
	}else if (strNoRooms == "2") {
		
		ShowHide(strFloor+'Room2','');
		
	}

}
		 
		 
		 
function formatCurrency(num) { // adds commas & 2 pence
	num = num.toString().replace(/\£|\,/g,'');
	if(isNaN(num)) num = "0";
		sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	pence = num%100;
	num = Math.floor(num/100).toString();
	if(pence<10) pence = "0" + pence;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + '.' + pence);
}	

function formatInteger(num) { //adds commas & rounds to integer
	num = num.toString().replace(/\£|\,/g,'');
	if(isNaN(num)) num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.round(num).toString();
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num);
}

//check validity of entries 
	function checkNumber(input, min, max, msg) {
		msg = msg + " field has invalid data: " + input.value;
		//check number is a number
		var str = input.value;
		for (var i = 0; i < str.length; i++) {
			var ch = str.substring( i, i + 1)
			if ((ch < "0" || "9" < ch) && ch != '.') {
				alert(msg);
				return false;
			}
		}

		//check number lies between the min and max values allowed
		var num = 0 + str
		if (num < min || max < num) {
			alert(msg + " not in range [" + min + ".." + max + "]");
			return false;
		}
		input.value = str;
		return true;
	}
	



function computeField(input, strType) {
	
			if (input.value != null && input.value.length != 0)
			{
				input.value = "" + eval(input.value);
			}
			computeForm(input.form, strType);
		
	}

	function computeForm(form, strType) {
		
		if (strType == "mc"){
			var McLoan = form.McLoan.value;
			var McTermYears = form.McTermYears.value;
			var McIntNomPA =form.McIntNomPA.value;
		   var McRestsPA = form.McRestsPA.value;
	
			//check that an entry has been made in each field.
			if ((McLoan == null || McLoan.length == 0) ||
				(McIntNomPA == null || McIntNomPA.length == 0)) 
			{
				//alert('Some fields are blank');
				return false;
			}
	
			// check entries are valid by using check number
			if (!checkNumber(form.McLoan, 1, 9999999, "Amount") ||
				!checkNumber(form.McIntNomPA, 1, 100, "Interest Rate") ||
				!checkNumber(form.McRestsPA, 1, 365, "Rests") ||
				!checkNumber(form.McTermYears, 5, 35, "Term")) 
			{
				//form.Cm.value = "Invalid";
				return false;
			}
			// Calc Payment from i=interest rate fraction per period, n=number of periods, pv=present value, fv=future value
			function Pmt(i, n, pv, fv) {
				return pv * i * (1 / (1- (Math.pow(1/(1 + i),n)))) - fv * i / (Math.pow(1+i,n) -1); 
			} 
			
			// actual calculations
			var P = Pmt(McIntNomPA/(McRestsPA *100), McTermYears * McRestsPA, McLoan, 0) * McRestsPA / 12;
			form.McPmtPM.value = "£" + formatCurrency( P);
			form.McIntPM.value = "£" + formatCurrency((McIntNomPA * McLoan)/1200);
			//form.McLoan.focus();
		
		}else if(strType == "mac"){
			
			var MacPmtPM	= form.MacPmtPM.value;
			var MacTermYears = form.MacTermYears.value;
			var MacIntNomPA 	= form.MacIntNomPA.value;
			var MacSingMult = form.MacSing.value;
			var MacJointMult = form.MacJoint.value;
			
		//Check an entry has been made in each field.
			if ((MacPmtPM == null || MacPmtPM.length == 0) ||
				(MacIntNomPA == null || MacIntNomPA.length == 0)) 
			{
				//alert('Not all of the first three fields are filled in');
				return false;
			}
	
	
		// making sure that entries are valid by using check number
			if (!checkNumber(form.MacPmtPM, 1, 99999, "Monthly amount") ||
				!checkNumber(form.MacIntNomPA, 1, 100, "Interest rate") ||
				!checkNumber(form.MacSing, 1, 6, "Single Multiple") ||
				!checkNumber(form.MacJoint, 1, 6, "Joint Multiple") ||
				!checkNumber(form.MacTermYears, 5, 35, "Term")) 
			{
				//form.Loan.value = "Invalid";
				return false;
			}
			
		// maths to be computed
			var PV = PresentValue (MacIntNomPA / 1200, MacTermYears * 12, MacPmtPM, 0);
			var RoundedLoan = Math.round(PV/100)*100;
			form.MacLoan.value = "£" + formatInteger(RoundedLoan);
			form.MacSingleIncome.value = "£" + formatInteger(Math.round(PV / (MacSingMult * 10)) * 10);
			form.MacJointIncome.value = "£" + formatInteger(Math.round(PV / (MacJointMult * 10)) * 10);
		}
	}
	
	
	function PresentValue(i, n, pmt, fv) {
			return (fv + pmt * ((Math.pow(1 + i, n) - 1) / i)) / Math.pow(1 + i, n);
		}
		
		
function EnquiryFormDisplay(){
	
	var boolDisplayRequestCallBack = false;
	var boolDisplayMortgageCalculator = false;
	var boolDisplayMortgageAffordabilityCalculator = false;
	
	
	if (document.getElementById("EnqCallBack").checked){
		boolDisplayRequestCallBack = true;
	}
	
	if (document.getElementById("EnqFirstTimeMortgage").checked || document.getElementById("EnqNewMortgage").checked || document.getElementById("EnqReMortgage").checked || document.getElementById("EnqMortgageAgreementPrinciple").checked || document.getElementById("EnqAdverseCreditMortgage").checked || document.getElementById("EnqLettoBuy").checked || document.getElementById("EnqPurchasingPropertyAbroad").checked || document.getElementById("EnqBuytoLet").checked){
		boolDisplayMortgageCalculator = true;
		boolDisplayMortgageAffordabilityCalculator = true;
	}
	
	if(document.getElementById("EnqSharedEquityScheme").checked || document.getElementById("EnqEquityRelease").checked || document.getElementById("EnqCommercialMortgage").checked){
		
	}
	
	
	if (boolDisplayRequestCallBack){
		ShowHide('DisplayRequestCallBack','');
	}else{
		ShowHide('DisplayRequestCallBack','none');	
	}
	
	if (boolDisplayMortgageCalculator == true){
		ShowHide('DisplayMortgageCalculator','');
		ShowHide('AttachMortgageCalculator','');
	}else{
		ShowHide('DisplayMortgageCalculator','none');
		ShowHide('AttachMortgageCalculator','none');
	}
	
	if (boolDisplayMortgageAffordabilityCalculator){
		ShowHide('DisplayMortgageAffordabilityCalculator','');
		ShowHide('AttachMortgageAffordabilityCalculator','');
	}else{
		ShowHide('DisplayMortgageAffordabilityCalculator','none');	
		ShowHide('AttachMortgageAffordabilityCalculator','none');
	}

}


function InsuranceEnquiryFormDisplay(){
	
	var boolDisplayRequestCallBack = false;
	
	
	if (document.getElementById("EnqCallBack").checked){
		boolDisplayRequestCallBack = true;
	}
	
	
	
	if (boolDisplayRequestCallBack){
		ShowHide('DisplayRequestCallBack','');
	}else{
		ShowHide('DisplayRequestCallBack','none');	
	}
	
}

function SetPricing(){
	sltCurrency = document.getElementById("Currency");
	strCurrency= sltCurrency.options[sltCurrency.selectedIndex].value;;
	
	ShowHide('AdvertPricing','none');
	
	
	if (strCurrency != "0"){
		ShowHide('AdvertPricing','');
	}
}


//Our XmlHttpRequest object to get the auto suggest
var xmlRegions = getXmlHttpRequestObject();
var xmlCouncils = getXmlHttpRequestObject();

//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	}else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
} //function getXmlHttpRequestObject() {	
	
var strFormName = "";	
var strProductID = "";
function RegionLoad(FormName, ProductID){
	
	strFormName = FormName;
	strProductID = ProductID;
	
	var timestamp = Number(new Date());
	var url='ajax_regionlist.asp?ID=' + strProductID + '&ts=' + timestamp
	
	
	//sltRegionID = document.forms(FormName).RegionID;
	
	//Get the Values
	//strRegionID = sltRegionID.value;

	if (xmlRegions.readyState == 4 || xmlRegions.readyState == 0) {
		xmlRegions.open("GET", url, true);
		xmlRegions.onreadystatechange = RegionList_Handle; 
		xmlRegions.send(null);
	}
} //function RegionLoad(FormName, strProductID){

function RegionList_Handle() {
	if (xmlRegions.readyState == 4) {
		var strResponse = xmlRegions.responseText
		
		sltRegionID = document.forms(strFormName).RegionID;
		sltRegionID.options.length=0;
		
		if (strResponse != ""){
			var arrResponse = strResponse.split("||");	
			
			var arrLen = arrResponse.length;
			var intPos = 0;
			for(i=0;i<arrLen;i +=2){
				sltRegionID.options[intPos] = new Option(arrResponse[i + 1],arrResponse[i]);
				intPos +=1;
			}
			
			CouncilLoad(strFormName, strProductID)
			
		}
		
	}
} //function CMS_QuickSearch_Handle() {
	
function CouncilLoad(FormName, ProductID){
	
	strFormName = FormName;
	strProductID = ProductID;
	
	sltRegionID = document.forms(FormName).RegionID;

	
	//Get the Values
	strRegionID = sltRegionID.options[sltRegionID.selectedIndex].value;

	
	var timestamp = Number(new Date());
	var url='ajax_councillist.asp?ID=' + strProductID + '&rID=' + strRegionID + '&ts=' + timestamp
	
	if (xmlCouncils.readyState == 4 || xmlCouncils.readyState == 0) {
		xmlCouncils.open("GET", url, true);
		xmlCouncils.onreadystatechange = CouncilList_Handle; 
		xmlCouncils.send(null);
	}
} //function RegionLoad(FormName, strProductID){

function CouncilList_Handle() {
	if (xmlCouncils.readyState == 4) {
		var strResponse = xmlCouncils.responseText
		
		sltCouncilID = document.forms(strFormName).CouncilID;
		sltCouncilID.options.length=0;
		
		if (strResponse != ""){
			var arrResponse = strResponse.split("||");	
			
			var arrLen = arrResponse.length;
			var intPos = 0;
			for(i=0;i<arrLen;i +=2){
				
				strCurText = arrResponse[i + 1];
				strCurValue = arrResponse[i];
				
				strCurText = strCurText.replace("&pound;","\u00A3")
				
				sltCouncilID.options[intPos] = new Option(strCurText,strCurValue);
				intPos +=1;
			}
			
		}
		
	}
} //function CMS_QuickSearch_Handle() {	


var strSelectedRegionID = "";
//Our XmlHttpRequest object to get the auto suggest
var xmlCountryRegions = getXmlHttpRequestObject();

function CountryRegionLoad(FormName, SelectedRegionID, strAnyText){
	
	strFormName = FormName;
	strSelectedRegionID = SelectedRegionID;
	

	sltCountryID = document.forms(FormName).CountryID;
	
	//Get the Values
	strCountryID = sltCountryID.options[sltCountryID.selectedIndex].value;

	
	var timestamp = Number(new Date());
	var url='ajax_countryregionlist.asp?cID=' + strCountryID + '&anytext=' + strAnyText + '&ts=' + timestamp
	
	if (xmlCountryRegions.readyState == 4 || xmlCountryRegions.readyState == 0) {
		xmlCountryRegions.open("GET", url, true);
		xmlCountryRegions.onreadystatechange = CountryRegionLoad_Handle; 
		xmlCountryRegions.send(null);
	}
	
}

function CountryRegionLoad_Handle() {
	if (xmlCountryRegions.readyState == 4) {
		var strResponse = xmlCountryRegions.responseText
		
		sltRegions = document.forms(strFormName).Region;
		sltRegions.options.length=0;

		if (strResponse != ""){
			var arrResponse = strResponse.split("||");	
			
			var arrLen = arrResponse.length;
			var intPos = 0;
			for(i=0;i<arrLen;i +=2){
				
				strCurText = arrResponse[i + 1];
				strCurValue = arrResponse[i];
				
				sltRegions.options[intPos] = new Option(strCurText,strCurValue);
				intPos +=1;
			}
			
			sltRegions.value =strSelectedRegionID;
			
		}
		
	}
} //function CMS_QuickSearch_Handle() {	


//Our XmlHttpRequest object to get the auto suggest
var xmlRegionList = getXmlHttpRequestObject();
var xmlCountryList = getXmlHttpRequestObject();

function LoadCountryList(FormName, ProductID){
	
	
	var timestamp = Number(new Date());
	var url='ajax_loadcountrylist.asp?ID=' + ProductID + '&fn=' + FormName + '&ts=' + timestamp
	
	
	//sltRegionID = document.forms(FormName).RegionID;
	
	//Get the Values
	//strRegionID = sltRegionID.value;

	if (xmlCountryList.readyState == 4 || xmlCountryList.readyState == 0) {
		xmlCountryList.open("GET", url, true);
		xmlCountryList.onreadystatechange = LoadCountryList_Handle; 
		xmlCountryList.send(null);
	}
} //function LoadRegionList(FormName, strProductID){
	
function LoadCountryList_Handle() {
	if (xmlCountryList.readyState == 4) {
		var strResponse = xmlCountryList.responseText
		
		
		
		if (strResponse != ""){
			
			var arrResponse = strResponse.split("##");
			
			var strCurFormName = arrResponse[0];
			var strCurProductID = arrResponse[1];
			var arrCurDetails = arrResponse[2].split("||");
			var strCurDefaultID = arrResponse[3];
			
			sltCountryID = document.forms(strCurFormName).CountryID;
			sltCountryID.options.length=0;
					
			
			var arrLen = arrCurDetails.length;
			var intPos = 0;
			for(i=0;i<arrLen;i +=2){
				sltCountryID.options[intPos] = new Option(arrCurDetails[i + 1],arrCurDetails[i]);
				intPos +=1;
			}
			
			if (strCurDefaultID != ""){
				sltCountryID.value = strCurDefaultID;
			}
			
			LoadRegionList(strCurFormName, strCurProductID)
			
		}
		
	}
} //function LoadCountryList_Handle() {
	
	
function LoadRegionList(FormName, ProductID){
	
	
	sltCountryID = document.forms(FormName).CountryID;
	//Get the Values
	strCountryID = sltCountryID.options[sltCountryID.selectedIndex].value;
	
	
	var timestamp = Number(new Date());
	var url='ajax_loadregionlist.asp?ID=' + ProductID + '&fn=' + FormName + '&cID=' + strCountryID + '&ts=' + timestamp
	
	
	if (xmlRegionList.readyState == 4 || xmlRegionList.readyState == 0) {
		xmlRegionList.open("GET", url, true);
		xmlRegionList.onreadystatechange = LoadRegionList_Handle; 
		xmlRegionList.send(null);
	}
} //function LoadRegionList(FormName, strProductID){
	
function LoadRegionList_Handle() {
	if (xmlRegionList.readyState == 4) {
		var strResponse = xmlRegionList.responseText
		
		if (strResponse != ""){
			
			var arrResponse = strResponse.split("##");
			
			var strCurFormName = arrResponse[0];
			var arrCurDetails = arrResponse[1].split("||");
			
			sltRegionID = document.forms(strCurFormName).RegionID;
			sltRegionID.options.length=0;
					
			
			var arrLen = arrCurDetails.length;
			var intPos = 0;
			for(i=0;i<arrLen;i +=2){
				
				strCurText = arrCurDetails[i + 1];
				strCurValue = arrCurDetails[i];
				
				strCurText = strCurText.replace("&pound;","\u00A3")
				
				sltRegionID.options[intPos] = new Option(strCurText,strCurValue);
				intPos +=1;
			}
			
			
		}
		
	}
} //function LoadCountryList_Handle() {
