var callExtendedSearch=function(){var form=$("quick_find");form['extendedSearch'].value=1;form.submit();}
var submitToExtendedSearchForm=function(){var quickFindForm=$("quick_find");var extSearchForm=$('searchbox');try{extSearchForm["keywords"].value=quickFindForm["keywords"].value;extSearchForm.submit();}catch(ee){}
return false;}
var showOffers=function(formName,direction){var product=$(formName).elements["products_id"];var url='ajax_driven.php?action=showOffersLikeSlideshow&products_id='+product.value+'&direction='+direction;new Ajax.Request(url,{method:'get',onSuccess:function(transport,json){$('box_offer_of_month').innerHTML=transport.responseText;}});}

/*Suggest Search*/
/*
	This is the JavaScript file for the osCommerce AJAX Search Suggest

	You may use this code in your own projects as long as this 
	copyright is left	in place.  All code is provided AS-IS.
	This code is distributed in the hope that it will be useful,
 	but WITHOUT ANY WARRANTY; without even the implied warranty of
 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
	
	For the rest of this code visit http://www.osCommerce-SSL.com
	
	For a complete detailed tutorial on how this code works visit:
	http://www.dynamicajax.com/fr/AJAX_Suggest_Tutorial-271_290_312.html
	
	For more AJAX code and tutorials visit http://www.DynamicAJAX.com
	
	Copyright 2006 Ryan Smith / 345 Technical / 345 Group.	
	
	Auf XT-Commerce portiert von TechWay (Steffen Decker) mit Unterstützung von Purecut (aus dem ecombase.de Forum)
	Copyright 2006 @ TechWay, Steffen Decker
	Modified by Florian Rauhofer to match the needs of http://www.huttner-buerobedarf.de, 2011/05/30
*/

//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Bitte upgraden Sie Ihren Browser!");
	}
}

//Our XmlHttpRequest object to get the auto suggest
var searchReq = getXmlHttpRequestObject();

//Called from keyup on the search textbox.
//Starts the AJAX request.
function searchSuggest() {
	if (searchReq.readyState == 4 || searchReq.readyState == 0) {
		var str = escape(document.getElementById('txtSearch').value);
		searchReq.open("GET", 'searchSuggest.php?search=' + str, true);
		searchReq.onreadystatechange = handleSearchSuggest; 
		searchReq.send(null);
	}		
}

//Called when the AJAX response is returned.
function handleSearchSuggest() {
	if (searchReq.readyState == 4) {
		var ss = document.getElementById('search_suggest')
		ss.innerHTML = '';
		var str = searchReq.responseText.split("\n");
		for(i=0; i < str.length - 1; i++) {
			//Build our element string.  This is cleaner using the DOM, but
			//IE doesn't support dynamically added attributes.
			var suggest = '<div onmouseover="javascript:suggestOver(this);" ';
			suggest += 'onmouseout="javascript:suggestOut(this);" ';
			suggest += 'onclick="javascript:setSearch(this.innerHTML);" ';
			suggest += 'class="suggest_link">' + str[i] + '</div>';
			ss.innerHTML += suggest;
		}
		if (i==0) {
			ss.style.visibility  = "hidden";
		} else {
			ss.style.visibility  = "visible";
		}
		//Schließen link einfügen
		ss.innerHTML += '<p class="suggest_close" align="right"><a onClick="javascript:suggestClose(this);"><b>Fenster schließen</b></a></p>';
	}
}
// Close Function
function suggestClose (div_value) {
	document.getElementById('search_suggest').innerHTML = '';
	document.getElementById('search_suggest').style.visibility  = "hidden";
}

//Mouse over function
function suggestOver(div_value) {
	div_value.className = 'suggest_link_over';
}
//Mouse out function
function suggestOut(div_value) {
	div_value.className = 'suggest_link';
}
//Click function
function setSearch(value) {
	// HTML-TAGS entfernen
  	var newvalue = value.replace(/<.*?>/gi, '');
	//Kategorienamen entfernen (fängt mit &nbsp; an)
	
	//var Suche =	newvalue.indexOf("&nbsp;");
	//var produktname = newvalue.substring(0,Suche);
	
	var Suche = newvalue.indexOf("&nbsp;");
	var temp = newvalue.substring(Suche);
	var cut = temp.substring(6);
	var Suche2 = cut.indexOf("&nbsp;");
	var produktname = cut.substring(0,Suche2);
	
	document.getElementById('txtSearch').value = produktname;
	document.getElementById('search_suggest').innerHTML = '';
	document.getElementById('search_suggest').style.visibility  = "hidden";
	//zum Suchergebnis weiterleiten
	top.location.href = "advanced_search_result.php?keywords=" + produktname; 
}
/*End Suggest*/

/*jQuery load Website*/
function loadContent(elementSelector, sourceURL) {
jQuery(""+elementSelector+"").load("http://www.huttner-buerobedarf.de/"+sourceURL+"");
}
/*End load Website*/
