function CreateMap(){initialViewZoomLevel=15;minimumViewZoomLevel=6;maximumViewZoomLevel=23;directionOptions={credentials:"AkGcMAL0Mi6vh0-DpI500TDfbII91OR1klN59xr58ckkY_qxXegOkHcIN9AEZ1Fo",showLocateMeButton:!1,showScalebar:!1,showTermsLink:!1,showCopyright:!1,showLogo:!1,liteMode:!0};mapOptions={credentials:"AkGcMAL0Mi6vh0-DpI500TDfbII91OR1klN59xr58ckkY_qxXegOkHcIN9AEZ1Fo",showLocateMeButton:!1,showScalebar:!1,showTermsLink:!1,showCopyright:!1,showLogo:!1,liteMode:!0};pinOptions={draggable:!1,text:"",textOffset:0,visible:!0,icon:"/Content/Images/pushPin.png"};($("#hfPageName").val()==="registeredvoter"||$("#hfPageName").val()==="early-voting-search-results")&&(LoadPollMapValues(),BuildPollMap());LoadClerkMapValues();BuildClerkMap();CloseRouteRequestBox()}function BuildPollMap(){pollMap!==null&&(pollMap.dispose(),pollMap=null);pollMap=new Microsoft.Maps.Map(pollMapDiv,mapOptions);pollLat!="0"&&pollLat!=""&&pollLong!="0"&&pollLong!=""&&(document.getElementById("hfPollingMapPinType")&&$("#hfPollingMapPinType").val()=="early-voting"&&(pinOptions.icon="/Content/Images/pushPinLightGreen.png",$("#hfPollingMapPinType").val("election-day")),AddPinAndInfoBox(pollLat,pollLong,pollMap,"poll",pollRouteRequestTitle,`${pollingAddress}<br>${pollingCityStateZip}`),pinOptions.icon="/Content/Images/pushPin.png")}function BuildClerkMap(){clerkMap!==null&&(clerkMap.dispose(),clerkMap=null);clerkLat!="0"&&clerkLat!=""&&clerkLong!="0"&&clerkLong!=""&&(clerkMap=new Microsoft.Maps.Map(clerkMapDiv,mapOptions),AddPinAndInfoBox(clerkLat,clerkLong,clerkMap,"clerk",clerkRouteRequestTitle,clerkAddress))}function LoadClerkMapValues(){clerkRouteRequestTitle=$("#hfClerkRouteRequestTitle").val();clerkAddress=$("#hfClerkAddress").val();clerkCityStateZip=$("#hfClerkCityStateZip").val();clerkLat=$("#hfClerkLatitude").val();clerkLong=$("#hfClerkLongitude").val()}function LoadPollMapValues(){pollRouteRequestTitle=$("#hfPollRouteRequestTitle").val();pollingAddress=$("#hfPollingAddress").val();pollingCityStateZip=$("#hfPollingCityStateZip").val();pollLat=$("#hfPollLatitude").val();pollLong=$("#hfPollLongitude").val()}function AddPinAndInfoBox(n,t,i,r,u,f){var o=new Microsoft.Maps.Location(n,t),s=new Microsoft.Maps.Pushpin(o,pinOptions),e,h;Microsoft.Maps.Events.addHandler(s,"click",function(){PinClick(r)});e=new Microsoft.Maps.Location(n,t);e.latitude=e.latitude-.0035;e.longitude=e.longitude-.00375;h=new Microsoft.Maps.Infobox(e,{title:u,description:f,showPointer:!1});h.setMap(i);i.entities.push(s);i.setOptions({minZoom:minimumViewZoomLevel,maxZoom:maximumViewZoomLevel});i.setView({center:o,zoom:initialViewZoomLevel})}function PinClick(n){DisplayRouteRequestDialog(n)}function DisplayRouteRequestDialog(n){$("#hfMapType").val(n);n==="poll"?($("#RouteRequestTitle").html(pollRouteRequestTitle),$("#RouteRequestDetail1").html(`${pollingAddress}<br>${pollingCityStateZip}`)):($("#RouteRequestTitle").html(clerkRouteRequestTitle),$("#RouteRequestDetail1").html(clerkAddress),$("#RouteRequestDetail2").html(clerkCityStateZip));$("#RouteRequest").modal("show");$("#StartingPoint").html("")}function CloseRouteRequestBox(){$("#RouteRequestTitle").html("");$("#RouteRequestDetail1").html("");$("#RouteRequestDetail2").html("");$("#StartingPoint").html("");$("#RouteRequest").modal("hide")}function GetDirections(){(searchText=$("#StartingPoint").val(),searchText)&&($("#StartingPoint").val(""),$("#RouteRequestTitle").val(""),$("#routeDirectionsItinerary").html(""),$("#hfMapType").val()==="poll"?(routeLat=pollLat,routeLong=pollLong,routeAddress=pollRouteRequestTitle,$("#DirectionsTitle").text(pollingAddress+", "+pollingCityStateZip),RouteDirections()):(routeLat=clerkLat,routeLong=clerkLong,routeAddress=clerkRouteRequestTitle,$("#DirectionsTitle").text(clerkAddress+", "+clerkCityStateZip),RouteDirections()))}function RouteDirections(){var n;routeMap?(routeMap.layers.clear(),n=new Microsoft.Maps.Layer,routeMap.layers.insert(n),routeMap.setView({zoom:minimumViewZoomLevel})):(routeMap=new Microsoft.Maps.Map(routeMapDiv,directionOptions),n=new Microsoft.Maps.Layer,routeMap.layers.insert(n),routeMap.setView({zoom:minimumViewZoomLevel}));Microsoft.Maps.loadModule("Microsoft.Maps.Directions",function(){var n=new Microsoft.Maps.Directions.Waypoint({address:searchText}),t=new Microsoft.Maps.Directions.Waypoint({address:routeAddress,location:new Microsoft.Maps.Location(routeLat,routeLong)});routeDirectionsManager=new Microsoft.Maps.Directions.DirectionsManager(routeMap);routeDirectionsManager.clearAll();routeDirectionsManager.addWaypoint(n);routeDirectionsManager.addWaypoint(t);routeDirectionsManager.setRenderOptions({itineraryContainer:routeDirectionsItinerary});routeDirectionsManager.calculateDirections();routeDirectionsManager.setRequestOptions({routeMode:Microsoft.Maps.Directions.RouteMode.driving})});routeMap.setView({zoom:minimumViewZoomLevel});$("#RouteRequest").modal("hide");$("#RouteContainer").modal("show")}function PrintRoute(n,t){var u=window.screen.width,f=window.screen.height,i=u/2-512,r=f/2-480,e="printMap.aspx?lat="+n+"&long="+t+"&searchText="+searchText,o=window.open(e,"","width=1024,height=768,toolbar=0,location=0,directories=0,status=0,scrollbars=1,menubar=0,resizable=1,left="+i+",top="+r+",screenX="+i+",screenY="+r+",")}function DisplaySinglePollingLocationPoint(n){let t=$(`#${n}`).data("pin-type")=="early-voting";$("#hfPollRouteRequestTitle").val(`${t?"Early voting":"Election day"}: ${$(`#${n}`).data("name")}`);$("#hfPollingAddress").val($(`#${n}`).data("address"));$("#hfPollingCityStateZip").val($(`#${n}`).data("cityStateZip"));$("#hfPollLatitude").val($(`#${n}`).data("latitude"));$("#hfPollLongitude").val($(`#${n}`).data("longitude"));LoadPollMapValues();ShowSinglePinMessage();t&&(pinOptions.icon="/Content/Images/pushPinLightGreen.png");BuildPollMap();pinOptions.icon="/Content/Images/pushPin.png";ScrollAndUpdatePollingLocationMapName(n,`${t?"Early voting":"Election day"}: ${$(`#${n}`).data("name")}`)}function AddAllEVPointsToPollingLocationMap(){let n=[];CreateMultiPollMap();AddEVPinsToPollMap(n);pollMap.setView({bounds:Microsoft.Maps.LocationRect.fromLocations(n),padding:65});ShowMultiPinMessage();ScrollAndUpdatePollingLocationMapName("display-all-ev-on-map-btn","All early voting locations")}function AddAllVotingLocationsToMap(){let n=[];CreateMultiPollMap();AddEVPinsToPollMap(n);AddElectionDayPinToMultiPinPollMap(n);pollMap.setView({bounds:Microsoft.Maps.LocationRect.fromLocations(n),padding:65});ShowMultiPinMessage();ScrollAndUpdatePollingLocationMapName("display-all-voting-locations-on-map","All early voting and election day voting locations")}function CreateMultiPollMap(){CreateMap();pollMap=new Microsoft.Maps.Map(pollMapDiv,mapOptions);infobox=new Microsoft.Maps.Infobox(pollMap.getCenter(),{visible:!1});infobox.setMap(pollMap)}function ShowMultiPinMessage(){document.getElementById("single-pin-msg").hidden=!0;document.getElementById("multiple-pin-msg").hidden=!1}function ShowSinglePinMessage(){document.getElementById("single-pin-msg").hidden=!1;document.getElementById("multiple-pin-msg").hidden=!0}function AddElectionDayPinToMultiPinPollMap(n){document.getElementById("election-day-on-map-btn")&&AddMultiPinToPollMap("election-day-on-map-btn",n)}function AddEVPinsToPollMap(n){let t=0;for(pinOptions.icon="/Content/Images/pushPinLightGreen.png";t<$("#total-ev-map-points").val();)AddMultiPinToPollMap(`${t}-ev-map-btn`,n),t++;pinOptions.icon="/Content/Images/pushPin.png"}function AddMultiPinToPollMap(n,t){let i=$(`#${n}`),e=parseFloat(i.data("latitude")),u=parseFloat(i.data("longitude")),r=new Microsoft.Maps.Location(e,u);while(LocationInArray(t,r))u-=5e-5,r=new Microsoft.Maps.Location(e,u);t.push(r);var f=new Microsoft.Maps.Pushpin(r,pinOptions);f.metadata={title:`${i.data("pin-type")=="early-voting"?"Early voting":"Election day"}: ${i.data("name")}`,description:`${i.data("address")}<br>${i.data("cityStateZip")}`};Microsoft.Maps.Events.addHandler(f,"click",MultipleLocationsPushpinClicked);pollMap.entities.push(f)}function LocationInArray(n,t){for(let i=0,r=n.length;i<r;i++)if(n[i].latitude==t.latitude&&n[i].longitude==t.longitude)return!0;return!1}function MultipleLocationsPushpinClicked(n){n.target.metadata&&infobox.setOptions({location:n.target.getLocation(),title:n.target.metadata.title,description:n.target.metadata.description,visible:!0})}function ScrollAndUpdatePollingLocationMapName(n,t){EnableAllPollingLocationButtons();document.getElementById(n).disabled=!0;document.getElementById("mapTitle").textContent=t;document.getElementById("mapTitle").scrollIntoView({behavior:"smooth"})}function EnableAllPollingLocationButtons(){if(document.getElementById("election-day-on-map-btn")&&(document.getElementById("election-day-on-map-btn").disabled=!1),document.getElementById("display-all-ev-on-map-btn")&&(document.getElementById("display-all-ev-on-map-btn").disabled=!1),document.getElementById("display-all-voting-locations-on-map")&&(document.getElementById("display-all-voting-locations-on-map").disabled=!1),document.getElementById("total-ev-map-points")){let n=0;while(n<$("#total-ev-map-points").val())document.getElementById(`${n}-ev-map-btn`).disabled=!1,n++}}var clerkMap=null,clerkLat=null,clerkLong=null,clerkDirectionsManager=null,clerkRouteRequestTitle=null,clerkAddress=null,clerkCityStateZip=null,clerkMapDiv="#clerkMap",pollMap=null,pollLat=null,pollLong=null,pollRouteRequestTitle=null,pollingAddress=null,pollingCityStateZip=null,pollMapDiv="#pollMap",routeMap=null,routeLat=null,routeLong=null,routeAddress=null,routeDirectionsManager=null,routeMapDiv="#routeMap",routeDirectionsContainer="#routeDirectionsContainer",routeDirectionsItinerary="#routeDirectionsItinerary",infoboxTemplate='<div class="customInfobox"><div class="title">{title}<\/div>{description}<\/div>',initialViewZoomLevel=null,minimumViewZoomLevel=null,maximumViewZoomLevel=null,pinOptions=null,mapOptions=null,directionOptions=null,directionsManager=null,searchText=null;bing8_on_ready=jQuery.Deferred();GetMap=function(){bing8_on_ready.resolve()};jQuery.when(bing8_on_ready).then(function(){CreateMap()});$(document).ready(function(){$("#StartingPoint").keypress(function(n){n.which===13&&(n.preventDefault(),$("#btnRouteRequest").click())});$("#btnRouteRequest").on("click",function(){GetDirections()})})