var map = null;
var geocoder = null;
var text = null

function ShowMap(address, html){
	text = html;
	document.getElementById("GMap").style.display = "";
	document.getElementById("ShowMap").style.display = "none";
	document.getElementById("HideMap").style.display = "";
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("GMap"));

		map.addControl(new GSmallMapControl());
		map.enableDoubleClickZoom();
		map.enableScrollWheelZoom();
		//map.setCenter(new GLatLng(34, 0), 1);
		geocoder = new GClientGeocoder();
		// Retrieve location information, pass it to addToMap()
		geocoder.getLocations(address, showMarker);
		//map.setCenter(new GLatLng(45.427823,-75.696316), 15);
		//var marker = new GMarker(latlng);
		//map.addOverlay(marker);
		//marker.openInfoWindowHtml(text);

		//map.setCenter(new GLatLng(37.4419, -122.1419), 13);
		//map.openInfoWindow(map.getCenter(), document.createTextNode("Hello, world"));
		}
}

function HideMap(){
	document.getElementById("GMap").style.display = "none";
	document.getElementById("ShowMap").style.display = "";
	document.getElementById("HideMap").style.display = "none";
}

function showMarker(response) {

      // Retrieve the object
      place = response.Placemark[0];

      // Retrieve the latitude and longitude
      point = new GLatLng(place.Point.coordinates[1],
                          place.Point.coordinates[0]);

      // Center the map on this point
      map.setCenter(point, 15);

      // Create a marker
      marker = new GMarker(point);

	  
		  GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(text);});
	  

      // Add address information to marker
      //marker.openInfoWindowHtml(text);

	  // Add the marker to map
      map.addOverlay(marker);

}
