function getIcon(i) {
	// Icon
	var icon 				= new GIcon(G_DEFAULT_ICON);
	icon.image 				= "http://hbx-hannover.de/HBX/img/icon.png";
	icon.iconAnchor 		= new GPoint(16, 16);
	icon.infoWindowAnchor 	= new GPoint(16, 0);
	icon.iconSize 			= new GSize(32, 32);
	return icon;
}
function CenterByAddress( myMap, plz, address, html ) {
	// ====== Create a Client Geocoder ======
	var geo = new GClientGeocoder(); 
	
	// ====== Array for decoding the failure codes ======
	var reasons=[];
	reasons[G_GEO_SUCCESS]            = "Success";
	reasons[G_GEO_MISSING_ADDRESS]    = "Ungültige Adresse: The address was either missing or had no value.";
	reasons[G_GEO_UNKNOWN_ADDRESS]    = "Unbekannte Adresse:  No corresponding geographic location could be found for the specified address.";
	reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Nicht öffentliche Adresse:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
	reasons[G_GEO_BAD_KEY]            = "Abgelaufener Google Maps Key: The API key is either invalid or does not match the domain for which it was given";
	reasons[G_GEO_TOO_MANY_QUERIES]   = "Zu viele Anfragen, bitte versuchen Sie es erneut. (The daily geocoding quota for this site has been exceeded)";
	reasons[G_GEO_SERVER_ERROR]       = "Google Maps Server Fehler: The geocoding request could not be successfully processed.";

	// ====== Geocoding ======
	geo.getLocations(address, function (result) { 
		if (result.Status.code == G_GEO_SUCCESS) {
			for (var i=0; i<result.Placemark.length; i++) {
				var p 		= result.Placemark[i].Point.coordinates;
				var addr 	= result.Placemark[i].address;

				myMap.map.setCenter(myMap.map.getCenter(), 14);
				myMap.map.panTo(new GLatLng(p[1],p[0]));
				//window.scrollTo(0, 0);
				if(html.length>0) myMap.map.openInfoWindow(new GLatLng(p[1],p[0]), html);
			}
		} else {
			// ====== Decode the error status ======
			var reason="Code "+result.Status.code;
			if (reasons[result.Status.code]) {
				reason = reasons[result.Status.code]
			}
			//alert('"'+address+ '" konnte nicht geladen werden: ' + reason + '');
			//setTimeout(function() { window.reload(); }, 1000);
		} 
	});
}
function addAddress( myMap, plz, address, title, html ) {
	// ====== Create a Client Geocoder ======
	var geo = new GClientGeocoder(); 
	
	// ====== Array for decoding the failure codes ======
	var reasons=[];
	reasons[G_GEO_SUCCESS]            = "Success";
	reasons[G_GEO_MISSING_ADDRESS]    = "Ungültige Adresse: The address was either missing or had no value.";
	reasons[G_GEO_UNKNOWN_ADDRESS]    = "Unbekannte Adresse:  No corresponding geographic location could be found for the specified address.";
	reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Nicht öffentliche Adresse:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
	reasons[G_GEO_BAD_KEY]            = "Abgelaufener Google Maps Key: The API key is either invalid or does not match the domain for which it was given";
	reasons[G_GEO_TOO_MANY_QUERIES]   = "Zu viele Anfragen: The daily geocoding quota for this site has been exceeded.";
	reasons[G_GEO_SERVER_ERROR]       = "Google Maps Server Fehler: The geocoding request could not be successfully processed.";
	
	// ====== Geocoding ======
	geo.getLocations(address, function (result) { 
		if (result.Status.code == G_GEO_SUCCESS) {
			for (var i=0; i<result.Placemark.length; i++) {
				var p 		= result.Placemark[i].Point.coordinates;
				var addr 	= result.Placemark[i].address;

				// Marker
				var marker = plz==30159 ? new GMarker(new GLatLng(p[1],p[0]), getIcon(0)) : new GMarker(new GLatLng(p[1],p[0]));
				GEvent.addListener(marker, "click", function() {						 
					marker.openInfoWindowHtml( html );
				});
				
				myMap.mgr.addMarker( marker, 1, 15 );
				myMap.mgr.refresh();
				if(i>1) {
					document.getElementById("gtxt_message").innerHTML += "<br>"+(i+1)+": "+ result.Placemark[i].address + marker.getPoint();
				} else {
					if((typeof plz)=="number") {
						myMap.plz[plz] = plz;
					}
				}
			}
		} else {
			// ====== Decode the error status ======
			var reason="Code "+result.Status.code;
			if (reasons[result.Status.code]) {
				reason = reasons[result.Status.code]
			}
			//alert('"'+address+ '" konnte nicht gefunden werden! (' + reason + ')');
		} 
	});
}
