text: function addCommas(e){for(var t=(e+="").split("."),i=t[0],a=t.length>1?"."+t[1]:"",s=/(\d+)(\d{3})/;s.test(i);)i=i.replace(s,"$1,$2");return i+a}function camelize(e){return e.replace(/(?:^\w|[A-Z]|\b\w)/g,function(e,t){return 0==t?e.toLowerCase():e.toUpperCase()}).replace(/\s+/g,"")}var isOpera=!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,isFirefox="undefined"!=typeof InstallTrigger,isSafari=Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0,isChrome=!!window.chrome&&!isOpera,isIE=!!document.documentMode,version=detectIE();function detectIE(){var e=window.navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return parseInt(e.substring(t+5,e.indexOf(".",t)),10);if(e.indexOf("Trident/")>0){var i=e.indexOf("rv:");return parseInt(e.substring(i+3,e.indexOf(".",i)),10)}return!1}!1!==version&&alert("Internet Explorer users may experience problems with this application's functionality. We recommend using Edge, Chrome, or Firefox for best results.");var appTitle="2012 SPARROW Models for the Northeast: Total Phosphorus, Total Nitrogen, Suspended Sediment, and Streamflow",appVersion="v0.9.0",serviceBaseURL="https://sparrowtest.wim.usgs.gov/arcgis/rest/services/SparrowNortheast/SparrowNortheast/MapServer/",chartUnits=" (kg/yr.)",chartFeatureMax=2500,groupResultsInitIndex=1,splitLayers=[5,6,7,8,14,15,16,17,23,24,25,26,32,33,34,35],mapCenter=[-72.5,41.5];defaultZoomLevel=6,borderThreshold=10;var dynamicBorderLayers=["Catchment","12-Digit hydrologic unit code","Tributary"],initQueryParams=["ST","GP3","GP2","GP1"],groupResultsLabels={a:"Catchment ID",b:"12-Digit hydrologic unit code",c:"Major Watershed",d:"Major Estuary/Bay/Gulf Drainage",e:"State"},rootURL="https://sparrow.wim.usgs.gov/sparrow-northeast-2012/downloads/",phosphorusShapefileURL=rootURL+"northeast_cats_results_tp.zip",nitrogenShapefileURL=rootURL+"northeast_cats_results_tn.zip",streamflowShapefileURL=rootURL+"northeast_cats_results_q.zip",sedimentShapefileURL=rootURL+"northeast_cats_results_ss.zip",phosCalibrationURL=rootURL+"northeast_calibration_sites_tp.zip",nitroCalibrationURL=rootURL+"northeast_calibration_sites_tn.zip",streamflowCalibrationURL=rootURL+"northeast_calibration_sites_q.zip",sedimentCalibrationURL=rootURL+"northeast_calibration_sites_ss.zip",tableOutFields=[{field:"FID",name:"Unique Feature Id"},{field:"GRP1",name:"Major Estuary/Bay/Gulf Drainage"},{field:"GRP2",name:"Major Watershed"},{field:"GRP_3_NA_1",name:"Join Field"},{field:"Area_g3",name:"HUC10 area (mi2)"}],stateTableOutFields=[{field:"FID",name:"Unique Feature Id"},{field:"ST_GP3_NAM",name:"HUC10/State (combination) ID"},{field:"Area_S3",name:"HUC10 area within the state and the  model area (mi2)"},{field:"ST",name:"State"},{field:"GRP_1_NAM",name:"Independent Watershed name (in which HUC10 is nested)"},{field:"GP2",name:"HUC8 (in which HUC10 is nested)"},{field:"GRP_3_NAM",name:"HUC10"},{field:"ST_GP1_NAM",name:"State and Independent Watershed"},{field:"ST_GP2_NAM",name:"State amd HUC8"},{field:"ST_gp3_n_1",name:"Join Field"}],aggregateDefinitions={st:"State",gp1:"Major Estuary/Bay/Gulf Drainage",gp2:"Major Watershed",gp3:"12-Digit hydrologic unit code",sg1:"State_Drainage Area",sg2:"State_Tributary",sg3:"State_HUC12"},catchmentDefinitions={comid:"SPARROW Reach ID",st_comid:"SPARROW Reach by State",pname:"Catchment Name",accl:"Accumulated load (kg)",concentrat:"Concentration, mg/ L",incl:"Incremental load (kg)",accy:"Accumulated yield (kg/km2)",incy:"Incremental yield (kg/km2)",daccl:"Delivered accumulated load (kg)",daccy:"Delivered accumulated yield (kg/km2)",dincl:"Delivered incremental load  (kg)",dincy:"Delivered incremental yield (kg/km2)"},catchmentDefinitions_tn={comid:"SPARROW Reach ID ",st_comid:"SPARROW Reach ID by State",pname:"Catchment Name",accl:"Accumulated load (kg)",concentrat:"Concentration, mg/L",incl:"Incremental load (kg)",accy:"Accumulated yield (kg/km2)",incy:"Incremental yield (kg/km2)",daccl:"Delivered accumulated load (kg)",daccy:"Delivered accumulated yield (kg/km2)",dincl:"Delivered incremental load  (kg)",dincy:"Delivered incremental yield (kg/km2)"},catchmentDefinitions_q={comid:"SPARROW Reach ID ",st_comid:"SPARROW Reach ID by State",pname:"Catchment Name",accl:"Accumulated flow (cfs)",incl:"Incremental flow (cfs)",accy:"Accumulated yield (mm/yr)",incy:"Incremental yield (mm/yr)",daccl:"Delivered accumulated flow (cfs)",daccy:"Delivered accumulated yield (mm/yr)",dincl:"Delivered incremental flow (cfs)",dincy:"Delivered incremental yield (mm/yr)"},catchmentDefinitions_ss={comid:"SPARROW Reach ID ",st_comid:"SPARROW Reach ID by State",pname:"Catchment Name",accl:"Accumulated load (MT)",incl:"Incremental load (MT)",accy:"Accumulated yield (MT/km2)",incy:"Incremental yield (MT/km2)",daccl:"Delivered accumulated load (MT)",daccy:"Delivered accumulated yield (MT/km2)",dincl:"Delivered incremental load  (MT)",dincy:"Delivered incremental yield (MT/km2)"},mappedDefinitions={area:"Aggregated area (km2)",al:"Aggregated load (kg)",ay:"Aggregated yield (kg/km2)",dal:"Delivered aggregated load (kg)",day:"Delivered aggregated yield (kg/km2)"},mappedDefinitions_q={area:"Aggregated area (km2)",al:"Aggregated flow (cfs)",ay:"Aggregated yield (mm/yr)",dal:"Delivered aggregated flow (cfs)",day:"Delivered aggregated yield (mm/yr)"},mappedDefinitions_ss={area:"Aggregated area (km2)",al:"Aggregated load (MT)",ay:"Aggregated yield (MT/km2)",dal:"Delivered aggregated load (MT)",day:"Delivered aggregated yield (MT/km2)"},phosphorusSourceDefinitions={s1:"Municipal Wastewater Treatment Discharge",s2:"Urban Land",s3:"Farm Fertilizer",s4:"Manure",s5:"Mineral Phosphorus"},nitrogenSourceDefinitions={s1:"Municipal Wastewater Treatment Discharge",s2:"Urban Land",s3:"Septic System Effluent",s4:"Farm Fertilizer",s5:"Manure",s6:"Nitrogen Fixing Crops",s7:"Atmospheric Deposition"},streamflowSourceDefinitions={s1:"Precipitation minus Actual ET",s2:"Municipal Wastewater Treatment Discharge",s3:"Diversions into Area"},sedimentSourceDefinitions={s1:"Urban - Medium / Coarse",s2:"Urban - Residuum",s3:"Urban - Fine",s4:"Agriculture - Medium / Coarse / Resdiuum",s5:"Agriculture - Fine",s6:"Non - agriculture / non - urban land",s7:"Channel Sources"},fromSourceColor="#FFFFFF",toSourceColor="#000000",phosColors=["#BF0000","#FFCCFF","#FFEC99","#663100","#A2EB85"],nitroColors=["#BF0000","#FFCCFF","#c27ba0","#FFEC99","#663100","#d6ad00","#c9daf8"],streamflowColors=["#2980b9","#BF0000","#BB8FCE"],sedimentColors=["#ff3fff","#ffb9ff","#f2dcdb","#d6ad00","#fff811","#A2EB85","#f58833"];function getFields(e,t,i,a){var s=[];if(aggregateDefinitions.hasOwnProperty(a.toLowerCase()))for(var n in s.push({attribute:a.toUpperCase(),label:aggregateDefinitions[a]}),e)s.push({attribute:a.toUpperCase()+"_"+i.toUpperCase()+"_"+n.toUpperCase(),label:t[i.toLowerCase()]+" "+e[n]});else for(var n in s.push({attribute:a.toUpperCase(),label:t.comid}),e)s.push({attribute:i.toUpperCase()+"_"+n.toUpperCase(),label:t[i.toLowerCase()]+" "+e[n]});return s}var allLayers,Catchments=[{field:"ACCL",name:catchmentDefinitions.accl,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"accl","comid")},{field:"CONCENTRAT",name:catchmentDefinitions.concentrat,chartOutfields:[{attribute:"COMID",label:catchmentDefinitions.comid},{attribute:"CONCENTRAT",label:catchmentDefinitions.concentrat+" Total"}]},{field:"INCL",name:catchmentDefinitions.incl,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"incl","comid")},{field:"ACCY",name:catchmentDefinitions.accy,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"accy","comid")},{field:"INCY",name:catchmentDefinitions.incy,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"incy","comid")},{field:"DACCL",name:catchmentDefinitions.daccl,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"daccl","comid")},{field:"DACCY",name:catchmentDefinitions.daccy,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"daccy","comid")},{field:"DINCL",name:catchmentDefinitions.dincl,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"dincl","comid")},{field:"DINCY",name:catchmentDefinitions.dincy,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"dincy","comid")}],Group3=[{field:"GP3_AY",name:mappedDefinitions.ay,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"ay","gp3")},{field:"GP3_DAY",name:mappedDefinitions.day,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"day","gp3")},{field:"GP3_AL",name:mappedDefinitions.al,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"al","gp3")},{field:"GP3_DAL",name:mappedDefinitions.dal,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"dal","gp3")}],Group2=[{field:"GP2_AY",name:mappedDefinitions.ay,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"ay","gp2")},{field:"GP2_DAY",name:mappedDefinitions.day,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"day","gp2")},{field:"GP2_AL",name:mappedDefinitions.al,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"al","gp2")},{field:"GP2_DAL",name:mappedDefinitions.dal,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"dal","gp2")}],Group1=[{field:"GP1_AY",name:mappedDefinitions.ay,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"ay","gp1")},{field:"GP1_DAY",name:mappedDefinitions.day,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"day","gp1")},{field:"GP1_AL",name:mappedDefinitions.al,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"al","gp1")},{field:"GP1_DAL",name:mappedDefinitions.dal,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"dal","gp1")}],ST=[{field:"ST_AY",name:mappedDefinitions.ay,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"ay","st")},{field:"ST_DAY",name:mappedDefinitions.day,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"day","st")},{field:"ST_AL",name:mappedDefinitions.al,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"al","st")},{field:"ST_DAL",name:mappedDefinitions.dal,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"dal","st")}],Catchments_st=[{field:"ACCL",name:catchmentDefinitions.accl,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"accl","st_comid")},{field:"CONCENTRAT",name:catchmentDefinitions.concentrat,chartOutfields:[{attribute:"ST_COMID",label:catchmentDefinitions.comid},{attribute:"CONCENTRAT",label:catchmentDefinitions.concentrat+" Total"}]},{field:"INCL",name:catchmentDefinitions.incl,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"incl","st_comid")},{field:"ACCY",name:catchmentDefinitions.accy,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"accy","st_comid")},{field:"INCY",name:catchmentDefinitions.incy,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"INCY","st_comid")},{field:"DACCL",name:catchmentDefinitions.daccl,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"daccl","st_comid")},{field:"DACCY",name:catchmentDefinitions.daccy,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"daccy","st_comid")},{field:"DINCL",name:catchmentDefinitions.dincl,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"dincl","st_comid")},{field:"DINCY",name:catchmentDefinitions.dincy,chartOutfields:getFields(phosphorusSourceDefinitions,catchmentDefinitions,"dincy","st_comid")}],Group3_st=[{field:"SG3_AY",name:mappedDefinitions.ay,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"ay","sg3")},{field:"SG3_DAY",name:mappedDefinitions.day,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"day","sg3")},{field:"SG3_AL",name:mappedDefinitions.al,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"al","sg3")},{field:"SG3_DAL",name:mappedDefinitions.dal,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"dal","sg3")}],Group2_st=[{field:"SG2_AY",name:mappedDefinitions.ay,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"ay","sg2")},{field:"SG2_DAY",name:mappedDefinitions.day,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"day","sg2")},{field:"SG2_AL",name:mappedDefinitions.al,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"al","sg2")},{field:"SG2_DAL",name:mappedDefinitions.dal,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"dal","sg2")}],Group1_st=[{field:"SG1_AY",name:mappedDefinitions.ay,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"ay","sg1")},{field:"SG1_DAY",name:mappedDefinitions.day,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"day","sg1")},{field:"SG1_AL",name:mappedDefinitions.al,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"al","sg1")},{field:"SG1_DAL",name:mappedDefinitions.dal,chartOutfields:getFields(phosphorusSourceDefinitions,mappedDefinitions,"dal","sg1")}],Catchments_tn=[{field:"ACCL",name:catchmentDefinitions_tn.accl,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"accl","comid")},{field:"CONCENTRAT",name:catchmentDefinitions_tn.concentrat,chartOutfields:[{attribute:"COMID",label:catchmentDefinitions_tn.comid},{attribute:"CONCENTRAT",label:catchmentDefinitions_tn.concentrat+" Total"}]},{field:"INCL",name:catchmentDefinitions_tn.incl,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"incl","comid")},{field:"ACCY",name:catchmentDefinitions_tn.accy,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"accy","comid")},{field:"INCY",name:catchmentDefinitions_tn.incy,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"incy","comid")},{field:"DACCL",name:catchmentDefinitions_tn.daccl,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"daccl","comid")},{field:"DACCY",name:catchmentDefinitions_tn.daccy,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"daccy","comid")},{field:"DINCL",name:catchmentDefinitions_tn.dincl,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"dincl","comid")},{field:"DINCY",name:catchmentDefinitions_tn.dincy,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"dincy","comid")}],Group3_tn=[{field:"GP3_AY",name:mappedDefinitions.ay,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"ay","gp3")},{field:"GP3_DAY",name:mappedDefinitions.day,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"day","gp3")},{field:"GP3_AL",name:mappedDefinitions.al,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"al","gp3")},{field:"GP3_DAL",name:mappedDefinitions.dal,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"dal","gp3")}],Group2_tn=[{field:"GP2_AY",name:mappedDefinitions.ay,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"ay","gp2")},{field:"GP2_DAY",name:mappedDefinitions.day,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"day","gp2")},{field:"GP2_AL",name:mappedDefinitions.al,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"al","gp2")},{field:"GP2_DAL",name:mappedDefinitions.dal,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"dal","gp2")}],Group1_tn=[{field:"GP1_AY",name:mappedDefinitions.ay,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"ay","gp1")},{field:"GP1_DAY",name:mappedDefinitions.day,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"day","gp1")},{field:"GP1_AL",name:mappedDefinitions.al,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"al","gp1")},{field:"GP1_DAL",name:mappedDefinitions.dal,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"dal","gp1")}],ST_tn=[{field:"ST_AY",name:mappedDefinitions.ay,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"ay","st")},{field:"ST_DAY",name:mappedDefinitions.day,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"day","st")},{field:"ST_AL",name:mappedDefinitions.al,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"al","st")},{field:"ST_DAL",name:mappedDefinitions.dal,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"dal","st")}],Catchments_st_tn=[{field:"ACCL",name:catchmentDefinitions_tn.accl,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"accl","st_comid")},{field:"CONCENTRAT",name:catchmentDefinitions_tn.concentrat,chartOutfields:[{attribute:"ST_COMID",label:catchmentDefinitions_tn.comid},{attribute:"CONCENTRAT",label:catchmentDefinitions_tn.concentrat+" Total"}]},{field:"INCL",name:catchmentDefinitions_tn.incl,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"incl","st_comid")},{field:"ACCY",name:catchmentDefinitions_tn.accy,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"accy","st_comid")},{field:"INCY",name:catchmentDefinitions_tn.incy,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"incy","st_comid")},{field:"DACCL",name:catchmentDefinitions_tn.daccl,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"daccl","st_comid")},{field:"DACCY",name:catchmentDefinitions_tn.daccy,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"daccy","st_comid")},{field:"DINCL",name:catchmentDefinitions_tn.dincl,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"dincl","st_comid")},{field:"DINCY",name:catchmentDefinitions_tn.dincy,chartOutfields:getFields(nitrogenSourceDefinitions,catchmentDefinitions_tn,"dincy","st_comid")}],Group3_st_tn=[{field:"SG3_AY",name:mappedDefinitions.ay,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"ay","sg3")},{field:"SG3_DAY",name:mappedDefinitions.day,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"day","sg3")},{field:"SG3_AL",name:mappedDefinitions.al,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"al","sg3")},{field:"SG3_DAL",name:mappedDefinitions.dal,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"dal","sg3")}],Group2_st_tn=[{field:"SG2_AY",name:mappedDefinitions.ay,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"ay","sg2")},{field:"SG2_DAY",name:mappedDefinitions.day,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"day","sg2")},{field:"SG2_AL",name:mappedDefinitions.al,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"al","sg2")},{field:"SG2_DAL",name:mappedDefinitions.dal,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"dal","sg2")}],Group1_st_tn=[{field:"SG1_AY",name:mappedDefinitions.ay,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"ay","sg1")},{field:"SG1_DAY",name:mappedDefinitions.day,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"day","sg1")},{field:"SG1_AL",name:mappedDefinitions.al,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"al","sg1")},{field:"SG1_DAL",name:mappedDefinitions.dal,chartOutfields:getFields(nitrogenSourceDefinitions,mappedDefinitions,"dal","sg1")}],Catchments_q=[{field:"ACCL",name:catchmentDefinitions_q.accl,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"accl","comid")},{field:"INCL",name:catchmentDefinitions_q.incl,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"incl","comid")},{field:"ACCY",name:catchmentDefinitions_q.accy,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"accy","comid")},{field:"INCY",name:catchmentDefinitions_q.incy,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"incy","comid")},{field:"DACCL",name:catchmentDefinitions_q.daccl,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"daccl","comid")},{field:"DACCY",name:catchmentDefinitions_q.daccy,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"daccy","comid")},{field:"DINCL",name:catchmentDefinitions_q.dincl,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"dincl","comid")},{field:"DINCY",name:catchmentDefinitions_q.dincy,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"dincy","comid")}],Group3_q=[{field:"GP3_AY",name:mappedDefinitions_q.ay,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"ay","gp3")},{field:"GP3_DAY",name:mappedDefinitions_q.day,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"day","gp3")},{field:"GP3_AL",name:mappedDefinitions_q.al,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"al","gp3")},{field:"GP3_DAL",name:mappedDefinitions_q.dal,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"dal","gp3")}],Group2_q=[{field:"GP2_AY",name:mappedDefinitions_q.ay,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"ay","gp2")},{field:"GP2_DAY",name:mappedDefinitions_q.day,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"day","gp2")},{field:"GP2_AL",name:mappedDefinitions_q.al,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"al","gp2")},{field:"GP2_DAL",name:mappedDefinitions_q.dal,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"dal","gp2")}],Group1_q=[{field:"GP1_AY",name:mappedDefinitions_q.ay,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"ay","gp1")},{field:"GP1_DAY",name:mappedDefinitions_q.day,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"day","gp1")},{field:"GP1_AL",name:mappedDefinitions_q.al,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"al","gp1")},{field:"GP1_DAL",name:mappedDefinitions_q.dal,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"dal","gp1")}],ST_q=[{field:"ST_AY",name:mappedDefinitions_q.ay,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"ay","st")},{field:"ST_DAY",name:mappedDefinitions_q.day,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"day","st")},{field:"ST_AL",name:mappedDefinitions_q.al,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"al","st")},{field:"ST_DAL",name:mappedDefinitions_q.dal,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"dal","st")}],Catchments_st_q=[{field:"ACCL",name:catchmentDefinitions_q.accl,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"accl","st_comid")},{field:"INCL",name:catchmentDefinitions_q.incl,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"incl","st_comid")},{field:"ACCY",name:catchmentDefinitions_q.accy,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"accy","st_comid")},{field:"INCY",name:catchmentDefinitions_q.incy,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"incy","st_comid")},{field:"DACCL",name:catchmentDefinitions_q.daccl,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"daccl","st_comid")},{field:"DACCY",name:catchmentDefinitions_q.daccy,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"daccy","st_comid")},{field:"DINCL",name:catchmentDefinitions_q.dincl,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"dincl","st_comid")},{field:"DINCY",name:catchmentDefinitions_q.dincy,chartOutfields:getFields(streamflowSourceDefinitions,catchmentDefinitions_q,"dincy","st_comid")}],Group3_st_q=[{field:"SG3_AY",name:mappedDefinitions_q.ay,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"ay","sg3")},{field:"SG3_DAY",name:mappedDefinitions_q.day,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"day","sg3")},{field:"SG3_AL",name:mappedDefinitions_q.al,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"al","sg3")},{field:"SG3_DAL",name:mappedDefinitions_q.dal,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"dal","sg3")}],Group2_st_q=[{field:"SG2_AY",name:mappedDefinitions_q.ay,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"ay","sg2")},{field:"SG2_DAY",name:mappedDefinitions_q.day,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"day","sg2")},{field:"SG2_AL",name:mappedDefinitions_q.al,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"al","sg2")},{field:"SG2_DAL",name:mappedDefinitions_q.dal,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"dal","sg2")}],Group1_st_q=[{field:"SG1_AY",name:mappedDefinitions_q.ay,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"ay","sg1")},{field:"SG1_DAY",name:mappedDefinitions_q.day,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"day","sg1")},{field:"SG1_AL",name:mappedDefinitions_q.al,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"al","sg1")},{field:"SG1_DAL",name:mappedDefinitions_q.dal,chartOutfields:getFields(streamflowSourceDefinitions,mappedDefinitions_q,"dal","sg1")}],Catchments_ss=[{field:"ACCL",name:catchmentDefinitions_ss.accl,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"accl","comid")},{field:"INCL",name:catchmentDefinitions_ss.incl,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"incl","comid")},{field:"ACCY",name:catchmentDefinitions_ss.accy,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"accy","comid")},{field:"INCY",name:catchmentDefinitions_ss.incy,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"incy","comid")},{field:"DACCL",name:catchmentDefinitions_ss.daccl,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"daccl","comid")},{field:"DACCY",name:catchmentDefinitions_ss.daccy,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"daccy","comid")},{field:"DINCL",name:catchmentDefinitions_ss.dincl,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"dincl","comid")},{field:"DINCY",name:catchmentDefinitions_ss.dincy,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"dincy","comid")}],Group3_ss=[{field:"GP3_AY",name:mappedDefinitions_ss.ay,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"ay","gp3")},{field:"GP3_DAY",name:mappedDefinitions_ss.day,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"day","gp3")},{field:"GP3_AL",name:mappedDefinitions_ss.al,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"al","gp3")},{field:"GP3_DAL",name:mappedDefinitions_ss.dal,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"dal","gp3")}],Group2_ss=[{field:"GP2_AY",name:mappedDefinitions_ss.ay,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"ay","gp2")},{field:"GP2_DAY",name:mappedDefinitions_ss.day,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"day","gp2")},{field:"GP2_AL",name:mappedDefinitions_ss.al,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"al","gp2")},{field:"GP2_DAL",name:mappedDefinitions_ss.dal,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"dal","gp2")}],Group1_ss=[{field:"GP1_AY",name:mappedDefinitions_ss.ay,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"ay","gp1")},{field:"GP1_DAY",name:mappedDefinitions_ss.day,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"day","gp1")},{field:"GP1_AL",name:mappedDefinitions_ss.al,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"al","gp1")},{field:"GP1_DAL",name:mappedDefinitions_ss.dal,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"dal","gp1")}],ST_ss=[{field:"ST_AY",name:mappedDefinitions_ss.ay,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"ay","st")},{field:"ST_DAY",name:mappedDefinitions_ss.day,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"day","st")},{field:"ST_AL",name:mappedDefinitions_ss.al,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"al","st")},{field:"ST_DAL",name:mappedDefinitions_ss.dal,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"dal","st")}],Catchments_st_ss=[{field:"ACCL",name:catchmentDefinitions_ss.accl,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"accl","st_comid")},{field:"CONCENTRAT",name:catchmentDefinitions_ss.concentrat,chartOutfields:[{attribute:"COMID",label:catchmentDefinitions_ss.comid},{attribute:"CONCENTRAT",label:catchmentDefinitions_ss.concentrat+" Total"}]},{field:"INCL",name:catchmentDefinitions_ss.incl,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"incl","st_comid")},{field:"ACCY",name:catchmentDefinitions_ss.accy,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"accy","st_comid")},{field:"INCY",name:catchmentDefinitions_ss.incy,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"incy","st_comid")},{field:"DACCL",name:catchmentDefinitions_ss.daccl,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"daccl","st_comid")},{field:"DACCY",name:catchmentDefinitions_ss.daccy,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"daccy","st_comid")},{field:"DINCL",name:catchmentDefinitions_ss.dincl,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"dincl","st_comid")},{field:"DINCY",name:catchmentDefinitions_ss.dincy,chartOutfields:getFields(sedimentSourceDefinitions,catchmentDefinitions_ss,"dincy","st_comid")}],Group3_st_ss=[{field:"SG3_AY",name:mappedDefinitions_ss.ay,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"ay","sg3")},{field:"SG3_DAY",name:mappedDefinitions_ss.day,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"day","sg3")},{field:"SG3_AL",name:mappedDefinitions_ss.al,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"al","sg3")},{field:"SG3_DAL",name:mappedDefinitions_ss.dal,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"dal","sg3")}],Group2_st_ss=[{field:"SG2_AY",name:mappedDefinitions_ss.ay,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"ay","sg2")},{field:"SG2_DAY",name:mappedDefinitions_ss.day,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"day","sg2")},{field:"SG2_AL",name:mappedDefinitions_ss.al,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"al","sg2")},{field:"SG2_DAL",name:mappedDefinitions_ss.dal,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"dal","sg2")}],Group1_st_ss=[{field:"SG1_AY",name:mappedDefinitions_ss.ay,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"ay","sg1")},{field:"SG1_DAY",name:mappedDefinitions_ss.day,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"day","sg1")},{field:"SG1_AL",name:mappedDefinitions_ss.al,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"al","sg1")},{field:"SG1_DAL",name:mappedDefinitions_ss.dal,chartOutfields:getFields(sedimentSourceDefinitions,mappedDefinitions_ss,"dal","sg1")}];require(["esri/geometry/Extent","esri/layers/WMSLayerInfo","esri/layers/FeatureLayer","esri/layers/ImageParameters","esri/layers/LayerDrawingOptions","dojo/domReady!"],function(e,t,i,a,s){var n;n=($("#radio1")[0].checked,1);var r=new s;r.scaleSymbols=!0,allLayers=[{groupHeading:"SPARROW Model",showGroupHeading:!0,includeInLayerList:!0,layers:{"SPARROW Model Results":{url:serviceBaseURL,visibleLayers:[n],options:{id:"SparrowRanking",opacity:.75,visible:!0,layerDrawingOptions:r},wimOptions:{type:"layer",layerType:"agisDynamic",includeInLayerList:!0,hasOpacitySlider:!0,hasZoomto:!1,includeLegend:!1}}}},{groupHeading:"Model Calibration Sites",showGroupHeading:!0,includeInLayerList:!0,layers:{"Phosphorus Calibration Sites":{url:serviceBaseURL,visibleLayers:[36],options:{id:"phosCalibration",opacity:.85,visible:!1},wimOptions:{type:"layer",layerType:"agisDynamic",includeInLayerList:!0,zoomScale:144448,hasOpacitySlider:!0,hasZoomto:!1,includeLegend:!0}},"Nitrogen Calibration Sites":{url:serviceBaseURL,visibleLayers:[37],options:{id:"nitroCalibration",visible:!1,opacity:.85},wimOptions:{type:"layer",layerType:"agisDynamic",includeInLayerList:!0,hasOpacitySlider:!0,hasZoomto:!1,includeLegend:!1}},"Suspended Sediment Calibration Sites":{url:serviceBaseURL,visibleLayers:[39],options:{id:"sedimentCalibration",visible:!1,opacity:.85},wimOptions:{type:"layer",layerType:"agisDynamic",includeInLayerList:!0,hasOpacitySlider:!0,hasZoomto:!1,includeLegend:!1}},"Streamflow Calibration Sites":{url:serviceBaseURL,visibleLayers:[38],options:{id:"streamflowCalibration",visible:!1,opacity:.85},wimOptions:{type:"layer",layerType:"agisDynamic",includeInLayerList:!0,hasOpacitySlider:!0,hasZoomto:!1,includeLegend:!1}}}},{groupHeading:"Auxiliary Layers",showGroupHeading:!0,includeInLayerList:!0,layers:{"Reaches > 100 cfs":{url:serviceBaseURL,visibleLayers:[40],options:{id:"gt100",visible:!1},wimOptions:{type:"layer",layerType:"agisDynamic",includeInLayerList:!0,hasOpacitySlider:!0,hasZoomto:!1,includeLegend:!1}},"SPARROW Reaches":{url:serviceBaseURL,visibleLayers:[41],options:{id:"reaches",visible:!1},wimOptions:{type:"layer",layerType:"agisDynamic",includeInLayerList:!0,hasOpacitySlider:!0,hasZoomto:!1,includeLegend:!1}},"NLCD Land Use 2012":{url:"https://gis.wim.usgs.gov/arcgis/rest/services/SWTrends/lu2012_100515_test/ImageServer",options:{id:"lu2012",opacity:.5,visible:!1},wimOptions:{type:"layer",layerType:"agisImage",includeInLayerList:!0,hasOpacitySlider:!0,hasZoomto:!1,includeLegend:!1}}}}]}),function(e){"object"==typeof module&&module.exports?module.exports=e:e(Highcharts)}(function(e){"use strict";var t=e.each,i=e.pick,a=e.seriesTypes,s=void 0!==document.createElement("a").download;function n(t,i,a,n,r){var o,c,l,p=((t.options.exporting||{}).csv||{}).url||"https://www.highcharts.com/studies/csv-export/download.php";l=t.options.exporting.filename?t.options.exporting.filename:t.title?t.title.textStr.replace(/ /g,"-").toLowerCase():"chart",window.Blob&&window.navigator.msSaveOrOpenBlob?(c=new Blob([n]),window.navigator.msSaveOrOpenBlob(c,l+"."+a)):s?((o=document.createElement("a")).href=i,o.target="_blank",o.download=l+"."+a,t.container.append(o),o.click(),o.remove()):e.post(p,{data:n,type:r,extension:a})}e.setOptions({lang:{downloadCSV:"Download CSV",downloadXLS:"Download XLS",viewData:"View data table"}}),e.Chart.prototype.getDataRows=function(){var a,s,n,r,o,c,l,p=(this.options.exporting||{}).csv||{},d=this.xAxis,u={},f=[],m=[],g=p.dateFormat||"%Y-%m-%d %H:%M:%S",h=p.columnHeaderFormatter||function(t,i,a){return t instanceof e.Axis?t.options.title&&t.options.title.text||(t.isDatetimeAxis?"DateTime":"Category"):t?t.name+(a>1?" ("+i+")":""):"Category"},y=[];for(r in n=0,t(this.series,function(a){var s,r=a.options.keys||a.pointArrayMap||["y"],o=r.length,c=a.requireSorting,l={},p=e.inArray(a.xAxis,d);if(t(r,function(e){l[e]=a[e+"Axis"]&&a[e+"Axis"].categories||[]}),!1!==a.options.includeInCSVExport&&!1!==a.visible){for(e.find(y,function(e){return e[0]===p})||y.push([p,n]),s=0;s<o;)m.push(h(a,r[s],r.length)),s+=1;t(a.points,function(e,t){var d,f,m=c?e.x:t;for(s=0,u[m]||(u[m]=[],u[m].xValues=[]),u[m].x=e.x,u[m].xValues[p]=e.x,a.xAxis&&"name"!==a.exportKey||(u[m].name=e.name);s<o;)f=e[d=r[s]],u[m][n+s]=i(l[d][f],f),s+=1}),n+=s}}),u)u.hasOwnProperty(r)&&f.push(u[r]);for(s=[m],n=y.length;n--;)c=y[n][0],l=y[n][1],a=d[c],f.sort(function(e,t){return e.xValues[c]-t.xValues[c]}),o=h(a),s[0].splice(l,0,o),t(f,function(t){var s=t.name;s||(a.isDatetimeAxis?(t.x instanceof Date&&(t.x=t.x.getTime()),s=e.dateFormat(g,t.x)):s=a.categories?i(a.names[t.x],a.categories[t.x],t.x):t.x),t.splice(l,0,s)});return s=s.concat(f)},e.Chart.prototype.getCSV=function(e){var i="",a=this.getDataRows(),s=(this.options.exporting||{}).csv||{},n=s.itemDelimiter||",",r=s.lineDelimiter||"\n";return t(a,function(t,s){for(var o="",c=t.length,l=e?1.1.toLocaleString()[1]:".";c--;)"string"==typeof(o=t[c])&&(o='"'+o+'"'),"number"==typeof o&&","===l&&(o=o.toString().replace(".",",")),t[c]=o;i+=t.join(n),s<a.length-1&&(i+=r)}),i},e.Chart.prototype.getTable=function(e){var i="<table><thead>",a=this.getDataRows();return t(a,function(t,a){var s,n,r=a?"td":"th",o=e?1.1.toLocaleString()[1]:".";for(i+="<tr>",n=0;n<t.length;n+=1)"number"==typeof(s=t[n])?(s=s.toString(),","===o&&(s=s.replace(".",o)),i+="<"+r+' class="number">'+s+"</"+r+">"):i+="<"+r+">"+(void 0===s?"":s)+"</"+r+">";i+="</tr>",a||(i+="</thead><tbody>")}),i+="</tbody></table>"},e.Chart.prototype.downloadCSV=function(){var e=this.getCSV(!0);n(this,"data:text/csv,\ufeff"+encodeURIComponent(e),"csv",e,"text/csv")},e.Chart.prototype.downloadXLS=function(){var e,t='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head>\x3c!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>Ark1</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--\x3e<style>td{border:none;font-family: Calibri, sans-serif;} .number{mso-number-format:"0.00";}</style><meta name=ProgId content=Excel.Sheet><meta charset=UTF-8></head><body>'+this.getTable(!0)+"</body></html>";n(this,"data:application/vnd.ms-excel;base64,"+(e=t,window.btoa(unescape(encodeURIComponent(e)))),"xls",t,"application/vnd.ms-excel")},e.Chart.prototype.viewData=function(){this.dataTableDiv||(this.dataTableDiv=document.createElement("div"),this.dataTableDiv.className="highcharts-data-table",this.renderTo.parentNode.insertBefore(this.dataTableDiv,this.renderTo.nextSibling)),this.dataTableDiv.innerHTML=this.getTable()},e.getOptions().exporting&&e.getOptions().exporting.buttons.contextButton.menuItems.push({textKey:"downloadCSV",onclick:function(){this.downloadCSV()}},{textKey:"downloadXLS",onclick:function(){this.downloadXLS()}},{textKey:"viewData",onclick:function(){this.viewData()}}),a.map&&(a.map.prototype.exportKey="name"),a.mapbubble&&(a.mapbubble.prototype.exportKey="name")}),function(e){"object"==typeof module&&module.exports?module.exports=e:e(Highcharts)}(function(e){!function(e){var t=e.defaultOptions,i=e.doc,a=e.Chart,s=e.addEvent,n=e.removeEvent,r=e.fireEvent,o=e.createElement,c=e.discardElement,l=e.css,p=e.merge,d=e.pick,u=e.each,f=e.objectEach,m=e.extend,g=e.isTouchDevice,h=e.win,y=h.navigator.userAgent,D=e.Renderer.prototype.symbols;/Edge\/|Trident\/|MSIE /.test(y),/firefox/i.test(y),m(t.lang,{printChart:"Print chart",downloadPNG:"Download PNG image",downloadJPEG:"Download JPEG image",downloadPDF:"Download PDF document",downloadSVG:"Download SVG vector image",contextButtonTitle:"Chart context menu"}),t.navigation={buttonOptions:{theme:{},symbolSize:14,symbolX:12.5,symbolY:10.5,align:"right",buttonSpacing:3,height:22,verticalAlign:"top",width:24}},p(!0,t.navigation,{menuStyle:{border:"1px solid #999999",background:"#ffffff",padding:"5px 0"},menuItemStyle:{padding:"0.5em 1em",background:"none",color:"#333333",fontSize:g?"14px":"11px",transition:"background 250ms, color 250ms"},menuItemHoverStyle:{background:"#335cad",color:"#ffffff"},buttonOptions:{symbolFill:"#666666",symbolStroke:"#666666",symbolStrokeWidth:3,theme:{fill:"#ffffff",stroke:"none",padding:5}}}),t.exporting={type:"image/png",url:"https://export.highcharts.com/",printMaxWidth:780,scale:2,buttons:{contextButton:{className:"highcharts-contextbutton",menuClassName:"highcharts-contextmenu",symbol:"menu",_titleKey:"contextButtonTitle",menuItems:[{textKey:"printChart",onclick:function(){this.print()}},{separator:!0},{textKey:"downloadPNG",onclick:function(){this.exportChart()}},{textKey:"downloadJPEG",onclick:function(){this.exportChart({type:"image/jpeg"})}},{textKey:"downloadPDF",onclick:function(){this.exportChart({type:"application/pdf"})}},{textKey:"downloadSVG",onclick:function(){this.exportChart({type:"image/svg+xml"})}}]}}},e.post=function(e,t,a){var s=o("form",p({method:"post",action:e,enctype:"multipart/form-data"},a),{display:"none"},i.body);f(t,function(e,t){o("input",{type:"hidden",name:t,value:e},null,s)}),s.submit(),c(s)},m(a.prototype,{sanitizeSVG:function(e,t){if(t&&t.exporting&&t.exporting.allowHTML){var i=e.match(/<\/svg>(.*?$)/);i&&i[1]&&(i='<foreignObject x="0" y="0" width="'+t.chart.width+'" height="'+t.chart.height+'"><body xmlns="http://www.w3.org/1999/xhtml">'+i[1]+"</body></foreignObject>",e=e.replace("</svg>",i+"</svg>"))}return(e=e.replace(/zIndex="[^"]+"/g,"").replace(/isShadow="[^"]+"/g,"").replace(/symbolName="[^"]+"/g,"").replace(/jQuery[0-9]+="[^"]+"/g,"").replace(/url\(("|&quot;)(\S+)("|&quot;)\)/g,"url($2)").replace(/url\([^#]+#/g,"url(#").replace(/<svg /,'<svg xmlns:xlink="http://www.w3.org/1999/xlink" ').replace(/ (NS[0-9]+\:)?href=/g," xlink:href=").replace(/\n/," ").replace(/<\/svg>.*?$/,"</svg>").replace(/(fill|stroke)="rgba\(([ 0-9]+,[ 0-9]+,[ 0-9]+),([ 0-9\.]+)\)"/g,'$1="rgb($2)" $1-opacity="$3"').replace(/&nbsp;/g," ").replace(/&shy;/g,"­")).replace(/<IMG /g,"<image ").replace(/<(\/?)TITLE>/g,"<$1title>").replace(/height=([^" ]+)/g,'height="$1"').replace(/width=([^" ]+)/g,'width="$1"').replace(/hc-svg-href="([^"]+)">/g,'xlink:href="$1"/>').replace(/ id=([^" >]+)/g,' id="$1"').replace(/class=([^" >]+)/g,'class="$1"').replace(/ transform /g," ").replace(/:(path|rect)/g,"$1").replace(/style="([^"]+)"/g,function(e){return e.toLowerCase()})},getChartHTML:function(){return this.container.innerHTML},getSVG:function(t){var a,s,n,r,l,d=p(this.options,t);return i.createElementNS||(i.createElementNS=function(e,t){return i.createElement(t)}),s=o("div",null,{position:"absolute",top:"-9999em",width:this.chartWidth+"px",height:this.chartHeight+"px"},i.body),n=this.renderTo.style.width,l=this.renderTo.style.height,n=d.exporting.sourceWidth||d.chart.width||/px$/.test(n)&&parseInt(n,10)||600,l=d.exporting.sourceHeight||d.chart.height||/px$/.test(l)&&parseInt(l,10)||400,m(d.chart,{animation:!1,renderTo:s,forExport:!0,renderer:"SVGRenderer",width:n,height:l}),d.exporting.enabled=!1,delete d.data,d.series=[],u(this.series,function(e){(r=p(e.userOptions,{animation:!1,enableMouseTracking:!1,showCheckbox:!1,visible:e.visible})).isInternal||d.series.push(r)}),u(this.axes,function(t){t.userOptions.internalKey||(t.userOptions.internalKey=e.uniqueKey())}),a=new e.Chart(d,this.callback),t&&u(["xAxis","yAxis","series"],function(e){var i={};t[e]&&(i[e]=t[e],a.update(i))}),u(this.axes,function(t){var i=e.find(a.axes,function(e){return e.options.internalKey===t.userOptions.internalKey}),s=(n=t.getExtremes()).userMin,n=n.userMax;!i||void 0===s&&void 0===n||i.setExtremes(s,n,!0,!1)}),n=a.getChartHTML(),n=this.sanitizeSVG(n,d),d=null,a.destroy(),c(s),n},getSVGForExport:function(e,t){var i=this.options.exporting;return this.getSVG(p({chart:{borderRadius:0}},i.chartOptions,t,{exporting:{sourceWidth:e&&e.sourceWidth||i.sourceWidth,sourceHeight:e&&e.sourceHeight||i.sourceHeight}}))},exportChart:function(t,i){i=this.getSVGForExport(t,i),t=p(this.options.exporting,t),e.post(t.url,{filename:t.filename||"chart",type:t.type,width:t.width||0,scale:t.scale,svg:i},t.formAttributes)},print:function(){var e,t,a=this,s=a.container,n=[],o=s.parentNode,c=i.body,l=c.childNodes,p=a.options.exporting.printMaxWidth;a.isPrinting||(a.isPrinting=!0,a.pointer.reset(null,0),r(a,"beforePrint"),(t=p&&a.chartWidth>p)&&(e=[a.options.chart.width,void 0,!1],a.setSize(p,void 0,!1)),u(l,function(e,t){1===e.nodeType&&(n[t]=e.style.display,e.style.display="none")}),c.appendChild(s),h.focus(),h.print(),setTimeout(function(){o.appendChild(s),u(l,function(e,t){1===e.nodeType&&(e.style.display=n[t])}),a.isPrinting=!1,t&&a.setSize.apply(a,e),r(a,"afterPrint")},1e3))},contextMenu:function(e,t,a,n,r,c,p){var d,f,g=this,h=g.options.navigation,y=g.chartWidth,D=g.chartHeight,S="cache-"+e,b=g[S],O=Math.max(r,c);b||(g[S]=b=o("div",{className:e},{position:"absolute",zIndex:1e3,padding:O+"px"},g.container),d=o("div",{className:"highcharts-menu"},null,b),l(d,m({MozBoxShadow:"3px 3px 10px #888",WebkitBoxShadow:"3px 3px 10px #888",boxShadow:"3px 3px 10px #888"},h.menuStyle)),f=function(){l(b,{display:"none"}),p&&p.setState(0),g.openMenu=!1},g.exportEvents.push(s(b,"mouseleave",function(){b.hideTimer=setTimeout(f,500)}),s(b,"mouseenter",function(){clearTimeout(b.hideTimer)}),s(i,"mouseup",function(t){g.pointer.inClass(t.target,e)||f()})),u(t,function(e){var t;e&&(e.separator?t=o("hr",null,null,d):((t=o("div",{className:"highcharts-menu-item",onclick:function(t){t&&t.stopPropagation(),f(),e.onclick&&e.onclick.apply(g,arguments)},innerHTML:e.text||g.options.lang[e.textKey]},null,d)).onmouseover=function(){l(this,h.menuItemHoverStyle)},t.onmouseout=function(){l(this,h.menuItemStyle)},l(t,m({cursor:"pointer"},h.menuItemStyle))),g.exportDivElements.push(t))}),g.exportDivElements.push(d,b),g.exportMenuWidth=b.offsetWidth,g.exportMenuHeight=b.offsetHeight),t={display:"block"},a+g.exportMenuWidth>y?t.right=y-a-r-O+"px":t.left=a-O+"px",n+c+g.exportMenuHeight>D&&"top"!==p.alignOptions.verticalAlign?t.bottom=D-n-O+"px":t.top=n+c-O+"px",l(b,t),g.openMenu=!0},addButton:function(e){var t,i,a=this,s=a.renderer,n=p(a.options.navigation.buttonOptions,e),r=n.onclick,o=n.menuItems,c=n.symbolSize||12;if(a.btnCount||(a.btnCount=0),a.exportDivElements||(a.exportDivElements=[],a.exportSVGElements=[]),!1!==n.enabled){var l,u=n.theme,f=(g=u.states)&&g.hover,g=g&&g.select;delete u.states,r?l=function(e){e.stopPropagation(),r.call(a,e)}:o&&(l=function(){a.contextMenu(i.menuClassName,o,i.translateX,i.translateY,i.width,i.height,i),i.setState(2)}),n.text&&n.symbol?u.paddingLeft=d(u.paddingLeft,25):n.text||m(u,{width:n.width,height:n.height,padding:0}),(i=s.button(n.text,0,0,l,u,f,g).addClass(e.className).attr({"stroke-linecap":"round",title:a.options.lang[n._titleKey],zIndex:3})).menuClassName=e.menuClassName||"highcharts-menu-"+a.btnCount++,n.symbol&&(t=s.symbol(n.symbol,n.symbolX-c/2,n.symbolY-c/2,c,c).addClass("highcharts-button-symbol").attr({zIndex:1}).add(i)).attr({stroke:n.symbolStroke,fill:n.symbolFill,"stroke-width":n.symbolStrokeWidth||1}),i.add().align(m(n,{width:i.width,x:d(n.x,a.buttonOffset)}),!0,"spacingBox"),a.buttonOffset+=(i.width+n.buttonSpacing)*("right"===n.align?-1:1),a.exportSVGElements.push(i,t)}},destroyExport:function(e){var t=e?e.target:this;e=t.exportSVGElements;var i,a=t.exportDivElements,s=t.exportEvents;e&&(u(e,function(e,a){e&&(e.onclick=e.ontouchstart=null,i="cache-"+e.menuClassName,t[i]&&delete t[i],t.exportSVGElements[a]=e.destroy())}),e.length=0),a&&(u(a,function(e,i){clearTimeout(e.hideTimer),n(e,"mouseleave"),t.exportDivElements[i]=e.onmouseout=e.onmouseover=e.ontouchstart=e.onclick=null,c(e)}),a.length=0),s&&(u(s,function(e){e()}),s.length=0)}}),D.menu=function(e,t,i,a){return["M",e,t+2.5,"L",e+i,t+2.5,"M",e,t+a/2+.5,"L",e+i,t+a/2+.5,"M",e,t+a-1.5,"L",e+i,t+a-1.5]},a.prototype.renderExporting=function(){var e=this,t=e.options.exporting,i=t.buttons,a=e.isDirtyExporting||!e.exportSVGElements;e.buttonOffset=0,e.isDirtyExporting&&e.destroyExport(),a&&!1!==t.enabled&&(e.exportEvents=[],f(i,function(t){e.addButton(t)}),e.isDirtyExporting=!1),s(e,"destroy",e.destroyExport)},a.prototype.callbacks.push(function(e){e.renderExporting(),s(e,"redraw",e.renderExporting),u(["exporting","navigation"],function(t){e[t]={update:function(i,a){e.isDirtyExporting=!0,p(!0,e.options[t],i),d(a,!0)&&e.redraw()}}})})}(e)});var app={};function loadEventHandlers(){$(".radio").on("change",function(e){$("#page-loader").fadeIn();var t=$("#groupResultsSelect")[0].selectedIndex,i=this.firstElementChild.id;populateMetricOptions($("#groupResultsSelect")[0].selectedIndex),setAggregateGroup(t,i),updateSourceOptions(),generateRenderer()}),$("#phosphorusDownload").click(function(){window.location=phosphorusShapefileURL}),$("#nitrogenDownload").click(function(){window.location=nitrogenShapefileURL}),$("#sedimentDownload").click(function(){window.location=sedimentShapefileURL}),$("#streamflowDownload").click(function(){window.location=streamflowShapefileURL}),$("#phosphorusCalibrationDownload").click(function(){window.location=phosCalibrationURL}),$("#nitrogenCalibrationDownload").click(function(){window.location=nitroCalibrationURL}),$("#sedimentCalibrationDownload").click(function(){window.location=sedimentCalibrationURL}),$("#streamflowCalibrationDownload").click(function(){window.location=streamflowCalibrationURL}),$(".aoiSelect").on("change",AOIChange),$("#groupResultsSelect").on("loaded.bs.select",function(){$("#groupResultsSelect").selectpicker("val",groupResultsLabels.b),$("#groupResultsSelect").selectpicker("refresh"),populateMetricOptions($("#groupResultsSelect")[0].selectedIndex),updateSourceOptions(),generateRenderer()});var e=$("#clickPolyButton");function t(e,t,i,a,s){$("#clearAOIButton").append("<a class='"+e+"' data-toggle='tooltip' data-placement='top' title='Cannot show "+t+" Area of Interest while grouping by "+i+".'><span class='glyphicon glyphicon-warning-sign'></span></a>"),$(a+" option").attr("selected",!1),app.clearOneLayerDefObj(s),AOIChange({currentTarget:{id:a,value:""}})}e.click(function(){app.clickSelectionActive?(e.removeClass("active"),$("#shiftNote").remove(),e.html('<span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;Select'),app.map.setMapCursor("auto"),app.clickSelectionActive=!1,0==app.userSelectedShapes.length&&app.polygonResponseCount>chartFeatureMax?$("#chartButton").prop("disabled",!0).css("cursor","not-allowed"):$("#chartButton").prop("disabled",!1).css("pointer-events","auto").css("cursor","pointer")):app.clickSelectionActive||($("#customSelect").append('<div id="shiftNote" style="padding-left: 1em;color: orangered;">Shift+Click to Deselect</div>'),e.addClass("active"),e.html('<i class="glyphicon glyphicon-stop"></i>&nbsp;&nbsp;Stop selecting'),app.map.setMapCursor("crosshair"),$("#chartButton").prop("disabled",!0).css("cursor","not-allowed"),app.clickSelectionActive=!0)}),$("#groupResultsSelect").on("changed.bs.select",function(e){app.clearFindGraphics(),populateMetricOptions(e.currentTarget.selectedIndex),setAggregateGroup(e.currentTarget.selectedIndex,$(".radio input[type='radio']:checked")[0].id),updateSourceOptions(),generateRenderer()}),$("#displayedMetricSelect").on("changed.bs.select",function(e){$("#page-loader").fadeIn(),updateSourceOptions(),generateRenderer()}),$("#displayedSourceSelect").on("changed.bs.select",function(e){if("All Sources"==e.target.value)delete app.chosenSource;else{var t=e.target.selectedIndex;app.chosenSource={label:e.target[t].label,attribute:e.target.value}}$("#page-loader").fadeIn(),generateRenderer()}),$("#clearAOIButton").on("click",function(){$("#grp3-select").attr("disabled","disabled"),$("#grp3-select").addClass("disabled"),$("#grp3-select").selectpicker("refresh"),$("#page-loader").show();var e=app.map.getLayer("SparrowRanking").visibleLayers[0];if($.inArray(e,splitLayers)>-1){e=4==$("#groupResultsSelect")[0].selectedIndex?returnToStateLayer(e):returnDefaultLayer(e,$(".radio input[type='radio']:checked")[0].id);var t=[];t.push(e),app.map.getLayer("SparrowRanking").setVisibleLayers(t),app.map.getLayer("SparrowRanking").setDefaultLayerDefinitions(!0)}else app.map.getLayer("SparrowRanking").setDefaultLayerDefinitions(!0);$(".aoiSelect").selectpicker("val",""),populateMetricOptions($("#groupResultsSelect")[0].selectedIndex),updateSourceOptions(),generateRenderer(),app.clearLayerDefObj(),$(".grp1-warning").remove(),$(".grp2-warning").remove(),$(".grp3-warning").remove(),$("#groupResultsSelect option").each(function(){this.disabled=!1}),$("#groupResultsSelect").selectpicker("render")}),$(".nonAOISelect").on("change",function(){$("#page-loader").fadeIn(),$("#grp1-select").removeClass("disabled"),$("#grp1-select").removeAttr("disabled"),$(".grp1-warning").remove(),$("#grp2-select").removeClass("disabled"),$("#grp2-select").removeAttr("disabled"),$(".grp2-warning").remove(),$("#grp3-select").removeClass("disabled"),$("#grp3-select").removeAttr("disabled"),$(".grp3-warning").remove();var e=function(){return""!==$("#grp1-select")[0].value||(""!==$("#grp2-select")[0].value||(""!==$("#grp3-select")[0].value||""!==$("#st-select")[0].value))};switch($("#groupResultsSelect")[0].selectedIndex){case 0:!1===e()?($("#grp3-select").attr("disabled","disabled"),$("#grp3-select").addClass("disabled"),$("#grp3-select").selectpicker("refresh")):$("#grp3-select").selectpicker("refresh"),$("#grp1-select").selectpicker("refresh"),$("#grp2-select").selectpicker("refresh");break;case 1:app.getLayerDefObj().AOI2&&t("grp2-warning","HUC8","HUC8","#grp2-select","AOI2"),!1===e()?($("#grp3-select").attr("disabled","disabled"),$("#grp3-select").addClass("disabled"),$("#grp3-select").selectpicker("refresh")):$("#grp3-select").selectpicker("refresh"),$("#grp2-select").selectpicker("refresh"),$("#grp1-select").selectpicker("refresh");break;case 2:app.getLayerDefObj().AOI3&&t("grp3-warning","HUC8","HUC8","#grp3-select","AOI3"),$("#grp3-select").attr("disabled","disabled"),$("#grp3-select").addClass("disabled"),$("#grp3-select").selectpicker("refresh"),$("#grp2-select").selectpicker("refresh"),$("#grp1-select").selectpicker("refresh");break;case 3:app.getLayerDefObj().AOI2&&t("grp2-warning","HUC8","River Basin","#grp2-select","AOI2"),$("#grp2-select").attr("disabled","disabled"),$("#grp2-select").addClass("disabled"),$("#grp2-select").selectpicker("refresh"),$("#grp1-select").selectpicker("refresh"),app.getLayerDefObj().AOI3&&t("grp3-warning","HUC8","River Basin","#grp3-select","AOI3"),$("#grp3-select").attr("disabled","disabled"),$("#grp3-select").addClass("disabled"),$("#grp3-select").selectpicker("refresh");break;case 4:$("#grp1-select").selectpicker("refresh"),$("#grp2-select").selectpicker("refresh"),""!==$("#grp2-select")[0].value?($("#grp3-select").attr("disabled","disabled"),$("#grp3-select").addClass("disabled"),$("#grp3-select").selectpicker("refresh")):""!==$("#grp1-select")[0].value||""!==$("#grp2-select")[0].value||""!==$("#st-select")[0].value?($("#grp3-select").attr("disabled","disabled"),$("#grp3-select").addClass("disabled"),$("#grp3-select").selectpicker("refresh")):$("#grp3-select").selectpicker("refresh")}}),$("#chartButton").on("click",function(){""!=app.userSelectedDispFieldName?(app.formattedHighlightString=app.userSelectedDispFieldName+" IN ("+app.userSelectedShapes.join(",")+")",app.customChartClicked=!0,app.createChartQuery(app.formattedHighlightString),app.userSelectedDispFieldName="",app.userSelectedShapes=[]):app.createChartQuery()}),$(".chartDisabledGlyph").on("click",function(){alert("you can't do that")}),$("#aboutModal").on("show.bs.modal",function(){"legendInfoButton"==event.srcElement.id&&$(".nav-tabs a[href='#definitionsTabPane']").tab("show")}),$(window).resize(function(){$("#legendCollapse").hasClass("in")?(maxLegendHeight=.9*$("#mapDiv").height(),$("#legendElement").css("height",maxLegendHeight),$("#legendElement").css("max-height",maxLegendHeight),maxLegendDivHeight=$("#legendElement").height()-parseInt($("#legendHeading").css("height").replace("px","")),$("#legendDiv").css("max-height",maxLegendDivHeight)):$("#legendElement").css("height","initial")}),app.map.on("load",function(){app.initMapScale(),app.map.infoWindow.set("highlight",!1),app.map.infoWindow.set("titleInBody",!1),app.setupDraggableInfoWindow(),app.map.disableClickRecenter()}),app.map.on("update-end",function(){$("#page-loader").fadeOut()}),app.map.on("zoom-end",function(){var e=app.map.getScale().toFixed(0);$("#scale")[0].innerHTML=addCommas(e),console.log();var t=app.map.getZoom();app.currentZoomLevel<=borderThreshold&&t>borderThreshold?generateRenderer():app.currentZoomLevel>borderThreshold&&t<=borderThreshold&&generateRenderer(),app.currentZoomLevel=t}),app.map.on("mouse-move",function(e){app.updateMousePosition(e)}),app.map.on("pan-end",function(){app.updateMapCenter(app.map.extent)}),app.map.on("click",function(e){app.identifyParams=new esri.tasks.IdentifyParameters,app.identifyParams.tolerance=8,app.identifyParams.returnGeometry=!0,app.identifyParams.layerOption=esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE,app.identifyParams.width=app.map.width,app.identifyParams.height=app.map.height,app.identifyTask=new esri.tasks.IdentifyTask(serviceBaseURL),app.map.getLayer("SparrowRanking").layerDefinitions&&(app.identifyParams.layerDefinitions=app.map.getLayer("SparrowRanking").layerDefinitions),app.executeIdentifyTask(e)}),$("#btnStreets").on("click",function(){app.map.setBasemap("streets")}),$("#btnSatellite").on("click",function(){app.map.setBasemap("satellite")}),$("#btnHybrid").on("click",function(){app.map.setBasemap("hybrid")}),$("#btnTerrain").on("click",function(){app.map.setBasemap("terrain")}),$("#btnGray").on("click",function(){app.map.setBasemap("gray")}),$("#btnDark").on("click",function(){app.map.setBasemap("dark-gray")}),$("#btnNatGeo").on("click",function(){app.map.setBasemap("national-geographic")}),$("#btnOSM").on("click",function(){app.map.setBasemap("osm")}),$("#btnTopo").on("click",function(){app.map.setBasemap("topo")})}function populateMetricOptions(e){var t;if($("#displayedMetricSelect")[0].selectedOptions.length>0){var i=$("#displayedMetricSelect")[0].selectedOptions[0].label;$("#displayedMetricSelect option:selected")}if("radio1"==$(".radio input[type='radio']:checked")[0].id)switch(e){case 0:t=$("#st-select")[0].selectedIndex>0?Catchments_st:Catchments;break;case 1:t=$("#st-select")[0].selectedIndex>0?Group3_st:Group3;break;case 2:t=$("#st-select")[0].selectedIndex>0?Group2_st:Group2;break;case 3:t=$("#st-select")[0].selectedIndex>0?Group1_st:Group1;break;case 4:t=$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?Group3_st:$("#grp3-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?Group3_st:$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0?Group3_st:$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?Group2_st:$("#grp3-select")[0].selectedIndex>0?Group3_st:$("#grp2-select")[0].selectedIndex>0?Group2_st:$("#grp1-select")[0].selectedIndex>0?Group1_st:ST}if("radio2"==$(".radio input[type='radio']:checked")[0].id)switch(e){case 0:t=$("#st-select")[0].selectedIndex>0?Catchments_st_tn:Catchments_tn;break;case 1:t=$("#st-select")[0].selectedIndex>0?Group3_st_tn:Group3_tn;break;case 2:t=$("#st-select")[0].selectedIndex>0?Group2_st_tn:Group2_tn;break;case 3:t=$("#st-select")[0].selectedIndex>0?Group1_st_tn:Group1_tn;break;case 4:t=$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?Group3_st_tn:$("#grp3-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?Group3_st_tn:$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0?Group3_st_tn:$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?Group2_st_tn:$("#grp3-select")[0].selectedIndex>0?Group3_st_tn:$("#grp2-select")[0].selectedIndex>0?Group2_st_tn:$("#grp1-select")[0].selectedIndex>0?Group1_st_tn:ST_tn}if("radio3"==$(".radio input[type='radio']:checked")[0].id)switch(e){case 0:t=$("#st-select")[0].selectedIndex>0?Catchments_st_q:Catchments_q;break;case 1:t=$("#st-select")[0].selectedIndex>0?Group3_st_q:Group3_q;break;case 2:t=$("#st-select")[0].selectedIndex>0?Group2_st_q:Group2_q;break;case 3:t=$("#st-select")[0].selectedIndex>0?Group1_st_q:Group1_q;break;case 4:t=$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?Group3_st_q:$("#grp3-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?Group3_st_q:$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0?Group3_st_q:$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?Group2_st_q:$("#grp3-select")[0].selectedIndex>0?Group3_st_q:$("#grp2-select")[0].selectedIndex>0?Group2_st_q:$("#grp1-select")[0].selectedIndex>0?Group1_st_q:ST_q}if("radio4"==$(".radio input[type='radio']:checked")[0].id)switch(e){case 0:t=$("#st-select")[0].selectedIndex>0?Catchments_st_ss:Catchments_ss;break;case 1:t=$("#st-select")[0].selectedIndex>0?Group3_st_ss:Group3_ss;break;case 2:t=$("#st-select")[0].selectedIndex>0?Group2_st_ss:Group2_ss;break;case 3:t=$("#st-select")[0].selectedIndex>0?Group1_st_ss:Group1_ss;break;case 4:t=$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?Group3_st_ss:$("#grp3-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?Group3_st_ss:$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0?Group3_st_ss:$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?Group2_st_ss:$("#grp3-select")[0].selectedIndex>0?Group3_st_ss:$("#grp2-select")[0].selectedIndex>0?Group2_st_ss:$("#grp1-select")[0].selectedIndex>0?Group1_st_ss:ST_ss}$("#displayedMetricSelect").find("option").remove(),$.each(t,function(e,t){$("#displayedMetricSelect").append(new Option(t.name,t.field))}),$("#displayedMetricSelect").selectpicker("refresh");var a=function(e,t){for(var i=0,a=t.length;i<a;i++)if(e===t[i].name)return t[i];return null};i&&null!=a(i,t)?$("#displayedMetricSelect").selectpicker("val",a(i,t).field):$("#displayedMetricSelect").selectpicker("val",t[0].field)}function updateSourceOptions(){delete app.chosenSource,$("#displayedSourceSelect").find("option").remove(),$("#displayedSourceSelect").append(new Option("All Sources","All Sources"));var e=getChartOutfields(app.map.getLayer("SparrowRanking").visibleLayers[0]);$.each(e,function(e,t){if(t.attribute.indexOf("_")>-1){var i=t.label.split(") ")[1];$("#displayedSourceSelect").append(new Option(i,t.attribute))}}),$("#displayedSourceSelect").selectpicker("refresh"),$("#displayedSourceSelect").selectpicker("val","All Sources")}function returnDefaultLayer(e){switch(e){case 5:return 0;case 6:return 1;case 7:return 2;case 8:return 3;case 14:return 9;case 15:return 10;case 16:return 11;case 17:return 12;case 23:return 18;case 24:return 19;case 25:return 20;case 26:return 21;case 32:return 27;case 33:return 28;case 34:return 29;case 35:return 30}}function returnToStateLayer(e){switch(e){case 8:case 7:case 6:case 5:return 4;case 17:case 16:case 15:case 14:return 13;case 26:case 25:case 24:case 23:return 22;case 35:case 34:case 33:case 32:return 31}}function setAggregateGroup(e,t){var i;if("radio1"==t)switch(e){case 0:i=$("#st-select")[0].selectedIndex>0?5:0;break;case 1:i=$("#st-select")[0].selectedIndex>0?6:1;break;case 2:i=$("#st-select")[0].selectedIndex>0?7:2;break;case 3:i=$("#st-select")[0].selectedIndex>0?8:3;break;case 4:i=$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?6:$("#grp3-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?6:$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0?6:$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?7:$("#grp3-select")[0].selectedIndex>0?6:$("#grp2-select")[0].selectedIndex>0?7:$("#grp1-select")[0].selectedIndex>0?8:4}if("radio2"==t)switch(e){case 0:i=$("#st-select")[0].selectedIndex>0?14:9;break;case 1:i=$("#st-select")[0].selectedIndex>0?15:10;break;case 2:i=$("#st-select")[0].selectedIndex>0?16:11;break;case 3:i=$("#st-select")[0].selectedIndex>0?17:12;break;case 4:i=$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?15:$("#grp3-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?15:$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0?15:$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?16:$("#grp3-select")[0].selectedIndex>0?15:$("#grp2-select")[0].selectedIndex>0?16:$("#grp1-select")[0].selectedIndex>0?17:13}if("radio3"==t)switch(e){case 0:i=$("#st-select")[0].selectedIndex>0?23:18;break;case 1:i=$("#st-select")[0].selectedIndex>0?24:19;break;case 2:i=$("#st-select")[0].selectedIndex>0?25:20;break;case 3:i=$("#st-select")[0].selectedIndex>0?26:21;break;case 4:i=$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?24:$("#grp3-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?24:$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0?24:$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?25:$("#grp3-select")[0].selectedIndex>0?24:$("#grp2-select")[0].selectedIndex>0?25:$("#grp1-select")[0].selectedIndex>0?26:22}if("radio4"==t)switch(e){case 0:i=$("#st-select")[0].selectedIndex>0?32:27;break;case 1:i=$("#st-select")[0].selectedIndex>0?33:28;break;case 2:i=$("#st-select")[0].selectedIndex>0?34:29;break;case 3:i=$("#st-select")[0].selectedIndex>0?35:30;break;case 4:i=$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?33:$("#grp3-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?33:$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0?33:$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?34:$("#grp3-select")[0].selectedIndex>0?33:$("#grp2-select")[0].selectedIndex>0?34:$("#grp1-select")[0].selectedIndex>0?35:31}var a=[i];app.map.getLayer("SparrowRanking").setVisibleLayers(a)}function AOIChange(e){$("#page-loader").fadeIn();var t=e.currentTarget.id,i=e.currentTarget.value,a=$("#groupResultsSelect")[0].selectedIndex;1==$("#groupResultsSelect")[0].selectedIndex||0==$("#groupResultsSelect")[0].selectedIndex?($("#grp3-select").removeClass("disabled"),$("#grp3-select").removeAttr("disabled")):4==$("#groupResultsSelect")[0].selectedIndex&&!0==(""!==$("#grp1-select")[0].value||""!==$("#grp3-select")[0].value||""!==$("#st-select")[0].value)&&($("#grp3-select").removeClass("disabled"),$("#grp3-select").removeAttr("disabled"));var s={selectedId:t,selectedValue:i};populateMetricOptions($("#groupResultsSelect")[0].selectedIndex),setAggregateGroup(a,$(".radio input[type='radio']:checked")[0].id),updateSourceOptions(),""!=s.selectedValue&&app.setLayerDefObj(s),setLayerDefs(),generateRenderer(),"visible"==$("#chartWindowDiv").css("visibility")&&($("#toast_title").html("Loading..."),$("#toast_body").html("Chart updating"),$("#toast-fixed").fadeIn(),app.map.graphics.clear(),app.createChartQuery())}function setLayerDefs(){var e="",t=app.getLayerDefObj();t.AOIST&&(e+=""!=e?" AND ST = '"+t.AOIST+"'":"ST = '"+t.AOIST+"'"),t.AOI1&&(e+=""!=e?" AND GP1 = '"+t.AOI1+"'":"GP1 = '"+t.AOI1+"'"),t.AOI2&&(e+=""!=e?" AND GP2 = '"+t.AOI2+"'":"GP2 = '"+t.AOI2+"'"),t.AOI3&&(e+=""!=e?" AND GP3 = '"+t.AOI3+"'":"GP3 = '"+t.AOI3+"'");var i=[];i[0]=e,i[1]=e,i[2]=e,i[3]=e,i[4]=e,i[5]=e,i[6]=e,i[7]=e,i[8]=e,i[9]=e,i[10]=e,i[11]=e,i[12]=e,i[13]=e,i[14]=e,i[15]=e,i[16]=e,i[17]=e,i[18]=e,i[19]=e,i[20]=e,i[21]=e,i[22]=e,i[23]=e,i[24]=e,i[25]=e,i[26]=e,i[27]=e,i[28]=e,i[29]=e,i[30]=e,i[31]=e,i[32]=e,i[33]=e,i[34]=e,i[35]=e,app.map.getLayer("SparrowRanking").setLayerDefinitions(i)}function getTableFields(e,t){var i=[],a=[],s=[],n="";switch(t){case 0:s=Group3,n="GP3",$.each(tableOutFields,function(e,t){i.push(t)});break;case 4:s=Group3_st,n="SG3",$.each(stateTableOutFields,function(e,t){i.push(t)});break;case 7:s=Group3_tn,n="GP3",$.each(tableOutFields,function(e,t){i.push(t)});break;case 11:s=Group3_st_tn,n="SG3",$.each(stateTableOutFields,function(e,t){i.push(t)})}return $.each(s,function(e,t){i.push({field:t.field,name:t.name}),$.each(t.chartOutfields,function(e,t){t.attribute==n&&i.map(function(e){return e.field}).indexOf(n)<0?i.push({field:t.attribute,name:t.label}):t.attribute!=n&&i.push({field:t.attribute,name:t.label})})}),a.push("<tr>"),$.each(e,function(e,t){$.each(i,function(e,i){if(t==i.field)return a.push("<th>"+i.name+"</th>"),!1})}),a.push("</tr>"),a.join("")}function getLegendLabels(e){var t="",i=app.getLayerConfigObject(e),a=function(e){return e<=8?"Total Phosphorus":e>=9&&e<=17?"Total Nitrogen":e>=18&&e<=26?"Streamflow":e>26?"Suspended Sediment":void 0}(e);return $.each(i,function(e,i){$("#displayedMetricSelect").val()==i.field&&(t=i.name)}),app.chosenSource&&(t+=" from "+app.chosenSource.label),a+", "+t}function getChartOutfields(e){var t=[],i=app.getLayerConfigObject(e);return $.each(i,function(e,i){$("#displayedMetricSelect").val()==i.field&&$.each(i.chartOutfields,function(e,i){t.push(i)})}),t}function getExtraOutfields(e,t){var i=e;switch(t){case 0:case 9:case 18:case 27:i.push("CUMAREAKM2"),i.push("INCAREAKM2"),i.push("COMID");break;case 1:case 10:case 19:case 28:i.push("GP3_AREA");break;case 2:case 11:case 20:case 29:i.push("GP2_AREA");break;case 3:case 12:case 21:case 30:i.push("GP1_AREA");break;case 4:case 13:case 22:case 31:i.push("ST_AREA");break;case 5:case 14:case 23:case 32:i.push("STINCAREAK"),i.push("STCUMAREAK"),i.push("ST_COMID");break;case 6:case 15:case 24:case 33:i.push("SG3_AREA");break;case 7:case 16:case 25:case 34:i.push("SG2_AREA");break;case 8:case 17:case 26:case 35:i.push("SG1_AREA")}return i}function generateRenderer(){require(["esri/map","esri/Color","esri/dijit/Legend","esri/layers/LayerDrawingOptions","esri/symbols/SimpleLineSymbol","esri/symbols/SimpleFillSymbol","esri/tasks/ClassBreaksDefinition","esri/tasks/AlgorithmicColorRamp","esri/tasks/GenerateRendererParameters","esri/tasks/GenerateRendererTask","esri/tasks/query","esri/tasks/QueryTask","dojo/dom","dojo/dom-class","dojo/on","dojo/domReady!"],function(e,t,i,a,s,n,r,o,c,l,p,d,u,f,m){var g=app.map.getLayer("SparrowRanking").visibleLayers[0];if(app.map.getLayer("SparrowRanking").layerDefinitions){var h=app.map.getLayer("SparrowRanking").layerDefinitions[g];app.layerDef=h}else app.map.getLayer("SparrowRanking").setDefaultLayerDefinitions(),app.layerDef="1=1";app.Url=serviceBaseURL+g;var y=new p,D=new d(app.Url);y.where=app.layerDef,y.maxAllowableOffset=750,D.executeForCount(y,function(e){app.polygonResponseCount=e,app.polygonResponseCount>2500&&$("#chartButton").prop("disabled",!1)?($("#chartButton").prop("disabled",!0).css("pointer-events","none"),$("#chartButtonWrapper").css("cursor","not-allowed"),$("#fromMapTab").prop("disabled",!0)):($("#chartButton").prop("disabled",!1).css("pointer-events","auto"),$("#chartButtonWrapper").css("cursor","pointer"),$("#fromMapTab").prop("disabled",!1)),"visible"==$("#chartWindowDiv").css("visibility")&&(app.polygonResponseCount>2500?($("#toast_title").html("Warning"),$("#toast_body").html("Cannot show chart for "+app.polygonResponseCount+" features. Please narrow Area of Interest or Group Results and try again."),$("#toast-fixed").fadeIn(),setTimeout(function(){$("#toast-fixed").fadeOut()},5e3),app.map.graphics.clear(),$("#chartButton").html("Show Chart"),app.formattedHighlightString="",$("#chartWindowDiv").css("visibility","hidden"),$("#chartWindowContainer").empty(),$("#chartWindowPanelTitle").empty()):app.createChartQuery())},function(e){console.log(e)});var S=$("#displayedMetricSelect")[0].value;app.outFields=[S],app.currentAttribute=S;var b=new r;app.chosenSource?b.classificationField=app.chosenSource.attribute:b.classificationField=app.currentAttribute,b.classificationMethod="quantile",b.breakCount=5;app.map.getScale(),app.map.getZoom();dynamicBorderLayers.includes($("#groupResultsSelect")[0].value)?app.map.getZoom()>borderThreshold?b.baseSymbol=new n(n.STYLE_SOLID,new s(s.STYLE_SOLID,new t([168,168,168]),.1)):b.baseSymbol=new n("solid",null,null):b.baseSymbol=new n(n.STYLE_SOLID,new s(s.STYLE_SOLID,new t([168,168,168]),.1));var O=new o;"radio1"==$(".radio input[type='radio']:checked")[0].id&&(O.fromColor=new t.fromHex(void 0!=app.chosenSource?fromSourceColor:"#FFF6E8"),O.toColor=new t.fromHex(void 0!=app.chosenSource?toSourceColor:"#3F1700")),"radio2"==$(".radio input[type='radio']:checked")[0].id&&(O.fromColor=new t.fromHex(void 0!=app.chosenSource?fromSourceColor:"#F5EBB8"),O.toColor=new t.fromHex(void 0!=app.chosenSource?toSourceColor:"#003419")),"radio3"==$(".radio input[type='radio']:checked")[0].id&&(O.fromColor=new t.fromHex(void 0!=app.chosenSource?fromSourceColor:"#cef3f5"),O.toColor=new t.fromHex(void 0!=app.chosenSource?toSourceColor:"#00305")),"radio4"==$(".radio input[type='radio']:checked")[0].id&&(O.fromColor=new t.fromHex(void 0!=app.chosenSource?fromSourceColor:"#FFF6CF"),O.toColor=new t.fromHex(void 0!=app.chosenSource?toSourceColor:"#A04100")),O.algorithm="hsv",b.colorRamp=O;var I=new c;I.classificationDefinition=b,I.formatLabel=!1,I.where=app.layerDef,new l(app.Url).execute(I,function(e){function t(e){return e>0?parseFloat(e.toPrecision(3)).toString().replace(/\B(?=(\d{3})+(?!\d))/g,","):e.toString()}$.each(e.infos,function(i,a){var s=t(a.minValue),n=t(a.maxValue);if(4==i)var r="> "+s;else if(0==i)var r=s+" - "+n;else var r="> "+s+" - "+n;e.infos[i].label=r}),function(e){var t=app.map.getLayer("SparrowRanking").visibleLayers[0],s=app.map.getLayer("SparrowRanking"),n=[],r=new a;if(r.renderer=e,n[t]=r,s.setLayerDrawingOptions(n),app.hasOwnProperty("legend")){var o=app.legend.layerInfos,c=$.grep(o,function(e){return"SparrowRanking"!==e.layer.id}),l={layer:app.map.getLayer("SparrowRanking"),title:getLegendLabels(app.map.getLayer("SparrowRanking").visibleLayers[0])};c.unshift(l),app.legend.refresh(c)}else app.legend=new i({map:app.map,layerInfos:[{layer:app.map.getLayer("SparrowRanking"),title:getLegendLabels(app.map.getLayer("SparrowRanking").visibleLayers[0])}]},u.byId("legendDiv")),app.legend.startup();0==s.visible&&s.show()}(e)},function(e){console.log("generateRenderer Err ",e),$("#page-loader").fadeOut()})})}$(document).ready(function(){$(".nav-title").html(appTitle),$('[data-toggle="tooltip"]').tooltip(),$("#chartButtonWrapper").tooltip()}),require(["esri/arcgis/utils","esri/map","esri/tasks/QueryTask","esri/tasks/query","esri/Color","esri/dijit/HomeButton","esri/dijit/LocateButton","esri/dijit/Scalebar","esri/layers/ArcGISTiledMapServiceLayer","esri/layers/ArcGISDynamicMapServiceLayer","esri/layers/FeatureLayer","esri/layers/ArcGISImageServiceLayer","esri/layers/WMSLayer","esri/dijit/Geocoder","esri/dijit/PopupTemplate","esri/graphic","esri/geometry/Extent","esri/geometry/Multipoint","esri/geometry/Point","esri/layers/LayerDrawingOptions","esri/symbols/PictureMarkerSymbol","esri/symbols/SimpleLineSymbol","esri/symbols/SimpleFillSymbol","esri/tasks/ClassBreaksDefinition","esri/tasks/AlgorithmicColorRamp","esri/tasks/GenerateRendererParameters","esri/tasks/GenerateRendererTask","esri/tasks/IdentifyTask","esri/tasks/IdentifyParameters","esri/tasks/ProjectParameters","esri/geometry/webMercatorUtils","esri/SpatialReference","dojo/parser","dojo/dnd/Moveable","dojo/query","dojo/dom","dojo/dom-class","dojo/on","dojo/domReady!"],function(e,t,i,a,s,n,r,o,c,l,p,d,u,f,m,g,h,y,D,S,b,O,I,_,A,v,x,w,C,G,L,T,k,P,F,R,M,E){k.parse(),app.dragInfoWindows=!0,app.clickSelectionActive=!1,app.drawSelectionActive=!1,app.userSelectedDispFieldName="",app.userSelectedShapes=[],app.customChartClicked=!1,app.shiftKey=!1,app.formattedHighlightString,app.polygonResponseCount,app.defaultMapCenter=mapCenter,app.defaultZoom=defaultZoomLevel,app.currentZoomLevel=app.defaultZoom,app.map=t("mapDiv",{basemap:"gray",center:app.defaultMapCenter,zoom:app.defaultZoom}),app.home=new n({map:app.map},"homeButton"),app.home.startup(),$(".home").prop("title","Zoom to default extent"),app.locate=new r({map:app.map,scale:75e3},"locateButton"),app.locate.startup(),app.scalebar=new o({map:app.map,attachTo:"bottom-right",scalebarUnit:"dual"}),app.geocoder=new f({value:"",maxLocations:25,autoComplete:!0,arcgisGeocoder:!0,autoNavigate:!1,map:app.map},"geosearch"),app.geocoder.startup(),app.geocoder.on("select",function(e){app.clearFindGraphics(),(e.graphic?e.graphic:e.result.feature).setSymbol(Z)}),app.geocoder.on("findResults",K),app.geocoder.on("clear",app.clearFindGraphics),search_api.create("geosearch_usgs",{on_result:function(e){-1==["GNIS_MAJOR","GNIS_MINOR","ZIPCODE","AREACODE"].indexOf(e.result.properties.Source)?app.map.setExtent(new esri.geometry.Extent({xmin:e.result.properties.LonMin,ymin:e.result.properties.LatMin,xmax:e.result.properties.LonMax,ymax:e.result.properties.LatMax,spatialReference:{wkid:4326}}),!0):app.map.centerAndZoom(new D(e.result.properties.Lon,e.result.properties.Lat),12),app.map.infoWindow.setTitle("Search Result"),app.map.infoWindow.setContent($.map(Object.keys(e.result.properties),function(t){return"<b>"+t+": </b>"+e.result.properties[t]}).join("<br/>")),$("#geosearchModal").modal("hide"),app.map.infoWindow.show(new D(e.result.properties.Lon,e.result.properties.Lat))},include_usgs_sw:!0,include_huc2:!0,include_huc4:!0,include_huc6:!0,include_huc8:!0,include_huc12:!0});var N={},q=[],W=[],Y=[];loadEventHandlers(),"function"==typeof esri.layers.Layer.prototype._errorHandler&&(esri.layers.Layer.prototype._errorHandler=function(e){!e||!e.message||e.message},dojo.config.deferredOnError=function(e){},dojo._ioSetArgs2=dojo._ioSetArgs,dojo._ioSetArgs=function(e,t,i,a){return dojo._ioSetArgs2(e,t,i,function(e,t){return e})}),function(e,t,i){var a;a=new esri.tasks.QueryTask(e);var s=new esri.tasks.Query;s.returnGeometry=!1,s.outFields=t,s.where=i,s.returnDistinctValues=!0,a.execute(s,j)}(serviceBaseURL+5,["ST","GP3","GP2","GP1"],"1=1"),app.setLayerDefObj=function(e){switch(e.selectedId){case"st-select":N.AOIST=e.selectedValue;break;case"grp1-select":N.AOI1=e.selectedValue;break;case"grp2-select":N.AOI2=e.selectedValue;break;case"grp3-select":N.AOI3=e.selectedValue}if($("#groupResultsSelect option").each(function(){this.disabled=!1}),N.AOI3){var t=document.getElementById("groupResultsSelect").getElementsByTagName("option");t[2].disabled=!0,t[3].disabled=!0,$("#groupResultsSelect").selectpicker("render")}if(N.AOI2){var i=document.getElementById("groupResultsSelect").getElementsByTagName("option");i[1].disabled=!0,i[3].disabled=!0,$("#groupResultsSelect").selectpicker("render")}if(N.AOI1){document.getElementById("groupResultsSelect").getElementsByTagName("option");$("#groupResultsSelect").selectpicker("render")}app.updateAOIs(e.selectedId)},app.getLayerDefObj=function(){return N},app.clearLayerDefObj=function(){N={},$("#st-select").empty(),$("#grp1-select").empty(),$("#grp2-select").empty(),$("#grp3-select").empty(),V()},app.clearOneLayerDefObj=function(e){switch(e){case"AOIST":N.AOIST=void 0,app.updateAOIs("grp1-select"),app.updateAOIs("grp2-select"),app.updateAOIs("grp3-select");break;case"AOI1":N.AOI1=void 0,app.updateAOIs("st-select"),app.updateAOIs("grp2-select"),app.updateAOIs("grp3-select");break;case"AOI2":N.AOI2=void 0,app.updateAOIs("grp1-select"),app.updateAOIs("grp3-select"),app.updateAOIs("st-select");break;case"AOI3":N.AOI3=void 0,app.updateAOIs("grp1-select"),app.updateAOIs("grp2-select"),app.updateAOIs("st-select")}};var B=function(e,t){var i=[];for(var a in e)i.map(function(e){return e}).indexOf(e[a][t])<0&&i.push(e[a][t]);return i.sort()},H=function(e,t,i,a,s,n,r){return $(e).empty(),{filteredAOIOptions:q.filter(function(e){return e[t]==N[i]&&e[a]==N[s]}),prop:e,select:n,AOI:r}},U=function(e,t,i,a,s){return $(e).empty(),{filteredAOIOptions:q.filter(function(e){return e[t]==N[i]}),prop:e,select:a,AOI:s}};app.updateAOIs=function(e){var t=[];switch(Object.keys(app.getLayerDefObj()).length){case 4:var i=function(e){var t="",i="",a="",s="",n="",r="",o="",c="",l="",p="",d="",u="";switch(e){case"st-select":$("#grp1-select").empty(),s=q.filter(function(e){return e.ST===N.AOIST&&e.GP2==N.AOI2&&e.GP3===N.AOI3}),t="GP1",i="#grp1-select",a="AOI1",$("#grp2-select").empty(),c=q.filter(function(e){return e.ST===N.AOIST&&e.GP1==N.AOI1&&e.GP3===N.AOI3}),n="GP2",r="#grp2-select",o="AOI2",$("#grp3-select").empty(),u=q.filter(function(e){return e.ST===N.AOIST&&e.GP1==N.AOI1&&e.GP2===N.AOI2}),l="GP3",p="#grp3-select",d="AOI3";break;case"grp1-select":$("#st-select").empty(),s=q.filter(function(e){return e.GP1===N.AOI1&&e.GP2==N.AOI2&&e.GP3===N.AOI3}),t="ST",i="#st-select",a="AOIST",$("#grp2-select").empty(),c=q.filter(function(e){return e.GP1===N.AOI1&&e.ST==N.AOIST&&e.GP3===N.AOI3}),n="GP2",r="#grp2-select",o="AOI2",$("#grp3-select").empty(),u=q.filter(function(e){return e.GP1===N.AOI1&&e.ST==N.AOIST&&e.GP2===N.AOI2}),l="GP3",p="#grp3-select",d="AOI3";break;case"grp2-select":$("#st-select").empty(),s=q.filter(function(e){return e.GP2===N.AOI2&&e.GP1==N.AOI1&&e.GP3===N.AOI3}),t="ST",i="#st-select",a="AOIST",$("#grp1-select").empty(),c=q.filter(function(e){return e.GP2===N.AOI2&&e.ST==N.AOIST&&e.GP3===N.AOI3}),n="GP1",r="#grp1-select",o="AOI1",$("#grp3-select").empty(),u=q.filter(function(e){return e.GP2===N.AOI2&&e.ST==N.AOIST&&e.GP1===N.AOI1}),l="GP3",p="#grp3-select",d="AOI3";break;case"grp3-select":$("#st-select").empty(),s=q.filter(function(e){return e.GP3===N.AOI3&&e.GP1==N.AOI1&&e.GP2===N.AOI2}),t="ST",i="#st-select",a="AOIST",$("#grp1-select").empty(),c=q.filter(function(e){return e.GP3===N.AOI3&&e.ST==N.AOIST&&e.GP2===N.AOI2}),n="GP1",r="#grp1-select",o="AOI1",$("#grp2-select").empty(),u=q.filter(function(e){return e.GP3===N.AOI3&&e.ST==N.AOIST&&e.GP1===N.AOI1}),l="GP2",p="#grp2-select",d="AOI2"}return[{filterAOIs:s,prop:t,select:i,whichAOI:a},{filterAOIs:c,prop:n,select:r,whichAOI:o},{filterAOIs:u,prop:l,select:p,whichAOI:d}]}(e),a=B(i[0].filterAOIs,i[0].prop),s=B(i[1].filterAOIs,i[1].prop),n=B(i[2].filterAOIs,i[2].prop);z(a,i[0].select,i[0].whichAOI),z(s,i[1].select,i[1].whichAOI),z(n,i[2].select,i[2].whichAOI);break;case 3:var r="",o="",c="",l={},p={};if(N.AOI3)if(N.AOI2)if(N.AOI1)if($("#st-select").empty(),t=q.filter(function(e){return e.GP1===N.AOI1&&e.GP2==N.AOI2&&e.GP3===N.AOI3}),r="ST",o="#st-select",c="AOIST","grp1-select"==e)l=H("#grp2-select","GP1","AOI1","GP3","AOI3","GP1","AOI1"),p=H("#grp3-select","GP1","AOI1","GP2","AOI2","GP3","AOI3");else if("grp2-select"==e)l=H("#grp1-select","GP2","AOI2","GP3","AOI3","GP1","AOI1"),p=H("#grp3-select","GP2","AOI2","GP1","AOI1","GP3","AOI3");else l=H("#grp1-select","GP3","AOI3","GP2","AOI2","GP1","AOI1"),p=H("#grp2-select","GP3","AOI3","GP1","AOI1","GP2","AOI2");else if($("#grp1-select").empty(),t=q.filter(function(e){return e.ST===N.AOIST&&e.GP2==N.AOI2&&e.GP3===N.AOI3}),r="GP1",o="#grp1-select",c="AOI1","st-select"==e)l=H("#grp2-select","ST","AOIST","GP3","AOI3","GP2","AOI2"),p=H("#grp3-select","ST","AOIST","GP2","AOI2","GP3","AOI3");else if("grp2-select"==e)l=H("#st-select","GP2","AOI2","GP3","AOI3","ST","AOIST"),p=H("#grp3-select","GP2","AOI2","ST","AOIST","GP3","AOI3");else l=H("#st-select","GP3","AOI3","GP2","AOI2","ST","AOIST"),p=H("#grp2-select","GP3","AOI3","ST","AOIST","GP2","AOI2");else if($("#grp2-select").empty(),t=q.filter(function(e){return e.ST===N.AOIST&&e.GP1==N.AOI1&&e.GP3===N.AOI3}),r="GP2",o="#grp2-select",c="AOI2","st-select"==e)var l=H("#grp1-select","ST","AOIST","GP3","AOI3","GP1","AOI1"),p=H("#grp3-select","ST","AOIST","GP1","AOI1","GP3","AOI3");else if("grp1-select"==e)var l=H("#st-select","GP1","AOI1","GP3","AOI3","ST","AOIST"),p=H("#grp3-select","GP1","AOI1","ST","AOIST","GP3","AOI3");else var l=H("#st-select","GP3","AOI3","GP1","AOI1","ST","AOIST"),p=H("#grp1-select","GP3","AOI3","ST","AOIST","GP1","AOI1");else if($("#grp3-select").empty(),t=q.filter(function(e){return e.ST==N.AOIST&&e.GP1==N.AOI1&&e.GP2===N.AOI2}),r="GP3",o="#grp3-select",c="AOI3","st-select"==e)var l=H("#grp1-select","ST","AOIST","GP2","AOI2","GP1","AOI1"),p=H("#grp2-select","ST","AOIST","GP1","AOI1","GP2","AOI2");else if("grp1-select"==e)var l=H("#st-select","GP1","AOI1","GP2","AOI2","ST","AOIST"),p=H("#grp2-select","GP1","AOI1","ST","AOIST","GP2","AOI2");else var l=H("#st-select","GP2","AOI2","GP1","AOI1","ST","AOIST"),p=H("#grp1-select","GP2","AOI2","ST","AOIST","GP1","AOI1");0===t.length&&(t=q);var d=B(t,r),u=B(l.filteredAOIOptions,l.select),f=B(p.filteredAOIOptions,p.select);z(d,o,c),z(u,l.prop,l.AOI),z(f,p.prop,p.AOI);break;case 2:l={};var m="",g="",h="",y="",D="",S="";N.AOIST||N.AOI1?N.AOIST||N.AOI2?N.AOIST||N.AOI3?N.AOI1||N.AOI2?N.AOI1||N.AOI3?N.AOI2||N.AOI3||($("#grp2-select").empty(),$("#grp3-select").empty(),t=q.filter(function(e){return e.ST===N.AOIST&&e.GP1==N.AOI1}),l="st-select"==e?U("#grp1-select","ST","AOIST","GP1","AOI1"):U("#st-select","GP1","AOI1","ST","AOIST"),m="GP2",g="#grp2-select",h="AOI2",y="GP3",D="#grp3-select",S="AOI3"):($("#grp1-select").empty(),$("#grp3-select").empty(),t=q.filter(function(e){return e.ST===N.AOIST&&e.GP2==N.AOI2}),l="st-select"==e?U("#grp2-select","ST","AOIST","GP2","AOI2"):U("#st-select","GP2","AOI2","ST","AOIST"),m="GP1",g="#grp1-select",h="AOI1",y="GP3",D="#grp3-select",S="AOI3"):($("#grp1-select").empty(),$("#grp2-select").empty(),t=q.filter(function(e){return e.ST===N.AOIST&&e.GP3==N.AOI3}),l="st-select"==e?U("#grp3-select","ST","AOIST","GP3","AOI3"):U("#st-select","GP3","AOI3","ST","AOIST"),m="GP1",g="#grp1-select",h="AOI1",y="GP2",D="#grp2-select",S="AOI2"):($("#st-select").empty(),$("#grp3-select").empty(),t=q.filter(function(e){return e.GP1===N.AOI1&&e.GP2==N.AOI2}),l="grp1-select"==e?U("#grp2-select","GP1","AOI1","GP2","AOI2"):U("#grp1-select","GP2","AOI2","GP1","AOI1"),m="ST",g="#st-select",h="AOIST",y="GP3",D="#grp3-select",S="AOI3"):($("#st-select").empty(),$("#grp2-select").empty(),t=q.filter(function(e){return e.GP1===N.AOI1&&e.GP3==N.AOI3}),l="grp1-select"==e?U("#grp3-select","GP1","AOI1","GP3","AOI3"):U("#grp1-select","GP3","AOI3","GP1","AOI1"),m="ST",g="#st-select",h="AOIST",y="GP2",D="#grp2-select",S="AOI2"):($("#st-select").empty(),$("#grp1-select").empty(),t=q.filter(function(e){return e.GP2===N.AOI2&&e.GP3==N.AOI3}),l="grp2-select"==e?U("#grp3-select","GP2","AOI2","GP3","AOI3"):U("#grp2-select","GP3","AOI3","GP2","AOI2"),m="ST",g="#st-select",h="AOIST",y="GP1",D="#grp1-select",S="AOI1"),0===t.length&&(t=q);var b=B(t,m),O=(d=B(t,y),B(l.filteredAOIOptions,l.select));z(b,g,h),z(d,D,S),z(O,l.prop,l.AOI);break;case 1:var I=[],_=[],A=[];N.AOIST?($("#grp1-select").empty(),$("#grp2-select").empty(),$("#grp3-select").empty(),t=q.filter(function(e){return e.ST===N.AOIST}),I=["GP1","GP2","GP3"],_=["#grp1-select","#grp2-select","#grp3-select"],A=["AOI1","AOI2","AOI3"]):N.AOI1?($("#st-select").empty(),$("#grp2-select").empty(),$("#grp3-select").empty(),t=q.filter(function(e){return e.GP1===N.AOI1}),I=["ST","GP2","GP3"],_=["#st-select","#grp2-select","#grp3-select"],A=["AOIST","AOI2","AOI3"]):N.AOI2?($("#st-select").empty(),$("#grp1-select").empty(),$("#grp3-select").empty(),t=q.filter(function(e){return e.GP2===N.AOI2}),I=["ST","GP1","GP3"],_=["#st-select","#grp1-select","#grp3-select"],A=["AOIST","AOI1","AOI3"]):N.AOI3&&($("#st-select").empty(),$("#grp1-select").empty(),$("#grp2-select").empty(),t=q.filter(function(e){return e.GP3===N.AOI3}),I=["ST","GP1","GP2"],_=["#st-select","#grp1-select","#grp2-select"],A=["AOIST","AOI1","AOI2"]),0===t.length&&(t=q);for(var v=0;v<4;v++){var x=B(t,I[v]);z(x,_[v],A[v])}break;case 0:$(".aoiSelect").selectpicker("val",""),app.clearLayerDefObj()}};var z=function(e,t,i){$.each(e,function(e,i){$(t).append(new Option(i))}),$(t).selectpicker("refresh"),N[i]&&$(t).selectpicker("val",N[i])};function j(e){$.each(e.features,function(e,t){q.push(t.attributes)}),V()}function V(){var e=B(q,"GP2"),t=B(q,"GP1"),i=B(q,"ST");$.each(e,function(e,t){" "!=t&&$("#grp2-select").append(new Option(t))}),$.each(t,function(e,t){" "!=t&&$("#grp1-select").append(new Option(t))}),$.each(i,function(e,t){$("#st-select").append(new Option(t))}),$("#grp3-select").attr("disabled","disabled"),$("#grp3-select").addClass("disabled"),$("#grp2-select").selectpicker("refresh"),$("#grp1-select").selectpicker("refresh"),$("#st-select").selectpicker("refresh")}app.initMapScale=function(){var e=app.map.getScale().toFixed(0);$("#scale")[0].innerHTML=addCommas(e);var t=L.webMercatorToGeographic(app.map.extent.getCenter());$("#latitude").html(t.y.toFixed(3)),$("#longitude").html(t.x.toFixed(3))},app.updateMousePosition=function(e){if($("#mapCenterLabel").css("display","none"),null!==e.mapPoint){var t=L.webMercatorToGeographic(e.mapPoint);$("#latitude").html(t.y.toFixed(3)),$("#longitude").html(t.x.toFixed(3))}},app.updateMapCenter=function(e){$("#mapCenterLabel").css("display","inline");var t=L.webMercatorToGeographic(e.getCenter());$("#latitude").html(t.y.toFixed(3)),$("#longitude").html(t.x.toFixed(3))},app.setupDraggableInfoWindow=function(){if(!0===app.dragInfoWindows){var e=F(".title",app.map.infoWindow.domNode)[0],t=new P(app.map.infoWindow.domNode,{handle:e});E(t,"FirstMove",function(){var e=F(".outerPointer",app.map.infoWindow.domNode)[0];M.add(e,"hidden");var t=F(".pointer",app.map.infoWindow.domNode)[0];M.add(t,"hidden")}.bind(this))}},app.executeIdentifyTask=function(e){app.shiftKey=e.shiftKey;var t=app.map.getLayer("SparrowRanking").visibleLayers[0];app.identifyParams.layerIds=[t];var i,a,n=app.map.getLayersVisibleAtScale();for(i in n)"nitroCalibration"===n[i].id&&!0===app.map.getLayer("nitroCalibration").visible&&(a=app.map.getLayer("nitroCalibration").visibleLayers[0],app.identifyParams.layerIds.push(a)),"phosCalibration"===n[i].id&&!0===app.map.getLayer("phosCalibration").visible&&(a=app.map.getLayer("phosCalibration").visibleLayers[0],app.identifyParams.layerIds.push(a)),"streamflowCalibration"===n[i].id&&!0===app.map.getLayer("streamflowCalibration").visible&&(a=app.map.getLayer("streamflowCalibration").visibleLayers[0],app.identifyParams.layerIds.push(a)),"sedimentCalibration"===n[i].id&&!0===app.map.getLayer("sedimentCalibration").visible&&(a=app.map.getLayer("sedimentCalibration").visibleLayers[0],app.identifyParams.layerIds.push(a));app.identifyParams.geometry=e.mapPoint,app.identifyParams.mapExtent=app.map.extent,app.identifyParams.tolerance=3,app.identifyParams.maxAllowableOffset=200;app.identifyTask.execute(app.identifyParams).addCallback(function(t){if(app.clickSelectionActive)$.each(t,function(e,t){var i=t.feature,a="string"!=typeof t.value?t.value:"'"+t.value+"'";if(app.shiftKey){var n=app.map.graphics.graphics.filter(function(e){return e.symbol.id==t.value})[0];app.map.graphics.remove(n),app.userSelectedShapes.splice(app.userSelectedShapes.indexOf(a),1)}else{var r=new O(O.STYLE_SOLID,new s([255,255,0]),1);r.id=t.value,i.setSymbol(r),app.map.graphics.add(i),app.userSelectedShapes.push(a),""==app.userSelectedDispFieldName&&(app.userSelectedDispFieldName=t.displayFieldName)}}),0==app.userSelectedShapes.length&&app.userSelectedShapes.length<chartFeatureMax?$("#chartButton").html("Show Chart"):$("#chartButton").html("Show Chart for selection");else{var i=!1;if(app.map.graphics.clear(),t.length>=1&&($.each(t,function(t,a){if(36===a.layerId){var s=new esri.InfoTemplate;s.setTitle("SPARROW Phosphorus Calibration Site"),s.setContent("<div><b>Station Name:</b> "+a.feature.attributes.STATION_NA+"</div><br><div><b>Station ID:</b> </b>"+a.feature.attributes.STATION_ID+"</div><br><div><b>SPARROW Reach ID: </b>"+a.feature.attributes.COMID+"</div><br><div><b>Beale or Fluxmaster Estimated TP Load "+chartUnits+": </b>"+Math.round(a.feature.attributes.ACTUAL)+"</div><br><div><b>SPARROW Estimated TP Load "+chartUnits+": </b>"+Math.round(a.feature.attributes.PREDICT)+"</div><br>");new g;a.feature.setInfoTemplate(s),app.map.infoWindow.setFeatures([a.feature]),app.map.infoWindow.show(e.mapPoint),i=!0}if(37===a.layerId){(n=new esri.InfoTemplate).setTitle("SPARROW Nitrogen Calibration Site"),n.setContent("<div><b>Station Name:</b> "+a.feature.attributes.STATION_NA+"</div><br><div><b>Station ID:</b> </b>"+a.feature.attributes.STATION_ID+"</div><br><div><b>SPARROW Reach ID: </b>"+a.feature.attributes.COMID+"</div><br><div><b>Beale or Fluxmaster Estimated TN Load "+chartUnits+": </b>"+Math.round(a.feature.attributes.ACTUAL)+"</div><br><div><b>SPARROW Estimated TN Load "+chartUnits+": </b>"+Math.round(a.feature.attributes.PREDICT)+"</div><br>");new g;a.feature.setInfoTemplate(n),app.map.infoWindow.setFeatures([a.feature]),app.map.infoWindow.show(e.mapPoint),i=!0}if(38===a.layerId){(n=new esri.InfoTemplate).setTitle("SPARROW Streamflow Calibration Site"),n.setContent("<div><b>Station Name:</b> "+a.feature.attributes.STATION_NA+"</div><br><div><b>Station ID:</b> </b>"+a.feature.attributes.STATION_ID+"</div><br><div><b>SPARROW Reach ID: </b>"+a.feature.attributes.COMID+"</div><br><div><b>Average Measured Streamflow (cfs): </b>"+Math.round(a.feature.attributes.ACTUAL)+"</div><br><div><b>SPARROW Estimated Average Streamflow (cfs): </b>"+Math.round(a.feature.attributes.PREDICT)+"</div><br>");new g;a.feature.setInfoTemplate(n),app.map.infoWindow.setFeatures([a.feature]),app.map.infoWindow.show(e.mapPoint),i=!0}if(39===a.layerId){var n;(n=new esri.InfoTemplate).setTitle("Suspended Sediment Calibration Site"),n.setContent("<div><b>Station Name:</b> "+a.feature.attributes.STATION_NA+"</div><br><div><b>Station identifier:</b> </b>"+a.feature.attributes.STATION_ID+"</div><br><div><b>SPARROW Reach ID: </b>"+a.feature.attributes.COMID+"</div><br><div><b>Beale or Fluxmaster Estimated SSC or TSS Load (MT/yr): </b>"+Math.round(a.feature.attributes.ACTUAL)+"</div><br><div><b>SPARROW Estimated SSC Load (MT/yr): </b>"+Math.round(a.feature.attributes.PREDICT)+"</div><br>");new g;a.feature.setInfoTemplate(n),app.map.infoWindow.setFeatures([a.feature]),app.map.infoWindow.show(e.mapPoint),i=!0}}),1!=i)){var a=new O(O.STYLE_SOLID,new s([255,255,0]),1);a.id=t[0].value,t[0].feature.setSymbol(a),app.map.graphics.add(t[0].feature);var n=getChartOutfields(app.map.getLayer("SparrowRanking").visibleLayers[0]),r=(t[0].feature.attributes,t[0].displayFieldName+" = '"+t[0].value+"'");$.each(n,function(e,t){}),app.createChartQuery(r)}}})},app.clearFindGraphics=function(){app.map.infoWindow.hide(),app.map.graphics.clear()},app.createTableQuery=function(){$("#resultsTable").empty();var e=app.map.getLayer("SparrowRanking").visibleLayers[0];if(app.map.getLayer("SparrowRanking").layerDefinitions)var t=app.map.getLayer("SparrowRanking").layerDefinitions[e];else t="1=1";var i=serviceBaseURL+e;new esri.tasks.QueryTask(i);var a=new esri.tasks.Query;a.returnGeometry=!1,a.outFields=["*"],a.where=t},app.createChartQuery=function(e){if(app.polygonResponseCount>chartFeatureMax&&void 0==e)$("#toast_title").html("Warning"),$("#toast_body").html("Cannot show chart for "+app.polygonResponseCount+" features. Please narrow Area of Interest or Group Results and try again."),$("#toast-fixed").show(),setTimeout(function(){$("#toast-fixed").hide()},4e3);else{var t;"visible"!=$("#chartWindowDiv").css("visibility")?($("#chartWindowDiv").css({visibility:"visible",height:"800px",width:"800px",top:"50px",left:"510px"}),$("#chartWindowContent").addClass("content-loading")):$("#chartWindowContent").addClass("content-loading"),$("#chartContainer").empty();var i=app.map.getLayer("SparrowRanking").visibleLayers[0];if(void 0==e)if(app.map.getLayer("SparrowRanking").layerDefinitions)var a=app.map.getLayer("SparrowRanking").layerDefinitions[i];else a="1=1";else a=e;var s=serviceBaseURL+i;t=new esri.tasks.QueryTask(s);var n=getChartOutfields(i),r=[];$.each(n,function(e,t){r.push(t.attribute)});var o=new esri.tasks.Query;o.returnGeometry=!1,o.outFields=getExtraOutfields(r,i),o.where=a,t.execute(o,X),$("#chartTabContent").addClass("content-loading")}},app.downloadChartPNG=function(){},app.getLayerConfigObject=function(e){return function(t){switch(e){case 0:return Catchments;case 1:return Group3;case 2:return Group2;case 3:return Group1;case 4:return ST;case 5:return Catchments_st;case 6:return Group3_st;case 7:return Group2_st;case 8:return Group1_st;case 9:return Catchments_tn;case 10:return Group3_tn;case 11:return Group2_tn;case 12:return Group1_tn;case 13:return ST_tn;case 14:return Catchments_st_tn;case 15:return Group3_st_tn;case 16:return Group2_st_tn;case 17:return Group1_st_tn;case 18:return Catchments_q;case 19:return Group3_q;case 20:return Group2_q;case 21:return Group1_q;case 22:return ST_q;case 23:return Catchments_st_q;case 24:return Group3_st_q;case 25:return Group2_st_q;case 26:return Group1_st_q;case 27:return Catchments_ss;case 28:return Group3_ss;case 29:return Group2_ss;case 30:return Group1_ss;case 31:return ST_ss;case 32:return Catchments_st_ss;case 33:return Group3_st_ss;case 34:return Group2_st_ss;case 35:return Group1_st_ss}}()};var Z=new b({angle:0,xoffset:0,yoffset:12,type:"esriPMS",url:"../images/purple-pin.png",contentType:"image/png",width:13,height:24});new I(I.STYLE_SOLID,new O(O.STYLE_DASHDOT,new s([255,0,0]),2),new s([255,255,0,.5]));function K(e){if((e=e.results).length>0){app.clearFindGraphics();for(var t=0;t<e.length;t++);var i=new D(e[0].feature.geometry);app.map.centerAndZoom(i,17)}}function Q(e){switch(e){case 0:return $("#st-select")[0].selectedIndex>0?"ST_COMID":"COMID";case 1:return $("#st-select")[0].selectedIndex>0?"SG3":"GP3";case 2:return $("#st-select")[0].selectedIndex>0?"SG2":"GP2";case 3:return $("#st-select")[0].selectedIndex>0?"SG1":"GP1";case 4:return $("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?"SG3":$("#grp3-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?"SG3":$("#grp3-select")[0].selectedIndex>0&&$("#grp2-select")[0].selectedIndex>0?"SG3":$("#grp2-select")[0].selectedIndex>0&&$("#grp1-select")[0].selectedIndex>0?"SG2":$("#grp3-select")[0].selectedIndex>0?"SG3":$("#grp2-select")[0].selectedIndex>0?"SG2":$("#grp1-select")[0].selectedIndex>0?"SG1":"ST"}}function X(e){var t=[],i=[],a=[],n=[],r=[],o=[];$.each(e.features,function(e,t){o.push($.extend(!0,{},t.attributes)),$.map(Object.keys(t.attributes),function(e,i){(e.indexOf("AREA")>-1||e.indexOf("SQKM")>-1||e.indexOf("km2")>-1)&&delete t.attributes[e]}),r.push(t.attributes)});var c=0;$.each(r,function(e,t){$.each(t,function(e,t){"string"!==jQuery.type(t)&&"COMID"!==e&&(c+=t)}),t.total=c.toFixed(4),o[e].total=c.toFixed(4),c=0}),r.sort(function(e,t){return parseFloat(t.total)-parseFloat(e.total)}),$.each(e.features[0].attributes,function(e,t){i.push(e)}),i.pop(),$.each(i,function(e,t){var i=[];$.each(r,function(e,a){0==$("#groupResultsSelect")[0].selectedIndex?i.push({y:a[t],id:a.COMID||a.ST_COMID}):i.push(a[t])}),a.push(i)}),i.shift(),$.each(a.shift(),function(e,i){void 0!==i.y?t.push(i.y):t.push(i)});var l=getChartOutfields(app.map.getLayer("SparrowRanking").visibleLayers[0]),p=[];function d(){switch($("#groupResultsSelect")[0].selectedIndex){case 0:return groupResultsLabels.a;case 1:return groupResultsLabels.b;case 2:return groupResultsLabels.c;case 3:return groupResultsLabels.d;case 4:return groupResultsLabels.e}}function u(){var e,t=app.map.getLayer("SparrowRanking").visibleLayers[0],i=app.getLayerConfigObject(t);return $.each(i,function(t,i){i.field==$("#displayedMetricSelect").val()&&(e=i.name)}),e}$.each(l,function(e,t){p.push(t.label)}),W=o,Y=[],$.each(p,function(e,t){Y.push(t)}),ee(W,Y),p.shift(),$.each(p,function(e,t){n.push({name:t,turboThreshold:3e3})}),$.each(a,function(e,t){n[e].data=a[e]}),$("#chartWindowDiv").lobiPanel({unpin:!1,reload:!1,minimize:!1,close:!1,expand:!1,editTitle:!1,draggable:!0,minWidth:800,minHeight:800,maxHeight:1e3}),$("#chartWindowDiv").addClass("chartWindowMaximize"),$("#chartWindowDiv").removeClass("chartWindowMinimize"),$("#chartWindowDiv").css("visibility","visible"),$("#toast-fixed").fadeOut(),$("#toast-fixed").css("opacity","1"),"radio1"==$('.radio input[type="radio"]:checked')[0].id&&$("#chartWindowPanelTitle").text("Total Phosphorus "+u()),"radio2"==$('.radio input[type="radio"]:checked')[0].id&&$("#chartWindowPanelTitle").text("Total Nitrogen "+u()),"radio3"==$('.radio input[type="radio"]:checked')[0].id&&$("#chartWindowPanelTitle").text("Streamflow "+u()),"radio4"==$('.radio input[type="radio"]:checked')[0].id&&$("#chartWindowPanelTitle").text("Suspended Sediment "+u()),(e.features.length<=1||app.customChartClicked)&&($("#chartWindowPanelTitle").append('<br/><div><button type="button" class="btn btn-blue" data-toggle="tooltip" title="Cannot display full chart for more than '+chartFeatureMax+' features" id="popupChartButton"><span class="glyphicon glyphicon-signal"></span> Show Full Chart </button></div>'),$("#popupChartButton").tooltip({selector:'[data-toggle="tooltip"]'}),app.polygonResponseCount>chartFeatureMax?$("#popupChartButton").prop("disabled",!0).css("cursor","not-allowed"):$("#popupChartButton").prop("disabled",!1).attr("title",null).css("cursor","pointer"),app.customChartClicked&&(app.customChartClicked=!1)),0==$("#chartClose").length&&$("#chartWindowDiv .dropdown").prepend('<div id="chartClose" title="close"><b>X</b></div>'),$("#popupChartButton").on("click",function(){app.formattedHighlightString="",app.map.graphics.clear(),app.createChartQuery()});var f=$("#chartWindowDiv").data("lobiPanel");f.unpin();var m,g=f.getPosition().x;f.setPosition(g,50),$("#chartClose").on("click",function(){app.map.graphics.clear(),app.polygonResponseCount>2500&&$("#chartButton").prop("disabled",!1)&&($("#chartButton").prop("disabled",!0).css("pointer-events","none").html("Show Chart"),$("#chartButtonWrapper").css("cursor","not-allowed")),$("#chartButton").html("Show Chart"),app.formattedHighlightString="",$("#chartWindowDiv").css("visibility","hidden"),$("#chartWindowContainer").empty(),$("#chartWindowPanelTitle").empty()}),$("#chartWindowDiv").resize(function(){var e=$("#chartWindowDiv").height(),t=$("#chartWindowDiv").width();$("#chartWindowContainer").highcharts().setSize(t-50,e-105,!0)}),"radio1"==$('.radio input[type="radio"]:checked')[0].id&&(m=phosColors),"radio2"==$('.radio input[type="radio"]:checked')[0].id&&(m=nitroColors),"radio3"==$('.radio input[type="radio"]:checked')[0].id&&(m=streamflowColors),"radio4"==$('.radio input[type="radio"]:checked')[0].id&&(m=sedimentColors);$("#chartWindowContainer").highcharts();$(function(){Highcharts.setOptions({lang:{thousandsSep:","},colors:m});Highcharts.getOptions().exporting.buttons.contextButton.menuItems;$("#chartWindowContainer").highcharts({chart:{type:"column",zoomType:"x",backgroundColor:"rgba(255, 255, 255, 0.45)",events:{load:function(){this.renderer.text('<div><i class="fa fa-mouse-pointer"></i> Click on legend elements to toggle on/off sources</div>',100,40,!0).css({fontSize:"13px"}).add()},selection:function(e){var t,i=[];if(e.xAxis){var a=e.xAxis[0];a&&($.each(this.series,function(e,t){$.each(t.points,function(e,t){var s;t.x>=a.min&&t.x<=a.max&&(s=0==$("#groupResultsSelect")[0].selectedIndex?t.id:t.category,-1==i.indexOf(s)&&i.push(s))})}),J(i)),console.log(i)}app.map.graphics.clear();var n=app.map.getLayer("SparrowRanking").visibleLayers[0],r=app.map.getLayer("SparrowRanking").url,o=Q($("#groupResultsSelect")[0].selectedIndex);t=new esri.tasks.QueryTask(r+n.toString());var c=new esri.tasks.Query;if(c.returnGeometry=!0,c.outSpatialReference=app.map.spatialReference,c.outFields=[o],c.maxAllowableOffset=1e3,1!=e.resetSelection){var l="";$.each(i,function(e,t){l+='"'+t+'", '});var p=l.slice(0,l.length-2);function d(e){$.each(app.map.graphics.graphics,function(e,t){"zoomhighlight"==t.symbol.id&&app.map.graphics.remove(t)}),$.each(e.features,function(e,t){t=t;var i=new O(O.STYLE_SOLID,new s([255,255,0]),1);i.id="zoomHighlight",t.setSymbol(i),app.map.graphics.add(t)})}c.where=o+" IN ("+p+")",t.execute(c,d)}else{if(app.formattedHighlightString){function d(e){$.each(app.map.graphics.graphics,function(e,t){"zoomhighlight"==t.symbol.id&&app.map.graphics.remove(t)}),$.each(e.features,function(e,t){t=t;var i=new O(O.STYLE_SOLID,new s([255,255,0]),1);i.id="zoomHighlight",t.setSymbol(i),app.map.graphics.add(t)})}c.where=app.formattedHighlightString,t.execute(c,d)}J()}}}},title:{text:null},subtitle:{text:null},exporting:{enabled:!0,chartOptions:{chart:{events:{load:function(){this.chartBackground.attr({fill:"rgba(255, 255, 255, 1.0)"}),this.renderer.image("https://wim.usgs.gov/visuals/usgs/usgslogo1.jpg",2,2,50,30).add()}}}},buttons:{contextButton:{text:"Chart Download / Chart Options",theme:{fill:"#0F8AFF"},symbol:null,symbolFill:"#0F8AFF",height:80,align:"right",menuItems:[{text:"Download chart (PNG)",onclick:function(){this.exportChart({type:"PNG"})}},{text:"Download table (CSV)",onclick:function(){this.downloadCSV()}},{text:"Download table (Excel)",onclick:function(){this.downloadXLS()}},{text:"Change Chart Transparency",onclick:function(){"rgba"!=this.chartBackground.element.attributes.fill.value.substring(0,4)?this.chartBackground.attr({fill:"rgba(255, 255, 255, .45)"}):this.chartBackground.attr({fill:"rgb(255, 255, 255)"})}}]}}},xAxis:{categories:t,title:{text:"Ranked by "+d()}},yAxis:{min:0,title:{text:u()},stackLabels:{enabled:!1,style:{fontWeight:"bold",color:Highcharts.theme&&Highcharts.theme.textColor||"gray"}}},legend:{align:"left",x:10,verticalAlign:"top",y:40,floating:!1,padding:5,backgroundColor:Highcharts.theme&&Highcharts.theme.background2||"white",borderColor:"#CCC",borderWidth:1,shadow:!1,itemWidth:350,labelFormatter:function(){var e=this.name.indexOf(")");return e>-1?this.name.substring(e+1):this.name}},tooltip:{formatter:function(){var e=this.point.index+1,t=this.point.y/this.point.stackTotal*100;return"<b>"+d()+": <b>"+this.point.category+"</b></b><br/>"+this.series.name+": <b>"+this.point.y.toFixed(2)+" ("+t.toFixed(2)+"%)</b></b><br/>"+u()+" Total: <b>"+this.point.stackTotal.toFixed(2)+"</b></b><br/>Rank: <b>"+e+"</b>"}},plotOptions:{column:{stacking:"normal",dataLabels:{enabled:!1,color:Highcharts.theme&&Highcharts.theme.dataLabelsColor||"white"}},series:{point:{events:{mouseOver:function(){var e,t=0==$("#groupResultsSelect")[0].selectedIndex?this.id:this.category,i=app.map.getLayer("SparrowRanking").visibleLayers[0],a=app.map.getLayer("SparrowRanking").url,n=Q($("#groupResultsSelect")[0].selectedIndex);e=new esri.tasks.QueryTask(a+i.toString());var r=new esri.tasks.Query;r.returnGeometry=!0,r.outSpatialReference=app.map.spatialReference,r.outFields=[n],r.maxAllowableOffset=1e3,r.where=n+"= '"+t+"'",e.execute(r,function(e){$.each(app.map.graphics.graphics,function(e,t){void 0==t.symbol.id&&app.map.graphics.remove(t)});var t=e.features[0],i=new I(I.STYLE_SOLID,new O(O.STYLE_SOLID,new s([150,49,37]),2),new s([150,49,37,.33]));t.setSymbol(i),app.map.graphics.add(t)})},click:function(t){if(e.features.length>1){var i=Q($("#groupResultsSelect")[0].selectedIndex)+" = '"+(0==$("#groupResultsSelect")[0].selectedIndex?this.id:this.category)+"'";app.map.graphics.clear(),app.createChartQuery(i)}}}}}},credits:{enabled:!1},series:n}),$(".highcharts-button-box").click(function(){$.each(app.map.graphics.graphics,function(e,t){"zoomhighlight"==t.symbol.id&&app.map.graphics.remove(t)})}),app.chosenSource&&$.each($("#chartWindowContainer").highcharts().series,function(e,t){t.name.split(") ")[1]!==app.chosenSource.label?t.hide():t.show()})});var h=$("#chartWindowDiv").height()-65,y=$("#chartWindowDiv").width();$("#chartWindowContainer").highcharts().setSize(y-50,h-105,!0),$("#chartTabContent").removeClass("content-loading")}function J(e){if(void 0!==e){var t=Q($("#groupResultsSelect")[0].selectedIndex),i=[];$.each(e,function(e,a){i.push(W.filter(function(e){return e[t]==a})[0])}),ee(i,Y)}else ee(W,Y)}function ee(e,t){$("#resultsTable").empty();var i=[];$("#resultsTable").addClass("hover-highlight"),$("#resultsTable").append("<thead></thead>"),$.each(t,function(e,t){var a=t.indexOf(")"),s="";s=a>-1?t.substring(a+1):t,i.push(s)});var a=$("#groupResultsSelect")[0].selectedIndex;0==a?(i.push("Total"),i.push("Catchment Area"),i.push("Upstream Area")):(i.push("Total"),i.push("Area"));var s=[];s.push("<tr>"),$.each(i,function(e,t){s.push("<th>"+t+"</th>")}),s.push("</tr>"),$("#resultsTable").find("thead").html(s.join(""));var n=[];$("#resultsTable").append('<tbody id="tableBody"></tbody>'),$.each(e,function(e,t){var i=0==a?t.COMID||t.ST_COMID:e;n.push("<tr id='row"+i+"'>"),$.each(t,function(e,t){"total"==e?0==$("#groupResultsSelect")[0].selectedIndex?n.splice(-2,0,"<td>"+t+"</td>"):n.splice(-1,0,"<td>"+t+"</td>"):n.push("<td>"+t+"</td>")}),n.push("</tr>")}),$("#tableBody").html(n.join("")),$(".tablesorter").trigger("updateAll"),$(".tablesorter").tablesorter({widthFixed:!0,onRenderHeader:function(){var e;if("radio1"==$('.radio input[type="radio"]:checked')[0].id&&(e=phosColors),"radio2"==$('.radio input[type="radio"]:checked')[0].id&&(e=nitroColors),"radio3"==$('.radio input[type="radio"]:checked')[0].id&&(e=streamflowColors),"radio4"==$('.radio input[type="radio"]:checked')[0].id&&(e=sedimentColors),this.context.cellIndex>0){var t=this.context.cellIndex-1;this.append('<div style="background:'+e[t]+';height: 3px;margin-bottom:2px;"></div>')}}})}$(document).on("mouseenter","#tableBody tr",function(e){var t,i=0==$("#groupResultsSelect")[0].selectedIndex?e.currentTarget.id.substring(3):e.currentTarget.cells[0].innerHTML,a=app.map.getLayer("SparrowRanking").visibleLayers[0],n=app.map.getLayer("SparrowRanking").url,r=Q($("#groupResultsSelect")[0].selectedIndex);t=new esri.tasks.QueryTask(n+a.toString());var o=new esri.tasks.Query;o.returnGeometry=!0,o.outSpatialReference=app.map.spatialReference,o.outFields=[r],o.maxAllowableOffset=1e3,o.where=r+"= '"+i+"'",t.execute(o,function(e){$.each(app.map.graphics.graphics,function(e,t){void 0==t.symbol.id&&app.map.graphics.remove(t)});var t=e.features[0],i=new I(I.STYLE_SOLID,new O(O.STYLE_SOLID,new s([150,49,37]),2),new s([150,49,37,.33]));t.setSymbol(i),app.map.graphics.add(t)})}),$("#geosearchNav").click(function(){$("#geosearchModal").modal("show")}),$("#dataDownloadNav").click(function(){$("#downloadDatamodal").modal("show")}),$("#aboutNav").click(function(){$("#aboutModalHeader").html("About "+appTitle+" "),$("#aboutModal").modal("show")}),$("#userGuideNav").click(function(){$("#userGuideModal").modal("show")}),$(".showAboutDefinitions").click(function(){$("#userGuideModal").modal("hide"),$("#downloadDatamodal").modal("hide"),$("#geosearchModal").modal("hide"),$("#aboutModal").modal("show"),$("#definitionsTab").trigger("click")}),$("#html").niceScroll(),$("#sidebar").niceScroll(),$("#sidebar").scroll(function(){$("#sidebar").getNiceScroll().resize()}),$("#legendDiv").niceScroll(),app.maxLegendHeight=.95*$("#mapDiv").height(),$("#legendElement").css("max-height",app.maxLegendHeight),$("#legendCollapse").on("shown.bs.collapse",function(){app.maxLegendHeight=.95*$("#mapDiv").height(),$("#legendElement").css("max-height",app.maxLegendHeight)}),$("#legendCollapse").on("hide.bs.collapse",function(){$("#legendElement").css("height","initial")}),require(["dijit/form/CheckBox"],function(e){function t(e,t,i,a,s,n){if(app.map.addLayer(i),i.visible&&void 0!==n.hasOpacitySlider&&1==n.hasOpacitySlider&&void 0!==n.hasZoomto&&1==n.hasZoomto)var r=$('<div class="btn-group-vertical lyrTogDiv" style="cursor: pointer;" > <button id="'+i.id+'"type="button" class="btn btn-default active" aria-pressed="true" style="font-weight: bold;text-align: left"><i class="glyphspan fa fa-check-square-o"></i>&nbsp;&nbsp;'+a+'<span id="opacity'+camelize(a)+'" class="glyphspan glyphicon glyphicon-adjust pull-right opacity"></span><span class="glyphicon glyphicon-search pull-right zoomto"></span></button></div>');else if(i.visible||void 0===n.hasOpacitySlider||1!=n.hasOpacitySlider||void 0===n.hasZoomto||1!=n.hasZoomto){if(i.visible&&void 0!==n.hasOpacitySlider&&1==n.hasOpacitySlider&&void 0!==n.hasZoomto&&0==n.hasZoomto)r=$('<div class="btn-group-vertical lyrTogDiv" style="cursor: pointer;" > <button id="'+i.id+'"type="button" class="btn btn-default active" aria-pressed="true" style="font-weight: bold;text-align: left"><i class="glyphspan fa fa-check-square-o"></i>&nbsp;&nbsp;'+a+'<span id="opacity'+camelize(a)+'" class="glyphspan glyphicon glyphicon-adjust pull-right opacity"></span></button></div>');else if(!i.visible&&void 0!==n.hasOpacitySlider&&1==n.hasOpacitySlider&&void 0!==n.hasZoomto&&0==n.hasZoomto)r=$('<div class="btn-group-vertical lyrTogDiv" style="cursor: pointer;" > <button id="'+i.id+'"type="button" class="btn btn-default active" aria-pressed="true" style="font-weight: bold;text-align: left"><i class="glyphspan fa fa-square-o"></i>&nbsp;&nbsp;'+a+'<span id="opacity'+camelize(a)+'" class="glyphspan glyphicon glyphicon-adjust pull-right opacity"></span></button></div>')}else var r=$('<div class="btn-group-vertical lyrTogDiv" style="cursor: pointer;" > <button id="'+i.id+'"type="button" class="btn btn-default" aria-pressed="true" style="font-weight: bold;text-align: left"><i class="glyphspan fa fa-square-o"></i>&nbsp;&nbsp;'+a+'<span id="opacity'+camelize(a)+'" class="glyphspan glyphicon glyphicon-adjust pull-right opacity"></span><span class="glyphicon glyphicon-search pull-right zoomto"></span></button></div>');if(r.click(function(e){if("SparrowRanking"!=e.currentTarget.firstElementChild.id)if($(this).find("i.glyphspan").toggleClass("fa-check-square-o fa-square-o"),$(this).find("button").button("toggle"),e.preventDefault(),e.stopPropagation(),$("#"+camelize(a)).toggle(),i.visible){i.setVisibility(!1);var t=[];$.each(app.legend.layerInfos,function(e,i){t.push(i.layer.id)});var s=t.indexOf(i.id);s>-1&&app.legend.layerInfos.splice(s,1),app.legend.refresh()}else i.setVisibility(!0),app.legend.layerInfos.push({layer:i,title:e.currentTarget.innerText}),app.legend.refresh()}),t){var o=camelize(e);if(!$("#"+o).length){var c=$('<div id="'+o+'"><div class="alert alert-info" role="alert"><strong>'+e+"</strong></div></div>");$("#toggle").append(c)}$("#"+o).append(r),$("#opacity"+camelize(a)).length>0&&$("#opacity"+camelize(a)).hover(function(){$(".opacitySlider").remove();var e=app.map.getLayer(s.id).opacity,t=$('<div class="opacitySlider"><label id="opacityValue">Opacity: '+e+'</label><label class="opacityClose pull-right">X</label><input id="slider" type="range"></div>');$("body").append(t),$("#slider")[0].value=100*e,$(".opacitySlider").css("left",event.clientX-180),$(".opacitySlider").css("top",event.clientY-50),$(".opacitySlider").mouseleave(function(){$(".opacitySlider").remove()}),$(".opacityClose").click(function(){$(".opacitySlider").remove()}),$("#slider").change(function(e){var t=$("#slider")[0].value/100;$("#opacityValue").html("Opacity: "+t),app.map.getLayer(s.id).setOpacity(t)})}),$(".zoomto").hover(function(e){$(".zoomDialog").remove();var t=$('<div class="zoomDialog"><label class="zoomClose pull-right">X</label><br><div class="list-group"><a href="#" id="zoomscale" class="list-group-item lgi-zoom zoomscale">Zoom to scale</a> <a id="zoomcenter" href="#" class="list-group-item lgi-zoom zoomcenter">Zoom to center</a><a id="zoomextent" href="#" class="list-group-item lgi-zoom zoomextent">Zoom to extent</a></div></div>');$("body").append(t),$(".zoomDialog").css("left",e.clientX-80),$(".zoomDialog").css("top",e.clientY-5),$(".zoomDialog").mouseleave(function(){$(".zoomDialog").remove()}),$(".zoomClose").click(function(){$(".zoomDialog").remove()}),$("#zoomscale").click(function(e,t){var i=app.map.getLayer("streams").minScale;i>0?app.map.setScale(i):console.log("No minimum scale for layer.")}),$("#zoomcenter").click(function(e,t){var i=app.map.getLayer("SparrowRanking").fullExtent.getCenter(),a=new D(i.x,i.y,new T({wkid:4326}));app.map.centerAt(a)}),$("#zoomextent")&&$("#zoomextent").click(function(e,t){var i=app.map.getLayer("SparrowRanking").fullExtent,a=new G;a.outSR=new T(102100),a.geometries=[i],geomService.project(a,function(e){var t=e[0];map.setExtent(t,new T({wkid:102100}))})})})}}$.each(allLayers,function(e,i){$.each(i.layers,function(e,a){if("agisImage"===a.wimOptions.layerType){var s=new d(a.url,a.options);a.wimOptions&&1==a.wimOptions.includeLegend&&legendLayers.push({layer:s,title:legendLayerName}),a.visibleLayers&&s.setVisibleLayers(a.visibleLayers),t(i.groupHeading,i.showGroupHeading,s,e,a.options,a.wimOptions)}else{s=new l(a.url,a.options);a.visibleLayers&&s.setVisibleLayers(a.visibleLayers),t(i.groupHeading,i.showGroupHeading,s,e,a.options,a.wimOptions)}})})})}),$(".selectpicker").selectpicker();