    //<![CDATA[

    // Our global state
    var gLocalSearch;
    var gMap;
    var gSelectedResults = [];
    var gCurrentResults = [];

    // Set up the map and the local searcher.
    function OnLoad() {
	  //window.alert(dbPostcode);
      //var input = document.getElementById("q");
      //input.focus();

      // Initialize the map
      gMap = new GMap(document.getElementById("map"));
      gMap.addControl(new GSmallMapControl());
      gMap.addControl(new GMapTypeControl());
      gMap.setCenter(new GLatLng(52.432166,1.524954), 15);

      // Initialize the local searcher
      gLocalSearch = new GlocalSearch();
      gLocalSearch.setResultSetSize(GSearch.LARGE_RESULTSET); 
      gLocalSearch.setCenterPoint(gMap);
      gLocalSearch.setSearchCompleteCallback(null, OnLocalSearch);

      // Execute the initial search
      //gLocalSearch.execute(input.value);
	  //******************* POSCODE GOES HERE ********************
	  // original
	   //gLocalSearch.execute("n8 9sg");
	
	  // added by kenny -> patch in pcode from database
	   gLocalSearch.execute(dbPostcode);

    }

    // Called when Local Search results are returned, we clear the old
    // results and load the new ones.
    function OnLocalSearch() {
      if (!gLocalSearch.results) return;
      var searchWell = document.getElementById("searchwell");
      gCurrentResults = [];
      for (var i = 0; i < gLocalSearch.results.length; i++) {
        gCurrentResults.push(new LocalResult(gLocalSearch.results[i]));
      }

      // move the map to the first result
      var first = gLocalSearch.results[0];
      gMap.recenterOrPanToLatLng(new GPoint(parseFloat(first.lng), parseFloat(first.lat)));

    }

    // Cancel the form submission, executing an AJAX Search API search.
    function CaptureForm(form) {
      gLocalSearch.execute(form["q"].value);
      return false;
    }


    // A class representing a single Local Search result returned by the
    // Google AJAX Search API.
    function LocalResult(result) {
      this.result_ = result;
      this.resultNode_ = this.unselectedHtml();
      document.getElementById("searchwell").appendChild(this.resultNode_);
      gMap.addOverlay(this.marker(G_DEFAULT_ICON));
    }

    // Returns the GMap marker for this result, creating it with the given
    // icon if it has not already been created.
    LocalResult.prototype.marker = function(opt_icon) {
      if (this.marker_) return this.marker_;
      var marker = new GMarker(new GLatLng(parseFloat(this.result_.lat),
                                         parseFloat(this.result_.lng)),
                               opt_icon);
      
	  
	  this.marker_ = marker;
      return marker;
    }

    // "Saves" this result if it has not already been saved
    LocalResult.prototype.select = function() {
      if (!this.selected()) {
        this.selected_ = true;

        // Remove the old marker and add the new marker
        gMap.removeOverlay(this.marker());
        this.marker_ = null;
        gMap.addOverlay(this.marker(G_DEFAULT_ICON));

        // Add our result to the saved set
        document.getElementById("selected").appendChild(this.selectedHtml());

        // Remove the old search result from the search well
        this.resultNode_.parentNode.removeChild(this.resultNode_);
      }
    }

    // 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));
      return container;
    }


    LocalResult.prototype.unselectedWindowHtml = function() {
      var container = document.createElement("div");
      container.className = "unselected";
      container.appendChild(this.result_.html.cloneNode(true));

	//replace link to google with bold text
	  var mynode = container.childNodes[0].childNodes[0].childNodes[0];
      var newNode = document.createElement("b");
      newNode.innerHTML = mynode.childNodes[0].innerHTML;

		  var playDiv = document.createElement("div");
          var playNice = document.createElement("a");
		  playNice.className = "select";
		  mynode.parentNode.appendChild(newNode);
		  container.childNodes[0].childNodes[2].appendChild(playDiv);
		  mynode.parentNode.className = null;
		  mynode.parentNode.removeChild(mynode);

      return container;
    }

    // Returns the HTML we display for a result after it has been "saved"
    LocalResult.prototype.selectedHtml = function() {
      return this.result_.html.cloneNode(true);
    }

    // Returns true if this result is currently "saved"
    LocalResult.prototype.selected = function() {
      return this.selected_;
    }

    //]]>