fillKategorie();
//auswahl_="Selection...";

function fillKategorie()
{
	var kategorieName=""
	var liste="";
	var katL = kategorie.length;
		
	document.branchen.Kategorie.options.length=1;
	document.branchen.Art.options.length=1;
	document.branchen.Automatisierung.options.length=1;


	for(var i=0; i<katL; i++)
	{
		liste=kategorie[i].split("/");
		liste_bez=kategorieNotation[i].split("/");
		
		if(kategorieName!=liste[0])//-------- Eintrag entspricht nicht der aktuellen Kategorie
		{
			newEntry("Kategorie", liste_bez[0], liste[0]);
			kategorieName=liste[0];
		}
	}
}


function fillArt()
{
	var aktKategorie=document.branchen.Kategorie.options[document.branchen.Kategorie.selectedIndex].value;
	var artName=""
	var liste="";
	var katL = kategorie.length;
	var art=0;  // wird auf >0 gesetzt wenn ein Eintrag in Art geschrieben wurde
	var nullentry=false;

	var obj=document.branchen.Art;
	obj.options.length=1;
	obj.disabled="disabled"; 
	var NeuerEintrag = new Option(auswahl_, "nix", true, true);
	obj.options[0]=NeuerEintrag;

	var obj=document.branchen.Automatisierung;	
	obj.options.length=1;
	obj.disabled="disabled"; 
	var NeuerEintrag = new Option(auswahl_, "nix", true, true);
	obj.options[0]=NeuerEintrag;
			

	for(var i=0; i<katL; i++)
	{
		liste=kategorie[i].split("/");
		liste_bez=kategorieNotation[i].split("/");

		//------ Bei Eintrag "null" 
		if(liste.length>2 && liste[1]=="null" && aktKategorie==liste[0])
		{
			if(liste[1]=="null")
			{	
				var NeuerEintrag = new Option(auswahl_, "null", true, true); //-- Hier wird bei Auswahl der Wert "null" anstatt "nix" eingetragen.
				document.branchen.Art.options[0]=NeuerEintrag;
				newEntry("Automatisierung", liste_bez[2], liste[2]);
				art++;
				nullentry=true
			}
		}
		else
		{
			if(liste.length>1 && aktKategorie==liste[0] && artName!=liste[1])//-------- Eintrag entspricht der aktuellen Kategorie und gehört nicht zum aktuellen Eintrag in Art
			{ 
				newEntry("Art", liste_bez[1], liste[1]);
				artName=liste[1];
				art++;
			}
		}
	}
	
	
	if(art>1 && nullentry==false)
		newEntry("Art", entryAll_, "Alle");

	if(art>1 && nullentry==true)
		newEntry("Automatisierung", entryAll_, "Alle");

	if(art==0) //---- Kein Eintrag geschrieben. Das vorherige PopUp ist also Auslöser 
		goDetail();
}



function fillAutomatisierung()
{
	var aktKategorie=document.branchen.Kategorie.options[document.branchen.Kategorie.selectedIndex].value;
	var aktArt=document.branchen.Art.options[document.branchen.Art.selectedIndex].value;
	
	var automatName=""
	var artName=""
	
	var liste="";
	var katL = kategorie.length;
	var Automat=0;  // wird auf >0 gesetzt wenn ein Eintrag in Art geschrieben wurde
	
	var obj=document.branchen.Automatisierung;
	obj.options.length=1;
	obj.disabled="disabled"; 
	var NeuerEintrag = new Option(auswahl_, "nix", true, true);
	obj.options[0]=NeuerEintrag;
	

	for(var i=0; i<katL; i++)//------ Alle Kategorien durchlaufen
	{
		liste=kategorie[i].split("/");
		liste_bez=kategorieNotation[i].split("/");

		if(liste.length>2 && aktKategorie==liste[0] && aktArt==liste[1] && automatName!=liste[2] )//-------- Eintrag entspricht der aktuellen Kategorie, der aktuellen Art uund gehört nicht zum aktuellen Eintrag in Automatisierung 
		{ 
			newEntry("Automatisierung", liste_bez[2], liste[2]);
			automatName=liste[2];
			Automat++;
		}
	}
	
	
	if(Automat>1) 
		newEntry("Automatisierung", entryAll_,  "Alle"); //---- Die "1" ist zur markierung des Suchmodus bei goDetail()
		
	if(Automat==0) //---- Kein Eintrag geschrieben. Das vorherige PopUp ist also Auslöser 
		goDetail();
	
}

function goDetail() 
{
	var aktKategorie=document.branchen.Kategorie.options[document.branchen.Kategorie.selectedIndex].value;
	var aktArt=document.branchen.Art.options[document.branchen.Art.selectedIndex].value;
	var aktAutomatisierung=document.branchen.Automatisierung.options[document.branchen.Automatisierung.selectedIndex].value;
	
	var KatPfad="";
	var modus=0; //----- Modus 0=genau, 2=%LIKE%

	if(aktKategorie>"" && aktKategorie!= "nix")
		KatPfad+=aktKategorie;
	
	if(aktArt>"" && aktArt!= "nix")
	{
		if(aktArt=="Alle"){
			modus=1;
		}
		else{
			KatPfad+="/"+aktArt;
		}
	}

	
	if(aktAutomatisierung>"" && aktAutomatisierung!= "nix")
	{
		if(aktAutomatisierung==entryAll_){
			modus=1;
		}
		else{
			KatPfad+="/"+aktAutomatisierung;
		}
	}

	if(KatPfad>""){
		var ids=productIDs[KatPfad].split(";");	//------ Globale Variablen die per PHP generiert wurden
		var names=productNames[KatPfad].split(";");
		var descriptions=productDescription[KatPfad].split(";");

		var l= ids.length;

		for(var i=0; i<l; i++){
			addHits(ids[i], names[i], descriptions[i]);
		}
		document.location.href="/forwarding.php?id="+ids[0]+"&referer="+location.host;

	}
}




