//google search api

var searchControl;
event.observe(window, 'load', onLoad, false);
	function onLoad() {
		// Create a search control
		searchControl = new GSearchControl();
        searchControl.setResultSetSize(GSearch.large_resultset);
        searchControl.setLinkTarget(GSearch.link_target_self);

       
		// add a site-limited web search, with a custom label
		var siteSearch = new GwebSearch();
		siteSearch.setUserDefinedLabel("Search Results");
		siteSearch.setSiteRestriction("houston.org");
		searchControl.addSearcher(siteSearch);
		
					
		// setting the draw mode for the Google search
		var drawOptions = new GdrawOptions();
		// use tabbed view
		drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
		// set the input field (instead of the default one)
		drawOptions.setInput(document.getElementById('query'));
		// actually write the needed markup to the page
		searchControl.draw(document.getElementById("searchcontrol"), drawOptions);
		// set the google logo container
		//GSearch.getBranding(document.getElementById("branding"));
	searchControl.setNoResultsString( google.search.SearchControl.NO_RESULTS_DEFAULT_STRING );	
		
}
	
	var query = null;
	document.onkeydown = function(event) { kd(event); };
	function kd(e) {
		// make it work on FF and IE
		if (!e) e = event;
		// use ESC to clear the search results
		if (e.keyCode == 27)
			searchControl.clearAllResults();
		// get the input field
		if (query == null)
			query = document.getElementById('query');
		// and move the focus in there
		//query.focus();
	}
