function lookupAddress(n,t,i,r,u){var s=$("#"+n),o=s.val(),f=$("#"+t),h=$("#"+i),e=$("#Addresses"),a=$("#SelectAddress"),c=$("#"+u),v,y,l,p,w;if($manualAddressButton=$("#"+r),c.hide(),o.length>0)if(o=o.replace(/\s/g,""),v=/^[A-Z]{1,2}[0-9]{1,2} ?[0-9][A-Z]{2}$/i,y=v.test(o),y==!1)h.show(),f.hide(),$manualAddressButton.show();else if(l=postGenericAjaxObject("/ALS/JSON_AddressListForPostcode",{postcode:o}),l.Results.AddressesList.length==0)h.show(),f.slideUp("fast"),$manualAddressButton.show();else{p=l.Results.AddressesList;c.show();e.empty();e.append($("<option />").val(0).text("Please select address"));$.each(p,function(n,t){e.append($("<option />").val(t.Moniker).text(t.Address))});e.parent().slideDown("fast");h.hide();$("#modalAddressLookup").modal("show");s.parent().parent().find(".selected-postcode").length>0&&(s.parent().parent().find(".selected-postcode").show(),w=s.parent().find(".selected-postcode")[0],$(w).html(o),s.hide(),$("#find-address-button").hide());e.focus();a.length>0?a.click(function(){b(this)}):e.change(function(){c.hide();b(this)});function b(n){var i=e.val(),t;if(i!="0")return f.find(".als-address").val(""),t=postGenericAjaxObject("/ALS/JSON_AddressForMoniker",{moniker:i}),f.find(".als-address-line1").val(t.Property.FormattedAddressLineOne),f.find(".als-address-line2").val(t.Property.FormattedAddressLineTwo),f.find(".als-address-line3").val(t.Property.FormattedAddressLineThree),f.find(".als-address-city").val(t.Property.Town),f.find(".als-address-county").val(t.Property.County),f.find(".als-address-postcode").val(t.Property.Postcode),f.find(".als-address-summaryline").html(t.Address),f.find(".als-address-moniker").val(i),f.slideDown(),$manualAddressButton.fadeOut("fast"),$("#modalAddressLookup").modal("hide"),$(n).unbind(),!1}}else h.show(),$manualAddressButton.fadeIn("fast")}function manualAddressEntry(n,t){var i=$("#"+t);$(n).hide();i.slideDown("fast")}function changePostcode(n,t){var i=$("#"+n),r=$("#"+t),u=$("#Addresses");i.show();$("#find-address-button").hide().show();i.parent().parent().find(".selected-postcode").hide();$(".als-address").val("");u.parent().slideUp("fast");r.slideUp("fast")}var $manualAddressButton