	var map;
	var controlButton;
	var mainmap;
	var flag = new Array();
 	var marker_pin = new Array();
 	flag = [0,0,0,0,0,0];
	
        var baseIcon = new GIcon();
        baseIcon.iconSize = new GSize(32, 32);
        baseIcon.shadowSize = new GSize(54, 32);
        baseIcon.iconAnchor = new GPoint(15, 32);
        baseIcon.infoWindowAnchor = new GPoint(15, 2);
        baseIcon.infoShadowAnchor = new GPoint(18, 25);
		baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";

        var icon = new GIcon(baseIcon);		
		var pins = new Array();
		pins = ["0","http://maps.google.com/mapfiles/ms/micons/blue-dot.png","http://maps.google.com/mapfiles/ms/micons/red-dot.png","http://maps.google.com/mapfiles/ms/micons/green-dot.png","http://maps.google.com/mapfiles/ms/micons/yellow-dot.png","http://maps.google.com/mapfiles/ms/micons/pink-dot.png","http://maps.google.com/mapfiles/ms/micons/ltblue-dot.png"];
	

	function ZoomOutControl() {}
	ZoomOutControl.prototype = new GControl;
	ZoomOutControl.prototype.initialize = function(map) {
	  var button = this;
	  button = document.createElement("div");
	  button.style.width = "150px";
	  button.style.height = "17px";
	  button.style.border = "1px solid black";
	  button.style.background = "white";
	  button.style.cursor = "pointer";
	  button.style.color = "#000000";
	  button.style.font = "9pt Arial";
	  button.appendChild(document.createTextNode("Zoom Out to World Map"));
	  map.getContainer().appendChild(button);

	  GEvent.addDomListener(button, "click", function() {load_map();});
	  return button;
	};
	ZoomOutControl.prototype.getDefaultPosition = function() {return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(425, 7));};
	ZoomOutControl.prototype.getPanel = function() {return button;};


	function drop_down(k,cid,cont) {
		if (flag[k] == 0){
			j=0;
			str='';
			for(j=0;j<xml.documentElement.getElementsByTagName("gp").length;j++){
				if(cont == xml.documentElement.getElementsByTagName("continent")[j].childNodes[0].nodeValue) {
							str+='<A HREF="#" onclick="view_satellite_image('+j+')" onmouseover ="show_infowindow('+j+')" class="a6">'+xml.documentElement.getElementsByTagName("location")[j].childNodes[0].nodeValue+'<br>';
				}
			}
			document.getElementById("tree_icon"+k).innerHTML = '<IMG src="tree_collapse.gif" border="0">';
			document.getElementById(cid).innerHTML = str;
			
			flag[k] = 1;
		}
		else
		{
			document.getElementById("tree_icon"+k).innerHTML = '<IMG src="tree_expand.gif" border="0">';
			document.getElementById(cid).innerHTML ='<IMG border="0" height="1" width="1">';
			
			flag[k] = 0;
		}	
	}

	function list_all(){
		flag = [0,0,0,0,0,0];
		drop_down(0,'aus','Australia');
		drop_down(1,'na','North America');
		drop_down(2,'sa','South America');
		drop_down(3,'euro','Europe');
		drop_down(4,'asia','Asia');
		drop_down(5,'afr','Africa');
	}

	function show_infowindow(i) {
          if(mainmap == 1) marker_pin[i].openInfoWindowHtml("<b class=a2>"+xml.documentElement.getElementsByTagName("name")[i].childNodes[0].nodeValue+"</b><br><b class=a4>"+xml.documentElement.getElementsByTagName("circuit")[i].childNodes[0].nodeValue+"</b><br><input type='button' value='View Satellite Image' onclick=\"javascript: view_satellite_image("+i+");\"><br><br><b class=a2>Wikipedia Information:</b> <a class=a1 href=\""+xml.documentElement.getElementsByTagName("wiki1")[i].childNodes[0].nodeValue+"\" target=\"_blank\">Grand Prix</a>, <a class=a1 href=\""+xml.documentElement.getElementsByTagName("wiki2")[i].childNodes[0].nodeValue+"\" target=\"_blank\">Circuit</a>");

	}

	function view_satellite_image(i) {
		map.clearOverlays();
        map.setCenter(new GLatLng(eval(xml.documentElement.getElementsByTagName("lat")[i].childNodes[0].nodeValue), eval(xml.documentElement.getElementsByTagName("lng")[i].childNodes[0].nodeValue)), eval(xml.documentElement.getElementsByTagName("mapzoom")[i].childNodes[0].nodeValue));
        map.setMapType(G_SATELLITE_MAP);
		controlButton = new ZoomOutControl();
		map.addControl(controlButton);
		mainmap = 0;
		document.getElementById("heading").innerHTML = "<a class=\"a3\" href=\""+xml.documentElement.getElementsByTagName("wiki2")[i].childNodes[0].nodeValue+"\" target=\"_blank\">"+xml.documentElement.getElementsByTagName("circuit")[i].childNodes[0].nodeValue+"</a>, "+xml.documentElement.getElementsByTagName("country")[i].childNodes[0].nodeValue;
		document.getElementById("details").innerHTML = "<br><b><a class=\"a7\" href=\""+xml.documentElement.getElementsByTagName("wiki1")[i].childNodes[0].nodeValue+"\" target=\"_blank\">"+xml.documentElement.getElementsByTagName("name")[i].childNodes[0].nodeValue+"</a></b> - "+xml.documentElement.getElementsByTagName("year")[i].childNodes[0].nodeValue;
		document.getElementById("flags").innerHTML = "<IMG SRC=\""+xml.documentElement.getElementsByTagName("flag")[i].childNodes[0].nodeValue+"\" height=\"75\" width=\"125\" border=\"0\">"
    }

	function load_pin(i) {
			if(xml.documentElement.getElementsByTagName("continent")[i].childNodes[0].nodeValue == 'Europe')icon.image = pins[1];
			if(xml.documentElement.getElementsByTagName("continent")[i].childNodes[0].nodeValue == 'North America')icon.image = pins[2];
			if(xml.documentElement.getElementsByTagName("continent")[i].childNodes[0].nodeValue == 'South America')icon.image = pins[3];
			if(xml.documentElement.getElementsByTagName("continent")[i].childNodes[0].nodeValue == 'Australia')icon.image = pins[4];
			if(xml.documentElement.getElementsByTagName("continent")[i].childNodes[0].nodeValue == 'Africa')icon.image = pins[5];
			if(xml.documentElement.getElementsByTagName("continent")[i].childNodes[0].nodeValue == 'Asia')icon.image = pins[6];
			marker_pin[i] = new GMarker(new GLatLng(eval(xml.documentElement.getElementsByTagName("lat")[i].childNodes[0].nodeValue), eval(xml.documentElement.getElementsByTagName("lng")[i].childNodes[0].nodeValue)),icon);
			map.addOverlay(marker_pin[i]);
			GEvent.addListener(marker_pin[i], "click", function() {	view_satellite_image(i); });
			GEvent.addListener(marker_pin[i], "mouseover", function() {	show_infowindow(i); });
	}
	
    function load_map() {
		map.setCenter(new GLatLng(37.4419, 12.1419), 2);
		map.setMapType(G_NORMAL_MAP);
		map.removeControl(controlButton);
		for (var i = 1; i < xml.documentElement.getElementsByTagName("gp").length; i++) load_pin(i);
		mainmap = 1;
		document.getElementById("heading").innerHTML = '<a class="a3" href="http://en.wikipedia.org/wiki/List_of_Formula_One_circuits" onmouseover="list_all()" target="_blank">List of Formula One Circuits</a>';
		document.getElementById("details").innerHTML = '<a class="a7" href="http://en.wikipedia.org/wiki/History_of_Formula_One" target="_blank">History of Formula One</a>';
		document.getElementById("flags").innerHTML = '<IMG border="0" height="1" width="1">';
	}

	function init_map() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.addControl(new GMapTypeControl());
        map.addControl(new GLargeMapControl());
		map.addMapType(G_PHYSICAL_MAP); 		
		map.enableDoubleClickZoom();
		GDownloadUrl('f1c.xml', function(data, responseCode) {
			xml = GXml.parse(data);
			load_map();
		});
	  }
	}