__google_maps_ie6_version = '22.7.2009 v1.9.51'
var key = "";
var __x__debug_enabled = false;
try {
	if (console.debug) {
		__x__debug_enabled = true;
	}
} catch (ignore) {
	;
}

function __debug(s) {
	if (__x__debug_enabled)
		console.debug(s);
}
__debug('__google_maps_ie6_version=' + __google_maps_ie6_version);

function getGoogleKey() {
	__debug('getGoogleKey()');

	if (window.location.hostname.search(/localhost/) != -1) {
		key = 'ABQIAAAA8dJ48dygbiL5ODHMi90nbhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSoxYrWRn1g0XnVIO24REptS0qt-g';
	}
	if (window.location.hostname.search(/saadevlap1/) != -1) {
		key = 'ABQIAAAA8dJ48dygbiL5ODHMi90nbhTUXo3I0jn2i0Bf5VmsgZvehRXy2xSrr0WzRAJYO-RrOei-Bpmz2qGQAA';
	}
	if (window.location.hostname.search(/la-cuna/) != -1) {
		key = 'ABQIAAAA8dJ48dygbiL5ODHMi90nbhRdIespRf9P4MCOrli6sxibWeoFcxT-XUoNLe4T83jJmUgF3yi1NILhOQ';
	}
	if (window.location.hostname.search(/flug.de/) != -1) {
		key = 'ABQIAAAA8dJ48dygbiL5ODHMi90nbhTUXo3I0jn2i0Bf5VmsgZvehRXy2xSrr0WzRAJYO-RrOei-Bpmz2qGQAA';
	}
	if (window.location.hostname.search(/bausteine.flug.de/) != -1) {
		key = 'ABQIAAAA7ZWplVlUHkzYoeM_3IYlbxT42fNSSSDYMJSkMP-Ddcgu3yVlpBQPE-TQWsTMLI1H4xHYZDw-zNIUKg';
	}
	if (window.location.hostname.search(/hotel.flug.de/) != -1) {
		key = 'ABQIAAAA8dJ48dygbiL5ODHMi90nbhRVzFBAXcPDF-DsElFxpAWg7xHetRSYgSxYZaAaU9-BaJTa9X6Ev_35qw';
	}
	if (window.location.hostname.search(/bausteine.travelchannel.de/) != -1) {
		key = 'ABQIAAAA7ZWplVlUHkzYoeM_3IYlbxQ2Y_bAdvFVi-c7opIQHT8Cfy7RExSacsR7oKXVkVV-y3hVhP5nnhjYWQ';
	}
	if (window.location.hostname.search(/hotel.travelchannel.de/) != -1) {
		key = 'ABQIAAAA8dJ48dygbiL5ODHMi90nbhRM304kF0_bMYpW-oM235Bu6L6gBxTAat4S32ceUHCgFkoixVDy067rMw';
	}
	if (window.location.hostname.search(/bausteine.travel-overland.de/) != -1) {
		key = 'ABQIAAAA7ZWplVlUHkzYoeM_3IYlbxRHrlLg3BmAbX8cILNNKI1EbFIwYxQVLv4IVhehV6CFqMBjoWz5qTfCAQ';
	}
	if (window.location.hostname.search(/hotel.travel-overland.de/) != -1) {
		key = 'ABQIAAAA8dJ48dygbiL5ODHMi90nbhSlUPDkZgO_fzlyjamOZ7TdywSF6RQ9dXyt9yPbkqpYObDPFJBr5wS8SA';
	}
	if (window.location.hostname.search(/easynet.de/) != -1) {
		key = 'ABQIAAAA8dJ48dygbiL5ODHMi90nbhQ-XDLtVrLdFtGJALBH50EboeT5xxR6rlRGDoanvfa9n9b_vYKr2FaTkA';
	}
	if (window.location.hostname.search(/anixe.pl/) != -1) {
		key = 'ABQIAAAA8dJ48dygbiL5ODHMi90nbhQpTW5ZPRAwRfauVNWLYsE846gE_RTRSDa_OE57tMJVuoGUr32AhOYpMQ';
	}
	if (window.location.hostname.search(/resfinity.com/) != -1) {
		key = 'ABQIAAAA8dJ48dygbiL5ODHMi90nbhSsHJD1OtN3RhzprypQglgeIPRKJRR73im9A8tZVJ2MtTwF1pvsC6F-yw';
	}
	if (window.location.hostname.search(/aerticket.de/) != -1) {
		key = 'ABQIAAAA8dJ48dygbiL5ODHMi90nbhQWycN-70sGp8nVnnL6SKqn6hSmQhQWCAzQw_TFhvhX89akevVhOyTnPA';
	}
	if (window.location.hostname.search(/morehotels.de/) != -1) {
		key = 'ABQIAAAAI5JneGC4CWQApL6rUIrk8RQt1av5xneJRRb7edgPeh05SKNpTBSk_N3iNsxPx4WtJLgCa8u2GRQ2rg';
	}
	if (window.location.hostname.search(/traveltopia.de/) != -1) {
		key = 'ABQIAAAA8dJ48dygbiL5ODHMi90nbhS0CvDe54faq-yQspU7Yi0XACgHRRQpsBCt3PJHhGbf4FL-Pk_Jg3McEw';
	}
	if (window.location.hostname.search(/bausteine.traveltopia.de/) != -1) {
		key = 'ABQIAAAAI5JneGC4CWQApL6rUIrk8RQob0GcFTthHxCacUQ-IsWBZffZMBR_NuKVOzYHAwBrF6uYcKlGgizptw';
	}
	if (window.location.hostname.search(/travel-overland.de/) != -1) {
		key = 'ABQIAAAA8dJ48dygbiL5ODHMi90nbhRCfwKE4fzsm_njzoi5Jqwssli42BTtT3sglbpnv_hCWao3FkGK9j2jbQ';
	}
	if (window.location.hostname.search(/www.travel-overland.de/) != -1) {
		key = 'ABQIAAAA8dJ48dygbiL5ODHMi90nbhTUaN8v5aUOyMuXD2ESnF96rIb-ixSfJNsnQLX78syCOFj05FGJZMxYiw';
	}
}
var asyncASPNETInit = false;
var pageType = null;

