// JavaScript Document

// Create a base icon for all of our markers that specifies the
// shadow, icon dimensions, etc.
/**/
var ctfIcon = new GIcon(G_DEFAULT_ICON);
ctfIcon.shadow = "http://www.cafetheaterfestival.nl/_2010/wp-content/themes/ctf/images/gm_icon_shadow.png";
ctfIcon.image = "http://www.cafetheaterfestival.nl/_2010/wp-content/themes/ctf/images/gm_icon.png";
ctfIcon.iconSize = new GSize(39, 33);
ctfIcon.shadowSize = new GSize(39, 33);
ctfIcon.iconAnchor = new GPoint(5, 31);
ctfIcon.infoWindowAnchor = new GPoint(20, 20);
//ctfIcon.imageMap = [1,36,12,19,52,10,60,38,21,50,1,37];

// Creates a basic cafe marker whose info window displays the corresponding cafe info
function createMarker(point, cafe, voorst, voorst_url) {
  // Create a CTF icon for this event/point using icon class          
  var CTFcafeIcon = new GIcon(ctfIcon);		  
  
  // Set up GMarkerOptions object
  markerOptions = {icon:CTFcafeIcon};
    
  var marker = new GMarker(point, markerOptions);
  GEvent.addListener(marker, "click", function() {
	marker.openInfoWindowHtml("<img style=\"float:right;\" src=\"http://www.cafetheaterfestival.nl/_2010/wp-content/themes/ctf/images/logo_small.png\"/><strong>" + cafe + "</strong><br />Voorstelling:<br /><a href=\"" + voorst_url + "\">" + voorst + "</a>");
  });		  
  return marker;
}


function initialize(eventCenter, requestId) {
  if (GBrowserIsCompatible()) {
	  for (var i = 1; i < 6; i++) {
		if(i == 1) {
			var map = new GMap2(document.getElementById("map_canvasR1"));
			map.setCenter(new GLatLng(52.0946347, 5.1258716), 15);
			map.addControl(new GSmallMapControl());
			for (id in cafesCTF) {				
				if(cafesCTF[id].route == i) {
				  var point = new GLatLng(cafesCTF[id].lat, cafesCTF[id].lng);				    
				  map.addOverlay(createMarker(point, cafesCTF[id].cafe, cafesCTF[id].voorst, cafesCTF[id].voorst_url));
				}
			}
		}
		if(i == 2) {
			var map = new GMap2(document.getElementById("map_canvasR2"));
			map.setCenter(new GLatLng(52.094339, 5.116775), 15);
			map.addControl(new GSmallMapControl());	
			for (id in cafesCTF) {
				if(cafesCTF[id].route == i) {
				  var point = new GLatLng(cafesCTF[id].lat, cafesCTF[id].lng);				    
				  map.addOverlay(createMarker(point, cafesCTF[id].cafe, cafesCTF[id].voorst, cafesCTF[id].voorst_url));
				}
			}
		}
		if(i == 3) {
			var map = new GMap2(document.getElementById("map_canvasR3"));
			map.setCenter(new GLatLng(52.090925, 5.119758), 15);
			map.addControl(new GSmallMapControl());	
			for (id in cafesCTF) {
				if(cafesCTF[id].route == i) {
				  var point = new GLatLng(cafesCTF[id].lat, cafesCTF[id].lng);				    
				  map.addOverlay(createMarker(point, cafesCTF[id].cafe, cafesCTF[id].voorst, cafesCTF[id].voorst_url));
				}
			}
		}
		if(i == 4) {
			var map = new GMap2(document.getElementById("map_canvasR4"));
			map.setCenter(new GLatLng(52.089066, 5.118299), 16);
			map.addControl(new GSmallMapControl());	
			for (id in cafesCTF) {
				if(cafesCTF[id].route == i) {
				  var point = new GLatLng(cafesCTF[id].lat, cafesCTF[id].lng);				    
				  map.addOverlay(createMarker(point, cafesCTF[id].cafe, cafesCTF[id].voorst, cafesCTF[id].voorst_url));
				}
			}
		}
		if(i == 5) {
			var map = new GMap2(document.getElementById("map_canvasR5"));
			map.setCenter(new GLatLng(52.084161, 5.122504), 15);
			map.addControl(new GSmallMapControl());	
			for (id in cafesCTF) {
				if(cafesCTF[id].route == i) {
				  var point = new GLatLng(cafesCTF[id].lat, cafesCTF[id].lng);				    
				  map.addOverlay(createMarker(point, cafesCTF[id].cafe, cafesCTF[id].voorst, cafesCTF[id].voorst_url));
				}
			}
		}/**/	
	 }	
  }
}
