//<![CDATA[
	var map;
    var directionsPanel;
    var directions;

    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(17.735607,-64.721575), 13);
      }
    }
	
	function showAddress(address) {
		var map = new GMap2(document.getElementById("map"));
		var geocoder = new GClientGeocoder();
		if (geocoder) {
			geocoder.getLatLng(
			  address,
			  function(point) {
				if (!point) {
				  alert(address + " not found");
				} else {
				  map.setCenter(point, 13);
				  var marker = new GMarker(point);
				  map.addOverlay(marker);
				  marker.openInfoWindowHtml(address);
				  map.addControl(new GSmallMapControl());
				}
			  }
			);
		}
    }
	
    function setDirections(start, end) {
      map = new GMap2(document.getElementById("map"));
      directionsPanel = document.getElementById("route");
     // map.setCenter(new GLatLng(42.351505,-71.094455), 15);
      directions = new GDirections(map, directionsPanel);
	  // directionsPanel.style.border ="2px solid #A9511B;"; 
	  directionsPanel.style.backgroundColor = "#F0E9D7";
      directions.load(start + " to " + end);
    }
	
	function prepareDirections(){
		if(!document.getElementById) return false;
		if(!document.getElementById("map")) return false;
		
		// if(!document.getElementById("mapform")) return false;
		
		var map_id = document.getElementById("map");
		
		var route_form = document.getElementById("mapform");
		// 12 Hill St, Christiansted, St Croix, US Virgin Islands 00820
		// 12 Beeston Hill
		showAddress("Beeston Hill, Christiansted, Virgin Islands");
		
		route_form.onsubmit = function(){
			setDirections(this.startadd.value, this.finaladd.value); 
			return false;
		}
	}
	
	addLoadEvent(prepareDirections);
//]]>