function initLoaderASPNET(pageTypeName) {
	__debug('initLoaderASPNET: ' + pageTypeName);

	__goo_ahaead = false;
	asyncASPNETInit = true;
	pageType = pageTypeName;
	// alert('initLoaderASPNET');
	_iegg_timeout = 120;
	_iegg_timerId = null;

	loadWait();
	__debug('initLoaderASPNET: exit');
}

var _iegg_timerId, _iegg_timeout;
function loadWait() {
	__debug('loadWait:  _iegg_timeout=' + _iegg_timeout);
	if (!!(_iegg_timerId)) {
		if (_iegg_timeout == 0) {

			__debug("Program load timeout ...");
			initLoader(); // Ok to launch anyway ...
			return;
		}
		try {
			__debug('document.readyState=: ' + document.readyState);
			if (/loaded|complete|undefined/.test(document.readyState)) {
				__debug('loadWait::call initLoader');
				initLoader(); // Ok to launch the actual program
				return;
			} else {
				__debug('window.onLoad event not found ... yet');
			}
		} catch (ignore) {
			__debug('loadWait::exception ignore: ' + ignore);
		}
		_iegg_timeout -= 1;
	}
	_iegg_timerId = setTimeout("loadWait()", 1000);
	return;
}
function initLoader() {
	__debug('initLoader');
	getGoogleKey();

	var script = document.createElement("script");
	script.src = "http://www.google.com/jsapi?&key=" + key
			+ "&callback=loadMaps";
	script.type = "text/javascript";
	__debug('initLoader:: Google script.src=' + script.src);
	document.getElementsByTagName("head")[0].appendChild(script);
	__debug('initLoader:: appendChild done');
	if (asyncASPNETInit) {
		try {
			window.onunload = _GoogleUnload;
		} catch (ignore) {
			;
			__debug('initLoader:: set window.onunload failed' + ignore);
		}
	}
}
function loadMaps() {
	__debug('loadMaps()');
	google.load("maps", "2.x", {
		"callback" : load_other_scripts,
		"language" : "de",
		"key" : key,
		"other_params" : "sensor=true"
	});
}
function _GoogleUnload() {
	__debug('_GoogleUnload()');
	GUnload();
}
function load_other_scripts() {
	__debug('load_other_scripts()');

	maps_initialize();
	if (asyncASPNETInit) {
		__debug('load_other_scripts::asyncASPNETInit is set');
		if (pageType == null) {
			pageType = "list";
		}
		_maps_initialize(hotelLocations, pageType);
	}
}
var state = 'none';

