function showClear(){document.getElementById("clearButton").style.display="block"}function clearSearch(){document.getElementById("mySelect")!=null&&(document.getElementById("mySelect").style.display="none",$("#TenancyAddress").val(""))}function showError(n){var t=document.getElementById("errorMessage");t.innerText=n;t.style.display="block";setTimeout(function(){t.style.display="none"},1e4)}function enterSearch(){findAddress()}function findAddress(n,t){var r=$(n).parents(".lookup-form"),e=r.find(".searchBox").val(),o=$(n).attr("data-select-option"),f,u;if(r.find(".address-property p").html(""),r.find(".address-finder").hide(),resetAddressFields(r),e!==""){f="";t!==undefined&&(f=t);var i="";i+="&Key="+encodeURIComponent(Key);i+="&Text="+encodeURIComponent(e);i+="&IsMiddleware="+encodeURIComponent(!1);i+="&Container="+encodeURIComponent(f);i+="&Origin="+encodeURIComponent("");i+="&Countries="+encodeURIComponent("GBR");i+="&Limit="+encodeURIComponent("10");i+="&Language="+encodeURIComponent("en-gb");u=new XMLHttpRequest;u.open("POST","https://services.postcodeanywhere.co.uk/Capture/Interactive/Find/v1.10/json3.ws",!0);u.setRequestHeader("Content-type","application/x-www-form-urlencoded");u.onreadystatechange=function(){var n,h,f,c,l,t,e,i,s;if(u.readyState==4&&u.status==200)if(n=JSON.parse(u.responseText),n.Items.length==1&&typeof n.Items[0].Error!="undefined")showError(n.Items[0].Description);else if(n.Items.length==0)showError("Sorry, there were no results");else{for(h=r.find("#result"),f="mySelect",$("form#complaint-form").length>0&&(f=o),h.children.length>0&&(c=r.find("#"+f),c.remove()),l=r.find("#result"),t=document.createElement("select"),t.id="selectList",t.setAttribute("id",f),t.setAttribute("name",f),t.setAttribute("required","required"),t.classList="form-control addresslist-select",l.append(t),e=document.createElement("option"),e.text="Select Address",e.setAttribute("value",""),e.setAttribute("selected","selected"),t.append(e),i=0;i<n.Items.length;i++)s=document.createElement("option"),s.setAttribute("value",n.Items[i].Id),s.text=n.Items[i].Text+" "+n.Items[i].Description,s.setAttribute("class",n.Items[i].Type),t.append(s);selectAddress(r,f)}};u.send(i)}}function selectAddress(n,t){var r=n.find("#result"),i;if(r.children.length>0){i=n.find("#"+t);$(i).on("change",function(t){var i=t.target[t.target.selectedIndex];i.text!=="Select Address"&&(i.className==="Address"?($("#TenancyAddress").val(i.text),retrieveAddress(i.value,n)):findAddress(this,i.value))})}}function retrieveAddress(n,t){var r="",i;r+="&Key="+encodeURIComponent(Key);r+="&Id="+encodeURIComponent(n);r+="&Field1Format="+encodeURIComponent("{HomeNation}");i=new XMLHttpRequest;i.open("POST","https://services.postcodeanywhere.co.uk/Capture/Interactive/Retrieve/v1.00/json3.ws",!0);i.setRequestHeader("Content-type","application/x-www-form-urlencoded");i.onreadystatechange=function(){var u,n,r,f;if(i.readyState==4&&i.status==200)if(u=JSON.parse(i.responseText),u.Items.length==0)showError("Sorry, there were no results");else{n=u.Items[0];r=[];n.Company!=""&&n.Company!=undefined&&r.push(n.Company);n.Line1!=""&&n.Line1!=undefined&&r.push(n.Line1);n.Line2!=""&&n.Line2!=undefined&&r.push(n.Line2);n.Line3!=""&&n.Line3!=undefined&&r.push(n.Line3);let i=r.length>0?r.join(", "):"";t.find(".street-houseno").val(n.BuildingNumber);t.find(".street-address").val(i);t.find(".town-city").val(n.City);t.find(".county-field").val(n.Province!=""?n.Province:n.District);t.children(".address-property").css("display","block");t.children(".address-finder").css("display","none");t.find(".localauthority-field").val(n.AdminAreaName);t.find(".postal-code").val(n.PostalCode);t.find(".country-field").val(n.CountryName);t.find(".baseCountry-field").val(n.Field1);t.hasClass("nhos-search")?t.find(".searchBox").removeAttr("required").val(""):t.find(".searchBox").val(n.PostalCode);t.hasClass("property-details-form")?bindTenantAddress(!0):t.hasClass("landlord-details")&&(f=t.attr("landlord-count"),bindLandlordAddress(f,!0))}};i.send(r)}function resetAddressFields(n){n.find(".street-houseno").val("");n.find(".town-city").val("");n.find(".county-field").val("");n.find(".street-address").val("");n.find(".country-field").val("");n.find(".localauthority-field").val("");n.find(".postal-code").val("")}function AutocompleteSourceData(n,t,i){var r="",u;r+="&Key="+encodeURIComponent(Key);r+="&Text="+encodeURIComponent(n.term);r+="&IsMiddleware="+encodeURIComponent(!1);r+="&Origin="+encodeURIComponent("");r+="&Container="+encodeURIComponent(i);r+="&Countries="+encodeURIComponent("GBR");r+="&Limit="+encodeURIComponent("10");r+="&Language="+encodeURIComponent("en-gb");u=new XMLHttpRequest;u.open("POST","https://api.addressy.com/Capture/Interactive/Find/v1.10/json3.ws",!0);u.setRequestHeader("Content-type","application/x-www-form-urlencoded");u.onreadystatechange=function(){var n,r,i;if(u.readyState==4&&u.status==200)if(n=JSON.parse(u.responseText),n.Items.length==1&&typeof n.Items[0].Error!="undefined")showError(n.Items[0].Description);else if(n.Items.length==0)showError("Sorry, there were no results");else{for(r=[],i=0;i<n.Items.length;i++)r.push({value:n.Items[i].Id,label:n.Items[i].Text+" "+n.Items[i].Description,pType:n.Items[i].Type});t(r)}};u.send(r)}var Key="YU18-AW45-MG62-TG93"