var map;
var MapListContent = '<p>Click name to find on map.</p>';
var MarkerInfo = new Array();

// Create a base icon for all of our markers that specifies the shadow, icon, dimensions, etc.
var baseIcon = new GIcon();
baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);

if (GBrowserIsCompatible()) {
	function onLoad() {

		map = new GMap2(document.getElementById("MapWindow"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GOverviewMapControl());
		map.setCenter(new GLatLng(48.078079, 7.287305), 5);
		map.enableDoubleClickZoom();
		map.enableContinuousZoom();
		
		var arrnum = 0
		MarkerInfo[arrnum++] = [48.858011, 2.301612, '<div class="MapDiv"><div class="MapHeader">Days 1 - 8</div><div class="MapContent"><a href="Europe0404p1.html#Paris">Paris, France</a></div></div>', 'First Stop'];
		MarkerInfo[arrnum++] = [47.133761, 4.486188, '<div class="MapDiv"><div class="MapHeader">Days 8 - 9</div><div class="MapContent"><a href="Europe0404p2.html#Arnay-le-Duc">Arnay-le-Duc, France</a></div></div>', 'Second Stop'];
		MarkerInfo[arrnum++] = [47.023982, 4.838271, '<div class="MapDiv"><div class="MapHeader">Days 9 - 10</div><div class="MapContent"><a href="Europe0404p2.html#Beaune">Beaune, France</a></div></div>', 'Third Stop'];
		MarkerInfo[arrnum++] = [46.955176, 7.448173, '<div class="MapDiv"><div class="MapHeader">Days 10 - 12</div><div class="MapContent"><a href="Europe0404p2.html#Bern">Bern, Switzerland</a></div></div>', 'Fourth Stop'];
		MarkerInfo[arrnum++] = [47.052238, 8.307563, '<div class="MapDiv"><div class="MapHeader">Days 12 - 13</div><div class="MapContent"><a href="Europe0404p2.html#Luzern">Luzern, Switzerland</a></div></div>', 'Fifth Stop'];
		MarkerInfo[arrnum++] = [46.992197, 8.609161, '<div class="MapDiv"><div class="MapHeader">Days 13 - 14</div><div class="MapContent"><a href="Europe0404p2.html#Brunnen">Brunnen, Switzerland</a></div></div>', 'Sixth Stop'];
		MarkerInfo[arrnum++] = [47.262791, 11.394593, '<div class="MapDiv"><div class="MapHeader">Days 14 - 15</div><div class="MapContent"><a href="Europe0404p2.html#Innsbruck">Innsbruck, Austria</a></div></div>', 'Seventh Stop'];
		MarkerInfo[arrnum++] = [47.799117, 13.044956, '<div class="MapDiv"><div class="MapHeader">Day 15</div><div class="MapContent"><a href="Europe0404p2.html#Salzburg">Salzburg, Austria</a></div></div>', 'Eigth Stop'];
		MarkerInfo[arrnum++] = [48.192416, 16.338446, '<div class="MapDiv"><div class="MapHeader">Days 15 - 16</div><div class="MapContent"><a href="Europe0404p2.html#Vienna">Vienna, Austria</a></div></div>', 'Ninth Stop'];
		MarkerInfo[arrnum++] = [49.413109, 8.709261, '<div class="MapDiv"><div class="MapHeader">Days 16 - 18</div><div class="MapContent"><a href="Europe0404p3.html#Heidelberg">Heidelberg, Germany</a></div></div>', 'Tenth Stop'];
		MarkerInfo[arrnum++] = [49.247708, 4.003787, '<div class="MapDiv"><div class="MapHeader">Days 18 - 19</div><div class="MapContent"><a href="Europe0404p3.html#Reims">Reims, France</a></div></div>', 'Eleventh Stop'];
		MarkerInfo[arrnum++] = [48.876747, 2.333291, '<div class="MapDiv"><div class="MapHeader">Days 19 - 20</div><div class="MapContent"><a href="Europe0404p3.html#Paris">Paris, France</a></div></div>', 'Last Stop'];
				
		for (var i = 0; i < MarkerInfo.length; i++) {
			var marker = createMarker(i, MarkerInfo[i][0], MarkerInfo[i][1], MarkerInfo[i][2], MarkerInfo[i][3]);
			map.addOverlay(marker);
			
			if (i > 0) {
				var l = i - 1
				var polyline = new GPolyline([
					new GLatLng(MarkerInfo[l][0], MarkerInfo[l][1]),
					new GLatLng(MarkerInfo[i][0], MarkerInfo[i][1])
				], "#0000FF", 4);
				map.addOverlay(polyline);
			}
		}
	}
}

function createMarker(index, lat, lng, InfoText, ToolTip) {

	// Create a lettered icon for this point using our icon class
	var letter = String.fromCharCode("A".charCodeAt(0) + index);
	var icon = new GIcon(baseIcon);
	
	icon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
	var Options = {title:ToolTip, icon:icon}

	var marker = new GMarker(new GLatLng(lat, lng), Options);
		
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(InfoText);
	});

	return marker;
}

