// 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 + '<form action="http://maps.google.com/maps" method="get" target="_blank" style="margin:0px;padding:0px">' +
	 '<input type="text" name="saddr" id="saddr" value="" style="width:235px;" /><br>' +
	 '<INPUT value="Get Directions" TYPE="SUBMIT" class="input-button" style="margin-top:3px;margin-bottom:3px;">' +
	 '<input type="hidden" name="daddr" value="2417 North Bartlett, Milwaukee, WI 53211" /></form>';

   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.061700, -87.889423), 15);

 // Set up three markers with info windows 

 var point = new GLatLng(43.061700, -87.889423);
 var marker = createMarker(point,"<div style='width:237px;height:auto;padding-bottom:2px;font-family: Verdana, Arial, Helvetica, sans-serif;'><p style='margin-bottom:8px;margin-top:0px;font-size:11px;font-family:Verdana, Arial, Helvetica, sans-serif;'><img src='/images/champs_front_googlemap.jpg' width='100' height='100' border='0' style='float:right;'><strong><span style='font-size:13px;color:#3C5727;'>Champion's Pub</span></strong><br />2417 North Bartlett<br />Milwaukee, WI 53211<br />414.332.2440</p><p style='padding:14px 0px 0px 0px;margin:0px;color:#3C5727;font-size:11px;'><strong>Directions To Us -<br />Starting Address:</strong></p></div>")
 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/
