addEvent( window, "load", load );
addEvent( window, "unload", GUnload );

function addEvent( obj, type, fn ) 
{
	if (obj.addEventListener)
	{
		obj.addEventListener( type, fn, false );
	}
	else if ( obj.attachEvent ) 
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() 
		{ 
			obj["e"+type+fn]( window.event ); 
		}
		obj.attachEvent( "on"+type, obj[type+fn] );
	} 
}

function load() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(51.915751411762976, 4.478473663330078), 15);
		var point = new GLatLng(51.915751411762976, 4.478473663330078);
		
		// Create our "tiny" marker icon
		var icon = new GIcon();
		icon.image = "/images/icon-essencia.png";
		icon.shadow = "/images/logo-essencia-maps-shadow.png";
		icon.iconSize = new GSize(86, 59);
		icon.shadowSize = new GSize(70, 40);
		icon.iconAnchor = new GPoint(20, 40);
		icon.infoWindowAnchor = new GPoint(5, 1);
		map.addOverlay(new GMarker(point, icon));
		//map.addOverlay(createMarker(point, icon));
	}
}

function createMarker(point) {
  var marker = new GMarker(point);
  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml("<strong>Essencia</strong><br />William Boothlaan 3x<br />3012 VG Rotterdam");
  });
  return marker;
}
