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

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

 // A function to create the marker and set up the event window
   var previousCenterPoint ; 
   var previousZoom ;

function createMarker(point,html) {
   var marker = new GMarker(point);

   // The inactive version of the direction info
   html = html + '<strong style="font-family:Arial, Helvetica, sans-serif;color:#7D541F;">Directions To Us - Starting Address:</strong>' +
	 '<form action="http://maps.google.com/maps" method="get" target="_blank" style="width:250px;height:1px;padding-bottom:0px;margin-bottom:0px;">' +
	 '<input type="text" name="saddr" id="saddr" value="" style="width:240px;" /><br>' +
	 '<INPUT value="Get Directions" TYPE="SUBMIT" class="input-button" style="margin-top:3px;margin-bottom:3px;">' +
	 '<input type="hidden" name="daddr" value="9 Cherokee Circle #202,Madison, WI 53704-8485"/></form><br />';

   GEvent.addListener(marker, "click", function() {
	previousCenterPoint = map.getCenter() ; 
	previousZoom = map.getZoom() ; 
	marker.openInfoWindowHtml(html);
	});
	GEvent.addListener(map, "infowindowclose", function() { 
     map.setCenter(previousCenterPoint,previousZoom); 
	// add your code to inform user here 
	}); 
   gmarkers[i] = marker;
   htmls[i] = html;
   i++;
   return marker;
 }

 // functions that open the directions forms
 function tohere(i) {
   gmarkers[i].openInfoWindowHtml(to_htmls[i]);
 }
 // Display the map, with some controls and set the initial location 
 var map = new GMap2(document.getElementById("map"));
 map.addControl(new GLargeMapControl());
 map.setCenter(new GLatLng(43.146087, -89.363611), 14);

 // Set up three markers with info windows 

 var point = new GLatLng(43.146087, -89.363611);
 var marker = createMarker(point,"<p style='margin-bottom:2px;font-family:Arial, Helvetica, sans-serif;'><strong><span style='font: bold 16px/18px Arial, Helvetica, sans-serif !important;color:#7D541F;'>Wheeler Road</span></strong><br />9 Cherokee Circle #202<br />Madison, WI 53704-8485<br /><br />Phone: 608.249.2304</p>")
 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/
