   //<![CDATA[
	 function MyKeepHandler(result) {
		  address = result.streetAddress;
		  if (result.city) {
			  address += ", " + result.city + " " + result.region;
		  }
      if( $('search_title') ) {
        title = result.titleNoFormatting
  		  set_selected_address(address,app.location,result.lat,result.lng,title);
      } else {
  		  set_selected_address(address,app.location,result.lat,result.lng);
      }
			app.location="";
			if ($('local_search')) {
		  	$("local_search").hide();
		  }
		}

		App.prototype.OnSearchComplete = function(sc,searcher) {

     // if we have local search results, put them on the map
     if ( searcher.results && searcher.results.length > 0) {
       for (var i = 0; i < searcher.results.length; i++) {
         var result = searcher.results[i];
					if (i==0) {
						this.myMap.setCenter(new GLatLng(parseFloat(result.lat), parseFloat(result.lng)),13);
					}
         // if this is a local search result, then proceed...
         if (result.GsearchResultClass == GlocalSearch.RESULT_CLASS ) {
           var markerObject = new Object();
           markerObject.result = result;
           markerObject.latLng = new GLatLng(parseFloat(result.lat), parseFloat(result.lng));
           markerObject.gmarker = new GMarker(markerObject.latLng);
           var clickHandler = method_closure(this, App.prototype.OnMarkerClick, [markerObject]);
           GEvent.bind(markerObject.gmarker, "click", this, clickHandler);
           this.markerList.push(markerObject);
           this.myMap.addOverlay(markerObject.gmarker);
           result.__markerObject__ = markerObject;
         }
       }
       this.OnMarkerClick(this.markerList[0]);
     }

   }


  App.prototype.OnSearchStarting = function(sc, searcher, query) {
    // close the info window and clear markers
		if (! this.myMap) {
    	this.myMap = new GMap2(document.getElementById("local_search_map_div"));
     	this.myMap.addControl(new GSmallMapControl());
		} else {
    	this.clearMap();
    }
 	}


  App.prototype.OnMarkerClick = function(markerObject) {
     this.myMap.closeInfoWindow();
     var htmlNode = markerObject.result.html.cloneNode(true);
     markerObject.gmarker.openInfoWindow(htmlNode);
   }


   function method_closure(object, method, opt_argArray) {
     return function() {
       return method.apply(object, opt_argArray);
     }
   }
	App.prototype.clearMap = function() {
		if (this.myMap) {
			this.myMap.closeInfoWindow();
     	for (var i=0; i < this.markerList.length; i++) {
       	var markerObject = this.markerList[i];
       	this.myMap.removeOverlay(markerObject.gmarker);
     	}
    	this.markerList = new Array();
    	
		}
		
	}

   function App() {
    this.myMap = null;
    this.markerList = new Array();
    this.searchControl = new GSearchControl();
    var options = new GdrawOptions();
    options.setSearchFormRoot(document.getElementById("SF"));
    // Add in a full set of searchers
    this.localSearch = new GlocalSearch();
		this.localSearch.setNoHtmlGeneration();
    searcherOptions = new GsearcherOptions();
    searcherOptions.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
    this.searchControl.addSearcher(this.localSearch,searcherOptions);
    this.searchControl.draw(document.getElementById('searchController'),options);
    this.searchControl.setOnKeepCallback( this, MyKeepHandler, "select this location");
    this.searchControl.setSearchCompleteCallback(this, App.prototype.OnSearchComplete);
    this.searchControl.setSearchStartingCallback(this, App.prototype.OnSearchStarting);
		this.location="";
		GSearch.getBranding(document.getElementById("google_branding"));
  }
	function close_window() {
		if ($('local_search')) {
			$('local_search').hide();
		}

		set_selected_address("",app.location,"","");
		app.location="";
	}
  function close_disambiguator() {
    if($('disambiguator')) {
      $('disambiguator').hide();
    }
    
    set_selected_address("",app.location,"","");
    app.location=""
  }

  var app; 
  app = new App();
	if (window.on_local_search_load) {
		window.on_local_search_load();
	}
