//<![CDATA[
	var map;
	var geocoder;
	var inconyMarker;
	var addressIncony = 'Technologiepark 34, 33100 Paderborn';
	var route;
	
	function load() {
		if (GBrowserIsCompatible()) {
			map = new GMap2(document.getElementById('map'));
			map.addControl(new GLargeMapControl());
			
			//Ansichten (Map, Satellite, Hybrid)
			var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));
			map.addControl(new GMapTypeControl(), topRight);
			
			//Masstab
			map.addControl(new GScaleControl());
			
			//map.setCenter(new GLatLng(51.165, 10.455278), 5)
			geocoder = new GClientGeocoder();
			geocoder.setBaseCountryCode('de');
			showAddress(addressIncony, 'fileadmin/scripts2008/incony_logo.gif');
			
			route = new GDirections(map, document.getElementById("directions"));
			GEvent.addListener(route, "error", handleErrors);
		}
	}
	
	function showRoute() {
		var sAddr = trim(document.formular.sourceAddress.value);
		//alert("->"+sAddr+"<-");
		if (sAddr == "") {
			//alert("Bitte geben Sie eine gültige Adresse ein. || Please enter a valid address.");
			if (document.URL.indexOf("L=1") > 0) {
				alert("Please enter a valid address.");
			} else if (document.URL.indexOf("L=2") > 0){
				alert("Taper une adresse s'il vous plaît.");
			} else if (document.URL.indexOf("L=3") > 0){
				alert("Por favor, introduzca su dirección.");
			} else if (document.URL.indexOf("L=4") > 0){
				alert("?");
			} else if (document.URL.indexOf("L=5") > 0){
				alert("?");
			} else {
				alert("Bitte geben Sie eine gültige Adresse ein.");
			}
			
			document.formular.sourceAddress.focus();
			return false;
		}
		//map.removeOverlay(inconyMarker);
		//var route = new GDirections(map);
		var query = "from: " + document.formular.sourceAddress.value + " to: " + addressIncony;
		route.load(query);
	}
	
	function showAddress(address, file) {
		geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					alert(address + " not found");
				} else {
					mark(point, file);
				}
			}
		);
	}
	
	function mark(point, file) {
		map.setCenter(point, 13);
		inconyMarker = new GMarker(point,{title:"INCONY AG, Technologiepark 34, 33100 Paderborn"});
		map.addOverlay(inconyMarker);
		inconyMarker.bindInfoWindowHtml(createLogo(file));
		inconyMarker.openInfoWindowHtml(createLogo(file));
	}
	
	function createLogo(file) {
		var img = document.createElement("img");
		var src = document.createAttribute("src");
		src.nodeValue = file;
		img.setAttributeNode(src);
		return img;
	}
	
	function handleErrors(){
		if (route.getStatus().code == G_GEO_UNKNOWN_ADDRESS) {
			//alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + route.getStatus().code);
			if (document.URL.indexOf("L=1") > 0) {
				alert("Please enter a valid address. (The address could not be found.)");
			} else if (document.URL.indexOf("L=2") > 0){
				alert("Taper une adresse s'il vous plaît. (Impossible de trouver l'adresse.)");
			} else if (document.URL.indexOf("L=3") > 0){
				alert("Por favor, introduzca su dirección. (Podría no se encontrado la dirección.)");
			} else if (document.URL.indexOf("L=4") > 0){
				alert("?");
			} else if (document.URL.indexOf("L=5") > 0){
				alert("?");
			} else {
				alert("Bitte geben Sie eine gültige Adresse ein. (Die Adresse konnte nicht gefunden werden.)");
			}
		} else if (route.getStatus().code == G_GEO_SERVER_ERROR) {
			alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + route.getStatus().code);
		} else if (route.getStatus().code == G_GEO_MISSING_QUERY) {
			alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + route.getStatus().code);
		} else if (route.getStatus().code == G_GEO_BAD_KEY) {
			alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + route.getStatus().code);
		} else if (route.getStatus().code == G_GEO_BAD_REQUEST) {
     alert("A directions request could not be successfully parsed.\n Error code: " + route.getStatus().code);
		} else {
			//alert("An unknown error occurred.");
			if (document.URL.indexOf("L=1") > 0) {
				alert("Please enter a valid address. (The address could not be found!)");
			} else if (document.URL.indexOf("L=2") > 0){
				alert("Taper une adresse s'il vous plaît. (Impossible de trouver l'adresse!)");
			} else if (document.URL.indexOf("L=3") > 0){
				alert("Por favor, introduzca su dirección. (Podría no se encontrado la dirección!)");
			} else if (document.URL.indexOf("L=4") > 0){
				alert("?");
			} else if (document.URL.indexOf("L=5") > 0){
				alert("?");
			} else {
				alert("Bitte geben Sie eine gültige Adresse ein. (Die Adresse konnte nicht gefunden werden!)");
			}
		}
	}
	
	function trim(str) {
		if(typeof(str)=="string") return str.replace(/^\s+|\s+$/g,"");
		else return str;
	}
	
//]]>
