    //<![CDATA[
    var map;
    var geocoder;

    function load() {
      if (GBrowserIsCompatible()) {
        geocoder = new GClientGeocoder();
        map = new GMap2(document.getElementById('map'));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(37.766188, -122.398647), 11);
      }
    }

	var myIcon = new GIcon();
	myIcon.image = '/markers/image.png';
	myIcon.printImage = '/markers/printImage.gif';
	myIcon.mozPrintImage = '/markers/mozPrintImage.gif';
	myIcon.iconSize = new GSize(30,30);
	myIcon.shadow = '/markers/shadow.png';
	myIcon.transparent = '/markers/transparent.png';
	myIcon.shadowSize = new GSize(45,30);
	myIcon.printShadow = '/markers/printShadow.gif';
	myIcon.iconAnchor = new GPoint(15,30);
	myIcon.infoWindowAnchor = new GPoint(15,0);
	myIcon.imageMap = [29,0,29,1,29,2,29,3,29,4,29,5,29,6,29,7,29,8,29,9,29,10,29,11,29,12,29,13,29,14,29,15,29,16,29,17,29,18,29,19,29,20,29,21,29,22,29,23,29,24,29,25,29,26,29,27,29,28,29,29,0,29,0,28,0,27,0,26,0,25,0,24,0,23,0,22,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,0,4,0,3,0,2,0,1,0,0];

	markerOptions = { icon:myIcon };

	
   function searchLocations() {
     var address = document.getElementById('addressInput').value;
     geocoder.getLatLng(address, function(latlng) {
       if (!latlng) {
         alert(address + ' not found');
       } else {
         searchLocationsNear(latlng);
       }
     });
   }

   function searchLocationsNear(center) {
     var radius = document.getElementById('radiusSelect').value;
     var searchUrl = 'locate_store_xml.php?lat=' + center.lat() + '&lng=' + center.lng() + '&radius=' + radius;
     GDownloadUrl(searchUrl, function(data) {
       var xml = GXml.parse(data);
       var markers = xml.documentElement.getElementsByTagName('marker');
       map.clearOverlays();

       var sidebar = document.getElementById('sidebar');
       sidebar.innerHTML = '';
       if (markers.length == 0) {
         sidebar.innerHTML = 'We\'re sorry, we couldn\'t find a store near that location. Don\'t live near a store? You can always shop our full collection online at <a href="http://www.teacollection.com/">teacollection.com</a>.';
         map.setCenter(new GLatLng(40, -100), 4);
         return;
       }

       var bounds = new GLatLngBounds();
       for (var i = 0; i < markers.length; i++) {
         var name = markers[i].getAttribute('name');
         var address = markers[i].getAttribute('address');
         var address2 = markers[i].getAttribute('address2');
         var phone = markers[i].getAttribute('phone');
         var city = markers[i].getAttribute('city');
         var state = markers[i].getAttribute('state');
         var zip = markers[i].getAttribute('zip');
         var online = markers[i].getAttribute('online');
         var destinationstore = markers[i].getAttribute('destinationstore');
         var passportstore = markers[i].getAttribute('passportstore');
		 var distance = parseFloat(markers[i].getAttribute('distance'));
         var point = new GLatLng(parseFloat(markers[i].getAttribute('lat')),
                                 parseFloat(markers[i].getAttribute('lng')));
         
         var marker = createMarker(point, name, address, city, state, zip, online);
         map.addOverlay(marker);
         var sidebarEntry = createSidebarEntry(marker, name, address, address2, distance, phone, city, state, zip, destinationstore, passportstore);
         sidebar.appendChild(sidebarEntry);
         bounds.extend(point);
       }
       map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
     });
   }

    function createMarker(point, name, address, city, state, zip, online) {
      var marker = new GMarker(point, markerOptions);
      var html = '<b>' + name + '</b> <br/>' + address + '<br/>' + city + ', ' + state + ' ' + zip + '<br/><a href="http://maps.google.com/maps?q='+ point + '" target="_blank">Get Directions</a>';
      if (online != "")
	  html += ' - <a href="' + online + '" target="_blank" rel="nofollow">Visit Website</a>';
	  GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }

    function createSidebarEntry(marker, name, address, address2, distance, phone, city, state, zip, destinationstore, passportstore) {
      var div = document.createElement('div');
      var html = '<b>' + name + '</b><br/><small>(' + distance.toFixed(1) + ' miles)</small><br/>' + address + '<br/>'; 
	  if (address2 != "")
	  html += address2 + '<br />' + city + ', ' + state + ' ' + zip + '<br/>'+ phone;
	  else
	  html += city + ', ' + state + ' ' + zip + '<br/>'+ phone;
	  if (destinationstore == true)
	  html += '<br /><a id=\"storetooltip\" title=\"Tea Destination stores carry the widest selection of Tea styles. Come meet their brand experts and discover our latest children\'s clothing collections and the inspiration and destination stories behind them.\" >a tea destination store</a>';
	  if (passportstore == true)
	  html += '<br /><a id=\"storetooltip\" title=\"Tea Passport stores carry a wide selection of Tea styles. Discover our latest children\'s clothing collections and the inspiration and destination stories behind them.\" >a tea passport store</a>';	  
      div.innerHTML = html;
      div.style.cursor = 'pointer';
      div.style.marginBottom = '10px'; 
      GEvent.addDomListener(div, 'click', function() {
        GEvent.trigger(marker, 'click');
      });
      GEvent.addDomListener(div, 'mouseover', function() {
        $("#sidebar a[title]").tooltip({ position: "bottom center" });
		div.style.backgroundColor = '#eee';
      });
      GEvent.addDomListener(div, 'mouseout', function() {
        div.style.backgroundColor = '#fff';
      });
      return div;
    }
    //]]>
