function handleCoordsOnSubmit(formId) {
	//alert("handleCoordsOnSubmit();");
	var mapx = document.getElementById("mapx");
	var mapy = document.getElementById("mapy");
	//alert("MapX:"+mapx+", value="+mapx.value);
	if(mapx.value == "" || mapy.value == "") {
		//alert("bla");
		var geocoder = new GClientGeocoder();
		geocoder.getLatLng(
		getAddressString(),
		function(point) {
			
			
			if (!point) {
				//alert(addressObj.value + " not found");
				alert("Die eingegebene Addresse konnte nicht gefunden werden!");
				
			} else {
				var mapx = document.getElementById("mapx");
				var mapy = document.getElementById("mapy");
				mapx.value = point.x;
				mapy.value = point.y;
				var form =  document.getElementById(formId);
				//alert("Form:"+form);
				form.submit();
			}
		}
		);
		//alert("return false");
		return false;
	} else {
		//alert("return true");
		return true;
	}
}

function getCoords(adressString,formId){
	var geocoder = new GClientGeocoder();
	//alert(adressString);
	//alert(formId);
	
	if(adressString==''){
		var mapx = document.getElementById("mapx");
				var mapy = document.getElementById("mapy");
				mapx.value = '8.547';
				mapy.value = '47.366175';
				var form =  document.getElementById(formId);
				//alert("Form:"+form);
				form.submit();
			return false;
	}
	
	

	
	
	adressString = adressString+' ,schweiz';
	
	
	geocoder.getLatLng(adressString,
	function(point) {
		if (!point) {
			//alert(addressObj.value + " not found");
			alert("Die eingegebene Addresse konnte nicht gefunden werden!");
			return false;
		} else {
			var mapx = document.getElementById("mapx");
			var mapy = document.getElementById("mapy");
			mapx.value = point.x;
			mapy.value = point.y;
		
			var form =  document.getElementById(formId);
			form.submit();
			
		}
		
	}



	); return false;
	
	
}


function getAddressString() {
	var addressObj = document.getElementById("address");
	var zipObj = document.getElementById("zip");
	var cityObj = document.getElementById("city");
	var country = document.getElementById("land");
	return addressObj.value + ", " + zipObj.value + ", " + cityObj.value + ", " + country;
}


function showAddress(address) {
	var geocoder = new GClientGeocoder();
	map = getMap();
	  geocoder.getLatLng(
	    address,
	    function(point) {
	      if (!point) {
	        alert(address + " not found");
	      } else {
	        map.setCenter(point, 13);
	        /*alert(point.toString());
	        alert(point.x);
	        alert(point.y);*/
	        var marker = new GMarker(point);
	        map.addOverlay(marker);
	        marker.openInfoWindowHtml(address);
	      }
	    }
	  );
}

function setMapCenter(x, y,zoom) {
	//alert("setMapCenter: "+x+","+y);
	
	var tmpMap = getMap();
	if(zoom!=''){
		tmpMap.setCenter(new GLatLng(y, x),zoom);
	} else  {
		tmpMap.setCenter(new GLatLng(y, x));
	}
}

function setMapZoom(zoom) {
	//alert("setMapCenter: "+x+","+y);
	
	var tmpMap = getMap();
	
		tmpMap.setZoom(zoom);

}


var mapObj = null;
function setMap(theMap) {
	mapObj = theMap;
}
function getMap() {
	return mapObj;
}