$(function(){function n(){$(".remove").length===0?$(".remove").hide():$(".remove").show();$(".remove").length>=t?($(".add").prop("disabled",!0),$(".add").attr("title","Sorry, you have reached the maximum number of documents you can upload.")):($(".add").prop("disabled",!1),$(".add").attr("title",""))}function i(){$(".remove").click(function(t){$(this).parents(".dynamicRow").remove();n();t.preventDefault()})}$(".add").click(function(){var t=$(this).data("request-url");t||(t="Planning");$.get({url:(rootURL==="//"?"/":rootURL)+"Document/AddDocument/?module="+t,dataType:"html",cache:!1}).done(function(t){$(".dynamicList").append(t);i();n();$("form").each(function(){$("form").validate().destroy()});$.validator.unobtrusive.parse($("form"))})});$(".add").keypress(function(n){event.keyCode==13&&n.preventDefault()});var t=5;$(function(){$("form[data-maximumdocuments!=''][data-maximumdocuments]").length>0&&(t=$("form[data-maximumDocuments!=''][data-maximumdocuments]").data("maximumdocuments"))});n();i()});$(document).ready(function(){var n=".blockComment";$(n).length>0&&(Cookies!==undefined&&Cookies.get("CommentSubmitted")!==undefined&&$(n).attr("disabled",!0),$("#commentsForm").submit(function(){$("#commentsForm").valid()&&$(n,this).attr("disabled",!0)}))});$(function(){$(".txtCommentsCount").keyup(function(){$(".chars").text($(".chars").data("limit")-$(this).val().length)})});$(function(){if($(".clear-form").length)$("form").on("click",".clear-form",function(n){n.preventDefault();var t=$(this).closest("form");t.find(":input").not(":button, :submit, :reset, :hidden, :checkbox, :radio, :text[readonly]").prop("value","");t.find(":checkbox, :radio").prop("checked",!1)})});$(function(){function n(){var n=$(this).data("openGroupClass")||"caret",t=$(this).data("closedGroupClass")||"caretUp";$(this).find(".header").click(function(){$(this).nextUntil("tr.header").toggle();$(this).find("."+n).toggleClass(t)});$(this).find(".header").keypress(function(n){n.which===13&&(n.preventDefault(),$(this).click())})}$(".document-list").each(n);$(".document-list").on("document-reload",n)});$(function(){($(".disable-cookie-alert").length||Cookies===undefined||Cookies.get("AcceptedCookies")!==undefined)&&$("#cookie-alert").hide();$("#cookie-alert button").click(function(){return Cookies.set("AcceptedCookies",!0,{expires:30}),$("#cookie-alert").slideUp(),!1})});$.validator.addMethod("maxlengthdefaulterror",function(n,t){var i=t.attributes["data-val-maxlengthdefaulterror-length"].nodeValue;return n.length<=i});$.validator.unobtrusive.adapters.add("maxlengthdefaulterror",["maxlengthdefaulterror"],function(n){n.rules.maxlengthdefaulterror="#"+n.params.maxlengthdefaulterror;n.messages.maxlengthdefaulterror=n.message});$(function(){var n=".datePicker",t;if(!($(n).length<1)&&$.isFunction($(n).datepicker)&&(t="dd/mm/yy",$(n).datepicker({dateFormat:t,changeMonth:!0,changeYear:!0,yearRange:"1900:+00",minDate:"01/01/1900",onSelect:function(){$(this).parents("form").valid()}}),$.validator!==undefined)){function n(n){try{return $.datepicker.parseDate(t,n),!0}catch(i){return!1}}$.validator.methods.date=function(t,i){return this.optional(i)||n(t)}}});$(function(){function t(){var t=$(this);ToggleDownloadButton(t);t.find(".selectAll").click(function(){var i=this.checked;t.find(n).each(function(){CanSelect(this)&&$(this).prop("checked",i)});ToggleDownloadButton(t)});t.find(n).change(function(){t.find(".selectAll").prop("checked",t.find(n+":checked").length===t.find(n).length);ToggleDownloadButton(t)})}function i(){$(".documentsgroup").each(function(){$(this).hide()});var n=$("#documentSearch").val();$(".documentrow").each(function(){var t=$(this).find(".documentdescription").text();t.toLowerCase().indexOf(n.toLowerCase())>=0?($(this).removeClass("imagefilter"),$(this).parent().show()):$(this).addClass("imagefilter")})}if($(".download-selected").length){var n='input[name="selectedDoc"]';$.isFunction(window.CanEnableDownloadButton)||(window.CanEnableDownloadButton=function(){return!0});$.isFunction(window.CanSelect)||(window.CanSelect=function(){return!0});window.ToggleDownloadButton=function(t){$(".download-selected:eq("+$(".document-list").index(t)+")").prop("disabled",!CanEnableDownloadButton(t)||t.find(n+":checked").length<1)};$(".document-list").each(t);$(".document-list").on("document-reload",t);$(".download-selected").click(function(){function t(n,t){r.append($("<input />").attr({type:"hidden",name:n,value:t}))}var i,r;if(typeof rootURL=="undefined"){alert("rootURL not set up in View.");return}if(i=$(".document-list:eq("+$(".download-selected").index(this)+")"),!i.find(n+":checked").length){alert("Please tick any documents that you wish to download first.");return}r=$("<form><\/form>").attr({action:(rootURL==="//"?"/":rootURL)+"Document/DownloadSelected",method:"post",style:"display:none;"});i.find(n+":checked").each(function(){var n=$(this).data();t("modules",n.module);t("recordNumbers",n.record);t("planIds",n.planid);t("imageIds",n.imageid);t("isPlans",n.isplans);t("filenames",n.filename)});r.appendTo("body").submit().remove()});$("#documentSearch").on("input",function(){i()})}});$(function(){$(".addressArea").hide();$(".hideOnLoad").hide();$(".GazetteerLoading").hide();$(".searchGazetteer").click(function(){var t=$(this),n=$(".gazetteerarea").length?t.parents(".gazetteerarea"):t.parents("body"),i=n.find(".postcode").val();if(t.attr("disabled",!0),n.find(".GazetteerLoading").show(),!i){alert("Please enter a postcode.");t.attr("disabled",!1);n.find(".GazetteerLoading").hide();return}$.post({url:(rootURL==="//"?"/":rootURL)+"Addresses/GetAddresses",data:{postcode:i},context:n.find(".addresses"),datatype:"html"}).done(function(i){$(this).html(i);var r=$(this).find(".GazetteerData").length>0;n.find(".addressArea").toggle(!r);n.find(".hideOnLoad").toggle(r);n.find(".GazetteerLoading").hide();t.attr("disabled",!1);t.focus()})});$(".manual").click(function(){var n=$(".gazetteerarea").length?$(this).parents(".gazetteerarea"):$(this).parents("body");return n.find(".addressArea").toggle(),!1});$(".addresses").on("change",".GazetteerData",function(){var n=$(".gazetteerarea").length?$(this).parents(".gazetteerarea"):$(this).parents("body"),t=$(this).find("option:selected");n.find(".address").val(t.text());n.find(".uprn").val(t.val())})});!function(n){var t=!1,r,i;("function"==typeof define&&define.amd&&(define(n),t=!0),"object"==typeof exports&&(module.exports=n(),t=!0),t)||(r=window.Cookies,i=window.Cookies=n(),i.noConflict=function(){return window.Cookies=r,i})}(function(){function n(){for(var i,r,n=0,t={};n<arguments.length;n++){i=arguments[n];for(r in i)t[r]=i[r]}return t}function t(i){function r(t,u,f){var o,c,l,s,v,e,h;if("undefined"!=typeof document){if(arguments.length>1){"number"==typeof(f=n({path:"/"},r.defaults,f)).expires&&(c=new Date,c.setMilliseconds(c.getMilliseconds()+864e5*f.expires),f.expires=c);f.expires=f.expires?f.expires.toUTCString():"";try{o=JSON.stringify(u);/^[\{\[]/.test(o)&&(u=o)}catch(n){}u=i.write?i.write(u,t):encodeURIComponent(u+"").replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent);t=(t=(t=encodeURIComponent(t+"")).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape);l="";for(s in f)f[s]&&(l+="; "+s,!0!==f[s]&&(l+="="+f[s]));return document.cookie=t+"="+u+l}t||(o={});for(var y=document.cookie?document.cookie.split("; "):[],p=/(%[0-9A-Z]{2})+/g,a=0;a<y.length;a++){v=y[a].split("=");e=v.slice(1).join("=");this.json||'"'!==e.charAt(0)||(e=e.slice(1,-1));try{if(h=v[0].replace(p,decodeURIComponent),e=i.read?i.read(e,h):i(e,h)||e.replace(p,decodeURIComponent),this.json)try{e=JSON.parse(e)}catch(n){}if(t===h){o=e;break}t||(o[h]=e)}catch(n){}}return o}}return r.set=r,r.get=function(n){return r.call(r,n)},r.getJSON=function(){return r.apply({json:!0},[].slice.call(arguments))},r.defaults={},r.remove=function(t,i){r(t,"",n(i,{expires:-1}))},r.withConverter=t,r}return t(function(){})}),function(n){var t=!1,r,i;typeof define=="function"&&define.amd&&(define(n),t=!0);typeof exports=="object"&&(module.exports=n(),t=!0);t||(r=window.Cookies,i=window.Cookies=n(),i.noConflict=function(){return window.Cookies=r,i})}(function(){function n(){for(var n=0,r={},t,i;n<arguments.length;n++){t=arguments[n];for(i in t)r[i]=t[i]}return r}function t(i){function r(t,u,f){var o,c,l,s,v,e,h;if(typeof document!="undefined"){if(arguments.length>1){f=n({path:"/"},r.defaults,f);typeof f.expires=="number"&&(c=new Date,c.setMilliseconds(c.getMilliseconds()+f.expires*864e5),f.expires=c);f.expires=f.expires?f.expires.toUTCString():"";try{o=JSON.stringify(u);/^[\{\[]/.test(o)&&(u=o)}catch(w){}u=i.write?i.write(u,t):encodeURIComponent(String(u)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent);t=encodeURIComponent(String(t));t=t.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent);t=t.replace(/[\(\)]/g,escape);l="";for(s in f)f[s]&&(l+="; "+s,f[s]!==!0)&&(l+="="+f[s]);return document.cookie=t+"="+u+l}t||(o={});for(var y=document.cookie?document.cookie.split("; "):[],p=/(%[0-9A-Z]{2})+/g,a=0;a<y.length;a++){v=y[a].split("=");e=v.slice(1).join("=");this.json||e.charAt(0)!=='"'||(e=e.slice(1,-1));try{if(h=v[0].replace(p,decodeURIComponent),e=i.read?i.read(e,h):i(e,h)||e.replace(p,decodeURIComponent),this.json)try{e=JSON.parse(e)}catch(w){}if(t===h){o=e;break}t||(o[h]=e)}catch(w){}}return o}}return r.set=r,r.get=function(n){return r.call(r,n)},r.getJSON=function(){return r.apply({json:!0},[].slice.call(arguments))},r.defaults={},r.remove=function(t,i){r(t,"",n(i,{expires:-1}))},r.withConverter=t,r}return t(function(){})});const returnKey=13;$(function(){$(".icon").click(function(){$(this).parent().toggleClass("responsive")});$(".tab").on("click keypress",function(n){if(n.type!=="keypress"||n.which===returnKey){var t=$(this).parent();t.siblings(".tab-content").children(".tabContent").each(function(){$(this).hide()});t.siblings(".tab-content").children(".tabContent").eq(t.children(".tab").index(this)%t.children(".tab").length).show();$(this).addClass("active in btn-primary round").siblings().removeClass("active in btn-primary round");t.hasClass("topnav responsive")&&$(this).parent().removeClass("responsive")}});$(".tab-menu-dropdown").on("change",function(){var n=$(this).val();$(".active").removeClass("active");$(n).addClass("active")});$.each($(".topnav"),function(){$(this).children(".tab").first().click()})});$(".resultsPerPage").change(function(){$(this).closest("form").submit()});$(document).ready(function(){if($("#DevelopmentScaleCode").val()!=null&$("#DevelopmentScaleCode").val()!=""){var n=$("#AdviceLevelCode").val();$("#DevelopmentScaleCode").trigger("change")}$("#DevelopmentScaleCode").change(function(){var n=$("#PreApplication").data("advicelistaction");n=n.substring(0,n.length-1);$.getJSON(n+"?DevelopmentScaleCode="+$("#DevelopmentScaleCode").val(),function(n){var t="<option>Select a advice level<\/option>";$.each(n,function(){t+="<option data-code='"+this.HasFee+"' value='"+this.Code+"'>"+this.AdviceLevel+"<\/option>"});$("#AdviceLevelCode").html(t);$("#AdviceLevelCode").prop("disabled",!1)})});$("#AdviceLevelCode").change(function(){var n=$("#AdviceLevelCode").find(":selected").data("code")==!0?"Pay now":"Submit",t=$("#submitButton")[0];$(t).value=n;$(t).html(n)})});$(function(){function i(i,r,u,f){var e=i.find("tr").sort(function(i,e){if($(i).hasClass("header")||$(e).hasClass("header"))return $(e).hasClass("header");var o=t(i,u),s=t(e,u);return f==="date"?n(new Date(Number(o.substr(6,4)),Number(o.substr(3,2))-1,Number(o.substr(0,2))),new Date(Number(s.substr(6,4)),Number(s.substr(3,2))-1,Number(s.substr(0,2))),r):f==="number"?n(parseInt(s),parseInt(o),r):o===s?0:r?o.localeCompare(s):s.localeCompare(o)});i.html(e)}function n(n,t,i){return n===t?0:(i?n<=t:t<=n)?-1:1}function t(n,t){var i=$("td:eq("+t+")",n);return(i.data("sortValue")||i.text()).toString()}$(".document-list").on("document-reload",!1);$(".sortable .sort").click(function(){var n=$(this),r=n.data("sortOrder")!==!1,t;n.data("sortOrder",!r);t=n.closest("table");t.find("tbody").each(function(){i($(this),r,n.index(),n.data("sortType"))});t.find(".sorted").html("");n.find(".sorted").html(r?"▲":"▼");t.closest(".document-list").triggerHandler("document-reload")})});$(function(){var n="active",t="active",i;$(".tab-configuration").length>0&&(i=$(".tab-configuration").first().data(),n=i.activeButtonClass||n,t=i.activePaneClass||t);$(".tab-button").click(function(i){$(".tab-button."+n).removeClass(n);$(".tab-pane."+t).removeClass(t);$(this).addClass(n);$(".tab-pane").eq($(".tab-button").index(this)%$(".tab-pane").length).addClass(t);i.preventDefault()})});$(function(){$(".caret").toggleClass("caretUp")})