var map;
function load() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		
		
		if(typeof(defaultLatitude) != "undefined") {
			var center = new GLatLng(defaultLatitude, defaultLongitude);
		} else {
			var center = new GLatLng(51.92259364946845, 4.478731155395508);
		}
		if(typeof(isCenter) != "undefined") {
			map.setCenter(center, isCenter);
		} else {
			map.setCenter(center, 13);
		}
		
		var blueIcon = new GIcon();
		
		//blueIcon.image = "/gfx/icon.gif";
		blueIcon.iconSize = new GSize(25, 25);
		blueIcon.iconAnchor = new GPoint(12, 12);
		blueIcon.infoWindowAnchor = new GPoint(0, 0);
		markerOptions = { icon:blueIcon };
		
		// Set up our GMarkerOptions object
		// Create a lettered icon for this point using our icon class
		for(i = 0 ; i < info.length ; i++) {
			blueIcon.image = info[i][5];
			var point = new GLatLng(info[i][0], info[i][1]);
			map.addOverlay(createMarker(point, info[i][2], i));
		}
	}
	function createMarker(point, msg, num) {
	  var marker = new GMarker(point, markerOptions);
	  //var marker = new GMarker(point);
	  
	  //marker.value = number;
	  GEvent.addListener(marker, "click", function() {
	    var myHtml = msg;
	  	if(msg != "") {
		  	a = new Array();
			a["maxWidth"] = 450;
		
		    map.openInfoWindowHtml(point, myHtml, a);
		}
	    document.getElementById("title").innerHTML = info[num][3];
		document.getElementById("info").innerHTML = info[num][4];
	    
	  });
	  return marker;
	}
	gdir = new GDirections(map, document.getElementById("directions"));
}
function moveMap(who) {
	var c = new GLatLng(info[who][0],info[who][1]);
	if(map.getZoom() < 14) {
		map.setZoom(14);
	}
	map.panTo(c);
	
	a = new Array();
	a["maxWidth"] = 450;
	msg = info[who][2];
    map.openInfoWindowHtml(c, msg, a);

}
function setDirections(fromAddress1, fromAddress2, toAddress, locale) {
	map.clearOverlays();
	if(fromAddress1 && fromAddress2) {
		gdir.load("from: " + fromAddress1 + ", " + fromAddress2  + " to: " + map.getCenter(), { "locale": locale });
	} else {
		gdir.load("from: " + fromAddress1 + " " + fromAddress2  + " to: " + map.getCenter(), { "locale": locale });
	}
}
function showInfo(num) {
	
	
}

function getCategoryPage(who) {
	document.location.href = "?category_id=" + $(who).val();
}