function opener(n,t,i){var u=$("#map-panel"),r=$("#side-panel"),e=$("#opener"),o=$("#HomeButton"),s=$("#map-cite"),f,c;t=$(window).height();i=$(window).width();i<=320|i<=767&&(size="SMALL",r.width()==0?(r.removeClass("visible"),r.addClass("not-visible")):(r.addClass("visible"),r.removeClass("not-visible")));i>=768&&i<=1024&&(size="MEDIUM");i>1024&&(size="LARGE");f=!1;switch(size){case"SMALL":r.hasClass("visible")?(r.removeClass("visible"),u.animate({width:"100%"},100),r.animate({width:"0"},100,function(){r.css("top","-9999px")}),o.css("display","block"),s.css("display","block")):r.hasClass("not-visible")&&(f=!0,r.removeClass("not-visible"),u.animate({width:"0"},100),r.animate({width:"100%"},100,function(){r.css("top","0px")}),r.css("display","block"),o.css("display","none"),s.css("display","none"));break;case"MEDIUM":h()?($(r).toggle("slide",{direction:"right"},100),r.removeClass("visible"),e.animate({right:"0%"},100),u.animate({width:"100%"},100)):(f=!0,$(r).toggle("slide",{direction:"right"},100),r.addClass("visible"),e.animate({right:"45%"},100),u.animate({width:"55%"},100));break;case"LARGE":h()?($(r).toggle("slide",{direction:"right"},100),r.removeClass("visible"),e.animate({right:"0%"},100),u.animate({width:"100%"},100)):(f=!0,$(r).toggle("slide",{direction:"right"},100),r.addClass("visible"),e.animate({right:"25%"},100),u.animate({width:"75%"},100))}map.resize();map.reposition();f&&(c=$("#municipality").val(),c==""?loadGroupedRainfall():loadRainfallLast24Hours($("#municipality").val(),$("#municipality").children("option").filter(":selected").text()))}function loadMap(){require(["esri/map","esri/config","esri/dijit/Popup","esri/InfoTemplate","esri/layers/FeatureLayer","esri/tasks/query","esri/tasks/FeatureSet","esri/symbols/SimpleMarkerSymbol","esri/symbols/SimpleLineSymbol","esri/symbols/SimpleFillSymbol","esri/renderers/SimpleRenderer","esri/renderers/UniqueValueRenderer","esri/geometry/Point","esri/layers/ArcGISDynamicMapServiceLayer","esri/dijit/Legend","esri/graphic","dojo/parser","esri/tasks/query","esri/tasks/QueryTask","dojo/dom","application/bootstrapmap","dijit/registry","esri/Color","esri/dijit/HomeButton","dojo/_base/array","dijit/form/HorizontalRule","dijit/form/HorizontalRuleLabels","dijit/form/HorizontalSlider","dijit/layout/AccordionContainer","dojo/domReady!"],function(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,f,b,k,d,g,nt,tt){function ut(n){var t=[],e=n.mapPoint,r=n.graphic.attributes,i;$.map(r,function(n){return t.push(n),t});n.graphic._layer.name=="Participating Municipality/Permittee"?(k.byId("municipality").val=t[3],document.getElementById("municipality").value=t[7],clearSelectedLayers(),i=new f,i.where="GNIS = '"+t[3]+"'",lyrMunicipalities.selectFeatures(i,u.SELECTION_NEW,function(){}),$.each(legendLayers,function(n){return legendLayers[n].name==="lyrMunicipalities"?(legendLayers.splice(n,1),!1):legendLayers[n].name==="lyrWaterbodies"?(legendLayers.splice(n,1),!1):void 0}),legendLayers.splice(2,0,{layer:lyrMunicipalities,title:" ",name:"lyrMunicipalities"}),loadRainfallLast24Hours(t[7],t[3])):(clearSelectedLayers(),$.each(legendLayers,function(n){if(legendLayers[n].name==="lyrWaterbodies")return legendLayers.splice(n,1),!1}),legendLayers.splice(2,0,{layer:lyrMunicipalities,title:" ",name:"lyrWaterbodies"}))}function st(n){clearSelectedLayers();var t=new f;t.where="IW_ID = "+n;lyrWaterbodies.selectFeatures(t,u.SELECTION_NEW,function(n){var t=n[0].geometry.getExtent().expand(2);map.setExtent(t)})}function ht(n){clearSelectedLayers();var t=new f;t.where="GNIS = '"+n+"'";lyrMunicipalities.selectFeatures(t,u.SELECTION_NEW,function(n){var t=n[0].geometry.getExtent().expand(2);map.setExtent(t)})}var ft,et,ct,it,lt;w.parse();mapCenter=[-74.14,40.72];ft=new esri.geometry.Extent({xmin:-8306564.7378047425,ymin:4921750.6594549045,xmax:-8206432.2307511233,ymax:5021118.7962256717,spatialReference:{wkid:102100}});map=d.create("map",{basemap:"topo",slider:!0,scrollWheelZoom:!0,extent:ft,autoResize:!0});map.enableMapNavigation();et=new tt({map:map},"HomeButton");et.startup();map.on("load",function(){var n=k.byId("loadImageMap");esri.hide(n)});var at=new h(h.STYLE_SOLID,new s(s.STYLE_SOLID,new nt([55,55,55,.35]),1),new nt([255,255,0,.35])),yt=new h(h.STYLE_SOLID,new s(s.STYLE_SOLID,new nt([255,255,0]),2),new nt([125,125,125,.35])),ot={type:"simple",label:"Selected municipality or waterbody",description:"",symbol:at},vt=(new h).setColor(new nt([255,255,0]),2),rt=new r;rt.setTitle("${PVSC_SDE.DBO.Participating_Municipalities.MUN_LABEL}");rt.setContent("<b>Date of last CSO:<\/b> <br/>${PVSCRainfallMonitoring.dbo.MunicipalityLastPredictedCSOView.LastPredictedDate:dteval}");dteval=function(n){if(n==null)return"N/A";var t=new Date(n);return t.toDateString()};municipalities=new u("https://maps.hdrgateway.com/arcgis/rest/services/Kentucky/PVSC/MapServer/4",{outFields:["*"],infoTemplate:rt});municipalities.setOpacity(.75);lyrWaterbodies=new u("https://maps.hdrgateway.com/arcgis/rest/services/Kentucky/PVSC/MapServer/2",{mode:u.MODE_SELECTION});lyrWaterbodies.setRenderer(new c(ot));lyrMunicipalities=new u("https://maps.hdrgateway.com/arcgis/rest/services/Kentucky/PVSC/MapServer/4",{mode:u.MODE_SELECTION});lyrMunicipalities.setRenderer(new c(ot));bufferedOverlay=new u("https://maps.hdrgateway.com/arcgis/rest/services/Kentucky/PVSC/MapServer/6");ct=new u("https://maps.hdrgateway.com/arcgis/rest/services/Kentucky/PVSC/MapServer/5");it=new u("https://maps.hdrgateway.com/arcgis/rest/services/Kentucky/PVSC/MapServer/0");it.setScaleRange(25e4,0);legendLayers.push({layer:municipalities,title:" ",name:"municipalities"});legendLayers.push({layer:bufferedOverlay,title:" ",name:"bufferedOverlay"});legendLayers.push({layer:it,title:" ",name:"csoOutfalls"});map.on("layers-add-result",function(){var n=legendLayers,t;n.length>0&&(t=new y({map:map,layerInfos:n},"legendDiv"),t.startup())});map.addLayers([municipalities,lyrMunicipalities,lyrWaterbodies,bufferedOverlay,it]);map.reorderLayer(bufferedOverlay,2);map.reorderLayer(municipalities,0);map.reorderLayer(lyrMunicipalities,3);map.infoWindow.resize(200,300);loadGroupedRainfall();municipalities.setSelectionSymbol(vt);map.on("load",function(){});lt="";municipalities.on("click",ut);lyrWaterbodies.on("click",ut);$("#waterbodies").on("change",function(){$(this).val()==""?(resetMap(),$.each(legendLayers,function(n){return legendLayers[n].name==="lyrWaterbodies"?(legendLayers.splice(n,1),!1):legendLayers[n].name==="lyrMunicipalities"?(legendLayers.splice(n,1),!1):void 0}),legendLayers.filter(function(n){return n.name!=="lyrMunicipalities"})):(st($(this).val()),$.each(legendLayers,function(n){return legendLayers[n].name==="lyrWaterbodies"?(legendLayers.splice(n,1),!1):legendLayers[n].name==="lyrMunicipalities"?(legendLayers.splice(n,1),!1):void 0}),legendLayers.splice(2,0,{layer:lyrWaterbodies,title:" ",name:"lyrWaterbodies"}),legendLayers.filter(function(n){return n.name!=="lyrMunicipalities"}))});$("#municipality").on("change",function(){$(this).val()==""?(resetMap(),$.each(legendLayers,function(n){if(legendLayers[n].name==="lyrWaterbodies")return legendLayers.splice(n,1),!1}),$.each(legendLayers,function(n){if(legendLayers[n].name==="lyrMunicipalities")return legendLayers.splice(n,1),!1}),legendLayers.filter(function(n){return n.name!=="lyrWaterbodies"})):(ht($(this).val()),$.each(legendLayers,function(n){if(legendLayers[n].name==="lyrMunicipalities")return legendLayers.splice(n,1),!1}),legendLayers.splice(2,0,{layer:lyrMunicipalities,title:" ",name:"lyrMunicipalities"}),loadRainfallLast24Hours($(this).val(),$(this).children("option").filter(":selected").text()))})})}function loadInnerMap(){require(["esri/map","esri/config","esri/layers/ArcGISDynamicMapServiceLayer","dojo/dom"],function(n,t,i,r){function f(){var n=new Date,t=n.getHours()>=12?"PM":"AM";$("#radarLastUpdated").html(n.getMonth()+1+"/"+n.getDate()+"/"+n.getFullYear()+" "+(n.getHours()>12?n.getHours()-12:n.getHours())+":"+(n.getMinutes()<10?"0"+n.getMinutes():n.getMinutes())+" "+t)}innerMap=new n("innerMap",{basemap:"national-geographic",center:[-74.1,40.85],zoom:7,slider:!0});innerMap.on("load",function(){var n=r.byId("loadImageInnerMap");esri.hide(n)});var u=new i("https://nowcoast.noaa.gov/arcgis/rest/services/nowcoast/radar_meteo_imagery_nexrad_time/MapServer",{refreshInterval:refreshInterval});innerMap.addLayer(u);dojo.connect(u,"onError",function(){$("#innerMap").html("<i>Radar is not currently available.<\/i>");$("#radarLastUpdatedParent").hide()});dojo.connect(u,"onLoad",function(){dojo.connect(u,"onUpdateEnd",f)})})}function resetMap(){clearSelectedLayers();$.each(legendLayers,function(n){if(legendLayers[n].name==="lyrWaterbodies")return legendLayers.splice(n,1),!1});$.each(legendLayers,function(n){if(legendLayers[n].name==="lyrMunicipalities")return legendLayers.splice(n,1),!1});$("#waterbodies")[0].selectedIndex=0;$("#municipality")[0].selectedIndex=0;hideRainfallChart();$("#chartError").hide();$("#chartNoToggle").hide();$("#chartToggleRC").show();$("#chartToggleRM").hide();$("#radarMap").show();loadGroupedRainfall()}function resetandClear(){clearSelectedLayers();$.each(legendLayers,function(n){if(legendLayers[n].name==="lyrWaterbodies")return legendLayers.splice(n,1),!1});$.each(legendLayers,function(n){if(legendLayers[n].name==="lyrMunicipalities")return legendLayers.splice(n,1),!1});$("#waterbodies")[0].selectedIndex=0;$("#municipality")[0].selectedIndex=0;hideRainfallChart();$("#chartError").hide();$("#chartNoToggle").hide();$("#chartToggleRC").show();$("#chartToggleRM").hide();$("#rainfallChart").css("top")=="-9999px"&&$("#chartToggleLoadBig").hide();loadGroupedRainfall(!0);$("#radarMap").show()}function clearSelectedLayers(){lyrMunicipalities.clearSelection();lyrWaterbodies.clearSelection();map.graphics.clear();map.infoWindow.hide();lyrMunicipalities.hide();lyrWaterbodies.hide();lyrMunicipalities.show();lyrWaterbodies.show()}function loadGroupedRainfall(n){loadRainfallLast24Hours(null,"NJ CSO Group",n)}function loadRainfallLast24Hours(n,t,i){xhr&&(xhr.abort(),$("#radarMap").css("display")==="none"&&showRainfallChart());var r=$("#rainfallChart").css("top")!="-9999px";xhr=$.ajax({url:$("#ajax-chart-url").val(),type:"GET",data:{municipalityCode:n},dataType:"json",contentType:"application/json; charset=utf-8",beforeSend:function(){chart&&chart.destroy();$("#chartNoToggle").hide();$("#chartToggleRC").hide();$("#chartToggleRM").hide();hideRainfallChart();$("#radarMap").css("display")=="none"&&$("#chartToggleLoadBig").show();i==!0&&$("#chartToggleLoadBig").hide()},success:function(n){xhr=null;$("#chartMunicipalityName").html(t);$("#chartToggleLoadBig").hide();showRainfallChart();$("#ajax-chart-data").val(JSON.stringify(n));createChart();r?$("#chartToggleRM").show():(hideRainfallChart(),$("#chartToggleRC").show());$("#chartError").hide()},error:function(n){n.statusText!="abort"&&$("#chartError").show()}})}function setupUI(){$("input[type=radio][name=sel]").change(function(){$("#waterbodies").hide();$("#municipality").hide();this.value=="ws"?($("#waterbodies").show(),resetMap()):this.value=="mu"&&($("#municipality").show(),resetMap())});$("#rdomu").prop("checked",!0);$("#btnSimulateSnowfall").click(function(){var n=$("#btnSimulateSnowfall");n.val()=="Show Snowfall Mode"?(showSnowfall(),n.val("Show Rainfall Mode")):(hideSnowfall(),n.val("Show Snowfall Mode"))})}function UpdateHourlyRainfallBegin(){$("#ajaxUpdate").show()}function UpdateHourlyRainfallSuccess(n){municipalities.refresh();bufferedOverlay.refresh();hideSnowfall();loadGroupedRainfall();$("#ajaxUpdate").hide();$("#lastUpdated").html(n)}function UpdateHourlySnowfallBegin(){}function UpdateResetSimulationSuccess(){location.reload()}function UpdateHourlySnowfallSuccess(){showSnowfall()}function hideSnowfall(){$("#map").show();$("#snow").hide()}function showSnowfall(){$("#map").hide();$("#snow").show()}function toggleRainfallChart(){$("#radarMap").hide();showRainfallChart();$("#chartNoToggle").hide();$("#chartToggleRC").hide();$("#chartToggleRM").show();createChart()}function toggleRadarMap(){$("#radarMap").show();hideRainfallChart();$("#chartNoToggle").hide();$("#chartToggleRC").show();$("#chartToggleRM").hide()}function hideRainfallChart(){$("#rainfallChart").css("position","absolute");$("#rainfallChart").css("top","-9999px")}function showRainfallChart(){$("#rainfallChart").css("display","inline");$("#rainfallChart").css("position","relative");$("#rainfallChart").css("top","0px");$("#rainfallChart").css("display","")}function showRefreshPrompt(){$("#myModal").modal("hide");$("#modalRefresh").on("hidden.bs.modal",function(){location.reload()});$("#modalRefresh").modal("show")}function initializeRefreshPrompt(){setTimeout(showRefreshPrompt,36e5)}function createChart(){var t=$("#ajax-chart-data").val(),n,i;t!==""&&(chart&&chart.destroy(),$("#myChart").remove(),$("#chartNowArrowHolder").before('<canvas id="myChart"><\/canvas>'),n=JSON.parse(t),n&&(i=document.getElementById("myChart").getContext("2d"),chart=new Chart(i).Bar(n.Result,{scaleOverride:!0,scaleSteps:n.ScaleSteps,scaleStepWidth:n.ScaleStepWidth,scaleStartValue:n.ScaleStartValue,scaleLabel:"<%= ' ' + value%>",scaleFontSize:8,responsive:!0})))}var orient,screenW,screenH,size;(function(n){function i(n,t){for(var i=window,r=(n||"").split(".");i&&r.length;)i=i[r.shift()];return typeof i=="function"?i:(t.push(n),Function.constructor.apply(null,t))}function u(n){return n==="GET"||n==="POST"}function o(n,t){u(t)||n.setRequestHeader("X-HTTP-Method-Override",t)}function s(t,i,r){var u;r.indexOf("application/x-javascript")===-1&&(u=(t.getAttribute("data-ajax-mode")||"").toUpperCase(),n(t.getAttribute("data-ajax-update")).each(function(t,r){var f;switch(u){case"BEFORE":f=r.firstChild;n("<div />").html(i).contents().each(function(){r.insertBefore(this,f)});break;case"AFTER":n("<div />").html(i).contents().each(function(){r.appendChild(this)});break;case"REPLACE-WITH":n(r).replaceWith(i);break;default:n(r).html(i)}}))}function f(t,r){var e,h,f,c;(e=t.getAttribute("data-ajax-confirm"),!e||window.confirm(e))&&(h=n(t.getAttribute("data-ajax-loading")),c=parseInt(t.getAttribute("data-ajax-loading-duration"),10)||0,n.extend(r,{type:t.getAttribute("data-ajax-method")||undefined,url:t.getAttribute("data-ajax-url")||undefined,cache:!!t.getAttribute("data-ajax-cache"),beforeSend:function(n){var r;return o(n,f),r=i(t.getAttribute("data-ajax-begin"),["xhr"]).apply(t,arguments),r!==!1&&h.show(c),r},complete:function(){h.hide(c);i(t.getAttribute("data-ajax-complete"),["xhr","status"]).apply(t,arguments)},success:function(n,r,u){s(t,n,u.getResponseHeader("Content-Type")||"text/html");i(t.getAttribute("data-ajax-success"),["data","status","xhr"]).apply(t,arguments)},error:function(){i(t.getAttribute("data-ajax-failure"),["xhr","status","error"]).apply(t,arguments)}}),r.data.push({name:"X-Requested-With",value:"XMLHttpRequest"}),f=r.type.toUpperCase(),u(f)||(r.type="POST",r.data.push({name:"X-HTTP-Method-Override",value:f})),n.ajax(r))}function h(t){var i=n(t).data(e);return!i||!i.validate||i.validate()}var t="unobtrusiveAjaxClick",r="unobtrusiveAjaxClickTarget",e="unobtrusiveValidation";n(document).on("click","a[data-ajax=true]",function(n){n.preventDefault();f(this,{url:this.href,type:"GET",data:[]})});n(document).on("click","form[data-ajax=true] input[type=image]",function(i){var r=i.target.name,u=n(i.target),f=n(u.parents("form")[0]),e=u.offset();f.data(t,[{name:r+".x",value:Math.round(i.pageX-e.left)},{name:r+".y",value:Math.round(i.pageY-e.top)}]);setTimeout(function(){f.removeData(t)},0)});n(document).on("click","form[data-ajax=true] :submit",function(i){var f=i.currentTarget.name,e=n(i.target),u=n(e.parents("form")[0]);u.data(t,f?[{name:f,value:i.currentTarget.value}]:[]);u.data(r,e);setTimeout(function(){u.removeData(t);u.removeData(r)},0)});n(document).on("submit","form[data-ajax=true]",function(i){var e=n(this).data(t)||[],u=n(this).data(r),o=u&&u.hasClass("cancel");(i.preventDefault(),o||h(this))&&f(this,{url:this.action,type:this.method||"GET",data:e.concat(n(this).serializeArray())})})})(jQuery);window.addEventListener("orientationchange",function(){orient=window.orientation},!1);$(window).resize(function(){screenH=$(window).height();screenW=$(window).width();var n=$("#side-panel").css("display")!=="none";return n&&($("#map-panel").removeAttr("style"),$("#side-panel").removeAttr("style"),$("#opener").removeAttr("style")),!0});var map,serviceAreaTask,params,clickpoint,lyrWaterbodies,lyrMunicipalities,municipalities,bufferedOverlay,mapCenter,mapZoom,chart,innerMap,refreshInterval=.25,legendLayers=[],xhr=null,package_path=window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/")),dojoConfig={packages:[{name:"application",location:package_path+"/Scripts/bootstrap-map-js"}]};$(document).ready(function(){loadMap();loadInnerMap();setupUI();$("#myModal").modal("show");initializeRefreshPrompt()})