function initMap(){var n,t,i;console.log("Initiating map.");map=new google.maps.Map(document.getElementById("map"),{center:defaultMapPosition,minZoom:2,maxZoom:16,zoom:defaultMapZoom,gestureHandling:"greedy",zoomControl:!0,mapTypeControl:!1,scaleControl:!0,streetViewControl:!1,rotateControl:!1,fullscreenControl:!1});console.log("initMap minZoom: "+map.minZoom);visibleRounds={};personalTotal=0;businessTotal=0;personalBusinessTotal=0;existingState="";map.addListener("idle",function(){console.log("Standard idle function");updateMapBounds(map)});map.data.setStyle(function(n){var t="#808080",i=1,r=.1;return n.getProperty("isSelected")&&(t="#d91f39",i=2,r=.9),n.getProperty("isHover")&&(t="#000000",i=2,r=.4),n.getProperty("isHover")&&n.getProperty("isSelected")&&(t="#d91f39",i=3,r=1),{fillColor:t,strokeWeight:i,fillOpacity:r,"background-blend-mode":"multiply"}});map.data.addListener("click",function(n){longPress?dropPin(n.latLng):toggleSelected(n.feature.getId())});map.addListener("click",function(n){longPress&&dropPin(n.latLng)});map.addListener("mousedown",function(){startPress=(new Date).getTime()});map.addListener("mouseup",function(){endPress=(new Date).getTime();var n=endPress-startPress;console.log("Map. Press length: "+n);longPress=n<500?!1:!0});map.data.addListener("mousedown",function(){startPress=(new Date).getTime()});map.data.addListener("mouseup",function(){endPress=(new Date).getTime();var n=endPress-startPress;console.log("Map.Data Press length: "+n);longPress=n<500?!1:!0});map.addListener("rightclick",function(n){console.log("map.addListener");dropPin(n.latLng)});map.data.addListener("rightclick",function(n){console.log("map.data.addListener");dropPin(n.latLng)});map.data.addListener("mouseover",function(n){n.feature.setProperty("isHover",!0);displayRoundStats(n.feature.getId())});map.data.addListener("mouseout",function(n){n.feature.setProperty("isHover",!1);displayRoundStats(-1)});infoWindowContent=generateInfoWindowContent();infoWindow=new google.maps.InfoWindow({content:infoWindowContent});$("#UmsSearchBox").autocomplete({source:function(n,t){$.ajax({url:"/UMS/SearchBoxAutoComplete",dataType:"json",data:{Location:n.term,State:$("#State").val()},success:function(n){t(n)}})},select:function(n,t){clickLocationName(t.item.value)}});$("#LocationSearchNav").click(function(){var n=$("#UmsSearchBox").val();clickLocationName(n)});n=document.createElement("h1");n.style.color="white";n.style.backgroundColor="#000000";n.innerHTML="Please select a state first.";t=document.createElement("div");t.id="selectStateOverlayDiv";t.appendChild(n);loadingOverlay=document.createElement("img");loadingOverlay.src="/Content/Images/ums-reloading-indicator.gif";map.controls[google.maps.ControlPosition.TOP_RIGHT].push(loadingOverlay);i=$("#State").val();i==""?map.controls[google.maps.ControlPosition.TOP_CENTER].push(t):(ChangeState(!1),ChangeDistributionDate(),mapIdToLoad&&LoadMap(mapIdToLoad));SetLoadSaveButtonEnabled();setLoading(!1)}function setLoading(n){n?$(loadingOverlay).show():$(loadingOverlay).hide()}function forceRoundSelected(n,t){var i=roundState[n];i?i.Selected=t:roundState[n]={Selected:t,Markers:[]}}function toggleSelected(n){var t=roundState[n];t?(t.Markers&&t.Markers.length>0?t.Selected==RoundStateEnum.On?t.Selected=RoundStateEnum.Off:t.Selected==RoundStateEnum.Off?t.Selected=RoundStateEnum.Neutral:t.Selected==RoundStateEnum.Neutral&&(t.Selected=RoundStateEnum.Off):t.Selected==RoundStateEnum.On?t.Selected=RoundStateEnum.Neutral:t.Selected==RoundStateEnum.Off?t.Selected=RoundStateEnum.On:t.Selected==RoundStateEnum.Neutral&&(t.Selected=RoundStateEnum.On),selected=!t.selected):roundState[n]={Selected:RoundStateEnum.On,Markers:[]};displaySelectedRounds()}function roundIsSelected(n){var t=roundState[n];return t&&(t.Selected==RoundStateEnum.On||t.Markers&&t.Markers.length>0&&t.Selected!=RoundStateEnum.Off)}function displayRoundStats(n){var i="",r="",t;n>0&&(t=roundCache[n],t&&(i=t.AdvertisablePrivateCount+t.AdvertisablePrivateBusinessCount,r=t.AdvertisableBusinessCount+t.AdvertisablePrivateBusinessCount));$("#PrivateCountDiv").html("Priv: "+i);$("#BusinessCountDiv").html("Bus: "+r)}function updateFeatureSelected(n){map.data.forEach(function(t){var i=t.getId();t.getProperty("isSelected")&&n.indexOf(i)==-1&&t.setProperty("isSelected",!1);!t.getProperty("isSelected")&&n.indexOf(i)>-1&&t.setProperty("isSelected",!0)})}function getAllKnownRounds(){var n=Object.keys(roundState);return markers&&markers.forEach(function(t){Object.keys(t.Distances).forEach(function(t){n.indexOf(t)==-1&&(n=n.push(t))})}),n}function getSelectedAndMarkerRounds(){var r=roundState?"rs: "+Object.keys(roundState).length:"rs is null",u=markers?"m: "+markers.length:"m is null",n,t,i;return onRounds=Object.keys(roundState).filter(function(n){return roundState[n].Selected==RoundStateEnum.On}),offRounds=Object.keys(roundState).filter(function(n){return roundState[n].Selected==RoundStateEnum.Off}),n=onRounds.slice(),t=onRounds.slice(),Object.keys(roundState).forEach(function(n){roundState[n].Markers=[]}),markers.forEach(function(i){var u=i.Distances,f=i.Radius*100,r;for(r in u)roundState.hasOwnProperty(r)||(roundState[r]={Selected:RoundStateEnum.Neutral,Markers:[]}),u[r]<f&&roundState[r].Markers.indexOf(i.Index)==-1&&roundState[r].Markers.push(i.Index),t.indexOf(r)==-1&&t.push(r),u[r]<f&&n.indexOf(r)==-1&&offRounds.indexOf(r)==-1&&n.push(r)}),i=t.diff(n),n}function displaySelectedRounds(){var h,u,t,n,i;console.log("displaySelectedRounds");var f=0,e=0,o=0,s=0,r=getSelectedAndMarkerRounds();if(updateFeatureSelected(r),r.length==0)$("#flex-right-column").html("");else{for(h=$("#RoundType").val(),divHtml="",u=0;u<r.length;u++)if(t=r[u],n=roundCache[t],n){var c=n.AdvertisablePrivateCount+n.AdvertisablePrivateBusinessCount,l=n.AdvertisableBusinessCount+n.AdvertisablePrivateBusinessCount,a=n.AdvertisablePrivateCount+n.AdvertisableBusinessCount+n.AdvertisablePrivateBusinessCount;f+=c;e+=l;o+=a;switch(h){case"0":i=c;break;case"1":i=l;break;case"2":i=a}s+=i;divHtml+='<div class="table-round-row" onmouseover="hoverRound('+t+', true)" onmouseout="hoverRound('+t+', false)"> <div class="table-round-suburb"><a onclick="gotoRound('+t+');">'+n.Suburb+'<\/a><\/div> <div class="table-round-count">'+i+'<\/div>  <div class="table-round-delete"><a href="javascript:hoverRound('+t+", false);toggleSelected("+t+')">X<\/a><\/div> <\/div>'}$("#flex-right-column").html(divHtml)}personalTotal=f;businessTotal=e;personalBusinessTotal=o;$("#RoundTotalDiv").html(s);CalculateTotals()}function hoverRound(n,t){var i=map.data.getFeatureById(n);i&&i.setProperty("isHover",t)}function gotoRound(n){var t=roundCache[n],i;t&&(console.log(t.CenterLongitude+" "+t.CenterLatitude),i=new google.maps.LatLng(t.CenterLatitude,t.CenterLongitude),map.panTo(i))}function updateMapBounds(n){var e=n.getZoom(),t,f;if(!(e<minZoomAfterLoad)&&(t=n.getBounds(),t)){var i=t.getNorthEast(),r=t.getSouthWest(),u=[];for(id in visibleRounds)u.push(id);f=$("#State").val();setLoading(!0);doAjaxRequest("/UMS/GetRoundsWithinBounds","PostroundUpdateCallback",{State:f,LongitudeFrom:i.lng(),LongitudeTo:r.lng(),LatitudeFrom:i.lat(),LatitudeTo:r.lat(),DisplayedPostrounds:u},"json",null)}}function PostroundUpdateCallback(n){var r,t,i;console.log("PostroundUpdateCallback started");r=new Date;t=(new Date).getMilliseconds();jQuery.each(n.AddingPostround,function(){showRound(this);cacheRoundData(this)});jQuery.each(n.RemovingPostround,function(){hideRound(this)});i=(new Date).getMilliseconds();setLoading(!1);console.log("PostroundUpdateCallback finished");console.log(i-t)}function LoadRoundData(){console.log("LoadRoundData");var n=getAllKnownRounds();setLoading(!0);doAjaxRequest("/UMS/GetRoundDataInList","LoadRoundDataCallback",{RequestedPostrounds:n},"json",null)}function LoadRoundDataCallback(n){console.log("LoadRoundDataCallback");jQuery.each(n.AddingPostround,function(){cacheRoundData(this)});displaySelectedRounds();setLoading(!1)}function clickLocationName(n){var t=$("#State").val();setLoading(!0);doAjaxRequest("/UMS/GetRoundsInLocation","GetRoundsInLocationCallback",{DeliveryAreaName:n,State:t,IncludeGeo:!1},"json",null)}function GetRoundsInLocationCallback(n){if(jQuery.each(n.MatchingPostrounds,function(){cacheRoundData(this);forceRoundSelected(this.RoundID,RoundStateEnum.On)}),displaySelectedRounds(),setLoading(!1),n.LatitudeCenter!=null&&n.LongitudeCenter!=null){var t={lat:parseFloat(n.LatitudeCenter),lng:parseFloat(n.LongitudeCenter)};map.panTo(t)}}function makePin(n){return new google.maps.Marker({position:n,map:map,icon:{url:markerIconUrl,scaledSize:new google.maps.Size(32,56)}})}function dropPin(n){var t=makePin(n),r=markerIndex++,f=parseInt($("#RadiusSelector").val()*10,10),e={lat:n.lat(),lng:n.lng()},i={Marker:t,Radius:f,Index:r,Position:e,Deleted:!1},u;t.addListener("rightclick",function(){deleteMarker(i)});t.addListener("click",function(){longPress?deleteMarker(i):showMarkerRadiusSlider(i)});t.addListener("mousedown",function(){startPress=(new Date).getTime()});t.addListener("mouseup",function(){endPress=(new Date).getTime();var n=endPress-startPress;console.log("Map.Data Press length: "+n);longPress=n<500?!1:!0});markers[r]=i;u=$("#State").val();setLoading(!0);doAjaxRequest("/UMS/GetRoundsInRadius","GetRoundsInRadiusCallback",{Latitude:n.lat(),Longitude:n.lng(),DistanceKm:maxRadius,State:u,IncludeGeo:!1,MarkerIndex:i.Index},"json",null)}function showMarkerRadiusSlider(n){selectedMarker=n.Index;infoWindow.open(map,n.Marker);$("#RadiusInfoWindowSlider").val(n.Radius)}function GetRoundsInRadiusCallback(n){jQuery.each(n.MatchingPostrounds,function(){cacheRoundData(this)});var t=markers[n.MarkerIndex];t.Distances=n.Distances;displaySelectedRounds();setLoading(!1);showMarkerRadiusSlider(t)}function generateInfoWindowContent(){var n;console.log("generateInfoWindowContent");var i=document.createElement("div"),r=document.createElement("span"),u=document.createElement("span"),f=document.createElement("table"),t=document.createElement("tr"),e=document.createElement("td"),o=document.createElement("td"),s=document.createElement("td");return r.innerHTML="0km",u.innerHTML="5km",n=document.createElement("input"),n.id="RadiusInfoWindowSlider",n.type="range",n.min=0,n.max=maxRadius*10,n.value=$("#RadiusSelector").val()*10,n.style="display:inline;",n.addEventListener("input",updateSlider),e.append(r),o.append(n),s.append(u),t.append(e),t.append(o),t.append(s),f.append(t),i.append(f),i}function updateSlider(){var t=$("#RadiusInfoWindowSlider").val(),n=markers[selectedMarker];n?(n.Radius=t,displaySelectedRounds()):console.log("UpdateSlider: Marker not found")}function deleteMarker(n){var t=markers.indexOf(n);n.Marker.setMap(null);n.Radius=0;n.Deleted=!0;Object.keys(roundState).forEach(function(n){var i=roundState[n],r=i.Markers.indexOf(t);r>-1&&(i.Markers=i.Markers.slice(r,1))});displaySelectedRounds()}function getMarkerDataForSave(){}function radiusSearch(n){var t=$("#State").val(),i=$("#RadiusSelector").val();setLoading(!0);doAjaxRequest("/UMS/GetRoundsInRadius","GetRoundsInLocationCallback",{Latitude:n.lat(),Longitude:n.lng(),DistanceKm:i,State:t,IncludeGeo:!1},"json",null)}function cacheRoundData(n){roundCache[n.RoundID]={AdvertisablePrivateCount:n.AdvertisablePrivateCount,AdvertisableBusinessCount:n.AdvertisableBusinessCount,AdvertisablePrivateBusinessCount:n.AdvertisablePrivateBusinessCount,DeliveryAreaName:n.DeliveryAreaName,Postcode:n.Postcode,Suburb:n.Suburb,CenterLongitude:n.CenterLongitude,CenterLatitude:n.CenterLatitude}}function showRound(n){if(!map.data.getFeatureById(n.RoundID)){var t=map.data.loadGeoJson("/Ums/Round/"+GetUmsMapVersionID()+"/"+n.RoundID,{idPropertyName:"RoundID"},loadGeoJsonCallback);visibleRounds[n.RoundID]=t}}function loadGeoJsonCallback(n){console.log(n[0]);n[0].setProperty("isSelected",roundIsSelected(n[0].getProperty("RoundID")))}function hideRound(n){var t=map.data.getFeatureById(n);t?(delete visibleRounds[n],map.data.remove(t)):console.log("Not Removed "+n)}function ClearMap(){map.data.forEach(function(n){n.getProperty("isSelected")&&n.setProperty("isSelected",!1)});selectedRounds=[];roundState={};markers.forEach(function(n){n.Marker.setMap(null)});markers=[];markerIndex=0;displaySelectedRounds()}function GetStateLatLng(n){switch(n){case"QLD":return{lat:-27.470125,lng:153.021072};case"NSW":return{lat:-33.865143,lng:151.2099};case"VIC":return{lat:-37.8148343342439,lng:144.96576890490724};case"SA":return{lat:-34.92123,lng:138.599503};case"WA":return{lat:-31.953512,lng:115.857048};case"ACT":return{lat:-35.2809,lng:149.13};case"NT":return{lat:-12.462827,lng:130.841782};case"TAS":return{lat:-42.8821,lng:147.3272}}}function ShowAustralia(){bounds=new google.maps.LatLngBounds;loc=new google.maps.LatLng(-10.461958149426509,161.31090892690054);bounds.extend(loc);loc2=new google.maps.LatLng(-43.002994881257528,109.11074413197866);bounds.extend(loc2);map.fitBounds(bounds);map.panToBounds(bounds)}function ChangeState(n){var t=$("#State").val(),i,u,r;console.log("ChangeState: "+map);map&&(map.minZoom<minZoomAfterLoad&&(map.setOptions({minZoom:minZoomAfterLoad}),map.setZoom(minZoomAfterLoad+1),console.log("ChangeState minZoom: "+map.minZoom)),i=!0,u=$("#selectStateOverlayDiv"),u.is(":visible")&&($("#selectStateOverlayDiv").hide(),i=!1),n&&(!i||selectedRounds.length==0||confirm("Changing state will clear your selected rounds")?(ClearMap(),r=GetStateLatLng(t),r!=null&&map.panTo(r),existingState=t):$("#State").val(existingState)),SetLoadSaveButtonEnabled());doAjaxRequest("/GetDistributionDates","SetDistributionDates",{State:t},"json","#loader-layout")}function SetDistributionDates(n){var r=!1,u=distributionDateDelayedLoad==""?$("#DistributionDate").val():distributionDateDelayedLoad,t,i;for(distributionDateDelayedLoad="",$("#DistributionDate").prop("disabled",!1),$("#ums-round-fields").removeClass("disabled-content"),t='<option value="">-- select --<\/option>',i=0;i<n.length;i++)d=n[i],t+='<option values="'+d+'"',d===u&&(t+=' selected="selected"',r=!0),t+=">"+d+"<\/option>";$("#DistributionDate").html(t);r?ChangeDistributionDate():$("#LodgementDate").val("")}function ChangeDistributionDate(){var t=$("#State").val(),n=$("#DistributionDate").val();n===""?$("#LodgementDate").val(""):doAjaxRequest("/SetLodgementDate","SetLodgementDate",{state:t,date:n},"json","#loader-layout")}function SetLodgementDate(n){$("#LodgementDate").val(n)}function GetRounds(){return getSelectedAndMarkerRounds()}function ChangeRoundType(){rounds=GetRounds();currectrounds=rounds;roundType=$("#RoundType").val();var n=$("#State").val();CalculateTotals();displaySelectedRounds()}function CalculateTotal(){CalculateTotals()}function CalculateTotals(){var i=$("#RoundType").val(),n=0,t;switch(i){case"0":n=personalTotal;break;case"1":n=businessTotal;break;case"2":n=personalBusinessTotal}$("#UMSQuantity").val(n);t=+$("#DeliveryOffice").val();$("#TotalQuantity").val(t+n)}function AddTocartUMS(){var t=$("#State").val(),i=$("#DistributionDate").val(),r=GetRounds(),e=$("#RoundType").val(),o=$("#DeliveryOffice").val(),s=$("#TotalQuantity").val(),h=$("#UMSQuantity").val(),u,f,n=map.getCenter();n&&(u=n.lat(),f=n.lng());var c=map.getZoom(),l=JSON.stringify(roundState),a=JSON.stringify(serializeMarkers()),v=validateUMSForm(t,i,r);v||($("#label-ums-disclaimer").hide(),$("#UMSSelected").val(!0),$("#UMSState").val(t),$("#UMSDistributionDate").val(i),$("#UMSRounds").val(r),$("#UMSRoundType").val(e),$("#UMSQty").val(h),$("#UMSOfficeQty").val(o),$("#UMSTotalQty").val(s),$("#UMSMapLatitude").val(u),$("#UMSMapLongitude").val(f),$("#UMSMapZoom").val(c),$("#UMSMapVersionID").val(GetUmsMapVersionID()),$("#UMSMarkers").val(a),$("#UMSRoundState").val(l),history.replaceState({page:"umsadded"},null,"#umsadded"),AddItemsTocart())}function UpdateUMS(n,t){var r=$("#State").val(),u=$("#DistributionDate").val(),f=GetRounds(),s=$("#RoundType").val(),h=$("#DeliveryOffice").val(),y=$("#TotalQuantity").val(),p=$("#UMSQuantity").val(),e,o,i=map.getCenter();i&&(e=i.lat(),o=i.lng());var c=map.getZoom(),l=JSON.stringify(roundState),a=JSON.stringify(serializeMarkers()),v=validateUMSForm(r,u,f);v||(history.pushState(null,null,"/Cart"),doAjaxRequest("/UpdateUMS","UpdateUMSCallback",{OrdersDetailsID:n,StockCode:t,State:r,DistributionDate:u,Rounds:f,RoundType:s,OfficeQty:h,MapZoom:c,MapLatitude:e,MapLongitude:o,UMSMapVersionID:GetUmsMapVersionID(),RoundState:l,Markers:a},"json","#loader-layout"))}function validateUMSForm(n,t,i){var r=!1;return n==""?($("#State").addClass("ums-error"),$("#label-ums-missing-fields").show(),r=!0):$("#State").removeClass("ums-error"),t==""?($("#DistributionDate").addClass("ums-error"),$("#label-ums-missing-fields").show(),r=!0):$("#DistributionDate").removeClass("ums-error"),i==""?($("[data-for-round='roundid']").addClass("ums-error"),$("#label-ums-missing-fields").show(),r=!0):$("[data-for-round='roundid']").removeClass("ums-error"),r||$("#label-ums-missing-fields").hide(),r}function UpdateUMSCallback(n){validateLogin(n);try{if(n[0]=="true"){closeModal();var t=n[1],r=n[2],u=n[3],f=n[4],e=n[5],o=n[6],s=n[7],h=n[8],c=n[9],l=n[10],a=n[11],i=$("#row-"+t).parent().parent();i.find("#totalPrice").html(r);i.find("#totalFreight").html(h);i.find("#totalPriceExGst").html(c);i.find("#totalGst").html(l);i.find("#totalPriceIncGst").html(a);$("#price-per-item-"+t).html(u);$("#ums-price-"+t).html(f);$("#ums-booking-price-"+t).html(e);$("#ums-total-quantity-"+t).html(s);$("#ums-rounds-"+t).html(o);$("#ums-expired-error").length&&location.reload()}else location.reload()}catch(v){location.reload()}}function loadUMSEditor(n){doAjaxRequest("/UMSEditData","UMSEditDataCallback",{ordersDetailsId:n},"HTML","#loader-layout")}function editUMS(n){console.log("Edit UMS called.");history.pushState({page:"umsedit",ordersDetailsId:n},null,"#umsedit");loadUMSEditor(n)}function UMSEditDataCallback(n){validateLogin(n);n.indexOf("password")>0?location.reload(!0):(console.log("Edit UMS callback."),$("body,html").animate({scrollTop:0},500),$("#modal-connect-body").html(n),$(modal).show())}function ShowUmsWithoutProduct(){doAjaxRequest("/UMSData","SetUMSDataNoProduct",{stockCode:""},"HTML","#loader-layout")}function SetUMSDataNoProduct(n){$("#modal-connect-body").html(n);$(modal).show()}function LoadSavedMap(){var n=$("#SavedMaps").val();n.length&&LoadMap(n)}function LoadMap(n){console.log("LoadMap");setLoading(!0);doAjaxRequest("/UMS/LoadSavedMap","LoadSavedMapCallback",{mapId:n},null,"#loader-layout")}function LoadSavedMapCallback(n){var t,i;console.log("LoadSavedMapCallback: success: "+n.Success);setLoading(!1);n.Success=="true"&&(ClearMap(),$("#State").val()!==n.State&&n.State!==""&&($("#State").val(n.State),ChangeState(!1)),distributionDateDelayedLoad=n.DistributionDate?n.DistributionDate:"",$("#RoundType").val(n.RoundType),$("#OfficeQuantity").val(n.OfficeQuantity),n.RoundState.length&&(roundState=JSON.parse(n.RoundState)),markersLoad=JSON.parse(n.Markers),markersLoad.forEach(function(n){n.Index>=markerIndex&&(markerIndex=n.Index+1);recreateMarker(n)}),console.log("LoadSavedMapCallback rs: "+roundState),console.log("LoadSavedMapCallback markers: "+markers),LoadRoundData(),t={lat:parseFloat(n.MapLatitude),lng:parseFloat(n.MapLongitude)},map.panTo(t),i=parseInt(n.MapZoom,10),map.setZoom(Math.max(i,minZoomAfterLoad)))}function recreateMarker(n){var r={lat:n.Lat,lng:n.Lng},t=makePin(r),u=n.Index,i={Marker:t,Radius:n.Radius,Index:n.Index,Distances:n.Distances,Position:r,Deleted:!1};t.addListener("rightclick",function(){deleteMarker(i)});t.addListener("click",function(){showMarkerRadiusSlider(i)});markers[u]=i}function serializeMarkers(){var n=[];return Object.keys(markers).forEach(function(t){var i=markers[t];i.Deleted||n.push({Lat:i.Position.lat,Lng:i.Position.lng,Radius:i.Radius,Distances:i.Distances,Index:i.Index})}),n}function SaveUMSMap(n){var r=getSelectedAndMarkerRounds(),t,i;if(r.length==0){alert("No rounds have been selected. ");return}if(t=$("#SavedMaps").val(),i="",(!t.length||n)&&(i=prompt("Please enter map name",""),t=null),i!=""&&i!=null||t!=null){var o=$("#State").val(),s=$("#DistributionDate").val(),h=$("#LodgementDate").val(),r=getSelectedAndMarkerRounds(),c=$("#RoundType").val(),l=$("#DeliveryOffice").val(),a=$("#TotalQuantity").val(),v=$("#UMSQuantity").val(),f,e,u=map.getCenter();u&&(f=u.lat(),e=u.lng());var y=map.getZoom(),p=JSON.stringify(roundState),w=JSON.stringify(serializeMarkers()),b={MapId:t,MapName:i,State:o,DistributionDate:s,LodggementDate:h,Rounds:r,RoundType:c,OfficeQty:l,Qty:v,TotalQty:a,MapZoom:y,MapLatitude:f,MapLongitude:e,UMSMapVersionID:GetUmsMapVersionID(),RoundState:p,Markers:w};doAjaxRequest("/UMS/SaveUMSMap","SaveUMSMapCallback",b,"json","#loader-layout")}}function SaveUMSMapCallback(n){if(n.success=="true"){if(n.MapID){var t=n.MapName+" "+n.MapSavedAt;$("#SavedMaps").append($("<option/>",{value:n.MapID,text:t}));$("#SavedMaps").val(n.MapID)}alert("Map Saved")}else alert("Error saving map");SetLoadSaveButtonEnabled()}function SetLoadSaveButtonEnabled(){var n,t;console.log("SetLoadSaveButtonEnabled");n=$("#SavedMaps").val()!="";$("#load-ums-map-button").prop("disabled",!n);$("#save-ums-map-button").prop("disabled",!n);t=$("#State").val()!="";$("#save-as-ums-map-button").prop("disabled",!t)}function SavedMapsChanged(){SetLoadSaveButtonEnabled()}function GetUmsMapVersionID(){return $("#MapVersionID").val()}var currectrounds,umsQty;Array.prototype.diff=function(n){return this.filter(function(t){return n.indexOf(t)<0})};var RoundStateEnum=Object.freeze({On:1,Off:-1,Neutral:0}),markerIconUrl="/Content/images/MapPin.png",mapIdToLoad,roundCache={},selectedRounds=[],visibleRounds={},roundState={},markers=[],markerIndex=0,selectedMarker=0,styleNormal={fillColor:"#808080",strokeWeight:1},styleSelected={fillColor:"#00000FF",strokeWeight:2},styleHover={fillColor:"#FFFF00",strokeWeight:1},personalTotal=0,businessTotal=0,personalBusinessTotal=0,maxRounds=10,existingState="",maxRadius=5,defaultMapPosition,defaultMapZoom,minZoomAfterLoad=13,infoWindow,infoWindowContent,longPress=!1,startPress,endPress,loadingIndicator,map,distributionDateDelayedLoad="";currectrounds=[];umsQty=0