function AdvisedSearchSmall(basic_color, selected_color, category_id, vendor_cat, all_cat, colors, color_names, scope, colormenu_position) {

	this.basic_color		= basic_color;
	this.selected_color 	= selected_color;
	this.category_id		= category_id;
	this.vendor_cat			= vendor_cat;
	this.all_cat 			= all_cat;
	this.colors				= colors;
	this.color_names		= color_names;
	this.scope				= scope;
	this.position 			= colormenu_position;

	if (this.scope.match(/sky|navi/i)) {
		this.button_size		= 15.5;
	} else {
		this.button_size 		= 13.5;
	}
	this.value_no_color		= 100;
	this.max_sub_cat_levels	= 5;
	
	

	var self 				= this;
	var all_cat_uid			= new Array();
	var all_cat_title		= new Array();
	var all_cat_parent_uid	= new Array();
	var all_cat_priority	= new Array();
	var priority_list		= new Array();

	var this_vendor_cat;
	var cat_path;
	var cat_layers_open;
	var no_col;

	this.init_page = function init_page() {
		for (var i=0; i<this.all_cat.length; i=i+4) {
		
			all_cat_uid[this.all_cat[i]]		= this.all_cat[i];
			all_cat_title[this.all_cat[i]]		= this.all_cat[i+1];
			all_cat_parent_uid[this.all_cat[i]]	= this.all_cat[i+2];
			all_cat_priority[this.all_cat[i]]   = this.all_cat[i+3];		
		}
		
		//zweidimensionales Array mit allen Kategorien und deren Priorität
		for (var j=0;j<all_cat_uid.length;j++){
			priority_list[j] = [  
				[ all_cat_uid[j] ], 
				[ all_cat_priority[j] ]
				];
		}
		
		// Liste aller [Sub]kategorien, die der aktuelle vendor hat
		// Wenn alle vendors ausgewählt sind, werden auch alle [Sub]kategorien ausgewählt
		this_vendor_cat				= this.get_this_vendor_cat();
		
		if (this.category_id == '') {
			this.category_id = '0';
		}
			
		cat_path 					= this.get_cat_path();
		cat_layers_open		= 0;
	
		var cat_form 				= document.forms['advised_search_'+this.scope].elements['category_id'];
		cat_form.value 				= this.category_id;

		if (this.scope.match(/all|navi/i)) {
			this.init_subcategories();
		}
	
		main_color					= document.forms['advised_search_'+this.scope].elements['main_color'];
		main_color.value			= this.basic_color_search;
			
		sel_color					= document.forms['advised_search_'+this.scope].elements['selected_color'];
		sel_color.value				= this.selected_color;
	
		// zweispaltiges Farbmenu aus den Hauptfarben erzeugen und darstellen
		this.buildColorMenu(this.colors.length, this.colors, this.scope+'_col_table', 0);
	}
	
	// Funktion zum Initialisieren der Kategorie-Levels
	this.init_subcategories = function init_subcategories() {

		if (this.scope == 'navi') {
			var container_height = 60;
		} else {
			var container_height = 80;
		}
	
	// die einzelnen [Sub]kategorie-Level von oben nach unten durchgehen
		for (var i=0; i<cat_path.length; i++) {
			var sel 	= document.forms['advised_search_'+this.scope].elements['swords_cat' + i];
			var layer 	= document.forms['advised_search_'+this.scope].elements['catlayer' + i];
	
			// alle bisherigen options von sel löschen bis aus 'alle'
			for (var j=sel.length-1; j>0; j--) {
				sel.remove(j);
			}
	
			var these_cats = Array();
			var uid_priority = new Array();
			
			if (i==0) {
				these_cats = this.get_sub_cats('0');
			} else {
				if (this.scope == 'square_all_blank' && i==1) {
					document.forms['advised_search_'+this.scope].elements['swords_cat1'].disabled = false;
				}
				these_cats = this.get_sub_cats(cat_path[i-1]);
			}
			
			//Kategorien in these_cats mit Kategorie-uids in Priority List vergleichen und entsprechende Priorität anhängen
			for (var l=0; l<these_cats.length;l++) {
				for (var t=0;t<priority_list.length;t++) {
					if (these_cats[l] == priority_list[t][0]) {
						//zweidimensionales Array mit ausgewählten Kategorien und entspr. Priorität
						uid_priority[l] = [					
								[ these_cats[l] ],
								[ priority_list[t][1] ],
							];
					}
				}
			}
			
			// Es soll nur nach Priorität sortiert werden, falls eine Priorität festgelegt ist 
			// und diese nicht doppelt vorhanden ist. 
			// Andernfalls wird nach Kategorie-uid sortiert
			
			for (var z=0; z<uid_priority.length; z++) {
				for (var x=0; x<uid_priority.length;x++) {
					if ( uid_priority [z][1] != '0' && uid_priority [z][1] != uid_priority [x][1] ) {
						// mehrdimensionales Array nach Priorität sortieren
						var uid_sorted = uid_priority.sort(sortCategory_navi);
						for (var k=0;k<uid_sorted.length; k++){
							// Priorität abtrennen und Array aus sortierten uids erstellen
							these_cats[k]	= uid_sorted[k][0];				
						}
					}
				}	
			}

			for (var k=0; k<these_cats.length; k++) {
				var newopt = new Option(sel);
				var this_selected = false;
	
				// Kategorie ID als Value eintragen
				newopt.value = these_cats[k];
	
				// Kategorie Bezeichnung als title eintragen
				newopt.text = all_cat_title[these_cats[k]];
		
				//diese Option vorwählen, falls ihr value mit letzter Kategorie übereinstimmt
				if (newopt.value == cat_path[i]) {
					this_selected = true;
				}
	
				sel.options[k+1] = newopt;
				sel.options[k+1].selected = this_selected;
			}			
	
			if (cat_layers_open == 0) {
				// nur bei Seiteninitialisierung
				if (i>0) {
					if (i>1) {
						layer.style.top = 25;
					} else {
						layer.style.top = 55;
					}				
					container_height += 25;
				}
			}
		}
			
		if (cat_layers_open == 0) {
			// bei Seiteninitialisierung
			cat_layers_open = cat_path.length;
	
			var container = document.getElementById(this.scope+"_toplayer");
			container.style.height = container_height;
		} else {
			if (cat_path.length > cat_layers_open) {
				// es müssen noch Layer geöffnet werden
				if (this.scope == 'navi') {
					for (var i=cat_layers_open; i<cat_path.length; i++) {
						move_layer("catlayer" + (i), 0, 25, "vertical", this.scope+"_toplayer");
					}
				}
			} else {
				// es müssen noch Layer geschlossen werden
				for (var i = cat_layers_open-1; i >= cat_path.length; i--) {
					if (this.scope == 'navi') {
						move_layer("catlayer" + (i), 0, -25, "vertical", this.scope+"_toplayer");
					} else if (this.scope == 'square_all_blank' && i == 1) {
						document.forms['advised_search_'+this.scope].elements['swords_cat'+i].value = '0';
						document.forms['advised_search_'+this.scope].elements['swords_cat'+i].disabled = true;
					}
				}
			}
			cat_layers_open = cat_path.length;
		}
	}
	
	/**
 	* Funktion zur Bestimmung aller [Sub]kategorien eines Vendors.
 	* Wenn alle vendors gewählt sind, werden alle Kategorien zurückgegeben.
 	*
 	* @return	array	alle [Sub]kategorien des gewählten Herstellers
 	*/
	
	this.get_this_vendor_cat = function get_this_vendor_cat() {
	
		var vendor = document.forms['advised_search_'+this.scope].elements['swords_vendor'];

		var cats = Array();
		if (vendor.value == '0') {
			for (var i=0; i<all_cat_uid.length; i++) {
				customPush(cats,all_cat_uid[i]);
			}
		} else {
			// state 0: vendor noch nicht gefunden, weitersuchen
			// state 1: vendor gefunden, cat ids auslesen
			// state 2: nächsten vendor gefunden, Abbruch
			var state = 0;
			for (var i = 0; (i < this.vendor_cat.length) && (state < 2); i++) {
				switch (state) {
					case 0:
						if (this.vendor_cat[i] == 'vendor:' + vendor.value) {
							state = 1;
						}
					break;
					
					case 1:
						if (this.vendor_cat[i].match(/vendor/)) {
							state = 2;
						} else {
							customPush(cats,this.vendor_cat[i]);
						}
					break;
				}
			}
		}
		return cats;
	}
	
	/**
 	* Funktion zur Bestimmung des Kategorien-Pfades anhand der Kategorie-ID.
	*
 	* @return	array	der Pfad zur Kategorie
 	*/
	
	this.get_cat_path = function get_cat_path() {
	
		var path=Array();
	
		var sc = this.get_sub_cats(this.category_id);
		
		// Falls es Unterkategorien gibt, wird eine Null angehängt
		if (sc.length>0)
		customPush(path, '0');
				
		// die eigentliche category_id vorn anhängen, falls es nicht root 0 ist
		if (this.category_id>0) {
			path = customUnshift(path, this.category_id);
		
			var parent_id = all_cat_parent_uid[this.category_id];
			while (parent_id > 0) {
				path = customUnshift(path, parent_id);
				parent_id = all_cat_parent_uid[parent_id];
			}
		}
		return path;
	}
	
	/**
 	* Funktion zur Bestimmung aller nichtrekursiven Subkategorien einer Kategorie unter 
 	* Berücksichtigung des ggf. ausgewählten vendors.
 	*/
	
	this.get_sub_cats = function get_sub_cats(cat_id) {
	
		var all_sub_cat = Array();
		for (var key in all_cat_parent_uid) {
			if (parseInt(all_cat_parent_uid[key])==parseInt(cat_id))
				customPush(all_sub_cat,key);
		}
			
		var is = intersect(all_sub_cat, this_vendor_cat);
		return is;
	}
	
	/**
 	* Wenn sich der Hersteller ändert muss die Kategorieauswahl dahingehend angepasst werden,
 	* dass nur diejenigen Kategorien dargestellt werden, die der gewählte Hersteller führt.
 	*/
	
	this.change_vendor = function change_vendor() {
		// Element vendor bestimmen
		var vendor 		= document.forms['advised_search_'+this.scope].elements['swords_vendor'];
		this_vendor_cat	= this.get_this_vendor_cat();
		
		if (vendor.value != 0) {
			// vendor steht nicht auf 'alle'
			// letzten Knoten vom Kategoriepfad nehmen
			// evtl. anhängigen Null-Unterknoten entfernen
			this.category_id = customPop(cat_path);
			if ((this.category_id == '0') && cat_path.length>0) {
				this.category_id = customPop(cat_path);
			}
			while (!isElementOf(this_vendor_cat, this.category_id) && cat_path.length>0) {
				this.category_id = customPop(cat_path);
			}
			if (!isElementOf(this_vendor_cat, this.category_id) && cat_path.length==0) {
				this.category_id = 0;
			}
			var cat_form 		= document.forms['advised_search_'+this.scope].elements['category_id'];
			cat_form.value 		= this.category_id;
		}
		cat_path = this.get_cat_path();
		this.init_subcategories();
	}
	
	/**
 	 * Funktion zur Ereignisbehandlung Änderung eines Category-Selects
 	 *
 	 * @param	HTMLSelectElement	obj	das zur Kategorie gehörige Element der Auswahlliste
 	 */
	
	this.change_cat = function change_cat(obj) {
		
		obj_id = parseInt(obj.id.split("swords_cat")[1]);
		for (var i=cat_path.length; i>obj_id; i--) {
			customPop(cat_path);
		}
		
		customPush(cat_path,obj.value);
		
		// Wenn bei einer echten Subkategorie "alle" ausgewählt werden,
		// also wenn obj.value=0 aber obj_id!=0, dann soll category_id
		// bestimmt werden aus [nächsthöheres obj].value
		if (obj.value==0 && obj_id!=0) {
			parent_obj = document.forms['advised_search_'+this.scope].elements['swords_cat' + parseInt(obj_id-1)];
			this.category_id = parent_obj.value;
		} else {
			this.category_id	= obj.value;
		}
		
		var cat_form 	= document.forms['advised_search_'+this.scope].elements['category_id'];
		cat_form.value 	= this.category_id;
		cat_path = this.get_cat_path();
		if (this.scope.match(/navi|all_blank/i)) {
			this.init_subcategories();
		}
	}
	
	this.submit_color = function submit_color() {
		self.no_col++;
		// onclick Anzeige der gewählten Hauptfarbe 
		var value								= document.getElementById(this.id);
		var color								= value.id;
		self.buildColorMenu(colors.length, colors,self.scope+'_col_table', color);
		main_color								= document.forms['advised_search_'+self.scope].elements['main_color'];
		main_color.value						= color.replace(/#/,'');
		this.basic_color						= color;
		sel_color 								= document.forms['advised_search_'+self.scope].elements['selected_color'];
		sel_color.value							= color.replace(/#/,'');
	}
	
	/**
 	* zweizeiliges Farbmenü der Hauptfarben erzeugen.
 	*
 	* @param	int		total_cells
 	* @param	int		rootID
 	* @param	string	marked_color
 	*/
	this.buildColorMenu = function buildColorMenu(total_cells, colors, rootID, marked_color) {
		if (this.scope == 'navi') {
			var border_selected = '2px solid #000000';
			var border_grey		= '2px solid #DEDEDE';
		} else {
			var border_selected = '1px solid #000000';
			var border_grey		= '1px solid #DEDEDE';
		}
		
		// gewählte Hauptfarbe
		var root 			= document.getElementById(rootID);
		
		if (this.position == 'horizontal') {
			var element = 'td';
			
			var table 			= document.createElement('table');
			table.id 			= 'swatch_simcol';
			table.cellpadding 	= 0;
			table.cellspacing 	= 1;
				
			root.appendChild(table);	
				
			var tbody 			= document.createElement('tbody');
			table.appendChild(tbody);
				
			row 				= tbody.appendChild(document.createElement('tr') );
			tbody.appendChild(row);
		} else {
			var element = 'li';
			
			var list 			= document.createElement('ul');
			list.style.listStyleType = 'none';
			list.id 				 = 'swatch_simcol';
			root.appendChild(list);
		}
				
		for (var i = 0; i < total_cells/2; i++) {
			if (i == 0) {
				// Button keine Farbe
				tda						= document.createElement(element);
				val						= document.createElement('input');
				val.type 				= "image";
				val.id					= this.value_no_color;
				val.src					= "fileadmin/img/advised_search/button_no_color.gif";
				val.title				= "keine Farbe";
				val.style.cursor		= "default";
				val.style.width			= 12;
				val.style.height		= 12;
				val.style.border		= border_grey;
				if (marked_color == this.value_no_color || (marked_color == 0 && this.basic_color == 0) ) {
					val.style.border	= border_selected;
					this.no_col = 0;
				} 
				// Farbwahl setzten		
				val.onclick				= this.submit_color;
				tda.appendChild(val);
				if (this.position == 'horizontal') {
					row.appendChild(tda);
				} else {
					list.appendChild(tda);
				}
			}
		
			tda						= document.createElement(element);
			val						= document.createElement('input');
			val.type 				= "button";
			val.id					= colors[i];
			val.title				= this.color_names[i];
			val.style.background 	= colors[i];
			val.style.width			= this.button_size;
			val.style.height		= this.button_size;
			val.style.border		= border_grey;
			val.className			= 'colorfield';
						
			if (colors[i] == this.basic_color && (!colors[i] == marked_color) && (marked_color != this.value_no_color)) {
				// gewählte Hauptfarbe markieren
				val.style.border		= border_selected;
			} 
			else if (colors[i] == marked_color) {
				val.style.border		= border_selected;
	
			}	
			if (this.no_col == 0) {
				val.style.opacity 	= .5;
				val.style.filter 	= 'alpha(opacity=' + 50 + ')';
			} 
				
			// Farbwahl setzten		
			val.onclick					= this.submit_color;
				
			tda.appendChild(val);
			if (this.position == 'horizontal') {
				row.appendChild(tda);
			} else {
				list.appendChild(tda);
			}		
		}
		
		if (this.position == 'horizontal' && !this.scope.match(/banner/i)) {
			br = document.createElement('tr');
			tbody.appendChild(br);
		}
		
		for (var i = total_cells/2; i < total_cells; i++) {
			tda						= document.createElement(element);
			val						= document.createElement('input');
			val.type 				= "button";
			val.id					= colors[i];
			val.title				= this.color_names[i];
			val.style.background 	= colors[i];
			val.style.width			= this.button_size;
			val.style.height		= this.button_size;
			val.style.border		= border_grey;
			val.className			= 'colorfield';
						
			if (colors[i] == this.basic_color && (!colors[i] == marked_color) && (marked_color != this.value_no_color)) {
				// gewählte Hauptfarbe markieren
				val.style.border		= border_selected;
			} 
			else if (colors[i] == marked_color) {
				val.style.border		= border_selected;
	
			}	
			if (this.no_col == 0) {
				val.style.opacity 	= .5;
				val.style.filter 	= 'alpha(opacity=' + 50 + ')';
			} 
				
			// Farbwahl setzten		
			val.onclick					= this.submit_color;
				
			tda.appendChild(val);
			if (this.position == 'horizontal' && !this.scope.match(/banner/i)) {
				br.appendChild(tda);
			} else if (this.position == 'vertical') {
				list.appendChild(tda);
			} else {
				row.appendChild(tda);
			}		
		}
		
		if (this.position == 'horizontal') {
			var rootElement = table;
		} else {
			var rootElement = list;
		}
		
		if ( root.hasChildNodes() ) {
			root.replaceChild(rootElement,root.firstChild);
		} else {
			root.appendChild(rootElement);
		}
	}
}

/** ---AJAX-Funktionen für Advised Search Navi--- **/

/**
 * Sendet einen AJAX-Request, der eine Liste mit möglichen gesuchten Artikeln zurückliefert.
 *
 * @param	string	parameter	das bisher eingegeben Suchwort
 * @param	int		vendor		die ID des aktuell gewählten Herstellers
 * @param	int		category	die ID der aktuell gewählten Kategorie
 *
 * @return	bool	false, wenn es einen Fehler gab
 */
function doRequest_navi(parameter_navi, vendor_navi, category_navi) {
	if (parameter_navi.length > 2) {
		var url_navi		= 'typo3conf/ext/tt_products/pi/ajax/autosuggest_article.php';
		parameter_navi		= '?param='		+ escape(parameter_navi);
		vendor_navi			= '&vendor='	+ escape(vendor_navi);
		category_navi		= '&category='	+ escape(category_navi);
		
		req = new ajaxRequest_navi(url_navi + parameter_navi + vendor_navi + category_navi);
	} else {
		return false;
	}
	if (req == false) {
		return false;
	}
}
	
/**
 * Diese Funktion wird vom AJAX-Request aus aufgerufen und verarbeitet die zurückgelieferten
 * Daten.
 */	
function ajaxResponse_navi() {

	/*
	* die readystates des XmlHttpRequest-Objektes (von http://www.oreilly.de/artikel/ajax3/index.html): 
	* 0: Die Anfrage ist noch nicht initialisiert (bevor Sie open() aufrufen).
	* 1: Die Anfrage ist erstellt und initialisiert, aber noch nicht gesendet (bevor Sie send() aufrufen).
	* 2: Die Anfrage wurde gesendet und wird verarbeitet (Sie können die Kopfdaten der Antwort auswerten).
	* 3: Die Anfrage wird verarbeitet; meistens steht ein Teil der Antwort schon zur Verfügung, doch der Server ist noch nicht mit der Antwort fertig.
	* 4: Die Anfrage ist abgeschlossen; die Antwort des Servers steht bereit.
	*/
	     
	 // wir wollen erst etwas machen, wenn die Anfrage komplett fertig ist und ohne 
	 // HTTP-Fehlercode zurückkomt
	   if ((request.readyState == 4) && (request.status == 200)) {
		// hier schreiben wir unsere vorschläge rein
	    var output	= document.forms['advised_search_navi'].elements['output'];
		// alle bisherigen Elemente loeschen
		while (output.length > 0) {			
			output.options[output.length - 1] = null;
		}
			
	    if (request.responseText == '') {
			// es wurde keine DB Übereinstimmung gefunden
			output.style.height = 0;
		} else {
			document.forms['advised_search_navi'].elements['output'].style.display = 'block';
			var foo 			= request.responseText;
			// Elemente entsprechend der Markierung extrahieren
			var elements 		= foo.split('/element/');
			for (var i = 0; i < elements.length; i++) {
				if (elements[i] != '') {
					// neues Option Element anlegen
					newopt 				= new Option(output);
					var txt				= replaceSpecialChars(elements[i],0);	
					// Value eintragen
					newopt.value 		= txt;
					// Bezeichnung eintragen
					newopt.text 		= txt;
					output.options[output.length] = newopt;	
				}
			}
				
			// height des Ausgabefeldes berechnen
			var height			 = (output.length * 20);
			if (height > 200) {
				height = 200;
			}
			output.style.height = height;	
		}
	} 
}
	
// Artikelvorschläge in Multiselect anzeigen
function showAutosuggest_navi(element) {
	var vendor 	 		= document.forms['advised_search_navi'].elements['swords_vendor'].value;
	var category 		= document.forms['advised_search_navi'].elements['category_id'].value;
	
	doRequest_navi(element.value, vendor, category);
}

/**
 * Beim drücken der Pfeiltaste nach unten Fokus auf Multiselect legen um
 * Tastennavigation zu ermöglichen
 */
function setFocus_navi(event) {
	var selectElement 	= document.forms['advised_search_navi'].elements['output'];
	if (event.keyCode==40) {
		selectElement.focus();
	}
}

/**
 * Setzt ausgewählten Artikel im Textfeld article_name
 */
function setValue_navi(element){
	var text	= document.forms['advised_search_navi'].elements['article_name'];
	text.value 	= element.value;

	while (element.length > 0) {			
		element.options[element.length - 1] = null;
	}
	
	text.focus();
	element.style.display = 'none';
}

/**
 * Komparator für das Sortieren des mehrdimensionalen Kategorie-Arrays anhand der Priorität
 *
 */
function sortCategory_navi(a, b)
{
    return parseInt(a[1]) > parseInt(b[1]) ? 1 :
    parseInt(a[1]) < parseInt(b[1]) ? -1 :
    0;
}