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);
		
		map.setCenter(new GLatLng(51.914891, 4.466093), 15);
		var point = new GLatLng(51.914891, 4.466093);

		//51.915765,4.467123&sspn=0.0225,0.028753&ie=UTF8&ll=51.914891,4.466093&spn=0.01125,0.014377&z=16&iwloc=addr
		
		// Create our "tiny" marker icon
		var icon = new GIcon();
		icon.image = "/images/mapicon-vinden.png";
		//icon.shadow = "/images/logo-essencia-maps-shadow.png";
		icon.iconSize = new GSize(121, 33);
		icon.shadowSize = new GSize(70, 40);
		icon.iconAnchor = new GPoint(48, 35);
		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>Vinden.net</strong><br />William Boothlaan 3C<br />3012 VG Rotterdam");
  });
  return marker;
}
