/* ----------------------------------------------------------------
 @name:     hAccordion (horizontal accordion plugin for jQuery)
 @version:  0.1
 @release:  2009-07-23
 @type:     googleSearch implementations without move to special page
 @author:   Tomáš Procházka
---------------------------------------------------------------- */

// Call this function when the page has been loaded
function GoogleSearch() {
	this.init = function() {
		// prep for decoupled search form
		var searchFormElement = document.getElementById("search");
		var drawOptions = new google.search.DrawOptions();
		drawOptions.setInput(searchFormElement);
		drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);

		var searchControl = new google.search.SearchControl();
		var search = new google.search.WebSearch()
		if (gSearch_siteAddress != "") {
			search.setSiteRestriction(gSearch_siteAddress);
		}
		searchControl.addSearcher(search);
		searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);

		searchControl.setSearchStartingCallback(this, GoogleSearch.prototype.searchStart);
		searchControl.draw(document.getElementById("content-box-search"),drawOptions);

		// úprava stránky
		document.getElementById('searchButton').onclick = function() {
			searchControl.execute(document.getElementById('search').value);
			return false;
		}
		// zablokování odeslání na enter
		$('#searchForm').submit(function() {
			return false;
		})
	};
}
GoogleSearch.prototype.searchStart = function(searchControl, searcher, query) {
	$(".crums").text(gSearch_textSearchResult + ":");
	document.getElementById('content-box').style.display = 'none';
}

var gs = new GoogleSearch();
google.load("search", "1");
google.setOnLoadCallback(gs.init, true);
