document.write('<scr' + 'ipt src="http://maps.google.com/maps/api/js?sensor=false&amp;language=de" type="text/javascript"></scr' + 'ipt>');document.write('<scr' + 'ipt src="/prototype.js" type="text/javascript"></scr' + 'ipt>');document.write('<scr' + 'ipt src="/scriptaculous.js" type="text/javascript"></scr' + 'ipt>');document.write('<scr' + 'ipt src="/control.validator.js" type="text/javascript"></scr' + 'ipt>');document.write('<scr' + 'ipt src="/control.browser.js" type="text/javascript"></scr' + 'ipt>');function initMap() {
	google.maps.Map.prototype.markers = new Array();
	google.maps.Map.prototype.polylines = new Array();
	google.maps.Map.prototype.addMarker = function(marker) {
		this.markers[this.markers.length] = marker;
	};
	google.maps.Map.prototype.addPolyline = function(polyline) {
		polyline.setMap(this);
		this.polylines[this.polylines.length] = polyline;
	};
	google.maps.Map.prototype.getMarkers = function() {
		return this.markers;
	};
	google.maps.Map.prototype.getPolylines = function() {
		return this.polylines;
	};
	google.maps.Map.prototype.clearMarkers = function() {
		for(var i=0; i<this.markers.length; i++){
			this.markers[i].setMap(null);
			if(!Object.isUndefined(this.markers[i].infowindow)) {
				this.markers[i].infowindow.close();
			}
			if(!Object.isUndefined(this.markers[i].statusBox)) {
				this.markers[i].statusBox.unbind("position");
				this.markers[i].statusBox.unbind("text");
				this.markers[i].statusBox.close();
			}
		}
	};
	google.maps.Map.prototype.clearPolylines = function() {
		for(var i=0; i<this.polylines.length; i++){
			this.polylines[i].setMap(null);
		}
	};
}function createBalloon(marker, latlon){
	if (!Object.isUndefined(marker.infowindow)) marker.infowindow.close();
	
	var geocoder = new google.maps.Geocoder();				
	geocoder.geocode({"latLng": latlon, "language":"de"},
		function(results, status) {
			if(!results) return;
			
			place = results[0].formatted_address;
			marker.infowindow = new google.maps.InfoWindow({content: "<br />" + place });
			marker.infowindow.open(map, marker);
		}
	);
}function createMarker(map, icon, latlng) {
	var marker = new google.maps.Marker({ position: latlng, map: map, icon: icon, shadow: new google.maps.MarkerImage("/images/shadow50.png", new google.maps.Size(37, 34), new google.maps.Point(0, 0), new google.maps.Point(22, 28)) });
	
	google.maps.event.addListener(marker, "mouseover", function() {
		createBalloon(marker, latlng);
	});
	google.maps.event.addListener(marker, "mouseout", function() {
		if (!Object.isUndefined(marker.infowindow)) marker.infowindow.close();
	});
	
	return marker;
};function LoadPlace(id, place){
	var geocoder = new google.maps.Geocoder();
	map = new google.maps.Map($(id), { 
			zoom:12, 
			center: new google.maps.LatLng(0, 0), 
			mapTypeId: google.maps.MapTypeId.ROADMAP 
	});
	map.clearMarkers();
	map.clearPolylines();
	if (geocoder) {
		geocoder.geocode( { "address": place}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				map.setCenter(results[0].geometry.location);
				var img = "/images/markerA.png";
				var l_marker = createMarker(map, new google.maps.MarkerImage(img, new google.maps.Size(48, 48), new google.maps.Point(0, 0), new google.maps.Point(24, 24)), results[0].geometry.location);
				map.addMarker(l_marker);
			}
		});
	}
}function LoadCity(id, place){
	map = new google.maps.Map($(id), { 
			zoom:12, 
			center: new google.maps.LatLng(0, 0), 
			mapTypeId: google.maps.MapTypeId.ROADMAP 
	});
	
	new Ajax.Request("/ajax_content.php?GETCITY", {
			method: "post",
			parameters: { placename: place },
			onSuccess: function(transport){
				pos = eval('(' + transport.responseText + ')');
				var lat = parseFloat(pos[0].latitude);
				var lon = parseFloat(pos[0].longitude);
				var org = new google.maps.LatLng(lat, lon);
				
				map.clearMarkers();
				map.clearPolylines();
				
				map.setCenter(org);
				var img = "/images/markerA.png";
				var l_marker = createMarker(map, new google.maps.MarkerImage(img, new google.maps.Size(48, 48), new google.maps.Point(0, 0), new google.maps.Point(24, 24)), org);
				
				/*
				l_marker.statusBox = new statusBox({
					map: map
				});
				l_marker.statusBox.setText(l_content);
				*/
				map.addMarker(l_marker);
				
			}
	});
}function LoadCountry(id, place){
	var geocoder = new google.maps.Geocoder();
	map = new google.maps.Map($(id), { 
			zoom:8, 
			center: new google.maps.LatLng(0, 0), 
			mapTypeId: google.maps.MapTypeId.ROADMAP 
	});
	map.clearMarkers();
	map.clearPolylines();
	if (geocoder) {
		geocoder.geocode( { "address": place}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				map.setCenter(results[0].geometry.location);
				var img = "/images/markerA.png";
				var l_marker = createMarker(map, new google.maps.MarkerImage(img, new google.maps.Size(48, 48), new google.maps.Point(0, 0), new google.maps.Point(24, 24)), results[0].geometry.location);
				map.addMarker(l_marker);
			}
		});
	}
}function LoadRouting(id, start, end, mode, hw, panel){
	map = new google.maps.Map($(id), { 
			zoom:12, 
			center: new google.maps.LatLng(0, 0), 
			mapTypeId: google.maps.MapTypeId.ROADMAP 
	});
	var directionsService = new google.maps.DirectionsService();
	var directionsDisplay = new google.maps.DirectionsRenderer();
	directionsDisplay.setMap(map);
	directionsDisplay.setPanel($(panel));
	
	var request = {
        origin: unescape(start), 
        destination: unescape(end),
        travelMode: mode?google.maps.DirectionsTravelMode.DRIVING:google.maps.DirectionsTravelMode.WALKING,
		avoidHighways: hw
    };
	
	directionsService.route(request, function(response, status) {
      if (status == google.maps.DirectionsStatus.OK) {
        directionsDisplay.setDirections(response);
      }
    });
}function HandleTextbox(){
	$$('INPUT.searchInput').each(function(item){ item.observe("click", function(e){ item.value=""; }); });
}function IEFix(){
	if(Prototype.Browser.IE && BrowserDetect.version < 7){
		$$('INPUT.searchInput').each(function(item){ item.setStyle({ height: "19px", fontFace:"Verdana, Geneva, sans-serif", fontSize: "14px", paddingTop: "3px", color: "#999", cssFloat: "left", marginLeft: "-25px", marginRight: "10px"}); });
		$$('INPUT[type="image"]').each(function(item){ item.setStyle({ marginTop: "-40px", marginRight: "15px", cssFloat: "right" }); });
		var adsense = $('adsense');
		if(adsense){
			adsense.setStyle({ marginTop: "-320px" });
		}
	}
}
