var cPath = (window.getRelativeWebRoot ? window.getRelativeWebRoot() : '') + 'js/Lib/';
document.write ('<SCR' + 'IPT LANGUAGE="JavaScript1.2" SRC="'+ cPath +'BMenu3.js" TYPE="text/javascript"><\/SCR' + 'IPT>');

function initMenus () {
	aMenuEntries = aMenuEntries[0][2];
	if (_aMs.length == 0) {
		var oMenu = new Menu(0);
	}
}

function openMenu() {
	if (_aMs[0]) _aMs[0].preset (aMenuEntries);
}


function StartMenu(nLevel) {
	this.init = Menu;
	this.init();
}


function Menu (nLevel) {
	this.init = BTextMenu;
	this.init (nLevel);
	this.nChildOffset = 3;
	this.nElementHeight = 24;
	
	this.findElementIndex = function (nElementID) {
		if (this.aElements) 
			for (var i=0; i<this.aElements.length; i++)
				if (this.aElements[i][0] == nElementID) return (i);
		return (null);
	}
	
	this.calculateSize = function() {
		this.nElementsWidth = this.getElementsWidth();
		this.nWidth = 36 + this.nElementsWidth;
	};

	this.getContent = function (nLayer) {
		var cPath = (window.getRelativeWebRoot ? window.getRelativeWebRoot() : '') + CONFIG['Images']['Dir'];
		var cHtml = '<table border="0" cellspacing="0" cellpadding="0" width="' + this.nWidth + '">';
		var bHasChildren;

		for (var i=0; i<this.aElements.length; i++) {
			bHasChildren = (this.aElements[i][2] && this.aElements[i][2].length > 0);
			cHtml += '<tr>';
			switch (nLayer) {
				case 0:
				case 1: 
					cHtml += '<td><img src="' + cPath + 'nav/menu_li_' + nLayer + '.gif" width="18" height="24" alt=""></td>';
					cHtml += '<td class="menu' + nLayer + '" width="' + this.nElementsWidth + '"><nobr>' + this.aElements[i][1] + '</nobr></td>';
					cHtml += '<td><img src="' + cPath + 'nav/menu_' + (bHasChildren ? 'pfeil_' : 're_')  + nLayer + '.gif" width="18" height="24" alt=""></td>';
					break;
				case 2: 
					cHtml += '<td><a ' + this.getLink(i) + ' onmouseover="return _aMs[' + this.nLevel + '].mo(' + i + ',1)" onmouseout="return _aMs[' + this.nLevel + '].mo(' + i + ')"><img src="' + cPath + 'leer.gif" width="' + this.nWidth + '" height="' + this.nElementHeight + '" border="0"></a></td>'; 
					break;
			}
			cHtml += '</tr>'
		}
		
		if (nLayer < 2 && this.aElements.length > 0) {
			cHtml += 	'<tr><td><img src="' + cPath + 'nav/menu_' + nLayer + '.gif" width="18" height="24" alt=""></td><td><img src="' + cPath + 'nav/menu_' + nLayer + '.gif" width="' + this.nElementsWidth + '" height="24" alt=""><td><img src="' + cPath + 'nav/menu_' + nLayer + '.gif" width="18" height="24" alt=""></td></td></tr>';
		}
		cHtml += '</table>';
		return (cHtml);
	};

	this.BMenu_getPosition = this.getPosition;
	
	this.getPosition = function () {
		var aPos = this.BMenu_getPosition();
		aPos[5]+=1;
		return (aPos);
	}

	if (this.nLevel == 0) {
		this.bSuspended = false;
		this.aPos = [10, 88];
	}
}