function createMarker(point, label) 
{
	var marker = new GMarker(point);
	GEvent.addListener(marker, "click", function() 
	{
		marker.openInfoWindowHtml(label);
	});
	return marker;
}

function addMap()
{
    if(document.getElementById('location')){
    if (GBrowserIsCompatible) {
		//if(document.getElementById('location')){
			var locationElem = document.getElementById("location");
			var mapContainer = document.createElement("div");
			mapContainer.setAttribute("id", "map");
			insertAfter(mapContainer, locationElem);
			var locationElemParent = locationElem.parentNode;
			locationElemParent.removeChild(locationElem);
			var theTitle = document.getElementsByTagName('h1');
			var bubbleText = theTitle[0].childNodes[0].nodeValue;
			//alert(document.getElementById("bubbleinfo").innerHTML);
			if(document.getElementById('bubbleinfo')){
				var bubbleInfo = document.getElementById("bubbleinfo").innerHTML;
				bubbleText = bubbleInfo;
			} else {
				bubbleText = '<strong>'+bubbleText+'</strong>';
			}
			/*
		} else {
			return;
		}
		*/
        var mapContainer = document.getElementById('map');
        var map = new GMap2(mapContainer);
		geocoder = new GClientGeocoder();
		geocoder.getLatLng(locationElem.childNodes[0].nodeValue, 
		function(point) 
			{
				map.setCenter(point, 15);
				map.addOverlay(createMarker(point, bubbleText));
			});
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
    }
    } else {
			return;
		}
}

window.onload = addMap;
window.onunload = GUnload;