function AddressFinderAjax_Initialise(A){jQuery("#"+A.txtHouseID).unbind("keypress").bind("keypress",{o:A},AddressFinderAjax_KeyPress);
jQuery("#"+A.txtPostcodeID).unbind("keypress").bind("keypress",{o:A},AddressFinderAjax_KeyPress);
jQuery("#"+A.btnFindID).unbind("click").bind("click",{o:A},AddressFinderAjax_FindClick);
}function AddressFinderAjax_KeyPress(A){var B=A.data.o;if(A.keyCode==13){AddressFinderAjax_FindAddress(B);
A.preventDefault();}}function AddressFinderAjax_FindClick(A){var B=A.data.o;AddressFinderAjax_FindAddress(B);
A.preventDefault();}function AddressFinderAjax_FindAddress(D){var B=jQuery("#"+D.txtHouseID).val();
var C=jQuery("#"+D.txtPostcodeID).val();var A=/^[A-Za-z]{1,2}\d/;if((C!="")&&A.test(C)){jQuery("#"+D.errorDivID).css("display","none").html("");
jQuery.ajax({url:D.webServiceUrl,type:"POST",contentType:"application/json; charset=utf-8",dataType:"json",data:"{house:'"+B.replace(/'/g,"\\'")+"',postcode:'"+C.replace(/'/g,"\\'")+"'}",success:function(F,E){if(F.d==undefined){jQuery("#"+D.errorDivID).html("Unable to recognise postcode "+AddressFinderAjax_HtmlEncode(C)).slideDown("fast");
}else{D.callBackFunction(F.d);}}});}else{jQuery("#"+D.errorDivID).html("Please enter a valid UK postcode").slideDown("fast");
}}function AddressFinderAjax_HtmlEncode(C){var A=document.createElement("div");var B=document.createTextNode(C);
A.appendChild(B);return A.innerHTML;}