var tooltip_altona;
var tooltip_ueberseebruecke;
var tooltip_hafencity;
var altona;
var ueberseebruecke;
var hafencity;

    function initialize(lang) {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(53.548,9.974), 13);
var blueIcon = new GIcon(G_DEFAULT_ICON);
blueIcon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
markerOptions = { icon:blueIcon };
altona = new GMarker(new GLatLng(53.543889,9.935833), markerOptions);
ueberseebruecke = new GMarker(new GLatLng(53.543611,9.977778), markerOptions);
hafencity = new GMarker(new GLatLng(53.538700,9.995722), markerOptions);
map.addOverlay(altona);
map.addOverlay(ueberseebruecke);
map.addOverlay(hafencity);

tooltip_altona = document.createElement("div");
document.getElementById("map_canvas").appendChild(tooltip_altona);
if(lang == 'en') {
	tooltip_altona.innerHTML = '<div class="map_tooltip"><strong>Hamburg Cruise Center Altona</strong><br /><br />Edgar –Engelhard-Kai<br />22767 Hamburg<br /><br />Total quay length: 326m</div>';
} else {
	tooltip_altona.innerHTML = '<div class="map_tooltip"><strong>Hamburg Cruise Center Altona</strong><br /><br />Edgar –Engelhard-Kai<br />22767 Hamburg<br /><br />Kailänge: 326m</div>';
}

tooltip_ueberseebruecke = document.createElement("div");
document.getElementById("map_canvas").appendChild(tooltip_ueberseebruecke);
if (lang == 'en') {
	tooltip_ueberseebruecke.innerHTML = '<div class="map_tooltip"><strong>Überseebrücke</strong><br /><br />Landungsbrücken<br />20459 Hamburg<br /><br />Total quay length: 260m</div>';
}
else {
	tooltip_ueberseebruecke.innerHTML = '<div class="map_tooltip"><strong>Überseebrücke</strong><br /><br />Landungsbrücken<br />20459 Hamburg<br /><br />Kailänge: 260m</div>';
}

tooltip_hafencity = document.createElement("div");
document.getElementById("map_canvas").appendChild(tooltip_hafencity);
if (lang == 'en') {
	tooltip_hafencity.innerHTML = '<div class="map_tooltip"><strong>Hamburg Cruise Center HafenCity</strong><br /><br />Großer Grasbrook/Chicagokai<br />20457 Hamburg<br /><br />Total quay length: 295m/330m</div>';
}
else {
	tooltip_hafencity.innerHTML = '<div class="map_tooltip"><strong>Hamburg Cruise Center HafenCity</strong><br /><br />Großer Grasbrook/Chicagokai<br />20457 Hamburg<br /><br />Kailänge: 295m/330m</div>';
}

GEvent.addListener(altona, "click", function() {
          window.location = "/node/8";
        });
GEvent.addListener(ueberseebruecke, "click", function() {
          window.location = "/node/99";
        });
GEvent.addListener(hafencity, "click", function() {
          window.location = "/node/9";
        });
GEvent.addListener(map, "moveend", function() {
	updateMapTooltips(map);
});
GEvent.addListener(map, "movestart", function() {
	hideTooltips(map);
});

updateMapTooltips(map);
      }
    }
	
function hideTooltips(map) {
	tooltip_hafencity.style.visibility = 'hidden';
	tooltip_ueberseebruecke.style.visibility="hidden";
	tooltip_altona.style.visibility="hidden";
}

function updateMapTooltips(map) {
var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom());
var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(altona.getPoint(),map.getZoom());
var anchor=altona.getIcon().iconAnchor;
var width = altona.getIcon().iconSize.width;
var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - point.x - anchor.x + width,- offset.y + point.y +anchor.y)); 
pos.apply(tooltip_altona);
tooltip_altona.style.visibility="visible";
offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(ueberseebruecke.getPoint(),map.getZoom());
anchor=ueberseebruecke.getIcon().iconAnchor;
width = ueberseebruecke.getIcon().iconSize.width;
pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - point.x - anchor.x + width,- offset.y + point.y +anchor.y)); 
pos.apply(tooltip_ueberseebruecke);
tooltip_ueberseebruecke.style.visibility="visible";
offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(hafencity.getPoint(),map.getZoom());
anchor=hafencity.getIcon().iconAnchor;
width = hafencity.getIcon().iconSize.width;
pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - point.x - anchor.x + width,- offset.y + point.y +anchor.y)); 
pos.apply(tooltip_hafencity);
tooltip_hafencity.style.visibility="visible";
}
