var starthoehe = 50;													// Höhe, wo die Baumstruktur beginnt
var defaulthoehe = 18;													// Allgemeiner Abstand der Elemente (wenn nichts angegeben
var einruecken = 20;													// Wie weit bei jedem Untermenu eingerückt werden soll
var starteinruecken = 0;												// Ausrichtung der Baumstruktur nach links
var bildabstand = 5;													// Abstand vom Bild zum nächsten Element

var divnum = 0;
var parentnum = 1;
var start;
var stop;
var ebene;
var checknext;
var hoehe;

var aktivalt;															// Variable um bei neuem klick die Farbe zurückzusetzen

var struktur = new Array();												// Array, das die Struktur verwaltet
for (var x = 0; x < array.length; x++) {								// Array durchgehen
	struktur[x]=new Array(x,'','','','','','','','','');				// und die ID und Felder definieren
}


document.write("<body leftmargin=0 topmargin=0  MARGINWIDTH=0 MARGINHEIGHT=0>");

////////////////////////////////////////////////////////////////////////// Erzeugt die Baumstruktur
function tree(parent) {                   								//
	for (var i = 0; i<array.length; i++) {								//
		if(array[i][2]==parent) {										//
			struktur[divnum][parentnum]=array[i][0];					// 
			array[i][4] = divnum;										//
			creatediv(array[i][0],array[i][1],array[i][3],parentnum);	//
			divnum++;													//
			parentnum++;												//
			tree(array[i][0]);											//
			parentnum--;												//
		}																//
	}																	//
}																		//
//////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////// Legt die Layers an
function creatediv(id,name,url,parentnum) {								//
	var flosse;
	
	if(parentnum!=1) {					  								//
		var script='onClick="showhide(' + id + ');"';
		if(url=="#") {
			var pfeil='<table border="0" cellpadding="0" cellspacing="0"><tr><td><A HREF="' + url + '" ' + script + '><IMG SRC="../design/images/nav_buttons/b_pfeil_rechts_a.gif" NAME="pfeil' + array[id][0] + '" valign=top border=0 vspace=0 hspace=0 align=middle></A></td>';
		} else {
			var pfeil='<table border="0" cellpadding="0" cellspacing="0"><tr><td><A HREF="' + url + '" ' + script + ' TARGET="main"><IMG SRC="../design/images/nav_buttons/b_pfeil_rechts_a.gif" NAME="pfeil' + array[id][0] + '" valign=top border=0 vspace=0 hspace=0 align=middle></A></td>';
		}
	} else {															//
		var pfeil='';													//
		var script='';													//
	}	  																//
																		//
	if(array[id][7]!='') {												//
		name = '<IMG SRC="' + array[id][7] + '" ALT="' + name + '" NAME="bild' + array[id][0] + '" BORDER="0" vspace=0 hspace=0  align="middle">';//
	}																	//

	if (url=="") {														//
	   var link=name;
	} else if (url=="#") {
	  var link='<td valign="middle"><b><A HREF="#" ' + 	script + '><span style="font-size:11px">&nbsp;' + name + '</span></A></b></td></tr></table>';
	} else {
	  var link='<td valign="middle"><b><A HREF="' + url + '" ' + script + ' TARGET="main"><span style="font-size:11px">&nbsp;' + name + '</span></A></b></td></tr></table>';												//
	}
	

	
	if (id=="229") {
		flosse='<div id="flosse" style="position:relative;top:-' + defaulthoehe + 'px;left:140px"><img src="../design/images/nav_fluke_blau.gif"></div>';
	} else {
		flosse="";
	}
	
	if (id=="208") {
		flosse2='<div id="flosse2" style="position:relative;top:-' + defaulthoehe + 'px;left:140px"><img src="../design/images/nav_fluke_blau.gif"></div>';
	} else {
		flosse2="";
	}
	
		//alert (pfeil + link);											//
	var aktuelleebene=parentnum;										//
	if(aktuelleebene==1) { aktuelleebene++ }							//
	var zusatzeinruecken = 0;
	if(aktuelleebene==2) { zusatzeinruecken = 0 }
	links = ((aktuelleebene-2) * einruecken) + starteinruecken + zusatzeinruecken;	// von der Ebene 2 abziehen um bei 0 zu sein (normal 1 aber damit Ebene 2 auf der gleichen Ebene wie Ebene1 wurde diese um 1 erhöht)
																		//
	document.write('<DIV ID="' + id + '" CLASS="menu" STYLE="position:absolute;left:' + links + ';"><b><nobr>');
	document.write(pfeil);												//
	document.write(link);
	//document.write("AID: " + id);
	//document.write("SID: " + divnum);
	document.write(flosse);
	document.write(flosse2);
	document.write('</nobr></b></DIV>');								//
}																		//
//////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////// Liefert die Unterelemente von ID im form von Start (erstes Kind) und Stop (letztes Kind)
function children(id) { 												// 
	var strukturid = array[id][4]; 										//
																		//
	for (var a = 1; a < struktur[strukturid].length; a++) {				//
		if (struktur[strukturid][a]!="") {								//
			ebene = a;													//
			break;														//
		}																//
	}																	//
																		//
																		//
	start = struktur[strukturid][0] + 1;								//
	stop = struktur.length;												//
																		//
	for (var b = start; b < struktur.length; b++) {						//
		if (struktur[b][ebene]!="") {									//
			stop = b;													//
			break;														//
		}																//
	}																	//
}																		//
//////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////// Setzt den Status der Elemente
function showhide(id)													//
{												
	init();
	array[id][5]="visible";
	showparent(id);
	showebene(id);
	scroll();		
}																		//
//////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
function showparent(id)
{
	if(array[id][2]!="")
	{
		array[array[id][2]][5]="visible";
		if(checkchild(array[id][0]))
		{
			eval ('document.images.pfeil'+array[id][0]+'.src="../design/images/nav_buttons/b_pfeil_unten_p.gif"');
		}
		else
		{
			eval ('document.images.pfeil'+array[id][0]+'.src="../design/images/nav_buttons/b_pfeil_rechts_p.gif"');
		}
		showparent(array[array[id][2]][0]);
		showebene(array[array[id][2]][0]);
	}
}
//////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
function showebene(id)													//
{																		//
	children(id);	// Rückgabewerte: Start / Stop / Ebene				//
	d = ebene + 1;														//
	if (start < array.length)											//
	{																	//
		for (var c = start; c < stop; c++)								//
		{																//
			var strukturid=struktur[c][d];								//
			if(strukturid!="")											//
			{															//
					array[strukturid][5]="visible";						//
			}															//
		}																//
	}																	//	
}																		//
//////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////// Baut die Menüstruktur neu auf
function scroll() {														//
	for (var z = 0; z < array.length; z++) {							// 
		if (document.getElementById) {									//
			document.getElementById(z).style.visibility = "hidden";		//
		} else {														
			eval('document.' + z + '.visibility = "hidden";');
		}
	}																	//
																		//
	hoehe = starthoehe;													//
																		//
	for (var i = 0; i < struktur.length; i++) {							//
		for (var j = 1; j < struktur[i].length; j++) {					//
			var id = struktur[i][j];									//
			if (id!="") {												//
				if (array[id][5]=='visible') {							//
					if (document.getElementById) {				
						document.getElementById(id).style.visibility = 'visible';//
						document.getElementById(id).style.top = hoehe;	//
					} else {
						eval('document.' + id + '.visibility = "visible";');
						eval('document.' + id + '.top = ' + hoehe + ';'); 
					}
					hoehe = hoehe + bildabstand;			  			//
					hoehe = hoehe + array[id][6];						//
				}														//
			}															//
		}																//
	}																	//														
}																		//																
//////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////// Startfunktion - Eltern visible, Rest hidden und höhen eintragen
function init() {														// 
	for (var id = 0; id < array.length; id++) {							//													
		if(array[id][7]!="") {											//
			xyz = new Image();											// 
			xyz.src = array[id][7];										//
		}																//
		array[id][5] = "hidden";
		if(array[id][2]!="")
		{
			eval ('document.images.pfeil'+array[id][0]+'.src="../design/images/nav_buttons/b_pfeil_rechts_a.gif"');																//
		}
	}	
	if(document.images.nav_home)
	{
			eval ('document.images.nav_home.src="../design/images/nav_buttons/b_pfeil_rechts_a.gif"');																//
	}
																		//
	for (var id = 0; id < struktur.length; id++) {						//
		if ((struktur[id][1]!="")) {			 						//
		    var idx=struktur[id][1];	   								//
			array[idx][5] = "visible";									//
		} else if (struktur[id][2]!="") {								//
		  	var idx=struktur[id][2];									//
			array[idx][5] = "visible";									//
		}	
	  																	//	
		if (array[id][6]=="") {											// 								
			if(array[id][7]!="") {										//
				bildname = "bild" + array[id][0];						//
				array[id][6]=eval("document." + bildname + ".height;");	//
			} else {													//
				array[id][6]=defaulthoehe;								//
			}															//			
		}																//
	}																	//
}																		//
//////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////// Überprüft, ob ID Unterelemente hat
function checkchild(id) {												//
	for (var i = 0; i < array.length; i++) {							//
		if (array[i][2]==id) {											//
			return true;												//
		}																//
	}																	//
}																		//
//////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////// Färbt den Homebutton bei klick
function homebutton()
{
	init();
	scroll();
	document.images.nav_home.src='../design/images/nav_buttons/b_pfeil_rechts_p.gif';
}
//////////////////////////////////////////////////////////////////////////

