var map;
var sofa_marker;
var geocoder;
function loadMaps() {
    if (GBrowserIsCompatible()) {
      map = new GMap2(document.getElementById("mapPane"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl()); 
      map.setCenter(new GLatLng(51.165567, 10.019531), 6);
		sofa_marker = new GIcon(null, '/public/images/marker.gif');
		geocoder = new GClientGeocoder();
    } else {
			window.location.href = "/spotfinder/simple";
		}
}


function addMarkerForAddress(address) {
  geocoder.getLatLng(
    address,
    function(point) {
      if (point) {
/*        map.setCenter(point, 13); */
        var marker = new GMarker(point);
        map.addOverlay(marker);
      }
    }
  );
}

function openInfo(address, text) {
	  geocoder.getLatLng(
	    address,
	    function(point) {
	      if (point) {
				  showMapPane();
	        map.setCenter(point, 16);
	        var marker = new GMarker(point);
					map.openInfoWindowHtml(point, text);
	      } else {
				  showInfoPane();
				}
	    }
	  );
	}

	function showMapPane() {
		Element.hide('informationPane');
		Element.hide('messagePane');
		Element.show('mapPane');
	}

	function showInfoPane() {
		Element.hide('messagePane');
		Element.hide('mapPane');
		Element.show('informationPane');
	}
	function showMessagePane() {
		Element.hide('informationPane');
		Element.hide('mapPane');
		Element.show('messagePane');
	}
