function IconProviderBase(){this.buildIcon=function(){var a=new GIcon();a.image="/Images/Maps/markers/big/"+this.getIconName()+".png";a.shadow="/Images/Maps/markers/big/shadow.png";a.iconSize=this.iconSize;a.shadowSize=this.shadowSize;a.iconAnchor=this.iconAnchor;a.infoWindowAnchor=this.infoWindowAnchor;return a};this.getIcon=this.buildIcon;this.getIconName=function(){};this.iconSize=new GSize(20,35);this.shadowSize=new GSize(33,35);this.iconAnchor=new GPoint(10,35);this.infoWindowAnchor=new GPoint(5,1)}function PlainIconProvider(){this.getIconName=function(){return"spike"}}PlainIconProvider.prototype=new IconProviderBase();function NumberedIconProvider(){this.index=0;this.getIconName=function(){return ++this.index}}NumberedIconProvider.prototype=new IconProviderBase();function AlphaIconProvider(){this.index=0;this.getIconName=function(){return String.fromCharCode(64+(++this.index))}}AlphaIconProvider.prototype=new IconProviderBase();var gdir;var map;var mgr;var area;var iconProvider=new PlainIconProvider();var markers=$A([]);var initMap=function(f){if(businessesToMap.length===0){return}var b;var a;mgr=new GMarkerManager(f);area=new GLatLngBounds();for(var c=0;c<businessesToMap.length;c++){var e=iconProvider.getIcon();if(businessesToMap[c].id===document.defaultBusinessId){e.image="/Images/Maps/markers/red/"+businessesToMap[c].icon+".png"}else{e.image="/Images/Maps/markers/big/"+businessesToMap[c].icon+".png"}for(var d=0;d<businessesToMap[c].locations.length;d++){extendLocation(businessesToMap[c].locations[d]);a=new GLatLng(businessesToMap[c].locations[d].lat,businessesToMap[c].locations[d].lng);area.extend(a);b=new GMarker(a,e);b.location=businessesToMap[c].locations[d];markers.push(b);businessesToMap[c].locations[d].point=a;businessesToMap[c].locations[d].marker=b}}mgr.addMarkers(markers,5);if(!area.isEmpty()){f.setCenter(area.getCenter(),Math.ceil(f.getBoundsZoomLevel(area)*0.9))}mgr.refresh()};document.highlightBusinessOnMap=function(d){var c=new GLatLngBounds();for(var a=0;a<businessesToMap.length;a++){for(var b=0;b<businessesToMap[a].locations.length;b++){businessesToMap[a].locations[b].marker.setImage("/Images/Maps/markers/big/"+businessesToMap[a].icon+".png")}}for(var a=0;a<businessesToMap.length;a++){if(businessesToMap[a].id===d){for(var b=0;b<businessesToMap[a].locations.length;b++){businessesToMap[a].locations[b].marker.setImage("/Images/Maps/markers/red/"+businessesToMap[a].icon+".png");c.extend(businessesToMap[a].locations[b].point)}}}if(!c.isEmpty()){map.panTo(c.getCenter())}};document.highlightLocationOnMap=function(d){var c=new GLatLngBounds();for(var a=0;a<businessesToMap.length;a++){for(var b=0;b<businessesToMap[a].locations.length;b++){businessesToMap[a].locations[b].marker.setImage("/Images/Maps/markers/big/"+businessesToMap[a].icon+".png")}}for(var a=0;a<businessesToMap.length;a++){for(var b=0;b<businessesToMap[a].locations.length;b++){if(businessesToMap[a].locations[b].id==d){businessesToMap[a].locations[b].marker.setImage("/Images/Maps/markers/red/"+businessesToMap[a].icon+".png");c.extend(businessesToMap[a].locations[b].point)}}}if(!c.isEmpty()){map.panTo(c.getCenter())}};function showDirections(c,a){if(gdir){gdir.clear()}else{gdir=new GDirections(map,$("CV-TurnByTurn"));GEvent.addListener(gdir,"error",handleDirectionErrors);GEvent.addListener(gdir,"addoverlay",function(){map.getInfoWindow().hide();$("CV-TurnByTurnTools").show();setTimeout(function(){markers.each(function(d){if(!d.isHidden()){d.hide()}})},10)})}var b=getLocation(c);if(b){gdir.origin=a;gdir.destination=b;gdir.load("from: "+a+" to: "+b.getAddressString())}}function getLocation(a){var b;businessesToMap.each(function(c){if(b){return}b=c.locations.find(function(d){return parseInt(d.id)===parseInt(a)})});return b}function extendLocation(a){a.getGLatLng=function(){return new GLatLng(this.lat,this.lng,null)};a.getAddressString=function(){var b="";if(this.streetAddress&&this.streetAddress.length>0){b+=this.streetAddress+", "}if(this.city&&this.city.length>0){b+=this.city+", "}if(this.state&&this.state.length>0){b+=this.state+" "}if(this.zipCode&&this.zipCode.length>0){b+=this.zipCode.strip()}return b}}function handleDirectionErrors(){if(gdir.getStatus().code==G_GEO_UNKNOWN_ADDRESS){alert("Sorry, we couldn't locate that address.")}else{alert("We were not able to retrive driving directions.  Please try again.")}}function cloneDirections(){var a=$("CV-DirectionsBlock").cloneNode(true);hookUpDirectionsPanel(a);return a}function initMarkersForDirections(){markers.each(function(a){GEvent.addListener(a,"click",function(){var b=$$("#CV-LocationChooser ul li").find(function(d){return d.locationid==a.location.id});$$("#CV-DirectionsBlock .CV-DirectionsBlockAddress")[0].update(b.innerHTML);$("CV-TurnByTurnTools").down('input[type="hidden"]').value=b.locationid;var c=getLocation(b.locationid);map.openInfoWindow(c.getGLatLng(),cloneDirections(),null);highlightAddress(b.locationid)})})}function hookUpDirectionsPanel(a){Event.observe(a.down("form"),"submit",function(d){var b=Event.element(d);if(b.tagName.toLowerCase()!="form"){b=b.up("form")}Event.stop(d);var c=$F(b.down('input[name="address"]'));if(!c||c.length===0){alert("Please enter an address");return}$("CV-DirectionsBlock").down('input[type="text"]').value=c;$("CV-TurnByTurnTools").hide();$("CV-TurnByTurnTools").down('input[name="address"]').value=c;showDirections(b.up("div").down('input[type="hidden"]').value,$F(b.down('input[name="address"]')))})}function highlightAddress(a){$$("#CV .CV-BusinessLocations li").each(function(b){if(b.locationid!=a){b.removeClassName("selected")}else{b.addClassName("selected")}})}Event.observe(window,"load",function(b){var a=$("CV-Map");if(a){map=new GMap2(a);map.addControl(new GSmallMapControl());map.setCenter(new GLatLng(37.09024,-95.712891),0);map.setZoom(3);initMap(map);$$("#CV .CV-BusinessLocations li").each(function(c){c.locationid=parseInt(c.down('input[type="hidden"]').value);Event.observe(c,"click",function(g){var d=Event.element(g);if(d.tagName.toLowerCase()!="li"){d=d.up("li")}if(!d){return}if(typeof(mapMode)!="undefined"&&mapMode==="directions"){$$("#CV-DirectionsBlock .CV-DirectionsBlockAddress")[0].update(d.innerHTML);$("CV-TurnByTurnTools").down('input[type="hidden"]').value=d.locationid;var f=getLocation(d.locationid);if(gdir&&gdir.origin&&gdir.destination){showDirections(f.id,gdir.origin)}else{map.openInfoWindow(f.getGLatLng(),cloneDirections(),null)}}else{document.highlightLocationOnMap(d.locationid)}highlightAddress(d.locationid)})});markers.each(function(c){GEvent.addListener(c,"click",function(){highlightAddress(c.location.id)})});if(typeof(mapMode)!="undefined"&&mapMode==="directions"){initMarkersForDirections();hookUpDirectionsPanel($("CV-DirectionsBlock"));hookUpDirectionsPanel($("CV-TurnByTurnTools"));Event.observe($("CV-DirectionsEdit"),"click",function(c){Event.stop(c);$("CV-ChangeAddress").toggle();if($("CV-ChangeAddress").visible()){$("CV-DirectionsEdit").innerHTML="Cancel Edit"}else{$("CV-DirectionsEdit").innerHTML="Edit Address"}});$("CV").select(".CV-PrintDirections").each(function(c){Event.observe(c,"click",function(g){Event.stop(g);var f=gdir&&gdir.origin?escape(gdir.origin):"";var d=gdir&&gdir.destination?escape(gdir.destination.getAddressString()):"";if(f&&d){window.open("http://maps.google.com/maps?ie=UTF8&saddr="+f+"&daddr="+d+"&pw=2","Directions","width=770,height=763,scrollbars=yes,resizable=yes",false)}else{d=escape(markers[0].location.getAddressString());window.open("http://maps.google.com/maps?f=d&ie=UTF8&saddr=&daddr="+d,"Directions","width=800",false)}})});if(selectedLocation){map.openInfoWindow(getLocation(selectedLocation).getGLatLng(),cloneDirections(),null)}}}});Event.observe(window,"unload",function(){GUnload()});