// google map-start code

var map;
var gmarkers = [];
var htmls = [];
var markerTypes = [];
var marker;
var i = 0;

// Create some custom icons

// This icon uses the same shape as the default Google marker
// So we can use its details for everything except the image 

var ALetterIcon = new GIcon();
ALetterIcon.image = "images/AIcon.png";
ALetterIcon.iconSize = new GSize(20, 34);
//ALetterIcon.shadow = "images/POIIconShadow.png";
//ALetterIcon.shadowSize = new GSize(40, 32);
ALetterIcon.iconAnchor = new GPoint(12, 31);
ALetterIcon.infoWindowAnchor = new GPoint(9, 2);
ALetterIcon.infoShadowAnchor = new GPoint(18, 25);
ALetterIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";

var BLetterIcon = new GIcon();
BLetterIcon.image = "images/BIcon.png";
BLetterIcon.iconSize = new GSize(20, 34);
//BLetterIcon.shadow = "images/POIIconShadow.png";
//BLetterIcon.shadowSize = new GSize(40, 32);
BLetterIcon.iconAnchor = new GPoint(12, 31);
BLetterIcon.infoWindowAnchor = new GPoint(9, 2);
BLetterIcon.infoShadowAnchor = new GPoint(18, 25);
BLetterIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";

var CLetterIcon = new GIcon();
CLetterIcon.image = "images/CIcon.png";
CLetterIcon.iconSize = new GSize(20, 34);
//CLetterIcon.shadow = "images/POIIconShadow.png";
//CLetterIcon.shadowSize = new GSize(40, 32);
CLetterIcon.iconAnchor = new GPoint(12, 31);
CLetterIcon.infoWindowAnchor = new GPoint(9, 2);
CLetterIcon.infoShadowAnchor = new GPoint(18, 25);
CLetterIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";

var DLetterIcon = new GIcon();
DLetterIcon.image = "images/DIcon.png";
DLetterIcon.iconSize = new GSize(20, 34);
//DLetterIcon.shadow = "images/POIIconShadow.png";
//DLetterIcon.shadowSize = new GSize(40, 32);
DLetterIcon.iconAnchor = new GPoint(12, 31);
DLetterIcon.infoWindowAnchor = new GPoint(9, 2);
DLetterIcon.infoShadowAnchor = new GPoint(18, 25);
DLetterIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";

var ELetterIcon = new GIcon();
ELetterIcon.image = "images/EIcon.png";
ELetterIcon.iconSize = new GSize(20, 34);
//ELetterIcon.shadow = "images/POIIconShadow.png";
//ELetterIcon.shadowSize = new GSize(40, 32);
ELetterIcon.iconAnchor = new GPoint(12, 31);
ELetterIcon.infoWindowAnchor = new GPoint(9, 2);
ELetterIcon.infoShadowAnchor = new GPoint(18, 25);
ELetterIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";

var mainMarker;
function load(iLat,iLong,iDist,iMapMode,bControls) {

	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.setCenter(new GLatLng(iLat, iLong), iDist);
		
		switch(iMapMode) {
			case(1) :
				map.setMapType(G_NORMAL_MAP);
				break;
			
			case(2) :
				map.setMapType(G_HYBRID_MAP);				
				break;
			
			case(3) :
				map.setMapType(G_SATELLITE_MAP);
				break;
			
		}
		
		//mainMarker = new GMarker(new GLatLng(iLat, iLong));
		//map.addOverlay(mainMarker);
		
		if (bControls == true) {
			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
		}
	}
}


function addMarker(iLat, iLong) {

	if (GBrowserIsCompatible()) {
		mainMarker = new GMarker(new GLatLng(iLat, iLong));
		map.addOverlay(mainMarker);	
        return marker;
	}
}

function addItem(iLat, iLong, sPlaceName, iMarkerID, sPlaceType) {
	
	switch (sPlaceType) {
		case "A", "B", "C", "D", "E" :
			var html = "<b>" + sPlaceName + "</b>";
			break;
	}


//	var html = "<img src=\"images/InfoRail.gif\" alt=\"Station\" align=\"left\" width=\"50\" height=\"50\" hspace=\"5\" /><br /><b>" + sPlaceName + "</b>";
	
	if (GBrowserIsCompatible()) {
		switch (sPlaceType) {
			case "A" :
				var marker = new GMarker(new GLatLng(iLat, iLong), ALetterIcon);
				break;
			case "B" :
				var marker = new GMarker(new GLatLng(iLat, iLong), BLetterIcon);
				break;
			case "C" :
				var marker = new GMarker(new GLatLng(iLat, iLong), CLetterIcon);
				break;
			case "D" :
				var marker = new GMarker(new GLatLng(iLat, iLong), DLetterIcon);
				break;
			case "E" :
				var marker = new GMarker(new GLatLng(iLat, iLong), ELetterIcon);
				break;
		}
		
		map.addOverlay(marker);	
		

		//GEvent.addListener(marker, "click", function() {
		//	marker.openInfoWindowHtml(html);
		//});

        gmarkers[iMarkerID] = marker;
        htmls[iMarkerID] = html;

        return marker;

//		GEvent.addListener(marker, "click", function() { 
//			marker.openInfoWindowHtml("<img src=\"images/InfoRail.gif\" alt=\"Station\" align=\"left\" width=\"50\" height=\"50\" hspace=\"5\" /><br /><b>" + sPlaceName + "</b>"); 
//		});


	}
}

// This function opens the HTML info window for a marker
function myclick(i) {
	gmarkers[i].openInfoWindowHtml(htmls[i]);
}

