
    var iconPlane = new GIcon(); 
    iconPlane.image = '/icon/plane.png';
    iconPlane.shadow = '/icon/plane.shadow.png';
    iconPlane.iconSize = new GSize(16, 20);
    iconPlane.shadowSize = new GSize(22, 20);
    iconPlane.iconAnchor = new GPoint(6, 20);
    iconPlane.infoWindowAnchor = new GPoint(5, 1);

    var iconRed = new GIcon(); 
    iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
    iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
    iconRed.iconSize = new GSize(8, 10);
    iconRed.shadowSize = new GSize(11, 10);
    iconRed.iconAnchor = new GPoint(6, 20);
    iconRed.infoWindowAnchor = new GPoint(5, 1);

    var iconGreen = new GIcon(); 
    iconGreen.image = 'http://labs.google.com/ridefinder/images/mm_20_green.png';
    iconGreen.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
    iconGreen.iconSize = new GSize(6, 10);
    iconGreen.shadowSize = new GSize(11, 10);
    iconGreen.iconAnchor = new GPoint(6, 20);
    iconGreen.infoWindowAnchor = new GPoint(5, 1);

    var iconBlue = new GIcon(); 
    iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
    iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
    iconBlue.iconSize = new GSize(8, 10);
    iconBlue.shadowSize = new GSize(11, 10);
    iconBlue.iconAnchor = new GPoint(6, 20);
    iconBlue.infoWindowAnchor = new GPoint(5, 1);


    var customIcons = [];
    customIcons["airfield"] = iconRed;
    customIcons["cairfield"] = iconPlane;
    customIcons["cstrip"] = iconPlane;
    customIcons["strip"] = iconGreen;
    

    var markerGroups = { "airfield": [], "strip": [], "cairfield": [], "cstrip": []};

    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addMapType(G_PHYSICAL_MAP);
        map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.addControl(new GOverviewMapControl());
	map.addControl(new MapCursorControl());//custom map and graticule selector
	map.addOverlay(new LatLonGraticule()); 
        map.setCenter(new GLatLng(47, 3.5), 6);
        map.enableScrollWheelZoom();
	map.enableDoubleClickZoom();
        //map.setMapType(G_HYBRID_MAP);
        map.setMapType(G_PHYSICAL_MAP);
     
        GDownloadUrl("/php/phpsqlajax_genxml.php", function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            var id = markers[i].getAttribute("id");
            var name = markers[i].getAttribute("name");
            var icao = markers[i].getAttribute("icao_code");
            var descr = markers[i].getAttribute("description");
            var af_url = markers[i].getAttribute("url");
            var type = markers[i].getAttribute("type");
            var author = markers[i].getAttribute("author");
            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
            var imgWidth = markers[i].getAttribute("imgWidth");
            var imgHeight = markers[i].getAttribute("imgHeight");
            var fir = markers[i].getAttribute("fir");
            var bria = markers[i].getAttribute("bria");
            var siv = markers[i].getAttribute("siv");
            var additions = markers[i].getAttribute("additions");
            var notes = markers[i].getAttribute("notes");
            var AIRAC = markers[i].getAttribute("AIRAC");
            var marker = createMarker(point, id, name, type, icao, descr, af_url, author, imgWidth, imgHeight, fir, bria, siv, additions, notes, AIRAC);

            map.addOverlay(marker);
          }
        });
      }
    }

    function createMarker(point, id, name, type, icao, descr, af_url, author, imgWidth, imgHeight, fir, bria, siv, additions, notes, AIRAC) {

      if(descr.length == 0){
          var icontype = type; }
      else {
          var icontype = "c" + type; }



      var marker = new GMarker(point, customIcons[icontype]);
      markerGroups[icontype].push(marker);

//var html = "<html><head><link rel=\"stylesheet\" href=\"http://www.arthurandarthur.co.uk/css/tables/fpl.css\" type=\"text/css\"></head><body>";

		var html = "<html><head></head><body>";

      html = html +  "<b>" + name  + " (" + icao + ")</b><br><font size=\"2\">";

      if(descr.length > 0){ html = html + descr + "<br><font size=\"1\">Author: " + author + "</font>";}


      html = html + "<center><br><a href=\"http://www.arthurandarthur.co.uk/cgi-bin/awredir.pl?url=http://www.navigeo.org/" + icao + "\" target=\"_blank\">Details at Navigeo" + "</a>";

      if(af_url.length > 0){ 
         html = html + "    :    <a href=\"http://www.arthurandarthur.co.uk/cgi-bin/awredir.pl?url=" + af_url + "\" target=\"_blank\"> Airfield web site </a><nbsp><nbsp><nbsp>";}

      if(type == "airfield"){ html = html + "    :    <a href=\"http://www.arthurandarthur.co.uk/cgi-bin/awredir.pl?url=http://www.sia.aviation-civile.gouv.fr/aip/enligne/PDF_AIPparSSection/VAC/AD/2/" + AIRAC + "_AD-2." + icao + ".pdf\" target=\"_blank\"> SIA chart</a>";}

      html = html + "</center></font>";

      if(imgWidth > 0){ 
          html = html + "<center><br><img src=/flying/get_map_image.php?inum=" + id + " width=\"" + imgWidth + "\" height=\"" + imgHeight + "\" alt=\"Airfield image\"></center><br>";}

      

if(fir.length > 0)
	{ 
	html = html + "<table border=\"1\" class=\"fpltable\"><tr><th colspan=\"5\">Flight Plan codes from ";
    html = html + "<a target=\"_blank\" href=\"http://www.arthurandarthur.co.uk/cgi-bin/awredir.pl?url=https://www.sia.aviation-civile.gouv.fr/aip/enligne/fr/..%5CPDF_AIPparSSection%5CAIP%20FRANCE%5CENR%5C1%5C" + AIRAC + "_ENR-1.11.pdf\">SIA AIP ENR1.11</a>";
    html = html + "</th></tr><tr><th>Arriving</th><th>Departing</th><th>FIR</th><th>";
	html = html + "<a target=\"_blank\" href=\"http://www.arthurandarthur.co.uk/flying/get_BRIA_details.php?briaid=" + bria + "\" onClick='showPopup(this.href);return(false);'>BRIA</a></th>";

	html = html + "<th>SIV</th></tr><tr><td>" + icao + "ZTZX</td><td>" + icao + "ZPZX</td><td>" + fir + "ZFZX</td><td>";
	if(bria.length > 0)
		{
		html = html + bria + "ZPZX";
		}
	html = html + "</td><td>";

	if (siv.length > 0)
		{
		html = html + siv + "ZTZX";
		}
	html = html + "</td></tr><tr>";

	if (additions.length > 0)
		{
		html = html + "<td colspan=\"5\">Additional: " + additions;
		if (notes.length > 0)
			{
			html = html + " - " + notes;
			}	
		html = html + "</td>";
		}

	html = html + "</tr></table><br /></body></html>";
}



      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html,{maxWidth:450});
      });
      return marker;
    }

function toggleGroup(type) {
      for (var i = 0; i < markerGroups[type].length; i++) {
        var marker = markerGroups[type][i];
        if (marker.isHidden()) {
          marker.show();
        } else {
          marker.hide();
        }
      } 
    }



