    var iconSolar = new GIcon(); 
        iconSolar.image = 'http://www.wikienergy.de/img/wiki_sonne.png';
        iconSolar.iconAnchor = new GPoint(12, 12);
        iconSolar.iconSize = new GSize(24, 24);
        
    
    var iconSewageMethane = new GIcon();
        iconSewageMethane.image = 'http://www.wikienergy.de/img/wiki_muell.png';
        iconSewageMethane.iconAnchor = new GPoint(12, 12);
        iconSewageMethane.iconSize = new GSize(24, 24);
		
	var iconLandfillMethane = new GIcon(); 
        iconLandfillMethane.image = 'http://www.wikienergy.de/img/wiki_muell.png';
        iconLandfillMethane.iconAnchor = new GPoint(12, 12);
        iconLandfillMethane.iconSize = new GSize(24, 24);
        
    
    var iconWind = new GIcon(); 
        iconWind.image = 'http://www.wikienergy.de/img/wiki_wind.png';
        iconWind.iconAnchor = new GPoint(12, 12);
        iconWind.iconSize = new GSize(24, 24);
        
        
    var iconOther = new GIcon(); 
        iconOther.image = 'http://www.wikienergy.de/img/wiki_erdwaerme.png';
        iconOther.iconAnchor = new GPoint(12, 12);
        iconOther.iconSize = new GSize(24, 24);
		
	var iconWater = new GIcon(); 
        iconWater.image = 'http://www.wikienergy.de/img/wiki_laufwasser.png';
        iconWater.iconAnchor = new GPoint(12, 12);
        iconWater.iconSize = new GSize(24, 24);
        
    var iconBagasse = new GIcon(); 
        iconBagasse.image = 'http://www.wikienergy.de/img/wiki_biomasse.png';
        iconBagasse.iconAnchor = new GPoint(12, 12);
        iconBagasse.iconSize = new GSize(24, 24);
    
        var customIcons = [];
        customIcons["Solar"] = iconSolar;
        customIcons["Sewage methane"] = iconSewageMethane;
        customIcons["Wind"] = iconWind;
    	customIcons["Other"] = iconOther;
		customIcons["Landfill methane"] = iconLandfillMethane;
		customIcons["Water"] = iconWater;
		customIcons["Bagasse"] = iconBagasse;
    	var map;
    function load(type) {
    

    
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(-27.156371, 133.130742), 4);
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.addControl(new GScaleControl());
        

        var url = "points.php?type="+type;
        
        
			GDownloadUrl(url, function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("powerstation");
          for (var i = 0; i < markers.length; i++) {
            var eno = markers[i].getElementsByTagName("eno")[0].firstChild.nodeValue;
			var name = markers[i].getElementsByTagName("name")[0].firstChild.nodeValue;
            var legendIcon = markers[i].getElementsByTagName("legend-icon")[0].firstChild.nodeValue;
            var latitude = parseFloat(markers[i].getElementsByTagName("latitude")[0].firstChild.nodeValue);
            var longitude = parseFloat(markers[i].getElementsByTagName("longitude")[0].firstChild.nodeValue);
            var point = new GLatLng(latitude,longitude);
	        var marker = createMarker(point, eno, name, legendIcon);
            map.addOverlay(marker);
          }
        });
      }
    }

    function createMarker(point, eno, name, legendIcon) {
	icon = customIcons[legendIcon];
	var marker = new GMarker(point,{"icon":icon,"title":name});

      GEvent.addListener(marker, 'click', function() {
         getData(eno);
      });
      return marker;
    }
    
    
    function displayInfoTable (html) {
    	document.getElementById("data").innerHTML = html;
    }
    

