var map; var map_kml = null; var map_manager = null;
/*
function map_load_manager()
{
  map = new GMap2(document.getElementById('map_div'));
  map.enableContinuousZoom();
  map.enableDoubleClickZoom();
  if ((document.getElementById('map_clickable') == null) ? false : (document.getElementById('map_clickable').value == '0')) map.disableInfoWindow();
  map.addControl(new GSmallMapControl());
  map_manager = new GMarkerManager(map);
}
*/
function map_load()
{
  if (document.getElementById('map_div') == null) return;
  if (GBrowserIsCompatible())
  {
    map = new GMap2(document.getElementById('map_div'));
    map.enableContinuousZoom();
    map.enableDoubleClickZoom();
    if ((document.getElementById('map_clickable') == null) ? false : (document.getElementById('map_clickable').value == '0')) map.disableInfoWindow();
    map.addControl(new GSmallMapControl());
    var lng = (document.getElementById('lng') == null) ? -72.925014 : document.getElementById('lng').value, lat = (document.getElementById('lat') == null) ? 41.307165 : document.getElementById('lat').value;
    var zoom = (document.getElementById('zoom') == null) ? 15 : parseInt(document.getElementById('zoom').value);
    if (document.getElementById('lat2') == null)  map.setCenter(new GLatLng(lat, lng), zoom);
    else
    {
      var bounds = new GLatLngBounds();
      bounds.extend(new GLatLng(lat, lng));
      bounds.extend(new GLatLng(document.getElementById('lat2').value, document.getElementById('lng2').value));
      var zoom2 = map.getBoundsZoomLevel(bounds);
      if (zoom2 > zoom) zoom2 = zoom;
      map.setCenter(bounds.getCenter(), zoom2);
    }
    map_kml = new GGeoXml(document.getElementById('kml').value);
    map.addOverlay(map_kml);
  }
}
function map_navigate(num)
{
  if (map_kml)
  {
    var points = null;
    for(var i in map_kml)
    {
      if (map_kml[i][0])
      {
        if (map_kml[i][0].getPoint)
        {
          points = map_kml[i];
          alert(points);
          //break;
        }
      }
    }
    alert(num);
    alert(points.length);
    if (num < points.length) GEvent.trigger(points[num], 'click');
  }
}