	function PostcodeAnywhere_Interactive_RetrieveByPostcodeAndBuilding_v1_10Begin(Key, Postcode, Building, UserName) {
		var scriptTag = document.getElementById("PCA38d38252878f434581f85b249661cd94");
		var headTag = document.getElementsByTagName("head").item(0);
		var strUrl = "";

		//Build the url
		strUrl = ('https:' == document.location.protocol ? 'https://' : 'http://') + "services.postcodeanywhere.co.uk/PostcodeAnywhere/Interactive/RetrieveByPostcodeAndBuilding/v1.10/json.ws?";
		strUrl += "&Key=" + escape(Key);
		strUrl += "&Postcode=" + escape(Postcode);
		strUrl += "&Building=" + escape(Building);
		strUrl += "&UserName=" + escape(UserName);
		strUrl += "&CallbackFunction=PostcodeAnywhere_Interactive_RetrieveByPostcodeAndBuilding_v1_10End";

		//Make the request
		if (scriptTag) {
			try {
				headTag.removeChild(scriptTag);
			}
			catch (e) {
				//Ignore
			}
		}
		scriptTag = document.createElement("script");
		scriptTag.src = strUrl
		scriptTag.type = "text/javascript";
		scriptTag.id = "PCA38d38252878f434581f85b249661cd94";
		headTag.appendChild(scriptTag);
	}

	function PostcodeAnywhere_Interactive_RetrieveByPostcodeAndBuilding_v1_10End(response) {
		//Test for an error
		if (response.length==1 && typeof(response[0].Error) != 'undefined') {
			//Show the error message
			$('#findAddressSelectLI').hide();
			$("#fieldAddressSelect >option").remove();
			alert(response[0].Description);
		} else {
			//Check if there were any items found
			if (response.length==0) {
				$('#findAddressSelectLI').hide();
				$("#fieldAddressSelect >option").remove();
				alert("Sorry, no matching items found");
			} else {
				if (response.length==1) {
					$('#findAddressSelectLI').hide();
					$("#fieldAddressSelect >option").remove();
					PopulateForm(response[0]);
				} else {
					PopulateSelect(response);
				}
			}
		}
	}
	function PopulateForm(address) {
		$("#fieldAddress1").val(address.Line1);
		$("#fieldAddress2").val(address.Line2);
		$("#fieldAddress3").val(address.Line3);
		$("#fieldAddress4").val(address.Line4);
		$("#fieldAddress5").val(address.Line5);
		$("#fieldCity").val(address.PostTown);
		$("#fieldCounty").val(address.County);
	}
	
	function PopulateSelect(response) {
		var options = $("#fieldAddressSelect");
		$("#fieldAddressSelect >option").remove();
		options.append($("<option />").val("").text("Select Address"));
		$.each(response, function() {
			if (this.Line2.length > 0) {
				options.append($("<option />").val(this.Udprn).text(this.Line1 + ", " + this.Line2));
			} else {
				options.append($("<option />").val(this.Udprn).text(this.Line1));
			}
		});
		options.change(function () { PopulateSelForm(response, this.value); });
		$('#findAddressSelectLI').show('slow');
	}
	
	function PopulateSelForm(response, selValue) {
		$.each(response, function() {
			if (this.Udprn==selValue) {
				PopulateForm(this);
			}
		});
	}

