function LocationDataSource(){$.extend(this,new storeLocator.StaticDataFeed);this.setStores(window.Locations)}var storeLocator=function(){};window.storeLocator=storeLocator;storeLocator.toRad_=function(n){return n*Math.PI/180};storeLocator.Feature=function(n,t){this.id_=n;this.name_=t};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(){this.array_=[];this.hash_={};for(var n=0,t;t=arguments[n];n++)this.add(t)};storeLocator.FeatureSet=storeLocator.FeatureSet;storeLocator.FeatureSet.prototype.toggle=function(n){this.contains(n)?this.remove(n):this.add(n)};storeLocator.FeatureSet.prototype.contains=function(n){return n.getId()in this.hash_};storeLocator.FeatureSet.prototype.getById=function(n){return n in this.hash_?this.array_[this.hash_[n]]:null};storeLocator.FeatureSet.prototype.add=function(n){n&&(this.array_.push(n),this.hash_[n.getId()]=this.array_.length-1)};storeLocator.FeatureSet.prototype.remove=function(n){this.contains(n)&&(this.array_[this.hash_[n.getId()]]=null,delete this.hash_[n.getId()])};storeLocator.FeatureSet.prototype.asList=function(){for(var t,i=[],n=0,r=this.array_.length;n<r;n++)t=this.array_[n],t!==null&&i.push(t);return i};storeLocator.FeatureSet.NONE=new storeLocator.FeatureSet;storeLocator.Store=function(n,t,i,r){this.id_=n;this.location_=t;this.features_=i||storeLocator.FeatureSet.NONE;this.props_=r||{}};storeLocator.Store=storeLocator.Store;storeLocator.Store.prototype.setMarker=function(n){this.marker_=n;google.maps.event.trigger(this,"marker_changed",n)};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(n){return this.features_.contains(n)};storeLocator.Store.prototype.hasAllFeatures=function(n){var i,t,r;if(!n)return!0;for(i=n.asList(),t=0,r=i.length;t<r;t++)if(!this.hasFeature(i[t]))return!1;return!0};storeLocator.Store.prototype.getDetails=function(){return this.props_};storeLocator.Store.prototype.generateFieldsHTML_=function(n){for(var i,t=[],r=0,u=n.length;r<u;r++)i=n[r],this.props_[i]&&(t.push('<div class="'),t.push(i),t.push('">'),i==="slug"?t.push('<a href="/'+this.props_[i]+'" class="btn btn-xs btn-tertiary pull-right" style="margin-left: 10px;">VIEW VENUE <i class="fa fa-chevron-right"><\/i><\/a>'):t.push(this.props_[i]),t.push("<\/div>"));return t.join("")};storeLocator.Store.prototype.generateFeaturesHTML_=function(){var n=[],i,t,r;for(n.push('<ul class="features">'),i=this.features_.asList(),t=0;r=i[t];t++)n.push("<li>"),n.push(r.getDisplayName()),n.push("<\/li>");return n.push("<\/ul>"),n.join("")};storeLocator.Store.prototype.getInfoWindowContent=function(){if(!this.content_){var n=['<div class="storeinner">'];n.push(this.generateFieldsHTML_(["slug","title","address","phone","misc","web"]));n.push(this.generateFeaturesHTML_());n.push("<\/div>");this.content_=n.join("")}return this.content_};storeLocator.Store.prototype.getInfoPanelContent=function(){return this.getInfoWindowContent()};storeLocator.Store.infoPanelCache_={};storeLocator.Store.prototype.getInfoPanelItem=function(){var n=storeLocator.Store.infoPanelCache_,t=this,i=t.getId(),r;return n[i]||(r=t.getInfoPanelContent(),n[i]=$('<li class="store" id="store-'+t.getId()+'">'+r+"<\/li>")[0]),n[i]};storeLocator.Store.prototype.distanceTo=function(n){var t=this.getLocation(),i=storeLocator.toRad_(t.lat()),o=storeLocator.toRad_(t.lng()),r=storeLocator.toRad_(n.lat()),s=storeLocator.toRad_(n.lng()),u=r-i,f=s-o,e=Math.sin(u/2)*Math.sin(u/2)+Math.cos(i)*Math.cos(r)*Math.sin(f/2)*Math.sin(f/2),h=2*Math.atan2(Math.sqrt(e),Math.sqrt(1-e));return 6371*h};storeLocator.StaticDataFeed=function(){this.stores_=[]};storeLocator.StaticDataFeed=storeLocator.StaticDataFeed;storeLocator.StaticDataFeed.prototype.firstCallback_;storeLocator.StaticDataFeed.prototype.setStores=function(n){this.stores_=n;this.firstCallback_?this.firstCallback_():delete this.firstCallback_};storeLocator.StaticDataFeed.prototype.getStores=function(n,t,i){var e,r,u,f;if(!this.stores_.length){e=this;this.firstCallback_=function(){e.getStores(n,t,i)};return}for(r=[],u=0;f=this.stores_[u];u++)f.hasAllFeatures(t)&&r.push(f);this.sortByDistance_(n.getCenter(),r);i(r)};storeLocator.StaticDataFeed.prototype.sortByDistance_=function(n,t){t.sort(function(t,i){return t.distanceTo(n)-i.distanceTo(n)})};storeLocator.Panel=function(n,t){this.el_=$(n);this.el_.addClass("storelocator-panel");this.settings_=$.extend({locationSearch:!0,locationSearchLabel:"Location Search:",locationSearchPlaceholder:"Your Postcode",featureFilter:!0,directions:!0,view:null},t);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 n=this,i,t,f,r,u;if(this.itemCache_={},this.settings_.view&&this.set("view",this.settings_.view),this.filter_=$('<form class="storelocator-filter"/>'),this.el_.append(this.filter_),this.settings_.locationSearch&&(this.locationSearch_=$('<div class="location-search"><h4>'+this.settings_.locationSearchLabel+'<\/h4><input placeholder="'+this.settings_.locationSearchPlaceholder+'"><\/div>'),this.filter_.append(this.locationSearch_),typeof google.maps.places!="undefined"?this.initAutocomplete_():this.filter_.submit(function(){var t=$("input",n.locationSearch_).val();n.searchPosition(t)}),this.filter_.submit(function(){return!1}),google.maps.event.addListener(this,"geocode",function(t){var i,r;if(!t.geometry){n.searchPosition(t.name);return}this.directionsFrom_=t.geometry.location;n.directionsVisible_&&n.renderDirections_();i=n.get("view");i.highlight(null);r=i.getMap();t.geometry.viewport?r.fitBounds(t.geometry.viewport):(r.setCenter(t.geometry.location),r.setZoom(13));i.refreshView();n.listenForStoresUpdate_()})),this.settings_.featureFilter){for(this.featureFilter_=$('<div class="feature-filter"/>'),i=this.get("view").getFeatures().asList(),t=0,f=i.length;t<f;t++)r=i[t],u=$('<input type="checkbox"/>'),u.data("feature",r),$("<label/>").append(u).append(r.getDisplayName()).appendTo(this.featureFilter_);this.filter_.append(this.featureFilter_);this.featureFilter_.find("input").change(function(){var t=$(this).data("feature");n.toggleFeatureFilter_(t);n.get("view").refreshView()})}this.storeList_=$('<ul class="store-list"/>');this.el_.append(this.storeList_);this.settings_.directions&&(this.directionsPanel_=$('<div class="directions-panel"><form><input class="directions-to"/><input type="submit" value="Find directions"/><a href="#" class="close-directions">Close<\/a><\/form><div class="rendered-directions"><\/div><\/div>'),this.directionsPanel_.find(".directions-to").attr("readonly","readonly"),this.directionsPanel_.hide(),this.directionsVisible_=!1,this.directionsPanel_.find("form").submit(function(){return n.renderDirections_(),!1}),this.directionsPanel_.find(".close-directions").click(function(){n.hideDirections()}),this.el_.append(this.directionsPanel_))};storeLocator.Panel.prototype.toggleFeatureFilter_=function(n){var t=this.get("featureFilter");t.toggle(n);this.set("featureFilter",t)};storeLocator.geocoder_=new google.maps.Geocoder;storeLocator.Panel.prototype.listenForStoresUpdate_=function(){var t=this,n=this.get("view");this.storesChangedListener_&&google.maps.event.removeListener(this.storesChangedListener_);this.storesChangedListener_=google.maps.event.addListenerOnce(n,"stores_changed",function(){t.set("stores",n.get("stores"))})};storeLocator.Panel.prototype.searchPosition=function(n){var t=this,i={address:n,bounds:this.get("view").getMap().getBounds(),componentRestrictions:{country:"UK"}};storeLocator.geocoder_.geocode(i,function(n,i){i==google.maps.GeocoderStatus.OK&&google.maps.event.trigger(t,"geocode",n[0])});$.post(window.location.href,{Action:"FindNearestVenue",Location:n})};storeLocator.Panel.prototype.setView=function(n){this.set("view",n)};storeLocator.Panel.prototype.view_changed=function(){var n=this.get("view"),i,r,t;this.bindTo("selectedStore",n);i=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_);r=n.getMap().getCenter();t=function(){n.clearMarkers();i.listenForStoresUpdate_()};this.geolocationListener_=google.maps.event.addListener(n,"load",t);this.zoomListener_=google.maps.event.addListener(n.getMap(),"zoom_changed",t);this.idleListener_=google.maps.event.addListener(n.getMap(),"idle",function(){return i.idle_(n.getMap())});t();this.bindTo("featureFilter",n);this.autoComplete_&&this.autoComplete_.bindTo("bounds",n.getMap())};storeLocator.Panel.prototype.initAutocomplete_=function(){var n=this,t=$("input",this.locationSearch_)[0];this.autoComplete_=new google.maps.places.Autocomplete(t);this.get("view")&&this.autoComplete_.bindTo("bounds",this.get("view").getMap());google.maps.event.addListener(this.autoComplete_,"place_changed",function(){google.maps.event.trigger(n,"geocode",this.getPlace())})};storeLocator.Panel.prototype.idle_=function(n){this.center_?n.getBounds().contains(this.center_)||(this.center_=n.getCenter(),this.listenForStoresUpdate_()):this.center_=n.getCenter()};storeLocator.Panel.NO_STORES_HTML_='<li class="no-stores">There are no stores in this area.<\/li>';storeLocator.Panel.NO_STORES_IN_VIEW_HTML_='<li class="no-stores">Here are the venues that are closest to you<\/li>';storeLocator.Panel.prototype.stores_changed=function(){var e,i,o,n;if(this.get("stores")){var r=this.get("view"),u=r&&r.getMap().getBounds(),s=this,t=this.get("stores"),f=this.get("selectedStore");for(this.storeList_.empty(),t.length?u&&!u.contains(t[0].getLocation())&&this.storeList_.append(storeLocator.Panel.NO_STORES_IN_VIEW_HTML_):this.storeList_.append(storeLocator.Panel.NO_STORES_HTML_),e=function(){r.highlight(this.store,!0)},i=0,o=Math.min(10,t.length);i<o;i++)n=t[i].getInfoPanelItem(),n.store=t[i],f&&t[i].getId()==f.getId()&&$(n).addClass("highlighted"),n.clickHandler_||(n.clickHandler_=google.maps.event.addDomListener(n,"click",e)),s.storeList_.append(n)}};storeLocator.Panel.prototype.selectedStore_changed=function(){var t,n;if($(".highlighted",this.storeList_).removeClass("highlighted"),t=this,n=this.get("selectedStore"),n){this.directionsTo_=n;this.storeList_.find("#store-"+n.getId()).addClass("highlighted");this.settings_.directions&&this.directionsPanel_.find(".directions-to").val(n.getDetails().title);var f=t.get("view").getInfoWindow().getContent(),i=$("<a/>").text("Directions").attr("href","#").addClass("action").addClass("directions"),r=$("<a/>").text("Zoom here").attr("href","#").addClass("action").addClass("zoomhere"),u=$("<a/>").text("Street view").attr("href","#").addClass("action").addClass("streetview");i.click(function(){return t.showDirections(),!1});r.click(function(){t.get("view").getMap().setOptions({center:n.getLocation(),zoom:16})});u.click(function(){var i=t.get("view").getMap().getStreetView();i.setPosition(n.getLocation());i.setVisible(!0)});$(f).append(i).append(r).append(u)}};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 n=this.get("selectedStore");this.featureFilter_.fadeOut();this.storeList_.fadeOut();this.directionsPanel_.find(".directions-to").val(n.getDetails().title);this.directionsPanel_.fadeIn();this.renderDirections_();this.directionsVisible_=!0};storeLocator.Panel.prototype.renderDirections_=function(){var n=this,t;this.directionsFrom_&&this.directionsTo_&&(t=this.directionsPanel_.find(".rendered-directions").empty(),this.directionsService_.route({origin:this.directionsFrom_,destination:this.directionsTo_.getLocation(),travelMode:google.maps.DirectionsTravelMode.DRIVING},function(i,r){if(r==google.maps.DirectionsStatus.OK){var u=n.directionsRenderer_;u.setPanel(t[0]);u.setMap(n.get("view").getMap());u.setDirections(i)}}))};storeLocator.Panel.prototype.featureFilter_changed=function(){this.listenForStoresUpdate_()};storeLocator.PanelOptions=function(){};storeLocator.prototype.locationSearch;storeLocator.PanelOptions.prototype.locationSearchLabel;storeLocator.PanelOptions.prototype.featureFilter;storeLocator.PanelOptions.prototype.directions;storeLocator.PanelOptions.prototype.view;storeLocator.DataFeed=function(){};storeLocator.DataFeed=storeLocator.DataFeed;storeLocator.DataFeed.prototype.getStores=function(){};storeLocator.View=function(n,t,i){this.map_=n;this.data_=t;this.settings_=$.extend({updateOnPan:!0,geolocation:!0,features:new storeLocator.FeatureSet},i);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 n=this;window.navigator&&navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(t){var i=new google.maps.LatLng(t.coords.latitude,t.coords.longitude);n.getMap().setCenter(i);n.getMap().setZoom(11);google.maps.event.trigger(n,"load")},undefined,{maximumAge:6e4,timeout:1e4})};storeLocator.View.prototype.init_=function(){this.settings_.geolocation&&this.geolocate_();this.markerCache_={};this.infoWindow_=new google.maps.InfoWindow;var n=this,t=this.getMap();this.set("updateOnPan",this.settings_.updateOnPan);google.maps.event.addListener(this.infoWindow_,"closeclick",function(){n.highlight(null)});google.maps.event.addListener(t,"click",function(){n.highlight(null);n.infoWindow_.close()})};storeLocator.View.prototype.updateOnPan_changed=function(){if(this.updateOnPanListener_&&google.maps.event.removeListener(this.updateOnPanListener_),this.get("updateOnPan")&&this.getMap()){var n=this,t=this.getMap();this.updateOnPanListener_=google.maps.event.addListener(t,"idle",function(){n.refreshView()})}};storeLocator.View.prototype.addStoreToMap=function(n){var t=this.getMarker(n),i;n.setMarker(t);i=this;t.clickListener_=google.maps.event.addListener(t,"click",function(){i.highlight(n,!1)});t.getMap()!=this.getMap()&&t.setMap(this.getMap())};storeLocator.View.prototype.createMarker=function(n){var t={position:n.getLocation()},i=this.settings_.markerIcon;return i&&(t.icon=i),new google.maps.Marker(t)};storeLocator.View.prototype.getMarker=function(n){var t=this.markerCache_,i=n.getId();return t[i]||(t[i]=this.createMarker(n)),t[i]};storeLocator.View.prototype.getInfoWindow=function(n){if(!n)return this.infoWindow_;var t=$(n.getInfoWindowContent());return this.infoWindow_.setContent(t[0]),this.infoWindow_};storeLocator.View.prototype.getFeatures=function(){return this.settings_.features};storeLocator.View.prototype.getFeatureById=function(n){if(!this.featureById_){this.featureById_={};for(var i=0,t;t=this.settings_.features[i];i++)this.featureById_[t.getId()]=t}return this.featureById_[n]};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(){var n,t;for(n in this.markerCache_)this.markerCache_[n].setMap(null),t=this.markerCache_[n].clickListener_,t&&google.maps.event.removeListener(t)};storeLocator.View.prototype.refreshView=function(){var n=this;this.data_.getStores(this.getMap().getBounds(),this.get("featureFilter"),function(t){var r=n.get("stores"),i,u;if(r)for(i=0,u=r.length;i<u;i++)google.maps.event.removeListener(r[i].getMarker().clickListener_);n.set("stores",t)})};storeLocator.View.prototype.stores_changed=function(){for(var i=this.get("stores"),n=0,t;t=i[n];n++)this.addStoreToMap(t)};storeLocator.View.prototype.getMap=function(){return this.map_};storeLocator.View.prototype.highlight=function(n,t){var i=this.getInfoWindow(n);n?(i=this.getInfoWindow(n),n.getMarker()?i.open(this.getMap(),n.getMarker()):(i.setPosition(n.getLocation()),i.open(this.getMap())),t&&this.getMap().panTo(n.getLocation()),this.getMap().getStreetView().getVisible()&&this.getMap().getStreetView().setPosition(n.getLocation())):i.close();this.set("selectedStore",n)};storeLocator.View.prototype.selectedStore_changed=function(){google.maps.event.trigger(this,"selectedStore_changed",this.get("selectedStore"))};storeLocator.ViewOptions=function(){};storeLocator.ViewOptions.prototype.updateOnPan;storeLocator.ViewOptions.prototype.geolocation;storeLocator.ViewOptions.prototype.features;storeLocator.ViewOptions.prototype.markerIcon;LocationDataSource.prototype.FEATURES_=new storeLocator.FeatureSet;LocationDataSource.prototype.getFeatures=function(){return this.FEATURES_};LocationDataSource.prototype.parse_=function(n){for(var i,r=[],u=n.split("\n"),e=this.parseRow_(u[0]),f=1,t;t=u[f];f++){t=this.toObject_(e,this.parseRow_(t));i=new storeLocator.FeatureSet;i.add(this.FEATURES_.getById("Wheelchair-"+t.Wheelchair));i.add(this.FEATURES_.getById("Audio-"+t.Audio));var o=new google.maps.LatLng(t.Ycoord,t.Xcoord),s=this.join_([t.Shp_num_an,t.Shp_centre],", "),h=this.join_([t.Locality,t.Postcode],", "),c=new storeLocator.Store(t.uuid,o,i,{title:t.Fcilty_nam,address:this.join_([s,t.Street_add,h],"<br>"),hours:t.Hrs_of_bus});r.push(c)}return r};LocationDataSource.prototype.join_=function(n,t){for(var r=[],i=0,u=n.length;i<u;i++)n[i]&&r.push(n[i]);return r.join(t)};LocationDataSource.prototype.parseRow_=function(n){return n.charAt(0)=='"'&&(n=n.substring(1)),n.charAt(n.length-2)=='"'&&(n=n.substring(0,n.length-2)),n.split('","')};LocationDataSource.prototype.toObject_=function(n,t){for(var r={},i=0,u=t.length;i<u;i++)r[n[i]]=t[i];return r}