var map
var marker
var Stadiaicon;
var TAbatch = new Array();

function initMap(){
	if (GBrowserIsCompatible()){
		var icon = new GIcon();
		icon.image = BaseThemeURL+"images/lodging.png";
		icon.iconSize = new GSize(16, 16);
		icon.iconAnchor = new GPoint(8,8);
		icon.infoWindowAnchor = new GPoint(8, 8);

		Stadiaicon = new GIcon();
		Stadiaicon.image = "/images/2010_Stadia.png";
		Stadiaicon.iconSize = new GSize(16, 16);
		Stadiaicon.iconAnchor = new GPoint(8,8);
		Stadiaicon.infoWindowAnchor = new GPoint(8,8);

		map = new GMap2(document.getElementById("GMap"));
//		map.addControl(new GSmallMapControl());				// Use Small map scale control
		map.addControl(new GLargeMapControl());				// Use Large map scale control
//		map.addMapType(G_PHYSICAL_MAP);						// Add Terrain type Map
		map.removeMapType(G_SATELLITE_MAP);					// Remove Satellite type Map
		map.addControl(new GMapTypeControl());				// Map Satellite Hybrid
		
		map.addControl(new GScaleControl(),new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(68, 5))); // Map Scale

		// Add the small control bottem right
//		overview = new GOverviewMapControl();
//		map.addControl(overview);
//		ovmap=overview.getOverviewMap();		md=window.setTimeout("overview = new GOverviewMapControl();map.addControl(overview)",500);
		//done
		
		if (zm>9){
			point = new GLatLng(Lat, Lng);
			map.setCenter(point, zm);
			marker = new GMarker(point,icon);
			map.addOverlay(marker);
			}
		else{
			zm=5;
			Lat=-25.641526373065755
			Lng=24.9169921875
			point = new GLatLng(Lat, Lng);
			map.setCenter(point, zm);
			}
//		map.setMapType(G_SATELLITE_MAP);				// Set default to Satellite map;
//		map.setMapType(G_NORMAL_MAP);					// Set default to Street map;
		map.setMapType(G_HYBRID_MAP);					// Set default to Hybrid map;
//		map.setMapType(G_PHYSICAL_MAP);					// Set default to Terrain map;
		map.enableDoubleClickZoom();

		mgr = new MarkerManager(map,{trackMarkers:true});
		GDownloadUrl("/AScripts/Tourist_Attractions.xml", function(data, responseCode) {
			if(responseCode==200){
				var xml = GXml.parse(data);
				var markers = xml.documentElement.getElementsByTagName("marker");
				for (var i = 0; i < markers.length; i++) {
					var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("lng")));
					if(markers[i].getAttribute("icon")=="Stadiaicon"){
						var marker = new GMarker(point, {title: markers[i].getAttribute("info"), icon: Stadiaicon, draggable:false });
						}
					TAbatch.push(marker);
					}
				if(TAbatch.length>0){
					mgr.addMarkers(TAbatch, 5);
					mgr.refresh();
					}
				}
			});
		}
	}
function UnloadG(){
	if(typeof(GBrowserIsCompatible)!="undefined"){
		if(marker){map.removeOverlay(marker);}
			GUnload();
		}
	}
