function PostcodeAnywhere_Interactive_RetrieveByPostcodeAndBuilding_v1_10Begin(Key, Postcode, Building, UserName, Target){

if(Target==1){
var callback = 'PostcodeAnywhere_Interactive_RetrieveByPostcode';
$('#findAddress').attr('disabled', 'disabled');
	 $('#postcode').attr('disabled', 'disabled');
	 $('#address').attr('disabled', 'disabled');
} else {
var	callback = 'PostcodeAnywhere_Interactive_RetrieveByPostcode2';
	$('#findAddress_cb').attr('disabled', 'disabled');
	 $('#postcode_cb').attr('disabled', 'disabled');
	 $('#address_cb').attr('disabled', 'disabled');
}


     // var scriptTag = document.getElementById("PCA38d38252878f434581f85b249661cd94");
	  var scriptTag = document.getElementById("GD42-RA68-JJ64-MN94");
      var headTag = document.getElementsByTagName("head").item(0);
      var strUrl = "";

	
	 //Build the url
      strUrl = "https://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="+callback;

      //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 = "GD42-RA68-JJ64-MN94";
      headTag.appendChild(scriptTag);
   }
   
   
   
   

   
 function PostcodeAnywhere_Interactive_RetrieveByPostcode(response){
	$("#findAddress").removeAttr("disabled");
	 $("#postcode").removeAttr("disabled");
	//Test for an error
      if (response.length==1 && typeof(response[0].Error) != 'undefined'){
            //Show the error message
			jAlert('Error',response[0].Description);
    	} else{
            //Check if there were any items found
            if (response.length==0){
				jAlert('Error',"Sorry, no matching items found");
               }else{
			var $select = $('#address');
				if($select.prop) {
  var $options = $select.prop('options');
} else {
	var $options = $select.attr('options');
}
$('#address').removeAttr('disabled');
					$options[0] = new Option('Select your address', null);

									 for(i=0;i<response.length;i++){ 
									var label="";
									 if(response[i].Company !="") label+= response[i].Company+", ";
									 if(response[i].Line1 !="") label+= response[i].Line1+", " ;
									 if(response[i].Line2 !="") label+= response[i].Line2+", " ;
									 if(response[i].Line3 !="") label+= response[i].Line3+", " ;
									 if(response[i].PostTown !="") label+= response[i].PostTown;
	
									$options[i+1] = new Option(label, i);
	}
	 }
   }
   }
   
   
   
   
 function PostcodeAnywhere_Interactive_RetrieveByPostcode2(response){
	$("#findAddress_cb").removeAttr("disabled");
	 $("#postcode_cb").removeAttr("disabled");
	//Test for an error
      if (response.length==1 && typeof(response[0].Error) != 'undefined'){
            //Show the error message
			jAlert('Error',response[0].Description);
    	} else{
            //Check if there were any items found
            if (response.length==0){
				jAlert('Error',"Sorry, no matching items found");
               }else{
			var $select = $('#address_cb');
				if($select.prop) {
  var $options = $select.prop('options');
} else {
	var $options = $select.attr('options');
}
$('#address_cb').removeAttr('disabled');
					$options[0] = new Option('Select your address', null);

									 for(i=0;i<response.length;i++){ 
									var label="";
									 if(response[i].Company !="") label+= response[i].Company+", ";
									 if(response[i].Line1 !="") label+= response[i].Line1+", " ;
									 if(response[i].Line2 !="") label+= response[i].Line2+", " ;
									 if(response[i].Line3 !="") label+= response[i].Line3+", " ;
									 if(response[i].PostTown !="") label+= response[i].PostTown;
	
									$options[i+1] = new Option(label, i);
	}
	 }
   }
   }
   
   

