function MarkerClusterer(n,t,i){var r,u;this.extend(MarkerClusterer,google.maps.OverlayView);this.map_=n;this.markers_=[];this.clusters_=[];this.sizes=[53,56,66,78,90];this.styles_=[];this.ready_=!1;r=i||{};this.gridSize_=r.gridSize||60;this.minClusterSize_=r.minimumClusterSize||2;this.maxZoom_=r.maxZoom||null;this.styles_=r.styles||[];this.imagePath_=r.imagePath||this.MARKER_CLUSTER_IMAGE_PATH_;this.imageExtension_=r.imageExtension||this.MARKER_CLUSTER_IMAGE_EXTENSION_;this.zoomOnClick_=!0;r.zoomOnClick!=undefined&&(this.zoomOnClick_=r.zoomOnClick);this.averageCenter_=!1;r.averageCenter!=undefined&&(this.averageCenter_=r.averageCenter);this.setupStyles_();this.setMap(n);this.prevZoom_=this.map_.getZoom();u=this;google.maps.event.addListener(this.map_,"zoom_changed",function(){var n=u.map_.getZoom();u.prevZoom_!=n&&(u.prevZoom_=n,u.resetViewport())});google.maps.event.addListener(this.map_,"idle",function(){u.redraw()});t&&t.length&&this.addMarkers(t,!1)}function Cluster(n){this.markerClusterer_=n;this.map_=n.getMap();this.gridSize_=n.getGridSize();this.minClusterSize_=n.getMinClusterSize();this.averageCenter_=n.isAverageCenter();this.center_=null;this.markers_=[];this.bounds_=null;this.clusterIcon_=new ClusterIcon(this,n.getStyles(),n.getGridSize())}function ClusterIcon(n,t,i){n.getMarkerClusterer().extend(ClusterIcon,google.maps.OverlayView);this.styles_=t;this.padding_=i||0;this.cluster_=n;this.center_=null;this.map_=n.getMap();this.div_=null;this.sums_=null;this.visible_=!1;this.setMap(this.map_)}MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_="/Content/img/m";MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_EXTENSION_="png";MarkerClusterer.prototype.extend=function(n,t){return function(n){for(var t in n.prototype)this.prototype[t]=n.prototype[t];return this}.apply(n,[t])};MarkerClusterer.prototype.onAdd=function(){this.setReady_(!0)};MarkerClusterer.prototype.draw=function(){};MarkerClusterer.prototype.setupStyles_=function(){if(!this.styles_.length)for(var n=0,t;t=this.sizes[n];n++)this.styles_.push({url:this.imagePath_+(n+1)+"."+this.imageExtension_,height:t,width:t})};MarkerClusterer.prototype.fitMapToMarkers=function(){for(var r=this.getMarkers(),n=new google.maps.LatLngBounds,t=0,i;i=r[t];t++)n.extend(i.getPosition());this.map_.fitBounds(n)};MarkerClusterer.prototype.setStyles=function(n){this.styles_=n};MarkerClusterer.prototype.getStyles=function(){return this.styles_};MarkerClusterer.prototype.isZoomOnClick=function(){return this.zoomOnClick_};MarkerClusterer.prototype.isAverageCenter=function(){return this.averageCenter_};MarkerClusterer.prototype.getMarkers=function(){return this.markers_};MarkerClusterer.prototype.getTotalMarkers=function(){return this.markers_.length};MarkerClusterer.prototype.setMaxZoom=function(n){this.maxZoom_=n};MarkerClusterer.prototype.getMaxZoom=function(){return this.maxZoom_};MarkerClusterer.prototype.calculator_=function(n,t){for(var i=0,u=n.length,r=u;r!==0;)r=parseInt(r/10,10),i++;return i=Math.min(i,t),{text:u,index:i}};MarkerClusterer.prototype.setCalculator=function(n){this.calculator_=n};MarkerClusterer.prototype.getCalculator=function(){return this.calculator_};MarkerClusterer.prototype.addMarkers=function(n,t){for(var i=0,r;r=n[i];i++)this.pushMarkerTo_(r);t||this.redraw()};MarkerClusterer.prototype.pushMarkerTo_=function(n){if(n.isAdded=!1,n.draggable){var t=this;google.maps.event.addListener(n,"dragend",function(){n.isAdded=!1;t.repaint()})}this.markers_.push(n)};MarkerClusterer.prototype.addMarker=function(n,t){this.pushMarkerTo_(n);t||this.redraw()};MarkerClusterer.prototype.removeMarker_=function(n){var t=-1,i,r;if(this.markers_.indexOf)t=this.markers_.indexOf(n);else for(i=0;r=this.markers_[i];i++)if(r==n){t=i;break}return t==-1?!1:(n.setMap(null),this.markers_.splice(t,1),!0)};MarkerClusterer.prototype.removeMarker=function(n,t){var i=this.removeMarker_(n);return!t&&i?(this.resetViewport(),this.redraw(),!0):!1};MarkerClusterer.prototype.removeMarkers=function(n,t){for(var f,i=!1,r=0,u;u=n[r];r++)f=this.removeMarker_(u),i=i||f;if(!t&&i)return this.resetViewport(),this.redraw(),!0};MarkerClusterer.prototype.setReady_=function(n){this.ready_||(this.ready_=n,this.createClusters_())};MarkerClusterer.prototype.getTotalClusters=function(){return this.clusters_.length};MarkerClusterer.prototype.getMap=function(){return this.map_};MarkerClusterer.prototype.setMap=function(n){this.map_=n};MarkerClusterer.prototype.getGridSize=function(){return this.gridSize_};MarkerClusterer.prototype.setGridSize=function(n){this.gridSize_=n};MarkerClusterer.prototype.getMinClusterSize=function(){return this.minClusterSize_};MarkerClusterer.prototype.setMinClusterSize=function(n){this.minClusterSize_=n};MarkerClusterer.prototype.getExtendedBounds=function(n){var t=this.getProjection(),e=new google.maps.LatLng(n.getNorthEast().lat(),n.getNorthEast().lng()),o=new google.maps.LatLng(n.getSouthWest().lat(),n.getSouthWest().lng()),r=t.fromLatLngToDivPixel(e),i,u,f;return r.x+=this.gridSize_,r.y-=this.gridSize_,i=t.fromLatLngToDivPixel(o),i.x-=this.gridSize_,i.y+=this.gridSize_,u=t.fromDivPixelToLatLng(r),f=t.fromDivPixelToLatLng(i),n.extend(u),n.extend(f),n};MarkerClusterer.prototype.isMarkerInBounds_=function(n,t){return t.contains(n.getPosition())};MarkerClusterer.prototype.clearMarkers=function(){this.resetViewport(!0);this.markers_=[]};MarkerClusterer.prototype.resetViewport=function(n){for(var r,i,t=0;r=this.clusters_[t];t++)r.remove();for(t=0;i=this.markers_[t];t++)i.isAdded=!1,n&&i.setMap(null);this.clusters_=[]};MarkerClusterer.prototype.repaint=function(){var n=this.clusters_.slice();this.clusters_.length=0;this.resetViewport();this.redraw();window.setTimeout(function(){for(var t=0,i;i=n[t];t++)i.remove()},0)};MarkerClusterer.prototype.redraw=function(){this.createClusters_()};MarkerClusterer.prototype.distanceBetweenPoints_=function(n,t){if(!n||!t)return 0;var i=(t.lat()-n.lat())*Math.PI/180,r=(t.lng()-n.lng())*Math.PI/180,u=Math.sin(i/2)*Math.sin(i/2)+Math.cos(n.lat()*Math.PI/180)*Math.cos(t.lat()*Math.PI/180)*Math.sin(r/2)*Math.sin(r/2),f=2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u));return 6371*f};MarkerClusterer.prototype.addToClosestCluster_=function(n){for(var r,u,t,f=4e4,i=null,o=n.getPosition(),e=0;t=this.clusters_[e];e++)r=t.getCenter(),r&&(u=this.distanceBetweenPoints_(r,n.getPosition()),u=this.minClusterSize_&&n.setMap(null),this.updateIcon(),!0};Cluster.prototype.getMarkerClusterer=function(){return this.markerClusterer_};Cluster.prototype.getBounds=function(){for(var n=new google.maps.LatLngBounds(this.center_,this.center_),r=this.getMarkers(),t=0,i;i=r[t];t++)n.extend(i.getPosition());return n};Cluster.prototype.remove=function(){this.clusterIcon_.remove();this.markers_.length=0;delete this.markers_};Cluster.prototype.getSize=function(){return this.markers_.length};Cluster.prototype.getMarkers=function(){return this.markers_};Cluster.prototype.getCenter=function(){return this.center_};Cluster.prototype.calculateBounds_=function(){var n=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(n)};Cluster.prototype.isMarkerInClusterBounds=function(n){return this.bounds_.contains(n.getPosition())};Cluster.prototype.getMap=function(){return this.map_};Cluster.prototype.updateIcon=function(){var f=this.map_.getZoom(),t=this.markerClusterer_.getMaxZoom(),n,i,r,u;if(t&&f>t){for(n=0;i=this.markers_[n];n++)i.setMap(this.map_);return}if(this.markers_.length0&&this.anchor_[0]0&&this.anchor_[1]0?setTimeout(function(){t(i,r,u)},1):(n.update(),r(u))};return t}},function(n){n.exports=function(n){return n.handlers.filterStart=n.handlers.filterStart||[],n.handlers.filterComplete=n.handlers.filterComplete||[],function(t){var r;if(n.trigger("filterStart"),n.i=1,n.reset.filter(),void 0===t)n.filtered=!1;else{n.filtered=!0;for(var u=n.items,i=0,f=u.length;iv.page,r=new p(n[i],void 0,f),v.items.push(r),u.push(r);return v.update(),u}};this.show=function(n,t){return this.i=n,this.page=t,v.update(),v};this.remove=function(n,t,i){for(var u=0,r=0,f=v.items.length;r-1&&i.splice(r,1),v};this.trigger=function(n){for(var t=v.handlers[n].length;t--;)v.handlers[n][t](v);return v};this.reset={filter:function(){for(var n=v.items,t=n.length;t--;)n[t].filtered=!1;return v},search:function(){for(var n=v.items,t=n.length;t--;)n[t].found=!1;return v}};this.update=function(){var t=v.items,i=t.length,n;for(v.visibleItems=[],v.matchingItems=[],v.templater.clear(),n=0;n=v.i&&v.visibleItems.lengtht},innerWindow:function(n,t,i){return n>=t-i&&n<=t+i},dotted:function(n,t,i,r,u,f,e){return this.dottedLeft(n,t,i,r,u,f)||this.dottedRight(n,t,i,r,u,f,e)},dottedLeft:function(n,t,i,r,u,f){return t==i+1&&!this.innerWindow(t,u,f)&&!this.right(t,r)},dottedRight:function(n,t,i,r,u,f,e){return!n.items[e-1].values().dotted&&t==r&&!this.innerWindow(t,u,f)&&!this.right(t,r)}},e=function(t,i,r){u.bind(t,"click",function(){n.show((i-1)*r+1,r)})};return function(i){var r=new f(n.listContainer.id,{listClass:i.paginationClass||"pagination",item:"

  • ",valueNames:["page","dotted"],searchClass:"pagination-search-that-is-not-supposed-to-exist",sortClass:"pagination-sort-that-is-not-supposed-to-exist"});n.on("updated",function(){t(r,i)});t(r,i)}}},function(n,t,i){n.exports=function(n){var u=i(2)(n),f=function(n){for(var i=n.childNodes,r=[],t=0,u=i.length;t0?setTimeout(function(){r(i,u)},1):(n.update(),n.trigger("parseComplete"))};return n.handlers.parseComplete=n.handlers.parseComplete||[],function(){var i=f(n.list),u=n.valueNames;n.indexAsync?r(i,u):t(i,u)}}},function(n){n.exports=function(n){var o,t,i,r,u={resetList:function(){n.i=1;n.templater.clear();r=void 0},setOptions:function(n){2==n.length&&n[1]instanceof Array?t=n[1]:2==n.length&&"function"==typeof n[1]?(t=void 0,r=n[1]):3==n.length?(t=n[1],r=n[2]):t=void 0},setColumns:function(){0!==n.items.length&&void 0===t&&(t=void 0===n.searchColumns?u.toArray(n.items[0].values()):n.searchColumns)},setSearchString:function(t){t=n.utils.toString(t).toLowerCase();t=t.replace(/[-[\]{}()*+?.,\\^$|#]/g,"\\$&");i=t},toArray:function(n){var t=[];for(var i in n)t.push(i);return t}},f={list:function(){for(var t=0,i=n.items.length;t-1))},reset:function(){n.reset.search();n.searched=!1}},e=function(e){return n.trigger("searchStart"),u.resetList(),u.setSearchString(e),u.setOptions(arguments),u.setColumns(),""===i?f.reset():(n.searched=!0,r?r(i,t):f.list()),n.update(),n.trigger("searchComplete"),n.visibleItems};return n.handlers.searchStart=n.handlers.searchStart||[],n.handlers.searchComplete=n.handlers.searchComplete||[],n.utils.events.bind(n.utils.getByClass(n.listContainer,n.searchClass),"keyup",function(t){var i=t.target||t.srcElement,r=""===i.value&&!n.searched;r||e(i.value)}),n.utils.events.bind(n.utils.getByClass(n.listContainer,n.searchClass),"input",function(n){var t=n.target||n.srcElement;""===t.value&&e("")}),e}},function(n){n.exports=function(n){var t={els:void 0,clear:function(){for(var i=0,r=t.els.length;i]/g.exec(t))return u=document.createElement("tbody"),u.innerHTML=t,u.firstChild;if(t.indexOf("=1;)n.list.removeChild(n.list.firstChild)};r()};n.exports=function(n){return new t(n)}},function(n){n.exports=function(n,t){var r=n.getAttribute&&n.getAttribute(t)||null;if(!r)for(var u=n.attributes,f=u.length,i=0;i=48&&n<=57}function i(n,i){for(var r,e,o,h,s,c,v,y=(n+="").length,p=(i+="").length,l=0,a=0;l32)return!1;var f=g,tt=function(){for(var i={},n=0;n=d;r--)if(p=tt[n.charAt(r-1)],(h[r]=0===s?(h[r+1]<<1|1)&p:(h[r+1]<<1|1)&p|(v[r+1]|v[r])<<1|1|v[r+1],h[r]&k)&&(w=c(s,r-1),w<=o)){if(o=w,u=r-1,!(u>f))break;d=Math.max(1,2*f-u)}if(c(s+1,f)>o)break;v=h}return!(u<0)}}]),map,initialData,markerClusterer,shopList,dealersNearbyLabel,resultForLabel;document.addEventListener("DOMContentLoaded",function(){function o(n){n===GlobalRoute.MyLocation?f():($("#address").val(n),t())}function s(){let i=document.getElementById("address"),n=new google.maps.places.Autocomplete(i);n.setComponentRestrictions({country:GlobalRoute.CountryRestriction});google.maps.event.addListener(n,"place_changed",function(){let i=n.getPlace();i.geometry&&t()})}function h(){shopList=new List("shops",{page:3,valueNames:["shopFinderResultBox"],pagination:!0})}function n(n,t,u,f){i();var e=l(n);if(markerClusterer.addMarkers(e),h(),t===null||u===null||n.length===0)r(),$("#nearbyDealersCount").empty(),$("#searchString").empty();else{let n=new google.maps.LatLng(t,u);map.setCenter(n);f!==undefined&&map.setZoom(f)}}function r(){markerClusterer.fitMapToMarkers()}function c(n,t,i,r){google.maps.event.addListener(n,"click",function(){i.setContent(r);i.open(t,n)})}function l(n){for(var i,u,r=[],t=0;t
    '+n.Name+"",i=0;i'+n+""}n.Street&&(t+='
    '+n.Street+"");n.PostCode&&(t+='
    '+n.PostCode+"");n.City&&(t+='
    '+n.City+"");n.Phone&&(t+='
    '+n.Phone+"");for(let n=0;n'+i+""}return r=Math.round(n.Distance*10)/10,r>0&&(t+="
    "+r+" km"),t+=''+storeDirections+"",t+=""}function a(n){$("#shop-list").append(u(n))}function v(n){var t=new google.maps.InfoWindow({content:""}),i=new google.maps.LatLng(n.Latitude,n.Longitude);return marker=new google.maps.Marker({position:i,icon:{url:"../Content/img/icons/map/pin.png"}}),c(marker,map,t,u(n)),marker}function t(){var n=$("#address").val();return n!==""&&n!==null?(y(n),dataLayer=window.dataLayer||[],dataLayer.push({event:"search",gtm:{element:{dataset:{t:"dataSubmit",d1:"store locator cta",d2:"search"}}}})):p(),!1}function y(t){$.ajax({url:"/stores/GetStoresByAddressJSON",type:"GET",data:{searchAddress:t},dataType:"json",success:function(r){r.Stores.length!==0?($("#no-results").hide(),n(r.Stores,r.Latitude,r.Longitude,r.ZoomLevel),$("#searchText").removeClass("d-none"),$("#searchText").text(resultForLabel+' "'+t+'"')):(i(),$("#no-results").show())}})}function p(){$.ajax({url:"/stores/GetStoresJSON",success:function(t){$("#map").length&&(n(t,null,null,t.ZoomLevel),r())}})}function f(){dataLayer=window.dataLayer||[];dataLayer.push({event:"search",gtm:{element:{dataset:{t:"dataSubmit",d1:"store locator cta",d2:"use my location"}}}});navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(t){var r=t.coords.latitude,u=t.coords.longitude;$.ajax({url:"/stores/GetStoresByCoordinateJSON",type:"GET",data:{longitude:u,latitude:r},dataType:"json",success:function(t){t.Stores.length!==0?($("#no-results").hide(),n(t.Stores,t.Latitude,t.Longitude,t.ZoomLevel)):(i(),$("#no-results").show())}})})}function i(){markerClusterer.clearMarkers();shopList&&shopList.clear();$("#shop-list").empty();$("#nearbyDealersCount").empty();$("#searchText").addClass("d-none");$("#no-results").hide()}$("#searchSubmit").submit(t);$("#myLocalization").click(f);$("#searchButton").click(t);var e={initOnce:function(t){map=new google.maps.Map(document.getElementById("map"));markerClusterer=new MarkerClusterer(map,[],{imagePath:"/Content/img/icons/map/m"});dealersNearbyLabel=$("#nearbyDealersCount").text();resultForLabel=$("#searchText").text();s();searchString?o(searchString):n(t,null,null)}};$.ajax({url:"/stores/GetStoresJSON",success:function(n){initialData=n;$("#map").length&&e.initOnce(n)}})},!1)