//<![CDATA[

    // Check to see if this browser can run the Google API
    if (GBrowserIsCompatible()) {

      var gmarkers = [];
      var htmls = [];
      var to_htmls = [];
      var from_htmls = [];
      var i=0;

	  // Create some custom icons
	var bjtIcon = new GIcon();
	  bjtIcon.image = "img/mapIcon.png";
	  bjtIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
	  bjtIcon.iconSize = new GSize(20, 34);
	  bjtIcon.shadowSize = new GSize(37, 34);
	  bjtIcon.iconAnchor = new GPoint(9, 34);
	  bjtIcon.infoWindowAnchor = new GPoint(9, 2);
	  bjtIcon.infoShadowAnchor = new GPoint(18, 25);
	  bjtIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
	  bjtIcon.printImage = "img/mapIcon.gif";
	  bjtIcon.mozPrintImage = "img/mapIcon.gif";



		// A function to create the marker and set up the event window
      		function createMarker(point,name,html,icontype) {
			var marker = new GMarker(point,bjtIcon);

		// === store the name so that the tooltip function can use it ===
	       marker.tooltip = '<div class="tooltip">'+name+'</div>';

        // The info window version with the "to here" form open
        to_htmls[i] = html + '<br>Directions: <b>To here</b> - <a href="javascript:fromhere(' + i + ')">From here</a>' +
           '<br>Start address:<form action="http://maps.google.com/maps" method="get" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
           '<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() + 
                  // "(" + name + ")" + 
           '"/>';
        // The info window version with the "to here" form open
        from_htmls[i] = html + '<br>Directions: <a href="javascript:tohere(' + i + ')">To here</a> - <b>From here</b>' +
           '<br>End address:<form action="http://maps.google.com/maps" method="get"" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="daddr" id="daddr" value="" /><br>' +
           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
           '<input type="hidden" name="saddr" value="' + point.lat() + ',' + point.lng() +
                  // "(" + name + ")" + 
           '"/>';
        // The inactive version of the direction info
        html = html + '<br>Directions: <a href="javascript:tohere('+i+')">To here</a> - <a href="javascript:fromhere('+i+')">From here</a>';

        //  ======  listener for info window  ======
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
      	GEvent.addListener(marker,"mouseover", function() {
          marker.openInfoWindowHtml(html);
      	});        

		gmarkers[i] = marker;
        htmls[i] = html;
        i++;
        return marker;

}

     // ====== This function displays the tooltip ======
      function showTooltip(marker) {
      tooltip.innerHTML = marker.tooltip;
	  var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom());
	  var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom());
	  var anchor=marker.getIcon().iconAnchor;
	  var width=marker.getIcon().iconSize.width;
	  var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - point.x - anchor.x + width,- offset.y + point.y +anchor.y)); 
	  pos.apply(tooltip);
	  tooltip.style.visibility="visible";
      }

      // functions that open the directions forms
      function tohere(i) {
        gmarkers[i].openInfoWindowHtml(to_htmls[i]);
      }
      function fromhere(i) {
        gmarkers[i].openInfoWindowHtml(from_htmls[i]);
      }

      // Display the map, with some controls and set the initial location 
      var map = new GMap2(document.getElementById("map"));
	  map.addControl(new GSmallMapControl());
	  map.addControl(new GMapTypeControl());
	  map.setCenter(new GLatLng(47.6066,-122.335), 15);

	  // ====== set up marker mouseover tooltip div ======
      var tooltip = document.createElement("div");
      document.getElementById("map").appendChild(tooltip);
      tooltip.style.visibility="hidden";

      // Set up marker with info window 
	  var point = new GLatLng(47.6066,-122.335);
	  var marker = createMarker(point,'BJT','<strong>Breskin Johnson & Townsend</strong><br />1111 Third Avenue, Suite 2230, Seattle, WA 98101<br />(206) 652-8660')
	  map.addOverlay(marker);
  
	}

    
    // display a warning if the browser was not compatible
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }

    // This Javascript is based on code provided by the
    // Blackpool Community Church Javascript Team
    // http://www.commchurch.freeserve.co.uk/   
    // http://www.econym.demon.co.uk/googlemaps/

    //]]>