/* ************************************************************************************* */
/* * 
/* * Script file: Google Maps, Holiday Media
/* * Authors: Wim Latour & Jan Verharen
/* * dev@holiday.nl
/* * 
/* ************************************************************************************* */

var map = null;
var geocoder = null;
var zoom = 10;

function GMap_load(latitude,longitude) {
  var address = document.frmGMapLocation.frmGMapAddress.value;
  var content = document.frmGMapLocation.frmGMapContent.value;
  if (!content) content = address;

  if (document.frmGMapRoute && document.frmGMapRoute.frmGMapDestinationAddress) {
    if (! document.frmGMapRoute.frmGMapDestinationAddress.value)
      document.frmGMapRoute.frmGMapDestinationAddress.value = address;
  }
  
  if (GBrowserIsCompatible()) {
  
    var icon = new GIcon(); 
        icon.iconAnchor = new GPoint(8, 8);
        icon.infoWindowAnchor = new GPoint(8, 8);
        icon.iconSize = new GSize(22, 37);
        icon.image = "http://www.paalberg.nl/images/googlemaps/hs_paalberg.png";
    
    map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(latitude, longitude), zoom);
    map.setMapType(G_HYBRID_MAP); /* both layers */
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    map.addControl(new GOverviewMapControl(new GSize(100, 75)));
    geocoder = new GClientGeocoder();
    
     if (latitude&&longitude) {
      
      latitude  = 52.28937;
      longitude = 5.64478
      
      var marker = new GMarker(new GLatLng(latitude, longitude), icon);
      map.addOverlay(marker);

      var WINDOW_HTML = GMap_genHTML(content);

      GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(WINDOW_HTML);
      });
      //marker.openInfoWindowHtml(WINDOW_HTML);

    } else {

//      GMap_showAddress(address, content);

    }
  }
}

function GMap_genHTML(content) {
  var WINDOW_HTML;
  WINDOW_HTML = '<div class="GMapLocationPopup">';
  WINDOW_HTML += content;
  WINDOW_HTML += '</div>';
  return WINDOW_HTML;
}

