function alsLookUp(n){function p(n){var u=t.val(),h=$("#AddressLines"),c=$("#Postcode"),l=$("#ManualAddress"),f=$("#EncryptedData").val(),e=$("#ALSID"),s=$("#FormSection2"),r;return e.val(u),i.find(".als-address").val(""),r=postGenericAjaxObject("/ALS/JSON_AddressForMoniker",{moniker:u,encryptedData:f}),i.find(".als-address-line1").val(r.Property.FormattedAddressLineOne),i.find(".als-address-line2").val(r.Property.FormattedAddressLineTwo),i.find(".als-address-line3").val(r.Property.FormattedAddressLineThree),i.find(".als-address-line4").val(r.Property.Town),i.find(".als-address-postcode").val(r.Property.Postcode),i.slideDown(),o.fadeOut("fast"),s.slideDown("fast"),forceError($("#AddressID"),""),forceError($("#AddressLine1"),""),$(n).unbind(),!1}function w(n){u.text(n);u.fadeIn()}function c(n){n?s.fadeIn("500"):s.fadeOut("500")}var r=$("#"+n),l=r.find("[data-postcode]"),a=l.find("input[data-postcode-input]"),u=r.find("[data-postcode-error]"),b=$("#EncryptedData").val(),v=r.find("[data-entered]"),k=v.find("[data-entered-postcode]"),o=r.find("[data-address-manual]"),e=r.find("[data-results]"),t=e.find("[data-addresses-select]"),i=r.find("[data-address-fields]"),d=$("#SelectAddress"),s,f,h,y;$("#Postcode").prop("readonly",!0);s=$("#est-loading");f=a.val();a.length>0?(c(!0),f=f.replace(/\s/g,""),h=postGenericAjaxObject("/ALS/JSON_AddressListForPostcode",{postcode:f,encryptedData:b}),h.Results.AddressesList.length===0?(w("No results found, try and add your address manually. Please be aware this scheme is only available in England."),i.hide(),o.show(),c(!1)):(u.hide(),y=h.Results.AddressesList,t.empty(),t.append($("<option />").val("").text("Please select address")),$.each(y,function(n,i){t.append($("<option />").val(i.Moniker).text(i.Address))}),t.selectedIndex=0,l.hide(),k.html(f),v.show(),e.show(),o.show(),c(!1),t.focus(),t.keyup(function(n){n.keyCode===13&&(n.preventDefault(),e.hide(),p(this))}),d.click(function(){t.val()!=""&&(e.hide(),p(t))}))):w("Please enter a valid postcode")}function alsManualAddressEntry(n){var t=$("#"+n),u=$("#AddressID"),f=$("#FormSection2"),o=t.find("[data-postcode]"),s=t.find("[data-entered]"),i=t.find("[data-address-manual]"),r=t.find("[data-results]"),h=r.find("[data-addresses-select]"),e=t.find("[data-address-fields]");u.val(null);$("#Postcode").prop("readonly",!1);f.slideDown("fast");i.hide();e.slideDown("fast");r.hide();i.hide()}function alsChangePostcode(n){var t=$("#"+n),r=$("#FormSection2"),u=t.find("[data-postcode]"),i=t.find("[data-entered]"),f=i.find("[data-entered-postcode]"),e=t.find("[data-results]"),o=t.find("data-address-manual"),s=t.find("[data-address-fields]");u.show();i.hide();f.val("");e.slideUp("fast");s.slideUp("fast");o.hide();r.slideUp("fast")}