﻿function MarkerClusterer(map,opt_markers,opt_options){this.extend(MarkerClusterer,google.maps.OverlayView);this.map_=map;this.markers_=[];this.clusters_=[];this.sizes=[53,56,66,78,90];this.styles_=[];this.ready_=false;var options=opt_options||{};this.gridSize_=options['gridSize']||60;this.minClusterSize_=options['minimumClusterSize']||2;this.maxZoom_=options['maxZoom']||null;this.styles_=options['styles']||[];this.imagePath_=options['imagePath']||this.MARKER_CLUSTER_IMAGE_PATH_;this.imageExtension_=options['imageExtension']||this.MARKER_CLUSTER_IMAGE_EXTENSION_;this.zoomOnClick_=true;if(options['zoomOnClick']!=undefined){this.zoomOnClick_=options['zoomOnClick'];}
this.averageCenter_=false;if(options['averageCenter']!=undefined){this.averageCenter_=options['averageCenter'];}
this.setupStyles_();this.setMap(map);this.prevZoom_=this.map_.getZoom();var that=this;google.maps.event.addListener(this.map_,'zoom_changed',function(){var zoom=that.map_.getZoom();if(that.prevZoom_!=zoom){that.prevZoom_=zoom;that.resetViewport();}});google.maps.event.addListener(this.map_,'idle',function(){that.redraw();});if(opt_markers&&opt_markers.length){this.addMarkers(opt_markers,false);}}
MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_='../images/m';MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_EXTENSION_='png';MarkerClusterer.prototype.extend=function(obj1,obj2){return(function(object){for(var property in object.prototype){this.prototype[property]=object.prototype[property];}
return this;}).apply(obj1,[obj2]);};MarkerClusterer.prototype.onAdd=function(){this.setReady_(true);};MarkerClusterer.prototype.draw=function(){};MarkerClusterer.prototype.setupStyles_=function(){if(this.styles_.length){return;}
for(var i=0,size;size=this.sizes[i];i++){this.styles_.push({url:this.imagePath_+(i+1)+'.'+this.imageExtension_,height:size,width:size});}};MarkerClusterer.prototype.fitMapToMarkers=function(){var markers=this.getMarkers();var bounds=new google.maps.LatLngBounds();for(var i=0,marker;marker=markers[i];i++){bounds.extend(marker.getPosition());}
this.map_.fitBounds(bounds);};MarkerClusterer.prototype.setStyles=function(styles){this.styles_=styles;};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(maxZoom){this.maxZoom_=maxZoom;};MarkerClusterer.prototype.getMaxZoom=function(){return this.maxZoom_;};MarkerClusterer.prototype.calculator_=function(markers,numStyles){var index=0;var count=markers.length;var dv=count;while(dv!==0){dv=parseInt(dv/10,10);index++;}
index=Math.min(index,numStyles);return{text:count,index:index};};MarkerClusterer.prototype.setCalculator=function(calculator){this.calculator_=calculator;};MarkerClusterer.prototype.getCalculator=function(){return this.calculator_;};MarkerClusterer.prototype.addMarkers=function(markers,opt_nodraw){for(var i=0,marker;marker=markers[i];i++){this.pushMarkerTo_(marker);}
if(!opt_nodraw){this.redraw();}};MarkerClusterer.prototype.pushMarkerTo_=function(marker){marker.isAdded=false;if(marker['draggable']){var that=this;google.maps.event.addListener(marker,'dragend',function(){marker.isAdded=false;that.repaint();});}
this.markers_.push(marker);};MarkerClusterer.prototype.addMarker=function(marker,opt_nodraw){this.pushMarkerTo_(marker);if(!opt_nodraw){this.redraw();}};MarkerClusterer.prototype.removeMarker_=function(marker){var index=-1;if(this.markers_.indexOf){index=this.markers_.indexOf(marker);}else{for(var i=0,m;m=this.markers_[i];i++){if(m==marker){index=i;break;}}}
if(index==-1){return false;}
marker.setMap(null);this.markers_.splice(index,1);return true;};MarkerClusterer.prototype.removeMarker=function(marker,opt_nodraw){var removed=this.removeMarker_(marker);if(!opt_nodraw&&removed){this.resetViewport();this.redraw();return true;}else{return false;}};MarkerClusterer.prototype.removeMarkers=function(markers,opt_nodraw){var removed=false;for(var i=0,marker;marker=markers[i];i++){var r=this.removeMarker_(marker);removed=removed||r;}
if(!opt_nodraw&&removed){this.resetViewport();this.redraw();return true;}};MarkerClusterer.prototype.setReady_=function(ready){if(!this.ready_){this.ready_=ready;this.createClusters_();}};MarkerClusterer.prototype.getTotalClusters=function(){return this.clusters_.length;};MarkerClusterer.prototype.getMap=function(){return this.map_;};MarkerClusterer.prototype.setMap=function(map){this.map_=map;};MarkerClusterer.prototype.getGridSize=function(){return this.gridSize_;};MarkerClusterer.prototype.setGridSize=function(size){this.gridSize_=size;};MarkerClusterer.prototype.getMinClusterSize=function(){return this.minClusterSize_;};MarkerClusterer.prototype.setMinClusterSize=function(size){this.minClusterSize_=size;};MarkerClusterer.prototype.getExtendedBounds=function(bounds){var projection=this.getProjection();var tr=new google.maps.LatLng(bounds.getNorthEast().lat(),bounds.getNorthEast().lng());var bl=new google.maps.LatLng(bounds.getSouthWest().lat(),bounds.getSouthWest().lng());var trPix=projection.fromLatLngToDivPixel(tr);trPix.x+=this.gridSize_;trPix.y-=this.gridSize_;var blPix=projection.fromLatLngToDivPixel(bl);blPix.x-=this.gridSize_;blPix.y+=this.gridSize_;var ne=projection.fromDivPixelToLatLng(trPix);var sw=projection.fromDivPixelToLatLng(blPix);bounds.extend(ne);bounds.extend(sw);return bounds;};MarkerClusterer.prototype.isMarkerInBounds_=function(marker,bounds){return bounds.contains(marker.getPosition());};MarkerClusterer.prototype.clearMarkers=function(){this.resetViewport(true);this.markers_=[];};MarkerClusterer.prototype.resetViewport=function(opt_hide){for(var i=0,cluster;cluster=this.clusters_[i];i++){cluster.remove();}
for(var i=0,marker;marker=this.markers_[i];i++){marker.isAdded=false;if(opt_hide){marker.setMap(null);}}
this.clusters_=[];};MarkerClusterer.prototype.repaint=function(){var oldClusters=this.clusters_.slice();this.clusters_.length=0;this.resetViewport();this.redraw();window.setTimeout(function(){for(var i=0,cluster;cluster=oldClusters[i];i++){cluster.remove();}},0);};MarkerClusterer.prototype.redraw=function(){this.createClusters_();};MarkerClusterer.prototype.distanceBetweenPoints_=function(p1,p2){if(!p1||!p2){return 0;}
var R=6371;var dLat=(p2.lat()-p1.lat())*Math.PI/180;var dLon=(p2.lng()-p1.lng())*Math.PI/180;var a=Math.sin(dLat/2)*Math.sin(dLat/2)+
Math.cos(p1.lat()*Math.PI/180)*Math.cos(p2.lat()*Math.PI/180)*Math.sin(dLon/2)*Math.sin(dLon/2);var c=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));var d=R*c;return d;};MarkerClusterer.prototype.addToClosestCluster_=function(marker){var distance=40000;var clusterToAddTo=null;var pos=marker.getPosition();for(var i=0,cluster;cluster=this.clusters_[i];i++){var center=cluster.getCenter();if(center){var d=this.distanceBetweenPoints_(center,marker.getPosition());if(d<distance){distance=d;clusterToAddTo=cluster;}}}
if(clusterToAddTo&&clusterToAddTo.isMarkerInClusterBounds(marker)){clusterToAddTo.addMarker(marker);}else{var cluster=new Cluster(this);cluster.addMarker(marker);this.clusters_.push(cluster);}};MarkerClusterer.prototype.createClusters_=function(){if(!this.ready_){return;}
var mapBounds=new google.maps.LatLngBounds(this.map_.getBounds().getSouthWest(),this.map_.getBounds().getNorthEast());var bounds=this.getExtendedBounds(mapBounds);for(var i=0,marker;marker=this.markers_[i];i++){if(!marker.isAdded&&this.isMarkerInBounds_(marker,bounds)){this.addToClosestCluster_(marker);}}};function Cluster(markerClusterer){this.markerClusterer_=markerClusterer;this.map_=markerClusterer.getMap();this.gridSize_=markerClusterer.getGridSize();this.minClusterSize_=markerClusterer.getMinClusterSize();this.averageCenter_=markerClusterer.isAverageCenter();this.center_=null;this.markers_=[];this.bounds_=null;this.clusterIcon_=new ClusterIcon(this,markerClusterer.getStyles(),markerClusterer.getGridSize());}
Cluster.prototype.isMarkerAlreadyAdded=function(marker){if(this.markers_.indexOf){return this.markers_.indexOf(marker)!=-1;}else{for(var i=0,m;m=this.markers_[i];i++){if(m==marker){return true;}}}
return false;};Cluster.prototype.addMarker=function(marker){if(this.isMarkerAlreadyAdded(marker)){return false;}
if(!this.center_){this.center_=marker.getPosition();this.calculateBounds_();}else{if(this.averageCenter_){var l=this.markers_.length+1;var lat=(this.center_.lat()*(l-1)+marker.getPosition().lat())/l;var lng=(this.center_.lng()*(l-1)+marker.getPosition().lng())/l;this.center_=new google.maps.LatLng(lat,lng);this.calculateBounds_();}}
marker.isAdded=true;this.markers_.push(marker);var len=this.markers_.length;if(len<this.minClusterSize_&&marker.getMap()!=this.map_){marker.setMap(this.map_);}
if(len==this.minClusterSize_){for(var i=0;i<len;i++){this.markers_[i].setMap(null);}}
if(len>=this.minClusterSize_){marker.setMap(null);}
this.updateIcon();return true;};Cluster.prototype.getMarkerClusterer=function(){return this.markerClusterer_;};Cluster.prototype.getBounds=function(){var bounds=new google.maps.LatLngBounds(this.center_,this.center_);var markers=this.getMarkers();for(var i=0,marker;marker=markers[i];i++){bounds.extend(marker.getPosition());}
return bounds;};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 bounds=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(bounds);};Cluster.prototype.isMarkerInClusterBounds=function(marker){return this.bounds_.contains(marker.getPosition());};Cluster.prototype.getMap=function(){return this.map_;};Cluster.prototype.updateIcon=function(){var zoom=this.map_.getZoom();var mz=this.markerClusterer_.getMaxZoom();if(mz&&zoom>mz){for(var i=0,marker;marker=this.markers_[i];i++){marker.setMap(this.map_);}
return;}
if(this.markers_.length<this.minClusterSize_){this.clusterIcon_.hide();return;}
var numStyles=this.markerClusterer_.getStyles().length;var sums=this.markerClusterer_.getCalculator()(this.markers_,numStyles);this.clusterIcon_.setCenter(this.center_);this.clusterIcon_.setSums(sums);this.clusterIcon_.show();};function ClusterIcon(cluster,styles,opt_padding){cluster.getMarkerClusterer().extend(ClusterIcon,google.maps.OverlayView);this.styles_=styles;this.padding_=opt_padding||0;this.cluster_=cluster;this.center_=null;this.map_=cluster.getMap();this.div_=null;this.sums_=null;this.visible_=false;this.setMap(this.map_);}
ClusterIcon.prototype.triggerClusterClick=function(event){var markerClusterer=this.cluster_.getMarkerClusterer();google.maps.event.trigger(markerClusterer,'clusterclick',this.cluster_,event);if(markerClusterer.isZoomOnClick()){this.map_.fitBounds(this.cluster_.getBounds());}};ClusterIcon.prototype.onAdd=function(){this.div_=document.createElement('DIV');if(this.visible_){var pos=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(pos);this.div_.innerHTML=this.sums_.text;}
var panes=this.getPanes();panes.overlayMouseTarget.appendChild(this.div_);var that=this;var isDragging=false;google.maps.event.addDomListener(this.div_,'click',function(event){if(!isDragging){that.triggerClusterClick(event);}});google.maps.event.addDomListener(this.div_,'mousedown',function(){isDragging=false;});google.maps.event.addDomListener(this.div_,'mousemove',function(){isDragging=true;});};ClusterIcon.prototype.getPosFromLatLng_=function(latlng){var pos=this.getProjection().fromLatLngToDivPixel(latlng);if(typeof this.iconAnchor_==='object'&&this.iconAnchor_.length===2){pos.x-=this.iconAnchor_[0];pos.y-=this.iconAnchor_[1];}else{pos.x-=parseInt(this.width_/2,10);pos.y-=parseInt(this.height_/2,10);}
return pos;};ClusterIcon.prototype.draw=function(){if(this.visible_){var pos=this.getPosFromLatLng_(this.center_);this.div_.style.top=pos.y+'px';this.div_.style.left=pos.x+'px';}};ClusterIcon.prototype.hide=function(){if(this.div_){this.div_.style.display='none';}
this.visible_=false;};ClusterIcon.prototype.show=function(){if(this.div_){var pos=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(pos);this.div_.style.display='';}
this.visible_=true;};ClusterIcon.prototype.remove=function(){this.setMap(null);};ClusterIcon.prototype.onRemove=function(){if(this.div_&&this.div_.parentNode){this.hide();this.div_.parentNode.removeChild(this.div_);this.div_=null;}};ClusterIcon.prototype.setSums=function(sums){this.sums_=sums;this.text_=sums.text;this.index_=sums.index;if(this.div_){this.div_.innerHTML=sums.text;}
this.useStyle();};ClusterIcon.prototype.useStyle=function(){var index=Math.max(0,this.sums_.index-1);index=Math.min(this.styles_.length-1,index);var style=this.styles_[index];this.url_=style['url'];this.height_=style['height'];this.width_=style['width'];this.textColor_=style['textColor'];this.anchor_=style['anchor'];this.textSize_=style['textSize'];this.backgroundPosition_=style['backgroundPosition'];this.iconAnchor_=style['iconAnchor'];};ClusterIcon.prototype.setCenter=function(center){this.center_=center;};ClusterIcon.prototype.createCss=function(pos){var style=[];style.push('background-image:url('+this.url_+');');var backgroundPosition=this.backgroundPosition_?this.backgroundPosition_:'0 0';style.push('background-position:'+backgroundPosition+';');if(typeof this.anchor_==='object'){if(typeof this.anchor_[0]==='number'&&this.anchor_[0]>0&&this.anchor_[0]<this.height_){style.push('height:'+(this.height_-this.anchor_[0])+'px; padding-top:'+this.anchor_[0]+'px;');}else if(typeof this.anchor_[0]==='number'&&this.anchor_[0]<0&&-this.anchor_[0]<this.height_){style.push('height:'+this.height_+'px; line-height:'+(this.height_+this.anchor_[0])+'px;');}else{style.push('height:'+this.height_+'px; line-height:'+this.height_+'px;');}
if(typeof this.anchor_[1]==='number'&&this.anchor_[1]>0&&this.anchor_[1]<this.width_){style.push('width:'+(this.width_-this.anchor_[1])+'px; padding-left:'+this.anchor_[1]+'px;');}else{style.push('width:'+this.width_+'px; text-align:center;');}}else{style.push('height:'+this.height_+'px; line-height:'+
this.height_+'px; width:'+this.width_+'px; text-align:center;');}
var txtColor=this.textColor_?this.textColor_:'black';var txtSize=this.textSize_?this.textSize_:11;style.push('cursor:pointer; top:'+pos.y+'px; left:'+
pos.x+'px; color:'+txtColor+'; position:absolute; font-size:'+
txtSize+'px; font-family:Arial,sans-serif; font-weight:bold');return style.join('');};window['MarkerClusterer']=MarkerClusterer;MarkerClusterer.prototype['addMarker']=MarkerClusterer.prototype.addMarker;MarkerClusterer.prototype['addMarkers']=MarkerClusterer.prototype.addMarkers;MarkerClusterer.prototype['clearMarkers']=MarkerClusterer.prototype.clearMarkers;MarkerClusterer.prototype['fitMapToMarkers']=MarkerClusterer.prototype.fitMapToMarkers;MarkerClusterer.prototype['getCalculator']=MarkerClusterer.prototype.getCalculator;MarkerClusterer.prototype['getGridSize']=MarkerClusterer.prototype.getGridSize;MarkerClusterer.prototype['getExtendedBounds']=MarkerClusterer.prototype.getExtendedBounds;MarkerClusterer.prototype['getMap']=MarkerClusterer.prototype.getMap;MarkerClusterer.prototype['getMarkers']=MarkerClusterer.prototype.getMarkers;MarkerClusterer.prototype['getMaxZoom']=MarkerClusterer.prototype.getMaxZoom;MarkerClusterer.prototype['getStyles']=MarkerClusterer.prototype.getStyles;MarkerClusterer.prototype['getTotalClusters']=MarkerClusterer.prototype.getTotalClusters;MarkerClusterer.prototype['getTotalMarkers']=MarkerClusterer.prototype.getTotalMarkers;MarkerClusterer.prototype['redraw']=MarkerClusterer.prototype.redraw;MarkerClusterer.prototype['removeMarker']=MarkerClusterer.prototype.removeMarker;MarkerClusterer.prototype['removeMarkers']=MarkerClusterer.prototype.removeMarkers;MarkerClusterer.prototype['resetViewport']=MarkerClusterer.prototype.resetViewport;MarkerClusterer.prototype['repaint']=MarkerClusterer.prototype.repaint;MarkerClusterer.prototype['setCalculator']=MarkerClusterer.prototype.setCalculator;MarkerClusterer.prototype['setGridSize']=MarkerClusterer.prototype.setGridSize;MarkerClusterer.prototype['setMaxZoom']=MarkerClusterer.prototype.setMaxZoom;MarkerClusterer.prototype['onAdd']=MarkerClusterer.prototype.onAdd;MarkerClusterer.prototype['draw']=MarkerClusterer.prototype.draw;Cluster.prototype['getCenter']=Cluster.prototype.getCenter;Cluster.prototype['getSize']=Cluster.prototype.getSize;Cluster.prototype['getMarkers']=Cluster.prototype.getMarkers;ClusterIcon.prototype['onAdd']=ClusterIcon.prototype.onAdd;ClusterIcon.prototype['draw']=ClusterIcon.prototype.draw;ClusterIcon.prototype['onRemove']=ClusterIcon.prototype.onRemove;
;;;(function($){var defaultGeoCodeOptions={componentRestrictions:{country:'NZ'}}
var storeLocator=function(){};window.storeLocator=storeLocator;storeLocator.toRad_=function(a){return a*Math.PI/180};storeLocator.Feature=function(a,b){this.id_=a;this.name_=b};storeLocator.Feature=storeLocator.Feature;storeLocator.Feature.prototype.getId=function(){return this.id_};storeLocator.Feature.prototype.getDisplayName=function(){return this.name_};storeLocator.Feature.prototype.toString=function(){return this.getDisplayName()};storeLocator.FeatureSet=function(a){this.array_=[];this.hash_={};for(var b=0,c;c=arguments[b];b++)this.add(c)};storeLocator.FeatureSet=storeLocator.FeatureSet;storeLocator.FeatureSet.prototype.toggle=function(a){this.contains(a)?this.remove(a):this.add(a)};storeLocator.FeatureSet.prototype.contains=function(a){return a.getId()in this.hash_};storeLocator.FeatureSet.prototype.getById=function(a){return a in this.hash_?this.array_[this.hash_[a]]:null};storeLocator.FeatureSet.prototype.add=function(a){a&&(this.array_.push(a),this.hash_[a.getId()]=this.array_.length-
1)};storeLocator.FeatureSet.prototype.remove=function(a){this.contains(a)&&(this.array_[this.hash_[a.getId()]]=null,delete this.hash_[a.getId()])};storeLocator.FeatureSet.prototype.asList=function(){for(var a=[],b=0,c=this.array_.length;b<c;b++){var d=this.array_[b];null!==d&&a.push(d)}
return a};storeLocator.FeatureSet.NONE=new storeLocator.FeatureSet;storeLocator.GMEDataFeed=function(a){this.tableId_=a.tableId;this.apiKey_=a.apiKey;a.propertiesModifier&&(this.propertiesModifier_=a.propertiesModifier)};storeLocator.GMEDataFeed=storeLocator.GMEDataFeed;storeLocator.GMEDataFeed.prototype.getStores=function(a,b,c){debugger;var d=this,e=a.getCenter();a="(ST_INTERSECTS(geometry, "+this.boundsToWkt_(a)+") OR ST_DISTANCE(geometry, "+this.latLngToWkt_(e)+") \x3c 20000)";$.getJSON("https://www.googleapis.com/mapsengine/v1/tables/"+
this.tableId_+"/features?callback\x3d?",{key:this.apiKey_,where:a,version:"published",maxResults:300},function(a){a=d.parse_(a);d.sortByDistance_(e,a);c(a)})};storeLocator.GMEDataFeed.prototype.latLngToWkt_=function(a){return"ST_POINT("+a.lng()+", "+a.lat()+")"};storeLocator.GMEDataFeed.prototype.boundsToWkt_=function(a){var b=a.getNorthEast();a=a.getSouthWest();return["ST_GEOMFROMTEXT('POLYGON ((",a.lng()," ",a.lat(),", ",b.lng()," ",a.lat(),", ",b.lng()," ",b.lat(),", ",a.lng()," ",b.lat(),", ",a.lng()," ",a.lat(),"))')"].join("")};storeLocator.GMEDataFeed.prototype.parse_=function(a){if(a.error)return window.alert(a.error.message),[];a=a.features;if(!a)return[];for(var b=[],c=0,d;d=a[c];c++){var e=d.geometry.coordinates,e=new google.maps.LatLng(e[1],e[0]);d=this.propertiesModifier_(d.properties);d=new storeLocator.Store(d.id,e,null,d);b.push(d)}
return b};storeLocator.GMEDataFeed.prototype.propertiesModifier_=function(a){return a};storeLocator.GMEDataFeed.prototype.sortByDistance_=function(a,b){b.sort(function(b,d){return b.distanceTo(a)-d.distanceTo(a)})};storeLocator.GMEDataFeedOptions=function(){};storeLocator.Panel=function(a,b){this.el_=$(a);this.el_.addClass("storelocator-panel");this.settings_=$.extend({locationSearch:!0,locationSearchLabel:"Where are you?",featureFilter:!0,directions:!0,view:null},b);this.directionsRenderer_=new google.maps.DirectionsRenderer({draggable:!0});this.directionsService_=new google.maps.DirectionsService;this.init_()};storeLocator.Panel=storeLocator.Panel;storeLocator.Panel.prototype=new google.maps.MVCObject;storeLocator.Panel.prototype.init_=function(){var a=this;this.itemCache_={};this.settings_.view&&this.set("view",this.settings_.view);this.filter_=$('\x3cform class\x3d"storelocator-filter"/\x3e');this.el_.append(this.filter_);this.settings_.locationSearch&&(this.locationSearch_=$('\x3cdiv class\x3d"location-search"\x3e\x3ch4\x3e'+
this.settings_.locationSearchLabel+'\x3c/h4\x3e \x3cdiv class\x3d"form-inline"\x3e\x3cdiv class\x3d"form-group"\x3e \x3cinput placeholder\x3d"Full address, city or post code" class\x3d"form-control"\x3e\x3c/div\x3e\x3cbutton type="submit" class\x3d"location-search-search"\x3e   \x3ci class\x3d"fa fa-search fa-2x" aria-hidden\x3d"true"\x3e\x3c/i\x3e    \x3c/button\x3e\x3cbutton class="location-search-geolocate"\x3e   \x3ci class\x3d"fa fa-crosshairs fa-2x" aria-hidden\x3d"true"\x3e\x3c/i\x3e    \x3c/button\x3e\x3c/div\x3e\x3c/div\x3e     '),this.filter_.append(this.locationSearch_),this.filter_.append($('\x3cdiv class\x3d"location-search-desc"/\x3e')),"undefined"!=typeof google.maps.places?this.initAutocomplete_():this.filter_.submit(function(){var b=$("input",a.locationSearch_).val();a.searchPosition(b)}),this.filter_.submit(function(){return!1}),this.filter_.find('button').first().click(function(){var search=$('input',a.locationSearch_).val();if(window.location.origin.indexOf("housecall.co.nz")>-1){gtag('event','conversion',{'send_to':'AW-719151674/Nd1ICKvciOMBELrE9dYC'});}
a.searchPosition(search);}),google.maps.event.addListener(this,"geocode",function(b){if(b.geometry){this.directionsFrom_=b.geometry.location;a.directionsVisible_&&a.renderDirections_();var c=a.get("view");c.highlight(null);var d=c.getMap();b.geometry.viewport?(d.fitBounds(b.geometry.viewport),d.setZoom(10)):(d.setCenter(b.geometry.location),d.setZoom(10));c.refreshView();a.listenForStoresUpdate_()}else a.searchPosition(b.name)}));if(this.settings_.featureFilter){this.featureFilter_=$('\x3cdiv class\x3d"feature-filter"/\x3e');for(var b=this.get("view").getFeatures().asList(),c=0,d=b.length;c<d;c++){var e=b[c],f=$('\x3cinput type\x3d"checkbox"/\x3e');f.data("feature",e);$("\x3clabel/\x3e").append(f).append(e.getDisplayName()).appendTo(this.featureFilter_)}
this.filter_.append(this.featureFilter_);this.featureFilter_.find("input").change(function(){var b=$(this).data("feature");a.toggleFeatureFilter_(b);a.get("view").refreshView()})}
this.storeList_=$('\x3cul class\x3d"store-list list-unstyled"/\x3e');this.el_.append(this.storeList_);this.settings_.directions&&(this.directionsPanel_=$('\x3cdiv class\x3d"directions-panel"\x3e\x3cform\x3e\x3cinput class\x3d"directions-to form-control"/\x3e\x3cinput type\x3d"submit" class\x3d"btn btn-primary" value\x3d"Find directions"/\x3e\x3ca href\x3d"#" class\x3d"close-directions btn btn-default"\x3eClose\x3c/a\x3e\x3c/form\x3e\x3cdiv class\x3d"rendered-directions"\x3e\x3c/div\x3e\x3c/div\x3e'),this.directionsPanel_.find(".directions-to").attr("readonly","readonly"),this.directionsPanel_.hide(),this.directionsVisible_=!1,this.directionsPanel_.find("form").submit(function(){a.renderDirections_();return!1}),this.directionsPanel_.find(".close-directions").click(function(){a.hideDirections()}),this.el_.append(this.directionsPanel_))};storeLocator.Panel.prototype.toggleFeatureFilter_=function(a){var b=this.get("featureFilter");b.toggle(a);this.set("featureFilter",b)};storeLocator.geocoder_=new google.maps.Geocoder;storeLocator.Panel.prototype.listenForStoresUpdate_=function(){var a=this,b=this.get("view");this.storesChangedListener_&&google.maps.event.removeListener(this.storesChangedListener_);this.storesChangedListener_=google.maps.event.addListenerOnce(b,"stores_changed",function(){a.set("stores",b.get("stores"))})};storeLocator.Panel.prototype.searchPosition=function(a){var b=this;a=$.extend({address:a,bounds:this.get("view").getMap().getBounds(),},defaultGeoCodeOptions);storeLocator.geocoder_.geocode(a,function(a,d){d==google.maps.GeocoderStatus.OK&&google.maps.event.trigger(b,"geocode",a[0])
if(a[0].address_components[0].short_name=="NZ")
b.get("view").getMap().setZoom(5)})};storeLocator.Panel.prototype.setView=function(a){this.set("view",a)};storeLocator.Panel.prototype.view_changed=function(){var that=this;var a=this.get("view");this.bindTo("selectedStore",a);var b=this;this.geolocationListener_&&google.maps.event.removeListener(this.geolocationListener_);this.zoomListener_&&google.maps.event.removeListener(this.zoomListener_);this.idleListener_&&google.maps.event.removeListener(this.idleListener_);this.centerListener_&&google.maps.event.removeListener(this.centerListener_);a.getMap().getCenter();var setMaxDistance=function(){var map=a.getMap();var bounds=map.getBounds();if(!bounds){that.maxDistance=null
return;}
var center=bounds.getCenter();var ne=bounds.getNorthEast();var lat1=storeLocator.toRad_(center.lat());var lon1=storeLocator.toRad_(center.lng());var lat2=storeLocator.toRad_(ne.lat());var lon2=storeLocator.toRad_(ne.lng());var x1=lat2-lat1;var x2=lon2-lon1;var x3=Math.sin(x1/2)*Math.sin(x1/2)+Math.cos(lat1)*Math.cos(lat2)*Math.sin(x2/2)*Math.sin(x2/2);that.maxDistance=12742*Math.atan2(Math.sqrt(x3),Math.sqrt(1-x3));}
var c=function(){a.clearMarkers();b.listenForStoresUpdate_();setTimeout(function(){setMaxDistance();},10);};this.geolocationListener_=google.maps.event.addListener(a,"load",c);this.zoomListener_=google.maps.event.addListener(a.getMap(),"zoom_changed",c);this.idleListener_=google.maps.event.addListener(a.getMap(),"idle",function(){return b.idle_(a.getMap())});c();this.bindTo("featureFilter",a);this.autoComplete_&&this.autoComplete_.bindTo("bounds",a.getMap())};storeLocator.Panel.prototype.initAutocomplete_=function(){var a=this,b=$("input",this.locationSearch_)[0];this.autoComplete_=new google.maps.places.Autocomplete(b,defaultGeoCodeOptions);this.get("view")&&this.autoComplete_.bindTo("bounds",this.get("view").getMap());google.maps.event.addListener(this.autoComplete_,"place_changed",function(){google.maps.event.trigger(a,"geocode",this.getPlace())})};storeLocator.Panel.prototype.idle_=function(a){this.center_?a.getBounds().contains(this.center_)||(this.center_=a.getCenter(),this.listenForStoresUpdate_()):this.center_=a.getCenter()};storeLocator.Panel.NO_STORES_HTML_='\x3cli class\x3d"no-stores"\x3eThere are no stores in this area.\x3c/li\x3e';storeLocator.Panel.NO_STORES_IN_VIEW_HTML_='\x3cli class\x3d"no-stores"\x3eStores closest to you are listed below.\x3c/li\x3e';storeLocator.Panel.prototype.stores_changed=function(){if(this.get("stores")){var maxStores=this.maxStores||99;var that=this;var storesFound=0;var a=this.get("view"),b=a&&a.getMap().getBounds(),c=this.get("stores"),d=this.get("selectedStore");this.storeList_.empty();c.length?b&&!b.contains(c[0].getLocation())&&this.storeList_.append(storeLocator.Panel.NO_STORES_IN_VIEW_HTML_):this.storeList_.append(storeLocator.Panel.NO_STORES_HTML_);for(var b=function(){a.highlight(this.store,!0)},e=0,f=Math.min(maxStores,c.length);e<f;e++){var g=c[e].getInfoPanelItem();g.store=c[e];d&&c[e].getId()==d.getId()&&$(g).addClass("highlighted");g.clickHandler_||(g.clickHandler_=google.maps.event.addDomListener(g,"click",b));var maxDistance=that.maxDistance;if(maxDistance){if(maxDistance<16){maxDistance=16;}
var currentDistance=g.store.distanceTo(a.getMap().getCenter());if(currentDistance>maxDistance){continue;}}
storesFound++;this.storeList_.append(g)}
var searchResultsDesc="Found <strong>{0}</strong> centre".pluralise(storesFound,"s");searchResultsDesc=searchResultsDesc.replace(/\{0\}/,storesFound);that.get("view").getMarkerClusterer().repaint();}};storeLocator.Panel.prototype.selectedStore_changed=function(){$(".highlighted",this.storeList_).removeClass("highlighted");var a=this,b=this.get("selectedStore");if(b){this.directionsTo_=b;this.storeList_.find("#store-"+b.getId()).addClass("highlighted");this.settings_.directions&&this.directionsPanel_.find(".directions-to").val(b.getDetails().title);var c=a.get("view").getInfoWindow().getContent(),d=$("\x3ca/\x3e").text("Get driving directions").attr("href","#").addClass("action").addClass("directions"),e=$("\x3ca/\x3e").text("Zoom here").attr("href","#").addClass("action").addClass("zoomhere"),f=$("\x3ca/\x3e").text("Street view").attr("href","#").addClass("action").addClass("streetview");d.click(function(){a.showDirections();return!1});e.click(function(){a.get("view").getMap().setOptions({center:b.getLocation(),zoom:16})});f.click(function(){var c=a.get("view").getMap().getStreetView();c.setPosition(b.getLocation());c.setVisible(!0)});$(c).append(d).append(e).append(f)}};storeLocator.Panel.prototype.hideDirections=function(){this.directionsVisible_=!1;this.directionsPanel_.fadeOut();this.featureFilter_.fadeIn();this.storeList_.fadeIn();this.directionsRenderer_.setMap(null)};storeLocator.Panel.prototype.showDirections=function(){var a=this.get("selectedStore");this.featureFilter_.fadeOut();this.storeList_.fadeOut();this.directionsPanel_.find(".directions-to").val(a.getDetails().title);this.directionsPanel_.fadeIn();this.renderDirections_();this.directionsVisible_=!0};storeLocator.Panel.prototype.renderDirections_=function(){var a=this;if(this.directionsFrom_&&this.directionsTo_){var b=this.directionsPanel_.find(".rendered-directions").empty();this.directionsService_.route({origin:this.directionsFrom_,destination:this.directionsTo_.getLocation(),travelMode:google.maps.DirectionsTravelMode.DRIVING},function(c,d){if(d==google.maps.DirectionsStatus.OK){var e=a.directionsRenderer_;e.setPanel(b[0]);e.setMap(a.get("view").getMap());e.setDirections(c)}})}};storeLocator.Panel.prototype.featureFilter_changed=function(){this.listenForStoresUpdate_()};storeLocator.PanelOptions=function(){};storeLocator.StaticDataFeed=function(){this.stores_=[]};storeLocator.StaticDataFeed=storeLocator.StaticDataFeed;storeLocator.StaticDataFeed.prototype.setStores=function(a){this.stores_=a;this.firstCallback_?this.firstCallback_():delete this.firstCallback_};storeLocator.StaticDataFeed.prototype.getStores=function(a,b,c){if(this.stores_.length){for(var d=[],e=0,f;f=this.stores_[e];e++)f.hasAllFeatures(b)&&d.push(f);this.sortByDistance_(a.getCenter(),d);c(d)}else{var g=this;this.firstCallback_=function(){g.getStores(a,b,c)}}};storeLocator.StaticDataFeed.prototype.sortByDistance_=function(a,b){b.sort(function(b,d){return b.distanceTo(a)-d.distanceTo(a)})};storeLocator.Store=function(a,b,c,d){this.id_=a;this.location_=b;this.features_=c||storeLocator.FeatureSet.NONE;this.props_=d||{}};storeLocator.Store=storeLocator.Store;storeLocator.Store.prototype.setMarker=function(a){this.marker_=a;google.maps.event.trigger(this,"marker_changed",a)};storeLocator.Store.prototype.getMarker=function(){return this.marker_};storeLocator.Store.prototype.getId=function(){return this.id_};storeLocator.Store.prototype.getLocation=function(){return this.location_};storeLocator.Store.prototype.getFeatures=function(){return this.features_};storeLocator.Store.prototype.hasFeature=function(a){return this.features_.contains(a)};storeLocator.Store.prototype.hasAllFeatures=function(a){if(!a)return!0;a=a.asList();for(var b=0,c=a.length;b<c;b++)
if(!this.hasFeature(a[b]))return!1;return!0};storeLocator.Store.prototype.getDetails=function(){return this.props_};storeLocator.Store.prototype.generateFieldsHTML_=function(a){for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c];var hiddenField="";if(e=='URLBooking'){hiddenField=' hidden '+this.props_["URLPath"];}
else if(e=='EnrolmentStatus'||e=='Email'||e=='EnrolmentEmail'||e=='NurseEmail'||e=='PrimaryHealthOrganisation'||e=='PHOWebsite'||e=='URLPath'||e=='CovidVaccineEmail'||e=='UsesExternalEnrolmentForm'||e=='ExternalEnrolmentFormLink'){hiddenField=' hidden ';}
else if(e=="CovidVaccineBookingStatus"){hiddenField=' hidden ';}
else if(e=="PrescriptionLink"&&this.props_[e]!=""){hiddenField=' hidden ';}
else if(e=="FluBookingStatus"&&this.props_[e]!=""){hiddenField=' hidden ';}
if($('.menu-container .extra-nav-button.enabled').length>2){$('.menu-container nav .nav').addClass('decrease-font-size');}
this.props_[e]&&(b.push('\x3cdiv class\x3d"'),b.push(e),b.push(hiddenField),b.push('"\x3e'),b.push(this.props_[e]),b.push("\x3c/div\x3e"))}
$('#containerLocator').removeClass("show").css("pointer-events","all");return b.join("")};storeLocator.Store.prototype.generateFeaturesHTML_=function(){var a=[];a.push('\x3cul class\x3d"features"\x3e');for(var b=this.features_.asList(),c=0,d;d=b[c];c++)a.push("\x3cli\x3e"),a.push(d.getDisplayName()),a.push("\x3c/li\x3e");a.push("\x3c/ul\x3e");return a.join("")};storeLocator.Store.prototype.getInfoWindowContent=function(){if(!this.content_){var a=['\x3cdiv class\x3d"store"\x3e'];a.push(this.generateFieldsHTML_(["title","address","phone","misc","web"]));a.push(this.generateFeaturesHTML_());a.push("\x3c/div\x3e");this.content_=a.join("")
alert("Get info");}
return this.content_};storeLocator.Store.prototype.getInfoPanelContent=function(){return this.getInfoWindowContent()};storeLocator.Store.infoPanelCache_={};storeLocator.Store.prototype.getInfoPanelItem=function(){var a=storeLocator.Store.infoPanelCache_,b=this.getId();if(!a[b]){var c=this.getInfoPanelContent();if(this.props_["URLPath"]=='The-Doctors-Whakatipu'){a[b]=$('\x3cli class\x3d"store hidden" id\x3d"store-'+this.getId()+'"\x3e'+c+"\x3c/li\x3e")[0]}
else{a[b]=$('\x3cli class\x3d"store" id\x3d"store-'+this.getId()+'"\x3e'+c+"\x3c/li\x3e")[0]}}
return a[b]};storeLocator.Store.prototype.distanceTo=function(a){var b=this.getLocation(),c=storeLocator.toRad_(b.lat()),d=storeLocator.toRad_(b.lng()),b=storeLocator.toRad_(a.lat()),e=storeLocator.toRad_(a.lng());a=b-c;d=e-d;c=Math.sin(a/2)*Math.sin(a/2)+Math.cos(c)*Math.cos(b)*Math.sin(d/2)*Math.sin(d/2);return 12742*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))};storeLocator.DataFeed=function(){};storeLocator.DataFeed=storeLocator.DataFeed;storeLocator.DataFeed.prototype.getStores=function(a,b,c){};storeLocator.View=function(a,b,c,d){this.markerCluster_=d;this.map_=a;this.data_=b;this.settings_=$.extend({updateOnPan:!0,geolocation:!0,features:new storeLocator.FeatureSet},c);this.init_();google.maps.event.trigger(this,"load");this.set("featureFilter",new storeLocator.FeatureSet)};storeLocator.View=storeLocator.View;storeLocator.View.prototype=new google.maps.MVCObject;storeLocator.View.prototype.geolocate_=function(){var a=this;window.navigator&&navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(b){b=new google.maps.LatLng(b.coords.latitude,b.coords.longitude);a.getMap().setCenter(b);a.getMap().setZoom(10);google.maps.event.trigger(a,"load")},void 0,{maximumAge:6E4,timeout:1E4})};storeLocator.View.prototype.init_=function(){this.settings_.geolocation&&this.geolocate_();this.markerCache_={};this.infoWindow_=new google.maps.InfoWindow;var a=this,b=this.getMap();this.set("updateOnPan",this.settings_.updateOnPan);google.maps.event.addListener(this.infoWindow_,"closeclick",function(){a.highlight(null)});google.maps.event.addListener(b,"click",function(){a.highlight(null);a.infoWindow_.close()})};storeLocator.View.prototype.updateOnPan_changed=function(){this.updateOnPanListener_&&google.maps.event.removeListener(this.updateOnPanListener_);if(this.get("updateOnPan")&&this.getMap()){var a=this,b=this.getMap();this.updateOnPanListener_=google.maps.event.addListener(b,"idle",function(){a.refreshView()})}};storeLocator.View.prototype.addStoreToMap=function(a){var b=this.getMarker(a);a.setMarker(b);var c=this;var mc=this.getMarkerClusterer();b.clickListener_=google.maps.event.addListener(b,"click",function(){c.highlight(a,!1)});mc.addMarker(b);};storeLocator.View.prototype.createMarker=function(a){a={position:a.getLocation()};var b=this.settings_.markerIcon;b&&(a.icon=b);return new google.maps.Marker(a)};storeLocator.View.prototype.getMarker=function(a){var b=this.markerCache_,c=a.getId();b[c]||(b[c]=this.createMarker(a));return b[c]};storeLocator.View.prototype.getInfoWindow=function(a){if(!a)return this.infoWindow_;a=$(a.getInfoWindowContent());this.infoWindow_.setContent(a[0]);return this.infoWindow_};storeLocator.View.prototype.getFeatures=function(){return this.settings_.features};storeLocator.View.prototype.getFeatureById=function(a){if(!this.featureById_){this.featureById_={};for(var b=0,c;c=this.settings_.features[b];b++)this.featureById_[c.getId()]=c}
return this.featureById_[a]};storeLocator.View.prototype.featureFilter_changed=function(){google.maps.event.trigger(this,"featureFilter_changed",this.get("featureFilter"));this.get("stores")&&this.clearMarkers()};storeLocator.View.prototype.clearMarkers=function(){for(var a in this.markerCache_){this.markerCache_[a].setMap(null);var b=this.markerCache_[a].clickListener_;b&&google.maps.event.removeListener(b)}};storeLocator.View.prototype.refreshView=function(){var a=this;this.data_.getStores(this.getMap().getBounds(),this.get("featureFilter"),function(b){var c=a.get("stores");if(c)
for(var d=0,e=c.length;d<e;d++)google.maps.event.removeListener(c[d].getMarker().clickListener_);a.set("stores",b)})};storeLocator.View.prototype.stores_changed=function(){for(var a=this.get("stores"),b=0,c;c=a[b];b++)this.addStoreToMap(c)};storeLocator.View.prototype.getMap=function(){return this.map_};storeLocator.View.prototype.getMarkerClusterer=function(){return this.markerCluster_};storeLocator.View.prototype.highlight=function(a,b){var c=this.getInfoWindow(a);a?(c=this.getInfoWindow(a),a.getMarker()?c.open(this.getMap(),a.getMarker()):(c.setPosition(a.getLocation()),c.open(this.getMap())),b&&this.getMap().panTo(a.getLocation()),this.getMap().getStreetView().getVisible()&&this.getMap().getStreetView().setPosition(a.getLocation())):c.close();this.set("selectedStore",a)};storeLocator.View.prototype.selectedStore_changed=function(){google.maps.event.trigger(this,"selectedStore_changed",this.get("selectedStore"))};storeLocator.ViewOptions=function(){};})(jQuery);
;;;function renderMap(){var map=new google.maps.Map(document.getElementById('map-canvas'),{center:new google.maps.LatLng(-41.1896919,172.4495681),zoom:5,mapTypeId:google.maps.MapTypeId.ROADMAP});var mc=new MarkerClusterer(map,[],{styles:[{url:"/DesktopModules/NetPotential/StoreLocator/images/cluster.png",height:37,width:37,anchor:[0,0],textColor:"#fff",textSize:18}],gridSize:40,maxZoom:3});var panelId='panel';var panelDiv=document.getElementById(panelId);panelDiv.innerHTML='';var data=new storeLocator.RemoteDataFeed({url:'/DesktopModules/StoreLocator/API/Store/All',propertiesModifier:function(props){var addressLine1=join([props.StreetNumber,props.StreetName],', ');var locality=join([props.Suburb,props.Postcode],', ');return{id:props.UUID,title:props.Title,address:join([addressLine1,locality],'<br />')};}});var useLocationQueryString=window.location.href.match(/(\?\&)?uselocation=([^&]+)/i);var useLocation=!!(useLocationQueryString&&useLocationQueryString.length);var markerIcon='/DesktopModules/NetPotential/StoreLocator/images/marker.png';if(document.domain.includes("housecall")){markerIcon='/DesktopModules/NetPotential/StoreLocator/images/hc-marker.png';}
var view=new storeLocator.View(map,data,{geolocation:useLocation,markerIcon:markerIcon},mc);var store=new storeLocator.Panel(panelDiv,{view:view});window.Store=store;window.StoreView=view;var storeSearchPosition_=store.searchPosition;store.searchPosition=function(){if(arguments.length>=1&&arguments[0].length){var postCode=parseInt(arguments[0]);if(!isNaN(postCode)){arguments[0]='NZ '+arguments[0];}}
storeSearchPosition_.apply(this,arguments);}
if(!useLocation){var postCodeQueryString=window.location.href.match(/(\?\&)?postcode=([^&]+)/i);if(postCodeQueryString&&postCodeQueryString.length==3){var postCode=window.decodeURI(postCodeQueryString[2]);if(postCode&&postCode.length){setTimeout(function(){$(panelDiv).find('input').val(postCode);store.searchPosition(postCode);},50);}}}
$('form #'+panelId+' form').on('click','button',function(){var $form=$(this).closest('form');var filter=$form.find('input').val();store.searchPosition(filter);});$(panel).find('.location-search-geolocate').on('click',function(){if(view&&view.geolocate_){view.geolocate_();}else{if(useLocation){window.location.reload();}else{var url=window.location.href;window.location.href=url+(url.indexOf('?')>=0?'&':'?')+'uselocation=✓';}}
return false;});}
google.maps.event.addDomListener(window,'load',function(){if($('#map-canvas').parents("#containerLocator").length==0&&$('#map-canvas').children().length==0){renderMap();}});$(document).on('click','[data-locator]',function(e){e.preventDefault();if($('#map-canvas').parents("#containerLocator").length>0&&$('#map-canvas').children().length==0){renderMap();}
$('#containerLocator').modal();});function join(arr,sep){var parts=[];for(var i=0,ii=arr.length;i<ii;i++){arr[i]&&parts.push(arr[i]);}
return parts.join(sep);}
;;;storeLocator.RemoteDataFeed=function(opts){this.url_=opts['url'];if(opts['propertiesModifier']){this.propertiesModifier_=opts['propertiesModifier'];}};storeLocator['RemoteDataFeed']=storeLocator.RemoteDataFeed;storeLocator.RemoteDataFeed.prototype.getStores=function(bounds,features,callback){var that=this;var center=bounds.getCenter();$.getJSON(this.url_,function(resp){var stores=that.parse_(resp);that.sortByDistance_(center,stores);Cookies.set('stores',stores);callback(stores);});};storeLocator.RemoteDataFeed.prototype.latLngToWkt_=function(point){return'ST_POINT('+point.lng()+', '+point.lat()+')';};storeLocator.RemoteDataFeed.prototype.listenForMapZoom_=function(){var that=this;var view=(this.get('view'));if(this.mapZoomedListener_){google.maps.event.removeListener(this.mapZoomedListener_);}
this.mapZoomedListener_=google.maps.event.addListener(view,'zoom_changed',function(){zoomLevel=view.getMap().getZoom();console.log('Zoom level: '+zoomLevel);});};storeLocator.RemoteDataFeed.prototype.boundsToRect_=function(bounds){var ne=bounds.getNorthEast();var sw=bounds.getSouthWest();return["RECTANGLE(LATLNG(",sw.lat(),',',sw.lng(),'), LATLNG(',ne.lat(),',',sw.lng(),')',")"].join('');};storeLocator.RemoteDataFeed.prototype.boundsToWkt_=function(bounds){var ne=bounds.getNorthEast();var sw=bounds.getSouthWest();return["ST_GEOMFROMTEXT('POLYGON ((",sw.lng(),' ',sw.lat(),', ',ne.lng(),' ',sw.lat(),', ',ne.lng(),' ',ne.lat(),', ',sw.lng(),' ',ne.lat(),', ',sw.lng(),' ',sw.lat(),"))')"].join('');};storeLocator.Store.prototype.getInfoWindowContent=function(){if(!this.content_){var fields=['Title','BuildingName','StreetNo','StreetName','Suburb','City','Postcode','Phone','URLBooking','EnrolmentStatus','Email','EnrolmentEmail','NurseEmail','CovidVaccineEmail','URLPath','PrimaryHealthOrganisation','PHOWebsite','PrescriptionLink','CovidVaccineBookingStatus','FluBookingStatus','UsesExternalEnrolmentForm','ExternalEnrolmentFormLink'];var html=['<div class="store">'];html.push(this.generateFieldsHTML_(fields));html.push(this.generateFeaturesHTML_());html.push('</div>');this.content_=html.join('');}
return this.content_;};storeLocator.RemoteDataFeed.prototype.parse_=function(data){if(data['error']){window.alert(data['error']['message']);return[];}
var rows=data['rows'];if(!rows){return[];}
var stores=[];var columns=data['columns'];geometryIndex=columns.indexOf('Geometry');titleIndex=columns.indexOf('Title');buildingNameIndex=columns.indexOf('BuildingName');streetNoIndex=columns.indexOf('StreetNo');streetNameIndex=columns.indexOf('StreetName');suburbIndex=columns.indexOf('Suburb');cityIndex=columns.indexOf('City');postcodeIndex=columns.indexOf('Postcode');phoneIndex=columns.indexOf('Phone');urlPathIndex=columns.indexOf('URLPath');urlBookingIndex=columns.indexOf('URLBooking');enrolmentStatus=columns.indexOf('EnrolmentStatus');email=columns.indexOf('Email');enrolmentEmail=columns.indexOf('EnrolmentEmail');nurseEmail=columns.indexOf('NurseEmail');covidVaccineEmail=columns.indexOf('CovidVaccineEmail');urlPath=columns.indexOf('URLPath');primaryHealthOrganisation=columns.indexOf('PrimaryHealthOrganisation');phoWebsite=columns.indexOf('PHOWebsite');prescriptionLink=columns.indexOf('PrescriptionLink');covidVaccineBookingStatus=columns.indexOf('CovidVaccineBookingStatus');fluBookingStatus=columns.indexOf('FluBookingStatus');usesExternalEnrolmentForm=columns.indexOf('UsesExternalEnrolmentForm');externalEnrolmentFormLink=columns.indexOf('ExternalEnrolmentFormLink');for(var i=0,row;row=rows[i];i++){var props={UUID:i,Geometry:row[geometryIndex],Title:row[titleIndex],BuildingName:row[buildingNameIndex],StreetNo:row[streetNoIndex],StreetName:row[streetNameIndex],Suburb:row[suburbIndex],City:row[cityIndex],Postcode:row[postcodeIndex],Phone:row[phoneIndex],URLPath:row[urlPathIndex],URLBooking:row[urlBookingIndex],EnrolmentStatus:row[enrolmentStatus],Email:row[email],EnrolmentStatus:row[enrolmentStatus],Email:row[email],EnrolmentEmail:row[enrolmentEmail],NurseEmail:row[nurseEmail],CovidVaccineEmail:row[covidVaccineEmail],URLPath:row[urlPath],PrimaryHealthOrganisation:row[primaryHealthOrganisation],PHOWebsite:row[phoWebsite],PrescriptionLink:row[prescriptionLink],CovidVaccineBookingStatus:row[covidVaccineBookingStatus],FluBookingStatus:row[fluBookingStatus],UsesExternalEnrolmentForm:row[usesExternalEnrolmentForm],ExternalEnrolmentFormLink:row[externalEnrolmentFormLink]};var position=this.getGoogleMapsLatLngFromString_(props.Geometry);var store=new storeLocator.Store(props.UUID,position,null,props);stores.push(store);}
return stores;};storeLocator.RemoteDataFeed.prototype.getGoogleMapsLatLngFromString_=function(geometry){var lat=geometry.replace(/\s*\,.*/,'');var lng=geometry.replace(/.*,\s*/,'');var latLng=new google.maps.LatLng(parseFloat(lat),parseFloat(lng));return latLng;};storeLocator.RemoteDataFeed.prototype.propertiesModifier_=function(props){return props;};storeLocator.RemoteDataFeed.prototype.sortByDistance_=function(latLng,stores){stores.sort(function(a,b){return a.distanceTo(latLng)-b.distanceTo(latLng);});};storeLocator.RemoteDataFeedOptions=function(){};storeLocator.RemoteDataFeedOptions.prototype.tableId;storeLocator.RemoteDataFeedOptions.prototype.apiKey;storeLocator.RemoteDataFeedOptions.prototype.propertiesModifier;String.prototype.pluralise=function(count,plural){if(plural==null){plural=this+'s';}
return(count==1?this:this+plural)}
storeLocator.Panel.prototype.selectedStore_changed=function(){$('.highlighted',this.storeList_).removeClass('highlighted');var that=this;var store=this.get('selectedStore');if(!store){return;}
this.directionsTo_=store;var storeDetailURL=store.getDetails().URLPath;if(storeDetailURL.indexOf('http')>=0){window.location.href=storeDetailURL;return;}
else{storeDetailURL="https://thedoctors.co.nz/"+storeDetailURL;}
this.storeList_.find('#store-'+store.getId()).addClass('highlighted');if(this.settings_['directions']){this.directionsPanel_.find('.directions-to').val(store.getDetails().title);}
var node=that.get('view').getInfoWindow().getContent();var storeDetails=store.getDetails();var directionsURLBase="https://www.google.com/maps/dir/Current+Location/";var mapSearchArray=[storeDetails.Title,storeDetails.StreetNo,storeDetails.StreetName,storeDetails.Suburb,storeDetails.City,storeDetails.Postcode];var mapSearchString=mapSearchArray.join('+').replace(' ','+');var directionsURL=directionsURLBase+mapSearchString;var directionsLink=$('<a/>').text('Directions').attr('target','_blank').attr('href',directionsURL).addClass('action').addClass('directions').click(function(){dataLayer.push({'event':'trackEvent','eventCategory':'PracticeDetails','eventAction':'Directions','eventLabel':$(this).parent().find(".Title").text()});});var callLink=$('<a/>').text('Call').attr('href','tel:'+storeDetails.Phone).addClass('action').click(function(){dataLayer.push({'event':'trackEvent','eventCategory':'PracticeDetails','eventAction':'Call','eventLabel':$(this).parent().find(".Title").text()});});var bookingLink=$('<a/>').text('Book an Appointment').attr('href',storeDetails.URLBooking).attr('target','_blank').addClass('action').click(function(){insertTrackEvent($(this).parent().find(".URLBooking").text(),$(this).parent().find(".Title").text())});$(node).append(callLink).append(bookingLink);if(storeDetails.PrescriptionLink!==""){var prescriptionLink=$('<a/>').text('Repeat Prescription').attr('href',storeDetails.PrescriptionLink).attr('target','_blank').addClass('action');$(node).append(prescriptionLink);}
var storeDetailPage=$('<a/>').text('More Info').attr('href',storeDetailURL).addClass('action').addClass('storedetailpage');if(!document.domain.includes("thedoctors")){storeDetailPage.attr("target","_blank");}
var streetViewLink=$('<a/>').text('Street view').attr('href','javascript:;').addClass('action').addClass('streetview');that.get('view').getMap().setOptions({center:store.getLocation(),zoom:16});streetViewLink.click(function(){var streetView=that.get('view').getMap().getStreetView();streetView.setPosition(store.getLocation());streetView.setVisible(true);});$(node).append(storeDetailPage).append(directionsLink);$('#containerLocator').animate({scrollTop:$("#map-canvas").offset().top},2000);};
;;;var DNN_COL_DELIMITER=String.fromCharCode(16);var DNN_ROW_DELIMITER=String.fromCharCode(15);var __dnn_m_bPageLoaded=false;if(window.addEventListener){window.addEventListener("load",__dnn_Page_OnLoad,false)}else{window.attachEvent("onload",__dnn_Page_OnLoad)}function __dnn_ClientAPIEnabled(){return typeof(dnn)!="undefined"&&typeof(dnn.dom)!="undefined"}function __dnn_Page_OnLoad(){if(__dnn_ClientAPIEnabled()){dnn.dom.attachEvent(window,"onscroll",__dnn_bodyscroll)}__dnn_m_bPageLoaded=true}function __dnn_KeyDown(iKeyCode,sFunc,e){if(e==null){e=window.event}if(e.keyCode==iKeyCode){eval(unescape(sFunc));return false}}function __dnn_bodyscroll(){var a=document.forms[0];if(__dnn_ClientAPIEnabled()&&__dnn_m_bPageLoaded&&typeof(a.ScrollTop)!="undefined"){a.ScrollTop.value=document.documentElement.scrollTop?document.documentElement.scrollTop:dnn.dom.getByTagName("body")[0].scrollTop}}function __dnn_setScrollTop(c){if(__dnn_ClientAPIEnabled()){if(c==null){c=document.forms[0].ScrollTop.value}var a=dnn.getVar("ScrollToControl");if(a!=null&&a.length>0){var b=dnn.dom.getById(a);if(b!=null){c=dnn.dom.positioning.elementTop(b);dnn.setVar("ScrollToControl","")}}if(document.getElementsByTagName("html")[0].style.overflow!="hidden"){window.scrollTo(0,c)}}}function __dnn_SetInitialFocus(a){var b=dnn.dom.getById(a);if(b!=null&&__dnn_CanReceiveFocus(b)){b.focus()}}function __dnn_CanReceiveFocus(b){if(b.style.display!="none"&&b.tabIndex>-1&&b.disabled==false&&b.style.visible!="hidden"){var a=b.parentElement;while(a!=null&&a.tagName!="BODY"){if(a.style.display=="none"||a.disabled||a.style.visible=="hidden"){return false}a=a.parentElement}return true}else{return false}}function __dnn_ContainerMaxMin_OnClick(i,b){var g=dnn.dom.getById(b);if(g!=null){var e=i.childNodes[0];var l=dnn.getVar("containerid_"+b);var j=dnn.getVar("cookieid_"+b);var d=e.src.toLowerCase().substr(e.src.lastIndexOf("/"));var a;var h;var k;if(dnn.getVar("min_icon_"+l)){k=dnn.getVar("min_icon_"+l)}else{k=dnn.getVar("min_icon")}if(dnn.getVar("max_icon_"+l)){h=dnn.getVar("max_icon_"+l)}else{h=dnn.getVar("max_icon")}a=h.toLowerCase().substr(h.lastIndexOf("/"));var c=5;var f=dnn.getVar("animf_"+b);if(f!=null){c=new Number(f)}if(d==a){e.src=k;dnn.dom.expandElement(g,c);e.title=dnn.getVar("min_text");if(j!=null){if(dnn.getVar("__dnn_"+l+":defminimized")=="true"){dnn.dom.setCookie(j,"true",365)}else{dnn.dom.deleteCookie(j)}}else{dnn.setVar("__dnn_"+l+"_Visible","true")}}else{e.src=h;dnn.dom.collapseElement(g,c);e.title=dnn.getVar("max_text");if(j!=null){if(dnn.getVar("__dnn_"+l+":defminimized")=="true"){dnn.dom.deleteCookie(j)}else{dnn.dom.setCookie(j,"false",365)}}else{dnn.setVar("__dnn_"+l+"_Visible","false")}}return true}return false}function __dnn_Help_OnClick(a){var b=dnn.dom.getById(a);if(b!=null){if(b.style.display=="none"){b.style.display=""}else{b.style.display="none"}return true}return false}function __dnn_SectionMaxMin(f,c){var d=dnn.dom.getById(c);if(d!=null){var g=f.getAttribute("max_icon");var e=f.getAttribute("min_icon");var a=f.getAttribute("userctr")!=null;var b;if(d.style.display=="none"){f.src=e;d.style.display="";if(a){b="True"}else{dnn.setVar(f.id+":exp",1)}}else{f.src=g;d.style.display="none";if(a){b="False"}else{dnn.setVar(f.id+":exp",0)}}if(a){dnncore.setUserProp(f.getAttribute("userctr"),f.getAttribute("userkey"),b,null)}return true}return false}function __dnn_enableDragDrop(){var b=dnn.getVar("__dnn_dragDrop").split(";");var e;for(var c=0;c<b.length;c++){e=b[c].split(" ");if(e[0].length>0){var a=dnn.dom.getById(e[0]);var d=dnn.dom.getById(e[1]);if(a!=null&&d!=null){a.setAttribute("moduleid",e[2]);dnn.dom.positioning.enableDragAndDrop(a,d,"__dnn_dragComplete()","__dnn_dragOver()")}}}}var __dnn_oPrevSelPane;var __dnn_oPrevSelModule;var __dnn_dragEventCount=0;function __dnn_dragOver(){__dnn_dragEventCount++;if(__dnn_dragEventCount%75!=0){return}var c=dnn.dom.getById(dnn.dom.positioning.dragCtr.contID);var a=__dnn_getMostSelectedPane(dnn.dom.positioning.dragCtr);if(__dnn_oPrevSelPane!=null){__dnn_oPrevSelPane.pane.style.border=__dnn_oPrevSelPane.origBorder}if(a!=null){__dnn_oPrevSelPane=a;a.pane.style.border="4px double "+DNN_HIGHLIGHT_COLOR;var e=__dnn_getPaneControlIndex(c,a);var b;var f;for(var d=0;d<a.controls.length;d++){if(e>d&&a.controls[d].id!=c.id){b=a.controls[d]}if(e<=d&&a.controls[d].id!=c.id){f=a.controls[d];break}}if(__dnn_oPrevSelModule!=null){dnn.dom.getNonTextNode(__dnn_oPrevSelModule.control).style.border=__dnn_oPrevSelModule.origBorder}if(f!=null){__dnn_oPrevSelModule=f;dnn.dom.getNonTextNode(f.control).style.borderTop="5px groove "+DNN_HIGHLIGHT_COLOR}else{if(b!=null){__dnn_oPrevSelModule=b;dnn.dom.getNonTextNode(b.control).style.borderBottom="5px groove "+DNN_HIGHLIGHT_COLOR}}}}function __dnn_dragComplete(){var f=dnn.dom.getById(dnn.dom.positioning.dragCtr.contID);var d=f.getAttribute("moduleid");if(__dnn_oPrevSelPane!=null){__dnn_oPrevSelPane.pane.style.border=__dnn_oPrevSelPane.origBorder}if(__dnn_oPrevSelModule!=null){dnn.dom.getNonTextNode(__dnn_oPrevSelModule.control).style.border=__dnn_oPrevSelModule.origBorder}var b=__dnn_getMostSelectedPane(dnn.dom.positioning.dragCtr);var e;if(b==null){var a=__dnn_Panes();for(var c=0;c<a.length;c++){if(a[c].id==f.parentNode.id){b=a[c]}}}if(b!=null){e=__dnn_getPaneControlIndex(f,b);__dnn_MoveToPane(b,f,e);dnn.callPostBack("MoveToPane","moduleid="+d,"pane="+b.paneName,"order="+e*2)}}function __dnn_MoveToPane(a,e,d){if(a!=null){var c=new Array();for(var b=d;b<a.controls.length;b++){if(a.controls[b].control.id!=e.id){c[c.length]=a.controls[b].control}dnn.dom.removeChild(a.controls[b].control)}dnn.dom.appendChild(a.pane,e);e.style.top=0;e.style.left=0;e.style.position="relative";for(var b=0;b<c.length;b++){dnn.dom.appendChild(a.pane,c[b])}__dnn_RefreshPanes()}else{e.style.top=0;e.style.left=0;e.style.position="relative"}}function __dnn_RefreshPanes(){var b=dnn.getVar("__dnn_Panes").split(";");var a=dnn.getVar("__dnn_PaneNames").split(";");__dnn_m_aryPanes=new Array();for(var c=0;c<b.length;c++){if(b[c].length>0){__dnn_m_aryPanes[__dnn_m_aryPanes.length]=new __dnn_Pane(dnn.dom.getById(b[c]),a[c])}}}var __dnn_m_aryPanes;var __dnn_m_aryModules;function __dnn_Panes(){if(__dnn_m_aryPanes==null){__dnn_m_aryPanes=new Array();__dnn_RefreshPanes()}return __dnn_m_aryPanes}function __dnn_Modules(a){if(__dnn_m_aryModules==null){__dnn_RefreshPanes()}return __dnn_m_aryModules[a]}function __dnn_getMostSelectedPane(g){var c=new dnn.dom.positioning.dims(g);var f=0;var a;var h;for(var e=0;e<__dnn_Panes().length;e++){var b=__dnn_Panes()[e];var d=new dnn.dom.positioning.dims(b.pane);a=dnn.dom.positioning.elementOverlapScore(d,c);if(a>f){f=a;h=b}}return h}function __dnn_getPaneControlIndex(f,b){if(b==null){return}var a=new dnn.dom.positioning.dims(f);var e;if(b.controls.length==0){return 0}for(var c=0;c<b.controls.length;c++){e=b.controls[c];var d=new dnn.dom.positioning.dims(e.control);if(a.t<d.t){return e.index}}if(e!=null){return e.index+1}else{return 0}}function __dnn_Pane(a,b){this.pane=a;this.id=a.id;this.controls=new Array();this.origBorder=a.style.border;this.paneName=b;var f=0;var e="";for(var d=0;d<a.childNodes.length;d++){var g=a.childNodes[d];if(dnn.dom.isNonTextNode(g)){if(__dnn_m_aryModules==null){__dnn_m_aryModules=new Array()}var c=g.getAttribute("moduleid");if(c!=null&&c.length>0){e+=c+"~";this.controls[this.controls.length]=new __dnn_PaneControl(g,f);__dnn_m_aryModules[c]=g.id;f+=1}}}this.moduleOrder=e}function __dnn_PaneControl(a,b){this.control=a;this.id=a.id;this.index=b;this.origBorder=a.style.border}function __dnn_ShowModalPage(a){dnnModal.show(a,true,550,950,true,"")}function __dnncore(){this.GetUserVal=0;this.SetUserVal=1}__dnncore.prototype={getUserProp:function(b,c,a){this._doUserCallBack(dnncore.GetUserVal,b,c,null,new dnncore.UserPropArgs(b,c,a))},setUserProp:function(c,d,a,b){this._doUserCallBack(dnncore.SetUserVal,c,d,a,new dnncore.UserPropArgs(c,d,b))},_doUserCallBack:function(c,d,e,a,b){if(dnn&&dnn.xmlhttp){var f=c+COL_DELIMITER+d+COL_DELIMITER+e+COL_DELIMITER+a;dnn.xmlhttp.doCallBack("__Page",f,dnncore._callBackSuccess,b,dnncore._callBackFail,null,true,null,0)}else{alert("Client Personalization not enabled")}},_callBackSuccess:function(a,b,c){if(b.pFunc){b.pFunc(b.namingCtr,b.key,a)}},_callBackFail:function(a,b){window.status=a}};__dnncore.prototype.UserPropArgs=function(b,c,a){this.namingCtr=b;this.key=c;this.pFunc=a};var dnncore=new __dnncore();
;;;(function($){$.dnnSF=function(moduleId){var base=this;base.getServiceRoot=function(moduleName){var serviceRoot=dnn.getVar("sf_siteRoot","/");serviceRoot+="API/"+moduleName+"/";return serviceRoot;};base.getTabId=function(){return dnn.getVar("sf_tabId",-1);};base.getModuleId=function(){return moduleId;};base.setModuleHeaders=function(xhr){var tabId=base.getTabId();if(tabId>-1){xhr.setRequestHeader("ModuleId",base.getModuleId());xhr.setRequestHeader("TabId",tabId);}var afValue=base.getAntiForgeryValue();if(afValue){xhr.setRequestHeader("RequestVerificationToken",afValue);}};base.getAntiForgeryKey=function(){return"__RequestVerificationToken";};base.getAntiForgeryValue=function(){return $('[name="__RequestVerificationToken"]').val();};return base;};$.ServicesFramework=function(moduleId){return new $.dnnSF(moduleId);};})(jQuery);
;;;