/*
East Torrens Google Maps scripts
Created by: Ivan Brawley, 17-May-2008
ChangeLog:
*/

var etcfsStations = new Array();

etcfsStations["ghl"] = new Array();
etcfsStations["ghl"]["name"] = "Greenhill";
etcfsStations["ghl"]["coord"] = new GLatLng(-34.949562, 138.687147);
etcfsStations["ghl"]["mapctr"] = new GLatLng(-34.950064, 138.688531);
etcfsStations["ghl"]["url"] = "http://www.etcfs.org.au/index.php?page=greenhill";

etcfsStations["nsa"] = new Array();
etcfsStations["nsa"]["name"] = "Norton Summit/Ashton";
etcfsStations["nsa"]["coord"] = new GLatLng(-34.922387, 138.724744);
etcfsStations["nsa"]["mapctr"] = new GLatLng(-34.922387, 138.724744);
etcfsStations["nsa"]["url"] = "http://www.etcfs.org.au/index.php?page=norton-summit";

etcfsStations["smt"] = new Array();
etcfsStations["smt"]["name"] = "Summertown";
etcfsStations["smt"]["coord"] = new GLatLng(-34.959486, 138.731189);
etcfsStations["smt"]["mapctr"] = new GLatLng(-34.959486, 138.731189);
etcfsStations["smt"]["url"] = "http://www.etcfs.org.au/index.php?page=summertown";

etcfsStations["cgy"] = new Array();
etcfsStations["cgy"]["name"] = "Carey Gully";
etcfsStations["cgy"]["coord"] = new GLatLng(-34.964590, 138.762082);
etcfsStations["cgy"]["mapctr"] = new GLatLng(-34.964590, 138.762082);
etcfsStations["cgy"]["url"] = "http://www.etcfs.org.au/index.php?page=carey-gully";

etcfsStations["bkr"] = new Array();
etcfsStations["bkr"]["name"] = "Basket Range";
etcfsStations["bkr"]["coord"] = new GLatLng(-34.939378, 138.765285);
etcfsStations["bkr"]["mapctr"] = new GLatLng(-34.939378, 138.765285);
etcfsStations["bkr"]["url"] = "http://www.etcfs.org.au/index.php?page=basket-range";

etcfsStations["pcy"] = new Array();
etcfsStations["pcy"]["name"] = "Piccadilly";
etcfsStations["pcy"]["coord"] = new GLatLng(-34.982142, 138.725722);
etcfsStations["pcy"]["mapctr"] = new GLatLng(-34.982142, 138.725722);
etcfsStations["pcy"]["url"] = "http://www.etcfs.org.au/index.php?page=piccadilly";

etcfsStations["mct"] = new Array();
etcfsStations["mct"]["name"] = "Montacute";
etcfsStations["mct"]["coord"] = new GLatLng(-34.892380, 138.736337);
etcfsStations["mct"]["mapctr"] = new GLatLng(-34.892380, 138.736337);
etcfsStations["mct"]["url"] = "http://www.etcfs.org.au/index.php?page=montacute";

etcfsStations["cyv"] = new Array();
etcfsStations["cyv"]["name"] = "Cherryville";
etcfsStations["cyv"]["coord"] = new GLatLng(-34.911713, 138.765333);
etcfsStations["cyv"]["mapctr"] = new GLatLng(-34.911713, 138.765333);
etcfsStations["cyv"]["url"] = "http://www.etcfs.org.au/index.php?page=cherryville";

etcfsStations["ath"] = new Array();
etcfsStations["ath"]["name"] = "Athelstone";
etcfsStations["ath"]["coord"] = new GLatLng(-34.870579, 138.700471);
etcfsStations["ath"]["mapctr"] = new GLatLng(-34.870579, 138.700471);
etcfsStations["ath"]["url"] = "http://www.etcfs.org.au/index.php?page=athelstone";

etcfsStations["gpb"] = new Array();
etcfsStations["gpb"]["name"] = "East Torrens Group Base";
etcfsStations["gpb"]["coord"] = new GLatLng(-34.922387, 138.724744);
etcfsStations["gpb"]["mapctr"] = new GLatLng(-34.922387, 138.724744);
etcfsStations["gpb"]["url"] = "http://www.etcfs.org.au/index.php?page=east-torrens-group";

var thegmaps = new Array();

var debug_dragpoints = 0;

function initMap( tagid ) {
  if (thegmaps[tagid]) {
    return(thegmaps[tagid]);
  }

  if (GBrowserIsCompatible()) {
    thegmaps[tagid] = new GMap2(document.getElementById(tagid));
    thegmaps[tagid].addMapType(G_PHYSICAL_MAP);

    thegmaps[tagid].addControl(new GMenuMapTypeControl());
    thegmaps[tagid].addControl(new GSmallMapControl());
    thegmaps[tagid].enableScrollWheelZoom();

    return(thegmaps[tagid]);
  }

  return(NULL);
}

function showStation( map, station, zoom, maptype) {
  if (map) {
    map.setCenter(etcfsStations[station]["mapctr"], zoom, maptype);
    var micon = new GIcon();
    micon.image = "http://www.etcfs.org.au/uploads/googlemaps/cfs_marker.png";
    micon.shadow = "http://www.google.com/mapfiles/shadow50.png";
    micon.iconSize = new GSize(20,34);
    micon.shadowSize = new GSize(37, 34);
    micon.iconAnchor = new GPoint(9, 34);
    micon.infoWindowAnchor = new GPoint(9, 2);
    micon.infoShadowAnchor = new GPoint(18, 25);

    if(debug_dragpoints == 1) {
      var marker = new GMarker(etcfsStations[station]["coord"], { icon:micon, draggable:true });

      GEvent.addListener(marker, "dragend", function() {
        marker.openInfoWindowHtml(marker.getLatLng());
      });
    } else {
      var marker = new GMarker(etcfsStations[station]["coord"], { icon:micon });

      GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(etcfsStations[station]["coord"], "Info box for " + etcfsStations[station]["name"]);
      });
    }
    marker.value = station;

    GEvent.addListener(marker, "dblclick", function() {
      window.location = etcfsStations[station]["url"];
    });
    map.addOverlay(marker);
  }
}

function showAllStations( map, center, zoom ) {
  if (map) {
    for(station in etcfsStations) {
      if(station != "gpb") {
        showStation(map, station, zoom, G_PHYSICAL_MAP);
      }
    }
    map.setCenter(etcfsStations[center]["mapctr"], zoom, G_PHYSICAL_MAP);
  }
}

function showResponse( map, station ) {
  if (map) {
    showStation(map, station, 12, G_PHYSICAL_MAP);
    var geoXml = new GGeoXml("http://www.etcfs.org.au/uploads/googlemaps/" + station + "-response.kml");
    map.addOverlay(geoXml);
  }
}


