// JavaScript Document
function bodyLoad() {
  highlight();
  if (GBrowserIsCompatible()){
  loadMap();
  }
}

function loadMap() {
  glotowns(); // create js events for elements with tagName=a, class=town
  map = new GMap2(document.getElementById("mapdiv"));
  map.setCenter(new GLatLng(0,0),0);
  map.addControl(new GSmallMapControl());
  map.addControl(new GMapTypeControl());
  keyboard = new GKeyboardHandler(map);
  bounds = new GLatLngBounds();

  GEvent.addListener(map.getInfoWindow(), "closeclick", function() {
     map.returnToSavedPosition();
  });
  
  // triggered by clicking on any non-overlay point (icons are overlays)
  GEvent.addListener(map, "click", function(overlay, point){
    if (overlay == null){alert('lat= ' + point.x + ' lon= ' + point.y);}
  });
  
  for (var m= towns.length; m < (attArray.length); m++) {
    attractionMarker(map,'province',m,blat,blng);
  }
  
  // note: creating the townMarkers last ensures the towns overlay the attractions
  
  for (m= 0; m < towns.length; m++) {
    townMarker(map,bounds,'province',towns);
  }
  
  map.setCenter(bounds.getCenter());
  map.setZoom(map.getBoundsZoomLevel(bounds));
  


} // end of loadMap()

