function RawSearchControl() {
		
this.cursor = document.getElementById("cursor");
this.results = document.getElementById("results");
	
this.searcher = new GwebSearch();
this.searcher.setNoHtmlGeneration();
this.searcher.setResultSetSize(google.search.Search.LARGE_RESULTSET);
this.searcher.setSearchCompleteCallback(this,
					RawSearchControl.prototype.searchComplete,
					[this.searcher]
					);
//this.searcher.setSiteRestriction( window.location.hostname);	
this.searcher.setSiteRestriction('www.wag.at');	 
return this.searcher;     
	
}
	
RawSearchControl.prototype.searchComplete = function(searcher) {

this.clearResults();
	
 if (this.searcher.results && this.searcher.results.length > 0) {
	for (var i=0; i<this.searcher.results.length; i++) {
	var result = this.searcher.results[i];
	this.searcher.createResultHtml(result);
	if (result.html) {
	div = result.html.cloneNode(true);
	} else {
	div = createDiv("** failure to create html **");
	}
	this.results.appendChild(div);
	}

	if (this.searcher.cursor) {
	var cursorNode = createDiv(null, "gsc-cursor");
	for (var i=0; i<this.searcher.cursor.pages.length; i++) {
	var className = "gsc-cursor-page";
	if (i == this.searcher.cursor.currentPageIndex) {
	className = className + " gsc-cursor-current-page";
	}
	var pageNode = createDiv(this.searcher.cursor.pages[i].label, className);
	pageNode.onclick = methodClosure(this, this.gotoPage, 
					[this.searcher, i]); 
	cursorNode.appendChild(pageNode);
	}
	this.cursor.appendChild(cursorNode);
	var more = createLink(this.searcher.cursor.moreResultsUrl,
				GSearch.strings["more-results"] + "&nbsp;&raquo;",
				GSearch.LINK_TARGET_SELF,
				"gsc-trailing-more-results");
	this.cursor.appendChild(more);
	}
 } else {
	div = createDiv("Ihre Suche brachte leider keine Ergebnisse.");
	this.results.appendChild(div);
 }
}
	
RawSearchControl.prototype.gotoPage = function(searcher, page) {
	searcher.gotoPage(page);
}

RawSearchControl.prototype.clearResults = function() {

	removeChildren(this.results);
	removeChildren(this.cursor);

}


function createLink(href, opt_text, opt_target, opt_className, opt_divwrap) {
		
var el = document.createElement("a");
el.href = href;
if (opt_text) {
	el.innerHTML = opt_text;
}
if (opt_className) {
	el.className = opt_className;
}
if (opt_target) {
	el.target = opt_target;
}
if (opt_divwrap) {
	var div = this.createDiv(null, opt_className);
	div.appendChild(el);
	el = div;
}
return el;
}



function methodClosure(object, method, opt_argArray) {
		
return function() {
	return method.apply(object, opt_argArray);
}
	
}


/**
* Static DOM Helper Functions
*/
function removeChildren(parent) {
		
while (parent.firstChild) {
	parent.removeChild(parent.firstChild);
}
	
}
	
function createDiv(opt_text, opt_className) {
	var el = document.createElement("div");
	if (opt_text) {
		el.innerHTML = opt_text;
	}
	if (opt_className) { el.className = opt_className; }
	return el;
}

	
	
function doSearch (sword) {

	var s =  new RawSearchControl();
	s.clearResults();
	s.execute(sword);
	return false;   
	
}

$(document).ready(
           function(event) {
			   var sword = getURLParam('ipt_search');
	            if (sword.length > 0) {
				$('ipt_search').value = sword;
					doSearch(sword);		
		       };
       }
);






