function createEventListeners(){document.addEventListener("mapZoomEnd",handleMapMoveZoom,!1);document.addEventListener("mapDragEnd",handleMapMoveZoom,!1);document.addEventListener("markerClicked",markerClicked,!1)}function handleMapMoveZoom(){log(arguments.callee.toString().match(/function ([^\(]+)/)[1]);updateListResultsOnMapMove=$("#chkUpdateResults").is(":checked");listenForMapMove&&updateListResultsOnMapMove?getLocationsByMapBounds():listenForMapMove=!0}function locateAddress(){log(arguments.callee.toString().match(/function ([^\(]+)/)[1]);var n=$("#address1").val(),t=$("#address2").val(),i=$("#city").val(),r=$("#state").val(),u=$("#zip").val();gmap.locateAddress(n,t,i,r,u)}function getCurrentLocation(){if(log(arguments.callee.toString().match(/function ([^\(]+)/)[1]),$("#CurrentIp").val()){var n=$("#CurrentIp").val();$.getJSON("http://freegeoip.net/json/"+n,function(n){n.zip_code?(getLocationsByRadius(n.zip_code),createEventListeners(),listenForMapMove=!0):getLocations()}).fail(function(){getLocations()})}else getLocations()}function locationsByZip(n){log(arguments.callee.toString().match(/function ([^\(]+)/)[1]);n||(n={lng:0,lat:0});var t="POINT("+n.lng+" "+n.lat+")",i=$("#SelectedRadius").val(),r={point:t,radius:i},u="/"+region+"/StoreLocations/GetLocationsByZip";$.ajax({url:u,type:"GET",data:r,dataType:"json",success:function(n){loadLocationList(n);gmap.deleteMarkers();n.length===0?$("#divNoLoc").show():($("#divNoLoc").hide(),$.each(n,function(n,t){if(t.PointWkt){var i=(n+1).toString(),r=gmap.createMarkerFromWkt(t.PointWkt,!1,t.StoreId,i);gmap.plotPoint(r,!1)}}),listenForMapMove=!1,gmap.centerMapOnMarkers())},error:function(n,t,i){alert(n.status);alert(i)}})}function getLocations(){log(arguments.callee.toString().match(/function ([^\(]+)/)[1]);listenForMapMove=!1;var n="/"+region+"/StoreLocations/GetLocations";$.ajax({url:n,type:"GET",dataType:"json",success:function(n){loadLocationList(n);gmap.deleteMarkers();n.length===0?$("#divNoLoc").show():($("#divNoLoc").hide(),$("#ViewMap").is(":visible")?$("#map_canvas").hide():($.each(n,function(n,t){if(t.PointWkt){var i=(n+1).toString(),r=gmap.createMarkerFromWkt(t.PointWkt,!1,t.StoreId,i);gmap.plotPoint(r,!1)}}),listenForMapMove=!1,gmap.centerMapOnMarkers(),createEventListeners(),listenForMapMove=!0))},error:function(n,t,i){alert(n.status);alert(i)}})}function getLocationsByMapBounds(){if(listenForMapMove){log(arguments.callee.toString().match(/function ([^\(]+)/)[1]);var n="/"+region+"/StoreLocations/GetByRegionContainer";$.ajax({url:n,method:"GET",data:{bounds:gmap.getMapBounds()},dataType:"json",success:function(n){loadLocationList(n);gmap.deleteMarkers();$.each(n,function(n,t){if(t.PointWkt){var i=(n+1).toString(),r=gmap.createMarkerFromWkt(t.PointWkt,!1,t.StoreId,i);gmap.plotPoint(r,!1)}})},error:function(n,t,i){alert(n.status);alert(i)}})}}function getLocationsByRadius(n){log(arguments.callee.toString().match(/function ([^\(]+)/)[1]);var t=$("#PostalCode").val();!n&&t?(n=t,$.cookie("zipCode",n),$("#noZip").hide(),gmap.locateZipCode(n,locationsByZip)):$("#noZip").show()}function loadLocationList(n){log(arguments.callee.toString().match(/function ([^\(]+)/)[1]);n=encodeHtmlAttributes(n);var t={locations:JSON.stringify(n)},i="/"+region+"/StoreLocations/GetLocationList";$.ajax({url:i,type:"POST",data:t,dataType:"html",success:function(t){$("#divNoLoc").hide();$("#locationList").html(t);n.length===1&&toggleListItem(n[0].StoreId)},error:function(n,t,i){log(i)}})}function markerClicked(n){toggleListItem(n.markerId)}function markerHover(n){var r=n.markerId,i=$("#rowLocations").find("[data-id='"+r+"']"),u=i.children("div.itemDataContainer"),t=$("#locationList");t.scrollTop(i.offset().top-t.offset().top+t.scrollTop());$.doTimeout("scroll",250,function(){$(u).stop().slideDown()})}function markerHoverOut(n){var i=n.markerId,r=$("#rowLocations").find("[data-id='"+i+"']"),t=r.children("div.itemDataContainer");$(t).data("open")||$(t).stop().slideUp()}function toggleListItem(n){var r=$("#rowLocations").find("[data-id='"+n+"']"),t=r.children("div.itemDataContainer"),i=$("#locationList");i.scrollTop(r.offset().top-i.offset().top+i.scrollTop());$.doTimeout("scroll",250,function(){var i=$(t).data("open");i?($(t).stop().slideUp().data("open",!1),t.children(".fa-unlock").show(),t.children(".fa-lock").hide(),$("#selectedLocationId").val("")):($(t).stop().slideDown().data("open",!0),t.children(".fa-unlock").hide(),t.children(".fa-lock").show(),$("#selectedLocationId").val(n))})}function getDirections(){try{listenForMapMove=!1;var n=$("#txtDirectionsFrom").val().split(" ").join("+"),t=$("#selectedLocationId").val();gmap.getDirections(n,gmap.getMarkerById(parseInt(t)))}catch(i){listenForMapMove=!0}}function openDirections(n,t){n.preventDefault();var i=$(t).data("address"),r;r=mobileOS==="iOS"?"http://maps.apple.com/maps?q="+i:"http://maps.google.com/maps?q="+i;window.open(r)}function getMobileOperatingSystem(){var n=navigator.userAgent||navigator.vendor||window.opera;return/windows phone/i.test(n)?"WindowsPhone":/android/i.test(n)?"Android":/iPad|iPhone|iPod/.test(n)&&!window.MSStream?"iOS":"unknown"}function encodeHtmlAttributes(n){for(var i={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"},t=0;t<n.length;t++)n[t].Phone=n[t].Phone.replace(/[&<>"']/g,function(n){return i[n]}),n[t].Hours=n[t].Hours.replace(/[&<>"']/g,function(n){return i[n]}),n[t].Notes=n[t].Notes.replace(/[&<>"']/g,function(n){return i[n]});return n}function showMap(){log(arguments.callee.toString().match(/function ([^\(]+)/)[1]);listenForMapMove=!1;var n="/"+region+"/StoreLocations/GetLocations";$.ajax({url:n,type:"GET",dataType:"json",success:function(n){gmap.deleteMarkers();n.length===0?$("#divNoLoc").show():($("#divNoLoc").hide(),$("#ViewMap").hide(),$("#map_canvas").show(),$.each(n,function(n,t){if(t.PointWkt){var i=(n+1).toString(),r=gmap.createMarkerFromWkt(t.PointWkt,!1,t.StoreId,i);gmap.plotPoint(r,!1)}}),listenForMapMove=!1,gmap.centerMapOnMarkers(),createEventListeners())},error:function(n,t,i){alert(n.status);alert(i)}})}var listenForMapMove=!0,updateListResultsOnMapMove,currentLocation,region="",mobileOS;$(document).ready(function(){mobileOS=getMobileOperatingSystem();$("#map_canvas").hide();gmap.init(getCurrentLocation);$("#geoLocate").click(function(){LocateAddress()});$(document).on("mouseenter",".locationListContainer",null,function(){var n=$(this).data("id"),t;gmap.bounceMarker(n,!0);t=$(this).children("div.itemDataContainer").stop()});$(document).on("mouseleave",".locationListContainer",null,function(){var t=$(this).data("id"),n;gmap.bounceMarker(t,!1);n=$(this).children("div.itemDataContainer");$(n).data("open")||$(n).stop()});$(document).on("click",".locateOnMap",null,function(){var n=$(this).data("id");gmap.zoomToMarkerById(n);$("#selectedLocationId").val(n)});$(document).on("click",".locationTitleContainer",null,function(){var t=$(this),n=t.siblings(".itemDataContainer"),i=$(n).data("open"),r=$(n).data("id");i?($(n).stop().slideUp().data("open",!1),n.children(".fa-unlock").show(),n.children(".fa-lock").hide(),$("#selectedLocationId").val("")):($(n).stop().slideDown(400,"swing",function(){$(n).position().top+$(n).height()>0&&$(n).position().top+30<$("#locationList").height()||$("#locationList").animate({scrollTop:$("#locationList").scrollTop()+250},1e3)}).data("open",!0),n.children(".fa-unlock").hide(),n.children(".fa-lock").show(),$("#selectedLocationId").val(r))});$("#SelectedCity").change(function(){var n=$(this).val(),t={city:n},i="/"+region+"/StoreLocations/GetLocationsByCity";n?$.getJSON(i,t).done(function(n){loadLocationList(n);gmap.deleteMarkers();n.length===0?$("#divNoLoc").show():($("#divNoLoc").hide(),$("#ViewMap").hide(),$("#map_canvas").show(),$.each(n,function(n,t){if(t.PointWkt){var i=(n+1).toString(),r=gmap.createMarkerFromWkt(t.PointWkt,!1,t.StoreId,i);gmap.plotPoint(r,!1)}}),listenForMapMove=!1,gmap.centerMapOnMarkers())}):getCurrentLocation()});region=$("#RegionCode").val();region==undefined&&log("**** NO REGION DEFINED ****");var n=$.cookie("zipCode");n&&$("#PostalCode").val(n);updateListResultsOnMapMove=$("#chkUpdateResults").is(":checked")}),function(n){typeof define=="function"&&define.amd?define(["jquery"],n):typeof exports=="object"?n(require("jquery")):n(jQuery)}(function(n){function i(n){return t.raw?n:encodeURIComponent(n)}function f(n){return t.raw?n:decodeURIComponent(n)}function e(n){return i(t.json?JSON.stringify(n):String(n))}function o(n){n.indexOf('"')===0&&(n=n.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return n=decodeURIComponent(n.replace(u," ")),t.json?JSON.parse(n):n}catch(i){}}function r(i,r){var u=t.raw?i:o(i);return n.isFunction(r)?r(u):u}var u=/\+/g,t=n.cookie=function(u,o,s){var y,a,h,v,c,p;if(o!==undefined&&!n.isFunction(o))return s=n.extend({},t.defaults,s),typeof s.expires=="number"&&(y=s.expires,a=s.expires=new Date,a.setTime(+a+y*864e5)),document.cookie=[i(u),"=",e(o),s.expires?"; expires="+s.expires.toUTCString():"",s.path?"; path="+s.path:"",s.domain?"; domain="+s.domain:"",s.secure?"; secure":""].join("");for(h=u?undefined:{},v=document.cookie?document.cookie.split("; "):[],c=0,p=v.length;c<p;c++){var w=v[c].split("="),b=f(w.shift()),l=w.join("=");if(u&&u===b){h=r(l,o);break}u||(l=r(l))===undefined||(h[b]=l)}return h};t.defaults={};n.removeCookie=function(t,i){return n.cookie(t)===undefined?!1:(n.cookie(t,"",n.extend({},i,{expires:-1})),!n.cookie(t))}})