    //<![CDATA[
	  	var gLocalSearch;
	  	var map
		var gCurrentResults = [];
		var marker
		var theLat
		var theLng
		
		
	function CaptureForm(searchForm) {
      gLocalSearch.execute(searchForm.input.value);
      return false;
    }
	
	// Returns the HTML we display for a result before it has been "saved"
    LocalResult.prototype.unselectedHtml = function() {
      var container = document.createElement("div");
      container.className = "unselected";
      container.appendChild(this.result_.html.cloneNode(true));
      var saveDiv = document.createElement("div");
      saveDiv.className = "select";
      saveDiv.innerHTML = "Save this location";
      GEvent.bindDom(saveDiv, "click", this, function() {
        gMap.closeInfoWindow();
        this.select();
        gSelectedResults.push(this);
      });
      container.appendChild(saveDiv);
      return container;
    }
	
	// ----------- OnLocalSearch ----------------
	function OnLocalSearch() {
      if (!gLocalSearch.results) return;
      var searchWell = document.getElementById("dpanel");

      // Clear the map and the old search well
      searchWell.innerHTML = "";
      dirs.clear()

      gCurrentResults = [];
      for (var i = 0; i < gLocalSearch.results.length; i++) {
        gCurrentResults.push(new LocalResult(gLocalSearch.results[i]));
      }

      var attribution = gLocalSearch.getAttribution();
      if (attribution) {
        document.getElementById("searchwell").appendChild(attribution);
      }

      // move the map to the first result
      var first = gLocalSearch.results[0];
		theLat = parseFloat(first.lat)
		theLng = parseFloat(first.lng)
		fromStr = theLat + "," + theLng
		getDirections(fromStr)
		// map.recenterOrPanToLatLng(new GPoint(parseFloat(first.lng), parseFloat(first.lat)));
    }
	// ---------- End OnLocalSearch -------------------
	
	function LocalResult(result) {
      this.result_ = result;
      this.resultNode_ = this.unselectedHtml();
      document.getElementById("dpanel").appendChild(this.resultNode_);
      map.addOverlay(marker);
    }
	
    function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("dmap"));
		dirs = new GDirections(map, document.getElementById("dpanel"))
		
		gSearchForm = new google.search.SearchForm(false, document.getElementById("searchform"));
      	gSearchForm.setOnSubmitCallback(null, CaptureForm);
      	gSearchForm.input.focus();
		
		// Initialize the local searcher
      gLocalSearch = new google.search.LocalSearch();
      gLocalSearch.setCenterPoint(map);
      gLocalSearch.setSearchCompleteCallback(null, OnLocalSearch);
	  
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(53.627299,-1.766489), 11);
		var icon = new GIcon(G_DEFAULT_ICON);
		
		icon.infoWindowAnchor = new GPoint(10, 34);
		marker = new GMarker(map.getCenter(), icon)
		map.addOverlay(marker);
		
		var html = "<div style='width: 200px; font-family: verdana,arial,helvetica,sans-serif; font-size:80%; line-height: 110%;'><b>Ashes Common Farm</b><br>Ashes Lane, Almondbury, Huddersfield HD4 6TE<br><b>Tel/Fax: </b>01484 426507<br><b>Email: </b><a href=\"mailto:enquiries@ashescommonfarm.co.uk\">enquiries@ashescommonfarm.co.uk</a>";
		marker.openInfoWindowHtml(html)
		GEvent.addListener(marker, "click", function() {
  		  marker.openInfoWindowHtml(html);
		  
		 
  		});
		
      }
    }
	
	function getDirections(startPoint) {
		
		qStr = "from: " + startPoint + " to: 53.627299,-1.766489"
		dirs.clear()
		document.getElementById("dpanel").innerHTML = ""
		dirs.load(qStr)
	}
    //]]>
