function xload(){
 alert ("called")
}
var CUSTOMIcon;
var sidebar_html = "";

// arrays to hold copies of the markers and html used by the sidebar
// because the function closure trick doesnt work there
var gmarkers = [];
var names = [];
var airportLocs=[];
var i = 0;

function doclick(ref) {
	gmarkers[ref].openInfoWindowHtml("<B>"+names[ref]+"</B><BR>"+airportLocs[ref]);
}

function createMarker(point,name,airportLoc,airportCode,lat,lng) {
		//var marker = new GMarker(point);
		var marker= new GMarker(point, CUSTOMIcon)
		GEvent.addListener(marker, "mousedown", function() {
    hotelURL="http://www.parkandsave.com/cgi-bin/aph-hotel.pl";
 		parkingURL="http://www.parkandsave.com/car-parks.php?name="+escape(name)+"&airportLoc="+escape(airportLoc)+"&airportCode="+airportCode+"&lat="+lat+"&lng="+lng;
		links="";
		links="<BR>&#8226; <A href="+parkingURL+">Airport Car Parks</A>";
	  links+="<BR>&#8226; <A href="+hotelURL+">Hotels with Parking Packages</A>";
		links+="<BR>&#8226; <A href="+hotelURL+">View Nearby Hotels</A>";

			marker.openInfoWindowHtml("<B>"+name+"</B> ("+airportCode+")<BR>"+airportLoc+links);
		});
		// save the info we need to use later for the sidebar
		gmarkers[i] = marker;
    names[i]=name;
		airportLocs[i] = airportLoc;
 		
		// add a line to the sidebar html
		sidebar_html += '<a href="javascript:doclick(' + i + ')">' + name + '</a><br>';
		i++;
		return marker;
	}

function load(){
if (GBrowserIsCompatible()) {

	CUSTOMIcon = new GIcon();
	CUSTOMIcon.image = "plane.png";
	CUSTOMIcon.shadow = "plane-shadow.png";
	CUSTOMIcon.iconSize = new GSize(16, 16);
	CUSTOMIcon.shadowSize = new GSize(18, 16);
	CUSTOMIcon.iconAnchor = new GPoint(8, 8);
	CUSTOMIcon.infoWindowAnchor = new GPoint(8, 8);
	CUSTOMIcon.infoShadowAnchor = new GPoint(8, 8);
	CUSTOMIcon.transparent = "plane-tran.png";


 // this variable will collect the html which will eventualkly be placed in the sidebar


	// A function to create the marker and set up the event window


// create the map

		

	if(typeof showSpecificAirport =="undefined"){
		mapLayer=document.getElementById("AirportMap");
  		var map = new GMap2(mapLayer);

		map.addControl(new GSmallMapControl(), new GControlPosition(G_ANCHOR_BOTTOM_LEFT));
		map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_LEFT));
		map.setCenter(new GLatLng(54.5,-4.3),5,G_SATELLITE_MAP);
	//side=document.getElementById("sidebar");
	//side.style.height="400px";
	//side.style.width="200px";


		// Read the data from example.xml
		var request = GXmlHttp.create();
		request.open("GET", "airports.xml", true);
		request.onreadystatechange = function() {
			if (request.readyState == 4) {
				var xmlDoc = request.responseXML;
				// obtain the array of markers and loop through it
				var markers = xmlDoc.documentElement.getElementsByTagName("airport");
				for (var i = 0; i < markers.length; i++) {
					
					// obtain the attribues of each marker
					var lat = parseFloat(markers[i].getAttribute("latitude"));
					var lng = parseFloat(markers[i].getAttribute("longitude"));
					var point = new GLatLng(lat,lng);
					var airportLoc = markers[i].getAttribute("location");
					var airportCode = markers[i].getAttribute("code");
					var name = markers[i].getAttribute("name");
					// create the marker

					var marker = createMarker(point,name,airportLoc,airportCode,lat,lng);
					map.addOverlay(marker);
				}
				// put the assembled sidebar_html contents into the sidebar div
				//document.getElementById("sidebar").innerHTML = sidebar_html;
			}
		}
		request.send(null);
	}
	else{
		mapLayer=document.getElementById("AirportMap");
  		var map = new GMap2(mapLayer);

		map.addControl(new GSmallMapControl(), new GControlPosition(G_ANCHOR_BOTTOM_LEFT));
		map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_LEFT));

		map.setCenter(new GLatLng(lat,lng), 9,G_NORMAL_MAP);
var point = new GLatLng(lat,lng);
		var marker = createMarker(point,name,airportLoc,airportCode,lat,lng);
		map.addOverlay(marker);
	}


}
}