function build_html(hotel) {
	__debug('build_html: ' + hotel['name'] + ' lat:' + hotel['lat'] + ' lng:'
			+ hotel['lng']);

	var html = "<div class='googlemaphoteldiv'><style type='text/css'>.tooltip { background-color:#1f1f1f; font-weight:bold; border:2px #006699 solid;}</style>";
	if (hotel['img'] != null) {
		if (hotel['img'].length > 1) {
			html += "<img style='float:left; margin-right:4px; height:78px; width:78px;' src=\""
					+ hotel['img'] + "\" ";
		}
	}
	if (hotel['name'] != null) {
		if (hotel['name'].length > 1) {
			html += "Hotel: <b>" + hotel['name'] + "</b><br/>";
		}
	}
	if (hotel['addr'] != null) {
		if (hotel['addr'].length > 1) {
			html += hotel['addr'] + "<br/>";
		}
	}
	if (hotel['price'] != null) {
		if (hotel['price'].length > 1) {
			html += hotel['price'] + "<br/>";
		}
	}
	if (hotel['details'] != null) {
		if (hotel['details'].length > 1) {
			html += "<a href=\"javascript: popup('" + hotel['details']
					+ "', 'Hoteldetails', 670, 625);\">Hoteldetails</a>";
		}
	}
	html += "</div>";
	return html;
}

function _showhide(layer_ref, showhide) {
	__debug('call to _showhide: ' + layer_ref + ' showhide:' + showhide);
	var hza = null;
	hza = document.getElementById(layer_ref);

	if (hza != null) {
		state = hza.style.display;
		if (state == '') {
			state = 'none';
		} else if (state == 'inline') {
			state = 'none';
		} else if (state == 'block') {
			state = 'none';
		} else if (state == 'none') {
			state = 'block';
		} else {
			state = 'block';
		}
		if (showhide != null) {
			if (showhide) {
				state = 'block';
			} else {
				state = 'none';
			}
		}
		hza.style.display = state;
		_inner_maps_initialize(__we_safe_our_locations, __we_safe_our_typ);

	} else {
		__debug('ERROR _showhide: element not found' + layer_ref);
	}
	_showHide_Markers(showhide);
}
function _showHide_Markers(showhide) {
	__debug('call to _showHide_Markers: ' + showhide);

	var letters = new Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
			"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
			"X", "Y", "Z");
	for ( var i = 0; i < letters.length; ++i) {
		var id_name = 'map_marker_' + letters[i];
		if (document.getElementById(id_name)) {
			state = document.getElementById(id_name).style.display;
			if (state == '') {
				state = 'none';
			} else if (state == 'block') {
				state = 'none';
			} else if (state == 'inline') {
				state = 'none';
			} else if (state == 'none') {
				state = 'inline';
			} else {
				state = 'inline';
			}
		}
		if (showhide != null) {
			if (showhide) {
				state = 'inline';
			} else {
				state = 'none';
			}
		}
		if (document.getElementById(id_name)) {
			document.getElementById(id_name).style.display = state;
		}
	}
}
var myPano;

function _streetview_initialize(locations, typ) {
	for ( var i = 0; i < locations['hotels'].length; i++) {
		var view = locations['streetviews'][i];

		var fenwayPark = new GLatLng(view['lat'], view['lng']);

		panoramaOptions = {
			latlng : fenwayPark
		};
		myPano = new GStreetviewPanorama(document
				.getElementById("streetview_canvas"), panoramaOptions);
		GEvent.addListener(myPano, "error", handleNoFlash);
		break;
	}
}

function handleNoFlash(errorCode) {
	if (errorCode == FLASH_UNAVAILABLE) {
		alert("Error: Flash doesn't appear to be supported by your browser");
		return;
	}
}
var tooltip = null;
var map = null;
var __we_safe_our_locations;
var __we_safe_our_typ;

function _maps_initialize(locations, typ) {
	__we_safe_our_locations = locations;
	__we_safe_our_typ = typ;

	state = '';

	_canvas = document.getElementById("map_canvas");
	if (_canvas != null) {
		state = _canvas.style.display;
	}
	if (state != 'none') {
		_inner_maps_initialize(__we_safe_our_locations, __we_safe_our_typ);
	}
}

