// 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:#9E1C35;">Directions To Us - Starting Address:</strong>' +
	 '<form action="http://maps.google.com/maps" method="get" target="_blank" style="width:225px;height:auto;padding-bottom:0px;margin-bottom:0px;">' +
	 '<input type="text" name="saddr" id="saddr" value="" style="width:225px;" /><br>' +
	 '<INPUT value="Get Directions" TYPE="SUBMIT" class="input-button" style="margin-top:3px;margin-bottom:3px;">' +
	 '<input type="hidden" name="daddr" value="22 North Carroll Street, Madison, WI 53703"/></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.0743, -89.386395), 10);

 // Set up three markers with info windows 

 var point = new GLatLng(43.0743, -89.386395);
 var marker = createMarker(point,"<table width='225' border='0' cellspacing='0' cellpadding='0'><tr><td><p style='margin-bottom:6px;font: 10px/12px Arial, Helvetica, sans-serif;'><strong><span style='font: bold 16px/18px Arial, Helvetica, sans-serif !important;color:#9E1C35;'>TESS</span></strong><br />22 North Carroll Street<br />Suite 370<br />Madison, Wisconsin 53703<br />Phone: (608) 274-2577</p></td><td width='100' height='80' align='right' valign='top'><img src='/site-com/assets/images/p1tess-building.jpg' width='75' height='105'></td></tr></table>")
 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/

