/* ----------------------------------------------------------------
 @name:     hAccordion (horizontal accordion plugin for jQuery)
 @version:  0.1
 @release:  2009-07-23
 @type:     googleSearch implementations with 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"),drawOptions);
		
		searchControl.execute(document.getElementById('search').value);
	};
}

GoogleSearch.prototype.searchStart = function(searchControl, searcher, query) {
}

$(document).ready( function() {
	$('#search').focus(function() {
		this.value = '';
	})

	var gs = new GoogleSearch();
	if (window.location.pathname == gSearch_searchPage) {
		google.load("search", "1", {"callback" : gs.init});
		$('#searchForm').submit(function() {
			return false;
		});
	} else {
		$('#searchForm').attr('action', gSearch_searchPage);
	}
});

