var map;
var marker;
var show_map;

function debug(text)
{
	document.getElementById("debug").innerHTML += text+"<br />";
}


function load_google_map()
{


	try
	{
		show_map = GBrowserIsCompatible();
		if (!show_map)
		{
			debug("map: browser not compatible");
		}
	}
	catch (e)
	{
		debug("google map api not loaded. ("+e+")");
	}


	if (show_map)
	{
		map=new GMap2 (document.getElementById("map"));
	
		document.getElementById("geokoordinaten").style.display="none";
	
		var geo_text = document.getElementById("geokoordinaten").innerHTML;
		var ll = geo_text.split("/");
		
		var lat_lng  = new GLatLng(ll[0],ll[1]);

		map.setCenter(lat_lng,14)
		map.addControl(new GSmallMapControl());		// buttons pfeile + -
		map.addControl(new GMapTypeControl());		// buttons map satellite hybrid
		map.setMapType(G_HYBRID_MAP);

		marker=new GMarker ( lat_lng );
		map.addOverlay(marker);
	}
	else
	{
		document.getElementById("map").style.display="none";
	}
}



// we could execute load_google_map() right on the fly and it works with Firefox.
// IE has problems, with javascript modifying an element, which (or its container?) is not yet completed.
// so we want to execute load_google_map() as the onload-function of the "body" element...
// we dont have access to the cms html template, so we insert our onload-function here.
// it gets executed when the page is completly loaded... 

function addLoadEvent(func)
{
	var oldonload=window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload=func
	}
	else
	{
		window.onload = function()
		{
			if (oldonload)
			{
				oldonload();
			}
			func();
		}
	}
}


addLoadEvent(load_google_map);


