var iconData = {
  "Darwin": { width: 24, height: 14 },
  "home": { width: 36, height: 26 },
  "flag-shadow": { width: 40, height: 30 },
  "house": { width: 32, height: 32 },
  "house-shadow": { width: 59, height: 32 },
  "headquarters": { width: 32, height: 32 },
  "headquarters-shadow": { width: 59, height: 32 }
};

var officeLayer = [
  {
    "zoom": [0, 17],
    "places": [
      {
        "name": "Darwin",
        "posn": [-12.415119,130.932666]
      },
    ]
  },
  {
    "zoom": [8, 17],
    "places": [
 {
        "name": "A Good Rest B&B",
                        "icon": ["home", "flag-shadow"],
        "posn": [-23.675777,133.867447]
      },
    ]
  },
  {
    "zoom": [7, 17],
    "places": [
      {
        "name": "Casuarina Shopping Square",
        "posn": [-12.376514,130.881457]
      },      {
        "name": "Crocodillus Park",
        "posn": [-12.410089121150024,130.92681884765625]
      },      {
        "name": "Cullen Bay Marina & Restuarants",
        "posn": [-12.45468030824428,130.82107543945312]
      },      {
        "name": "Darwin CBD Shopping & Restaurants",
        "posn": [-12.460421,130.841502]
      },      {
        "name": "Fannie Bay Shopping, Restaurants, Beach, Racecourse",
        "posn": [-12.423500808775184,130.83609580993652]
      },      {
        "name": "East Point Coastal Reserve, WWII Relics",
        "posn": [-12.413358,130.822147]
      },	{
              "name": "East Point Coastal Reserve, WWII Relics",
        "posn": [-12.413358,130.822147]
      },	{
              "name": "Humpty Doo, Shopping, Bistro's",
        "posn": [-12.554878,131.118573]
      },	{
              "name": "Jumping Crocodile Cruises",
        "posn": [-12.655747916416404,131.33468627929687]
      },	{
              "name": "Umbruwarra Gorge National Park",
        "posn": [-14.006197,131.626167]
      },	{
              "name": "Jumping Crocodile Cruise",
        "posn": [-12.655747916416404,131.33468627929687]
      },	{
              "name": "Corroborree Billabong - Fishing",
        "posn": [-12.829878533281713,131.56814575195312]
      },	{
              "name": "Coomalie Cultural Precinct - Art Cultural Gallery",
        "posn": [-13.004139598400648,131.1225128173828]
      },	{
              "name": "Rum Jungle Historical Mining Location",
        "posn": [-13.001881592751694,130.99857330322266]
      },	{
              "name": "Litchfield National Park - Waterfalls, Rainforests, Swimming",
        "posn": [-13.04720502716969,130.9178924560547]
      },	{
              "name": "Adelaide River WWII & Historical Town",
        "posn": [-13.2399454992863,131.12045288085937]
      },	{              "name": "Batchelor Township - Shops & Dining",
        "posn": [-13.050547,131.030806]
      },  {            "name": "Katherine - Shopping, Cinemas, Restaurants, Galleries",
        "posn": [-14.465747,132.263619]
      },  {            "name": "Katherine Gorge Cruise, Picnic Area",
        "posn": [-14.311793231096727,132.42233276367187]
      },  {            "name": "Edith Falls, Swimming, Picnic Area",
        "posn": [-14.179685436634228,132.18998908996582]
      },
    ]
  }
];
    var map;
    var mgr;
    var icons = {};

    function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.addControl(new GLargeMapControl());
        map.setCenter(new GLatLng(-23.687476052297945,133.89359951019287), 13);
        map.enableDoubleClickZoom();
        window.setTimeout(setupOfficeMarkers, 0);
      }
    }

    function getIcon(images) {
      var icon = null;
      if (images) {
        if (icons[images[0]]) {
          icon = icons[images[0]];
        } else {
          icon = new GIcon();
          icon.image = "/markermanager/" + images[0] + ".png";
          var size = iconData[images[0]];
          icon.iconSize = new GSize(size.width, size.height);
          icon.iconAnchor = new GPoint(size.width >> 1, size.height >> 1);
          icon.shadow = "/markermanager/" + images[1] + ".png";
          size = iconData[images[1]];
          icon.shadowSize = new GSize(size.width, size.height);
          icons[images[0]] = icon;
        }
      }
      return icon;
    }

    function setupOfficeMarkers() {
      mgr = new GMarkerManager(map);
      for (var i in officeLayer) {
        var layer = officeLayer[i];
        var markers = [];
        for (var j in layer["places"]) {
          var place = layer["places"][j];
          var icon = getIcon(place["icon"]);
          var posn = new GLatLng(place["posn"][0], place["posn"][1]);
          markers.push(new GMarker(posn, { title: place["name"], icon: icon }));
        }
        mgr.addMarkers(markers, layer["zoom"][0], layer["zoom"][1]);
      }
      mgr.refresh();
    }

