/*****************************************************************************
 menufunctions.js
 Autor: Michael Lindner
 Version: 1.0
 Erstellt am: 26.06.2004
 Kommentar: Stammfunktionen, zur Darstellung und Erstellung des Menüs.
 *****************************************************************************/

var mnuFeld = new Array ();
var iMnu = 0;
var iSub = 0;
var AktMenu;

	// Hauptmenüeintrag hinzufügen.
function addMenu ( titel, hreflink )
{
		// Hauptmenü.
	mnuFeld[iMnu] = new Array ();
	mnuFeld[iMnu][0] = new Array ();
	
	mnuFeld[iMnu][0][0] = titel;
	mnuFeld[iMnu][0][1] = hreflink;
	mnuFeld[iMnu][0][2] = 0;
	
	iMnu++;
}

	// Untermenüeintrag erstellen (Submenü).
function addSubMenu ( mnuID, titel, hreflink )
{
		// Anzahl der bisherigen Einträge ermitteln.
	iSub = mnuFeld[mnuID].length;

	mnuFeld[mnuID][iSub] = new Array ();
	mnuFeld[mnuID][iSub][0] = titel;
	mnuFeld[mnuID][iSub][1] = hreflink;
	
	mnuFeld[mnuID][0][2] = parseInt(mnuFeld[mnuID][0][2]) + 1;
}

	// Menüleiste erstellen aus ausgeben. 
function printMenu ()
{
	var outText = "";
	document.write ( "<table border='0'><tr>" );
	for ( var i = 0; i < mnuFeld.length; i++ )
	{
		tmpText = mnuFeld[i][0][0];
		outText += "<td><div class='menuMainNonFocus' id='mnuID" + i + "_0' " +
							 	"onmousemove='menuFunctionAll(" + i + "); mnuFocusingMain(this.id, true);' " + 
								"onmouseout='mnuFocusingMain(this.id, false);' " + 
							 	"onclick='mnuClick(" + i + ", this.id);'>" + 
							 	tmpText +
						 "</div></td>";

	}
	document.write ( outText );
	document.write ( "</tr></table>" );
						 
	
	for ( var i = 0; i < mnuFeld.length; i++ )
	{
	document.write ("	<div id='dividmnu_" + i +"' class='menuDiv' " +
									"style='left:"+ (i * 100 + i * 4)+ "px'>" +
						"	  <table width='145' cellpadding='0' cellspacing='0' " + 
									"id='tabelleidmnu" + i + "'> " + 
						"		<tr> " +
						"		  <td height='15' class='menuBorder' id='mnuitems" + i + "' nowrap> " );
		
		for ( u = 1; u < mnuFeld[i].length; u++ )
		{
			document.write ("		<div " + 
										"id='mnuID" + i + "_" + u + "' class='menuItemNonFocus' " + 
										((mnuFeld[i][u][0] == "-")?"":"onmousemove='mnuFocusing(this.id, true);' ") +
										"onmouseout='mnuFocusing(this.id, false);' " + 
										"onclick='mnuClick(" + i + ", this.id);'>" + 
										((mnuFeld[i][u][0] == "-")? "<hr noshade />":mnuFeld[i][u][0]) + 
									"</div>" );
		}
		document.write ("		  </td>" +
						"		  <td valign='top' width='5'><img src='" + "genesis/bilder/menu/mnu_or.gif"  + "' width='7' height='9' alt=''><br> " +
						"									 <img src='genesis/bilder/menu/mnu_r.gif' id='mnur" + i + "' width='7' alt=''></td>" +
						"		</tr>" +
						"		<tr valign='top'> " +
						"		  <td height='6' id='mnushadow"+i+"'>" +
										"<img src='genesis/bilder/menu/mnu_ul.gif' width='8' height='6' alt=''>" + 
										"<img src='genesis/bilder/menu/mnu_u.gif' id='mnuu" + i + "' height='6' alt=''></td>" +
						"		  <td height='6'><img src='genesis/bilder/menu/mnu_ur.gif' width='7' height='6' alt=''></td>" +
						"		</tr>" +
						"	  </table>" +
						"	</div>");
	}
	mnuResize();

}

	// Menü formatieren. Schatten ausrichten.
function mnuResize()
{
	for ( i = 0; i < mnuFeld.length; i++ )
	{
		document.getElementById("mnur"+i).height = parseInt(document.getElementById("mnuitems"+i).height) + 
								parseInt(document.getElementById("mnushadow"+i).height) + 
								( mnuFeld[i][0][2] - 1 ) * 17;
	
		document.getElementById("mnuu"+i).width =  parseInt(document.getElementById("tabelleidmnu"+i).width) ;
	}
}

	// Ein- Ausblenden.
function menuFunctionAll (ID)
{
	
		// Das gewünschte Element einblenden.
	if (ID != -1 )
		if ( parseInt(mnuFeld[ID][0][2]) != 0 )
			document.getElementById( "dividmnu_" + ID ).style.visibility = "visible";
	
		// Alle außer das gewünschte Element ausblenden.
		// Bei -1 werden alle ausgeblendet!
	for ( i = 0; i < mnuFeld.length; i ++ )
		if ( i != ID )
			document.getElementById( "dividmnu_" + i ).style.visibility = "hidden";
}

	// Menü-Hover-Effekt.
function mnuFocusing (id, modus)
{
	document.getElementById(id).className = ( modus ) ? "menuItemFocus": "menuItemNonFocus";
}

	// Hauptmenüeintrag-Effekt.
function mnuFocusingMain (id, modus)
{
	document.getElementById(id).className = ( modus ) ? "menuMainFocus": "menuMainNonFocus";
}

	// Menücklick: OnClick
function mnuClick ( idMenu, id)
{
	var iPos = id.search(/_+/) + 1;
	var iLang = id.length;
	var SubMenuID = parseInt( id.substr( iPos, iLang - iPos ) );
	
	if ( !(mnuFeld[idMenu][SubMenuID][1]) == "")
		window.location.href=mnuFeld[idMenu][SubMenuID][1];
}