function getData(eno) {
	var html;
	url = "metadata.php?eno="+eno;
	GDownloadUrl(url, function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("powerstation");
          var latitude = parseFloat(markers[0].getElementsByTagName("latitude")[0].firstChild.nodeValue);
            var longitude = parseFloat(markers[0].getElementsByTagName("longitude")[0].firstChild.nodeValue);
          	      var name = markers[0].getElementsByTagName("name")[0].firstChild.nodeValue;
	              var state = markers[0].getElementsByTagName("state")[0].firstChild.nodeValue;
	              var owned = markers[0].getElementsByTagName("owned")[0].firstChild.nodeValue;
	              var legend = markers[0].getElementsByTagName("legend")[0].firstChild.nodeValue;
	              var fuelType = markers[0].getElementsByTagName("fuel-type")[0].firstChild.nodeValue;
	              var technology = markers[0].getElementsByTagName("technology")[0].firstChild.nodeValue;
	              if (markers[0].getElementsByTagName("turbine-number")[0].firstChild) var turbineNumber = markers[0].getElementsByTagName("turbine-number")[0].firstChild.nodeValue;
	              if (markers[0].getElementsByTagName("turbine-capacity")[0].firstChild) var turbineCapacity = markers[0].getElementsByTagName("turbine-capacity")[0].firstChild.nodeValue;
	              var totalCapacity = markers[0].getElementsByTagName("total-capacity")[0].firstChild.nodeValue;
	              var units = markers[0].getElementsByTagName("units")[0].firstChild.nodeValue;
	              if (markers[0].getElementsByTagName("commissioned")[0].firstChild) var commissioned = markers[0].getElementsByTagName("commissioned")[0].firstChild.nodeValue;
	              if (markers[0].getElementsByTagName("comments")[0].firstChild) var comments = markers[0].getElementsByTagName("comments")[0].firstChild.nodeValue;
	              var source = markers[0].getElementsByTagName("source")[0].firstChild.nodeValue;
	              var status = markers[0].getElementsByTagName("status")[0].firstChild.nodeValue;
	              var image = markers[0].getElementsByTagName("image")[0].firstChild.nodeValue;
	              var description = markers[0].getElementsByTagName("description")
            		var url = markers[0].getElementsByTagName("url")
            	
            	html = "<h2>"+name+"</h2>";
	    	html = "<TABLE><TR><TD VALIGN='top'><br>";
	    	html = html + "<h2>" + name + "</h2><br>";
	    	html = html + "<TABLE border=0><tr><td valign=top align=left>";
	    	html = html + "<img src='http://www.ga.gov.au/renewable/"+image+"' border=1>";
	    	html = html +  "<p><b>Additional Information:</b><br><dl>";
	    	for (i=0;i<description.length;i++){
	            	if (description[i].firstChild) html = html + "<dd><a href='"+url[i].firstChild.nodeValue+"'>"+description[i].firstChild.nodeValue+"</a><br />";
	     	}
	    
	    	html = html + "</dl></td><td valign=top align=left>";
	    	html = html + "Information for <b><em>"+name+"</em></b> power station:<menu>";
	    	html = html + "<li> <em>Fuel type:</em> "+fuelType;
	    	html = html + "<li> <em>Technology:</em> "+technology;
	    	html = html + "<li> <em>Installed Capacity ("+units+"):</em> "+totalCapacity;
	    	html = html + "<li> <em>State:</em> "+state;
	    	html = html + "<li> <em>Owned:</em> "+owned;
	    	html = html + "<li> <em>Commissioned:</em> "+commissioned;
	    	if (turbineNumber) html = html + "<li> <em>No. of units:</em> "+turbineNumber;
	    	if (turbineCapacity) html = html + "<li> <em>Unit MW:</em> "+turbineCapacity;
	    	html = html + "<li> <em>Comments:</em> "+comments;
	    	
	    	html = html + "<li> <em>Source:</em> "+source;
	    	html = html + "<li> <em>Status:</em> "+status;
	    	html = html + "<li> <em>Longitude:</em> "+longitude;
	    	html = html + "<li> <em>Latitude:</em> "+latitude;
	    	html = html + "<li> <a href='#' onclick='map.setCenter(new GLatLng("+latitude+","+longitude+"), 16, G_SATELLITE_MAP)'>Zoom to satellite image</a>";
		html = html + "</menu></td></tr></TABLE></td></tr></TABLE><br/><br/>";
		displayInfoTable (html);
		
          });
         
          
}