function _inner_maps_initialize(locations, typ) {

	try {
		__debug('call to _maps_initialize: ' + locations + ' typ:' + typ);

		if (GBrowserIsCompatible()) {
			var zoomLevel = 13;

			var baseIcon = new GIcon(G_DEFAULT_ICON);
			baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
			baseIcon.iconSize = new GSize(20, 34);
			baseIcon.shadowSize = new GSize(37, 34);
			baseIcon.iconAnchor = new GPoint(9, 34);
			baseIcon.infoWindowAnchor = new GPoint(9, 2);

			var myOptions = null;
			map = new GMap2(document.getElementById("map_canvas"), myOptions);

			if (typ == "small") {
				map.addControl(new GSmallZoomControl());
				map.addControl(new GScaleControl());

				tooltip = document.createElement("div");
				document.getElementById("map_canvas").appendChild(tooltip);
				tooltip.style.visibility = "hidden";

			} else {
				map.addControl(new GMapTypeControl());
			}

			var customUI = map.getDefaultUI();
			// Remove MapType.G_HYBRID_MAP
			customUI.maptypes.hybrid = false;
			map.setUI(customUI);

			// Creates a marker whose info window displays the letter
			// corresponding
			// to the given index.
			function createMarker(point, index) {

				var hotel = locations['hotels'][index];
				var html = build_html(hotel);
				// Set up our GMarkerOptions object
				var marker = null;
				if (typ == "small") {
					var tinyIcon = new GIcon();
					tinyIcon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
					tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
					tinyIcon.iconSize = new GSize(12, 20);
					tinyIcon.shadowSize = new GSize(22, 20);
					tinyIcon.iconAnchor = new GPoint(6, 20);
					tinyIcon.infoWindowAnchor = new GPoint(5, 1);
					markerOptions = {
						icon : tinyIcon
					};

					marker = new GMarker(point, markerOptions);
					marker.tooltip = '<div style="background-color:#ffffff;  border:1px #cccccc solid; padding:5px; font-size:11px">' + html + '<\/div>';

					// ====== The new marker "mouseover" and "mouseout"
					// listeners
					// ======
					GEvent.addListener(marker, "mouseover", function() {
						showTooltip(marker);
					});
					GEvent.addListener(marker, "mouseout", function() {
						tooltip.style.visibility = "hidden"
					});

				} else if (typ == "small_with_popup") {
					var opts = {
						draggable : true,
						text : html
					};
					// marker = new PopupMarker(point, opts);
					// GEvent.addListener(marker,"mouseover", function(){
					// marker.showPopup();});
					// GEvent.addListener(marker,"mouseout", function(){
					// marker.hidePopup();});
				} else if (typ == "details") {
					// Create a lettered icon for this point using our icon class
					var letteredIcon = new GIcon(baseIcon);
					letteredIcon.image = "http://www.google.com/mapfiles/marker.png";
					markerOptions = {
						icon : letteredIcon
					};
					marker = new GMarker(point, markerOptions);
					GEvent.addListener(marker, "mouseover", function() {
						marker.openInfoWindowHtml(html);
					});
				} else {
					// Create a lettered icon for this point using our icon class
					var letter = String.fromCharCode("A".charCodeAt(0) + index);
					var letteredIcon = new GIcon(baseIcon);
					letteredIcon.image = "http://www.google.com/mapfiles/marker"
							+ letter + ".png";
					markerOptions = {
						icon : letteredIcon
					};
					marker = new GMarker(point, markerOptions);
					GEvent.addListener(marker, "mouseover", function() {
						marker.openInfoWindowHtml(html);
					});
				}
				map.addOverlay(marker);

				marker.show();
				return marker;
			}
			var bounds = null;

			for ( var i = 0; i < locations['hotels'].length; i++) {
				var hotel = locations['hotels'][i];

				// alert('Hotel' + hotel['name']+' lat:' +hotel['lat'] + ' lng:'
				// +
				// hotel['lng']);
				var point = new GLatLng(hotel['lat'], hotel['lng']);

				map.setCenter(point, 13);
				if (bounds == null) {
					bounds = map.getBounds();
				}
				bounds.extend(point);
				map.setCenter(bounds.getCenter());
				map.setZoom(map.getBoundsZoomLevel(bounds));
				map.addOverlay(createMarker(point, i));

			}
			map.setCenter(bounds.getCenter());
			map.setZoom(map.getBoundsZoomLevel(bounds));
		}
	} catch (ignore) {
	}
}
// ====== This function displays the tooltip ======
// it can be called from an icon mousover or a side_bar mouseover
function showTooltip(marker) {
	tooltip.innerHTML = marker.tooltip;
	var point = map.getCurrentMapType().getProjection().fromLatLngToPixel(
			map.getBounds().getSouthWest(), map.getZoom());
	var offset = map.getCurrentMapType().getProjection().fromLatLngToPixel(
			marker.getPoint(), map.getZoom());
	var anchor = marker.getIcon().iconAnchor;
	var width = marker.getIcon().iconSize.width;
	// var pos = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(offset.x -
	// point.x - anchor.x + width,- offset.y + point.y +anchor.y));
	var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(offset.x
			- point.x - anchor.x + width, -offset.y + point.y));
	pos.apply(tooltip);
	tooltip.style.visibility = "visible";
}
// ===== This function is invoked when the mouse goes over an entry in the
// side_bar =====
// It launches the tooltip on the icon
function mymouseover(i) {
	showTooltip(gmarkers[i])
}
// ===== This function is invoked when the mouse leaves an entry in the side_bar
// =====
// It hides the tooltip
function mymouseout() {
	tooltip.style.visibility = "hidden";
}

