if(typeof AC==="undefined"){AC={}}AC.GoogleMap=Class.create({_map:false,_submitted:false,_resultTemplate:null,_letters:["a","b","c","d","e","f","g","h","i","j"],_letterMarkers:["/retail/locator/images/icons/letter_a.png","/retail/locator/images/icons/letter_b.png","/retail/locator/images/icons/letter_c.png","/retail/locator/images/icons/letter_d.png","/retail/locator/images/icons/letter_e.png","/retail/locator/images/icons/letter_f.png","/retail/locator/images/icons/letter_g.png","/retail/locator/images/icons/letter_h.png","/retail/locator/images/icons/letter_i.png","/retail/locator/images/icons/letter_j.png",],_pageCount:0,selectedLocation:false,globalMarkers:new Array(),globalLocations:new Array(),setDelegate:function(a){this.delegate=a
},setValueForKey:function(b,a){this[a]=b},setIdAndObjectForValue:function(b,a){if(typeof b==="string"){this.setValueForKey(b,a+"Id");
this.setValueForKey($(b),a)}else{this.setValueForKey(b.id,a+"Id");this.setValueForKey(b,a)
}},setTemplate:function(b,a){this.setValueForKey(b,a);this[a].removeClassName("template");
b.remove()},setMapElements:function(e,b,d,a,c){this.setMapWrapperElement(e);this.setMapViewElement(b);
this.setMapLegendElement(d);this.setMapOverlayMarkerElement(a);this.setMapOverlayTemplateElement(c)
},setMapWrapperElement:function(a){this.setIdAndObjectForValue(a,"mapWrapper")},setMapViewElement:function(a){this.setIdAndObjectForValue(a,"mapView")
},setMapLegendElement:function(a){this.setIdAndObjectForValue(a,"mapLegend")},setMapOverlayMarkerElement:function(a){this.setIdAndObjectForValue(a,"overlayMarker")
},setMapOverlayTemplateElement:function(a){(typeof a==="string")?this.setTemplate($(a),"overlayMarkerTemplate"):this.setTemplate(a,"overlayMarkerTemplate")
},setResultsElements:function(b,d,f,e,c,a){this.setResultsLoaderElement(b);this.setResultsHeadingAndContainerElements(d,f);
this.setResultsContainerElement(e);this.setResultsPaginationElements(c,a)},setResultsLoaderElement:function(a){this.setIdAndObjectForValue(a,"resultsLoader")
},setResultsHeadingAndContainerElements:function(b,a){this.setIdAndObjectForValue(b,"resultsHeadingContainer");
this.setIdAndObjectForValue(a,"resultsHeading")},_isResultsListSet:false,setResultsContainerElement:function(a){this.setIdAndObjectForValue(a,"resultsContainer");
this.setIdAndObjectForValue(this.resultsContainer.down("ul"),"resultsList");this._isResultsListSet=true;
this.setTemplate(this.resultsList.down(".result.template"),"_resultTemplate");this.setTemplate(this.resultsList.down(".no-result.template"),"_noResultTemplate")
},setResultsPaginationElements:function(b,a){this.setIdAndObjectForValue(b,"prevLink");
this.setIdAndObjectForValue(a,"nextLink")},setResultsCount:function(a){this.setValueForKey(a,"resultsCount")
},setSearchForm:function(a){if(!a){return false}(this.delegate&&typeof(this.delegate.willSetSearchForm)==="function")?this.delegate.willSetSearchForm(this):this.willSetSearchForm();
this.setIdAndObjectForValue(a,"searchForm");this.searchForm.mapquery.name="q";Event.observe(this.searchForm,"submit",this.getSearchResults.bindAsEventListener(this));
(this.delegate&&typeof(this.delegate.didSetSearchForm)==="function")?this.delegate.didSetSearchForm(this):this.didSetSearchForm()
},willSetSearchForm:function(){},_queryFromGet:false,didSetSearchForm:function(){var b=""+window.location.search+"&storename=Apple+Store",a,g,d=false,c,f,e,j=this.searchForm,h;
this._queryString=b.substring((b.indexOf("?"))+1);if(this._queryString!=""){a=this._queryString.split("&");
g=new Array();for(e in a){if(isNaN(e)==false){c=a[e];f=c.split("=");g[f[0]]=f[1]
}}h=g.mapquery||g.q;if(h!=""&&h!=null){j.mapquery.value=h;j.mapquery.value=j.mapquery.value.replace(/\%20/g," ");
j.mapquery.value=j.mapquery.value.replace(/\%2C/g,",");j.mapquery.value=j.mapquery.value.replace(/\+/g," ")
}if(g.storename!=""&&g.storename!=null){j.storename.value=g.storename;j.storename.value=j.storename.value.replace(/\%20/g," ");
j.storename.value=j.storename.value.replace(/\%2C/g,",");j.storename.value=j.storename.value.replace(/\+/g," ")
}if(h!=""&&h!=null){this._queryFromGet=this._queryString;this.getSearchResults()
}}},setAutocompleter:function(b,c){var a=(this.delegate&&typeof(this.delegate.shouldSetAutocompleter)==="function")?this.delegate.shouldSetAutocompleter(this):this.shouldSetAutocompleter();
if(a===false){return false}(this.delegate&&typeof(this.delegate.willSetAutocompleter)==="function")?this.delegate.willSetAutocompleter(this,b,c):this.willSetAutocompleter(b,c);
this._autocompleter=new Ajax.Autocompleter(b,c,"/global/scripts/ac_googlemap_autocomplete.php",{minChars:2,frequency:0.2,afterUpdateElement:this.getSearchResults.bind(this,null)});
(this.delegate&&typeof(this.delegate.didSetAutocompleter)==="function")?this.delegate.didSetAutocompleter(this,b,c):this.didSetAutocompleter(b,c)
},shouldSetAutocompleter:function(){return(!AC.Detector.isiPhone())?true:false},willSetAutocompleter:function(a,b){},didSetAutocompleter:function(a,b){},setGmapFormElements:function(c,a,d,b){this.setGmapFormQueryElement(c);
this.setGmapFormElement(a);this.setGmapFormDirectionsSubTabElement(d);this.setGmapFormToAddrElement(b)
},setGmapFormQueryElement:function(a){this.setIdAndObjectForValue(a,"gmapFormQuery")
},setGmapFormElement:function(a){this.setIdAndObjectForValue(a,"gmapFormElement")
},setGmapFormDirectionsSubTabElement:function(a){this.setIdAndObjectForValue(a,"directionsSubTab")
},setGmapFormToAddrElement:function(a){this.setIdAndObjectForValue(a,"toAddrElement")
},setResultsHeading:function(a){if(a){this.resultsHeading.innerHTML=a;this.resultsHeadingContainer.removeClassName("no-results");
this.resultsHeadingContainer.addClassName("results")}else{this.resultsHeadingContainer.removeClassName("results");
this.resultsHeadingContainer.addClassName("no-results")}},getSearchResults:function(a){if(a){Event.stop(a)
}if(!this._submitted){this._submitted=true;var c=this.searchForm.getAttribute("action"),b=window.location.href.match(c);
if(!b){window.location.href=c+"?"+Form.serialize(this.searchForm)}if(this.resultsLoaderId){Effect.Appear(this.resultsLoaderId,{duration:0.25,queue:"front"})
}this._queryString=this.searchForm.getAttribute("remoteaction")+"?"+Form.serialize(this.searchForm);
if(this.resultsList){this.resultsList.innerHTML="";this._pageCount=0;this.draw()
}}},getMarkerContent:function(a){var b=new Object();if(a.getAttribute("url")!=""){b.url=a.getAttribute("url")
}b.storename=unescape(a.getAttribute("name"));b.imageurl=a.getAttribute("imageurl");
b.streetaddress=a.getAttribute("address");b.locality=a.getAttribute("city");b.region=a.getAttribute("state");
b.postalcode=a.getAttribute("zip");b.tel=a.getAttribute("phone");if(a.getAttribute("applestore")=="yes"&&a.getAttribute("concierge")){b.concierge=a.getAttribute("concierge")
}return b},getMarker:function(o,g,k){var l=new GIcon(G_DEFAULT_ICON),i,n=this._resultTemplate.cloneNode(true),m=n.down(".adr"),h=n.down(".letter"),d=n.down(".storename"),b=n.down(".street-address"),a=n.down(".locality"),q=n.down(".region"),e=n.down(".postal-code"),p=n.down(".tel"),f,c,j=parseInt((this._pageCount*this.resultsCount)+k);
l.image=this._letterMarkers[j];l.iconSize=new GSize(28,39);l.iconAnchor=new GPoint(6,21);
l.infoWindowAnchor=new GPoint(9,5);i=new GMarker(o,l);i.markerContent=this.getMarkerContent(g);
i.internalId=k;GEvent.addListener(i,"click_action",function(){this.showMarkerInfo(i)
}.bind(this));GEvent.addListener(i,"click",function(){this.activateMarker(this.globalLocations[i.internalId])
}.bind(this));n.internalId=k;n.id="location_"+k;h.innerHTML=this._letters[j].toUpperCase();
d.innerHTML=unescape(g.getAttribute("name")).truncate(30);b.innerHTML=g.getAttribute("address");
a.innerHTML=g.getAttribute("city");q.innerHTML=g.getAttribute("state");e.innerHTML=g.getAttribute("zip");
if(AC.Detector.isiPhone()){m.remove();f=document.createElement("a");f.href="http://maps.google.com/maps?daddr="+g.getAttribute("address")+", "+g.getAttribute("city")+", "+g.getAttribute("state")+" "+g.getAttribute("zip");
f.appendChild(m);d.insert({after:f});telNumber="1"+g.getAttribute("phone");telNumber=telNumber.replace(/\(|\)/g,"-");
telNumber=telNumber.replace(/\s/g,"");c=document.createElement("a");c.href="tel:"+telNumber;
c.innerHTML=g.getAttribute("phone")}else{c=document.createTextNode(g.getAttribute("phone"))
}p.appendChild(c);this.globalLocations[n.internalId]=n;this.resultsList.appendChild(n);
this.highlightLocations();this.globalMarkers[k]=i;return i},togglePagination:function(d,a,c){var b=this._pageCount*this.resultsCount;
(b>0)?this.prevLink.addClassName("active"):this.prevLink.removeClassName("active");
((this._pageCount+1)>=c.length/this.resultsCount)?this.nextLink.removeClassName("active"):this.nextLink.addClassName("active")
},nextPage:function(a){if(a){Event.stop(a)}Effect.Appear(this.resultsLoaderId,{duration:0.25,queue:"front"});
Effect.BlindUp(this.resultsContainerId,{afterFinish:function(){this.resultsList.innerHTML="";
this._pageCount++;this.draw()}.bind(this)})},prevPage:function(a){if(a){Event.stop(a)
}Effect.Appear(this.resultsLoaderId,{duration:0.25,queue:"front"});Effect.BlindUp(this.resultsContainerId,{afterFinish:function(){this.resultsList.innerHTML="";
this._pageCount--;this.draw()}.bind(this)})},draw:function(){if(GBrowserIsCompatible()){this.mapWrapper.show();
this.mapLegend.show();if(!this._map){this._map=new GMap2(this.mapView);this._map.addControl(new GLargeMapControl3D());
this._map.addControl(new GScaleControl());this._map.setCenter(new GLatLng(37.926868,-97.294922));
this._map.setZoom(3);if(AC.Detector.isiPhone()){this._map.disablePinchToZoom()}if(this.prevLink){Event.observe(this.prevLink,"click",this.prevPage.bindAsEventListener(this))
}if(this.nextLink){Event.observe(this.nextLink,"click",this.nextPage.bindAsEventListener(this))
}return true}else{if(this.overlayMarker){this.overlayMarker.hide();this.deactivateMarker($("location_"+this.overlayMarker.marker.internalId))
}this._map.clearOverlays()}if(this._queryString===""){this._map.setCenter(new GLatLng(37.926868,-97.294922))
}else{GDownloadUrl(this._queryString,this.showResults.bind(this))}}else{}},showResults:function(h,n){var k=GXml.parse(h),b,c,e,j,a,l=0,g,m,f,o,d;
if(k.getElementsByTagName("store_xml").length>0){this.resultsList.addClassName("locations");
b=k.documentElement.getElementsByTagName("default_location")[0];this._map.setCenter(new GLatLng(b.getAttribute("lat"),b.getAttribute("lng")));
c=b.getAttribute("city")+", "+b.getAttribute("state");this.setResultsHeading(c);
e=k.documentElement.getElementsByTagName("store");a=new GLatLngBounds;d=this._pageCount*this.resultsCount;
end=(e.length<=this.resultsCount||(d+this.resultsCount)>=e.length)?e.length:d+this.resultsCount;
for(g=d;g<end;g++){m=new GLatLng(parseFloat(e[g].getAttribute("lat")),parseFloat(e[g].getAttribute("lng")));
j=this.getMarker(m,e[g],l++);this._map.addOverlay(j);a.extend(m)}this.togglePagination(d,this._pageCount,e);
this._map.setCenter(new GLatLng((a.getSouthWest().lat()+a.getNorthEast().lat())/2,(a.getSouthWest().lng()+a.getNorthEast().lng())/2));
this._map.setZoom(this._map.getBoundsZoomLevel(a));Effect.Fade(this.resultsLoaderId,{duration:0.25,queue:"front"})
}else{if(k.getElementsByTagName("noresult_xml").length>0){this._queryString="";
this._map.setCenter(new GLatLng(37.926868,-97.294922));this._map.setZoom(3);this.setResultsHeading();
this.nextLink.removeClassName("active");this.prevLink.removeClassName("active");
this.resultsList.addClassName("noresults");f=this._noResultTemplate.cloneNode(true);
this.resultsList.appendChild(f);if(this._queryFromGet.length>0&&this._autocompleter){this._autocompleter.activate()
}}}if(AC.Detector.isIE()){Effect.BlindDown(this.resultsContainerId,{afterFinish:function(){this.resultsContainer.style.height="1%"
}.bind(this)})}else{Effect.BlindDown(this.resultsContainerId);Effect.Fade(this.resultsLoaderId,{duration:0.25,queue:"end"})
}this._submitted=false},highlightLocations:function(){var a=this.resultsList.getElementsByTagName("li"),b,c=0;
for(c=0;b=a[c];c++){Event.observe(b,"mouseover",function(){Element.addClassName(this,"hover")
});Event.observe(b,"mouseout",function(){Element.removeClassName(this,"hover")});
Event.observe(b,"click",this.activateMarker.bind(this,b))}},activateMarker:function(a){if(this.selectedLocation==a){return false
}Element.addClassName(a,"selected");GEvent.trigger(this.globalMarkers[a.internalId],"click_action");
if(this.selectedLocation){Element.removeClassName(this.selectedLocation,"selected")
}this.selectedLocation=a},deactivateMarker:function(a){Element.removeClassName(a,"selected");
this.selectedLocation=false},closeMarker:function(a){if(a){Event.stop(a)}this.overlayMarker.hide();
this.deactivateMarker($("location_"+this.overlayMarker.marker.internalId));return false
},showMarkerInfo:function(a){this.mapPoint=this._map.fromLatLngToDivPixel(a.getPoint());
var b=(this.delegate&&typeof(this.delegate.willShowMarkerInfo)==="function")?this.delegate.willShowMarkerInfo(this,a):this.willShowMarkerInfo(a);
this._map.getPane(G_MAP_MARKER_PANE).appendChild(b);b.style.display="block";(this.delegate&&typeof(this.delegate.didShowMarkerInfo)==="function")?this.delegate.didShowMarkerInfo(this,b,a):this.didShowMarkerInfo(b,a)
},willShowMarkerInfo:function(d){var e,f,c,i,h,b,g,a;if(!this.overlayMarker){e=document.createElement("div");
e.style.display="none";e.innerHTML=this.overlayMarkerTemplate.innerHTML;e.id=this.overlayMarkerId;
document.body.appendChild(e)}f=$(this.overlayMarkerId);this.overlayMarker=f;c=f.down(".inside");
if(d.markerContent.url){i=document.createElement("a");i.href=d.markerContent.url;
i.target="_blank";i.innerHTML=d.markerContent.storename}else{i=document.createTextNode(d.markerContent.storename)
}c.down("img").src=d.markerContent.imageurl;c.down("img").alt=d.markerContent.storename;
c.down("h3").innerHTML="";c.down("h3").appendChild(i);c.down(".adr .street-address").innerHTML=d.markerContent.streetaddress;
c.down(".adr .locality").innerHTML=d.markerContent.locality;c.down(".adr .region").innerHTML=d.markerContent.region;
c.down(".adr .postal-code").innerHTML=d.markerContent.postalcode;c.down(".tel").innerHTML=d.markerContent.tel;
c.down(".informationlink").href=d.markerContent.url;if(d.markerContent.concierge){c.down(".reservationlink").href=d.markerContent.concierge;
c.down(".reservationlink").show()}else{c.down(".reservationlink").hide()}b=c.down(".directionslink");
if(AC.Detector.isiPhone()){b.href="http://maps.google.com/maps?daddr="+d.markerContent.streetaddress+", "+d.markerContent.locality+", "+d.markerContent.region+" "+d.markerContent.postalCode
}else{Event.observe(b,"click",this.showDirectionsForm.bindAsEventListener(this))
}g=c.down(".directions");Event.observe(g,"click",this.submitGmapForm.bindAsEventListener(this));
a=f.down(".close");Event.observe(a,"click",this.closeMarker.bindAsEventListener(this));
$(this.directionsSubTabId).hide();f.marker=d;return f},didShowMarkerInfo:function(b,a){this.positionWindow(b,a)
},showDirectionsForm:function(a){if(a){Event.stop(a)}$(this.directionsSubTabId).show();
this.positionWindow(this.overlayMarker,this.overlayMarker.marker);$(this.toAddrElementId).focus()
},positionWindow:function(c,b){var d=parseInt(this.mapPoint.y)-c.offsetHeight-20,a=parseInt(this.mapPoint.x)-50,e;
c.style.top=d+"px";c.style.left=a+"px";e=new GLatLng(b.getPoint().lat(),b.getPoint().lng());
this._map.panTo(e)},submitGmapForm:function(a){if(a){Event.stop(a)}var b="from: "+$(this.toAddrElementId).value;
b+=" to: "+this.overlayMarker.marker.markerContent.streetaddress+", "+this.overlayMarker.marker.markerContent.locality+", "+this.overlayMarker.marker.markerContent.region+" "+this.overlayMarker.marker.markerContent.postalcode;
$(this.gmapFormQueryId).value=b;$(this.gmapFormElementId).submit();return false
}});if(typeof GUnload==="function"){Event.observe(window,"unload",GUnload)};