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 () {
	if (_aMs.length == 0) {
		var oMenu = new StartMenu(0);
	}
}

function StartMenu (nLevel) {
	this.init = Menu;
	this.init (nLevel);
	
	this.calculateSize = function() {
		this.nElementsWidth = Math.max (this.getElementsWidth(), 125);
		this.nWidth = this.nElementsWidth + 9 + 15;
	};

	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 + '">';
		for (var i=0; i<this.aElements.length; i++) {
			if (nLayer < 2) bHasChildren = (this.aElements[i][2] && this.aElements[i][2].length > 0);
			cHtml += '<tr>';
			switch (nLayer) {
				case 0:
					cHtml += '<td width="' + (this.nWidth - 9) + '" class="smenu0" nowrap>&nbsp;' + this.aElements[i][1] + '</td><td class="smenu0" align="right"><img src="' + cPath +  (bHasChildren ? 'menu/pfeil.gif' : 'leer.gif') + '" width="9" height="18" alt=""/></td>';
					break;
				case 1: 
					cHtml += '<td width="' + (this.nWidth - 9) + '" class="smenu1" nowrap>&nbsp;' + this.aElements[i][1] + '</td><td class="smenu1" align="right"><img src="' + cPath +  (bHasChildren ? 'menu/pfeil.gif' : 'leer.gif') + '" width="9" height="18" alt=""/></td>';
					break;
				case 2: 
					cHtml += '<td height="18"><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) cHtml += '<tr><td class="smenu0"><img src="' + cPath + 'leer.gif" width="' + (this.nWidth - 9) + '" height="1" alt=""/></td><td class="smenu0"><img src="' + cPath + 'leer.gif" width="9" height="1" alt=""/></td></tr>';
		cHtml += '</table>';
		return (cHtml);
	};

	this.aElements = aMenuEntries;
	this.calculateSize();
	this.aElements = null;
	this.aPos = [210-this.nWidth, 130];
	this.preset (aMenuEntries);
	
	this.close = function() {
		this.highlight (null); 
		if (this.oChild) this.oChild.close(); 
	}
}


function Menu (nLevel) {
	this.init = BTextMenu;
	this.init (nLevel);
	this.nWidth = 0;
	this.nElementsWidth = 0;
	this.nElementHeight = 18;
	
	this.calculateSize = function() {
		this.nElementsWidth = this.getElementsWidth();
		this.nWidth = Math.max (this.nElementsWidth + 9 + 15 + 19, 145);
		if (this.nWidth > 145) this.nWidth = 145 + (Math.ceil ((this.nWidth - 145) / 19) + 1) * 19;
	};

	this.getPosition = function () {
		var aPos = [this.aPos[0], this.aPos[1]];
		if (this.oParent) {
			aPos[0] = this.oParent.aLayers[0].get('left') + this.oParent.nWidth + this.oParent.nChildOffset;
			aPos[1] = this.oParent.aLayers[0].get('top') + this.oParent.nSelected * this.oParent.nElementHeight;
		}	
		var aClipp = new Array (0, 0, this.nWidth+10, (this.nElementHeight * this.aElements.length)+1);
		return (aPos.concat (aClipp));
	};
	
	this.getContent = function (nLayer) {
		var cPath = (window.getRelativeWebRoot ? window.getRelativeWebRoot() : '') + CONFIG['Images']['Dir'];
		var cHtml = '';
		
		if (this.aElements && this.aElements.length > 0) {
			cHtml = '<table border="0" cellspacing="0" cellpadding="0" width="' + this.nWidth + '">';
			
			for (var i=0; i<this.aElements.length; i++) {
				cHtml += '<tr>';
				if (nLayer < 2 && i == 0) {
					cHtml += '<td rowspan="' + (this.aElements.length+1) + '" valign="top"><img src="' + cPath + 'menu/connect.gif" width="5" height="19" alt=""/></td>'; 
				}	
				bHasChildren = (this.aElements[i][2] && this.aElements[i][2].length > 0);
				switch (nLayer) {
					case 0:
						cHtml += '<td width="' + (this.nWidth - 9 - 5) + '" class="menu0" nowrap>&nbsp;' + this.aElements[i][1] + '</td><td class="menu0" align="right"><img src="' + cPath +  (bHasChildren ? 'menu/pfeil.gif' : 'leer.gif') + '" width="9" height="18" alt=""/></td>';
						break;
					case 1: 
						cHtml += '<td width="' + (this.nWidth - 9 -5) + '" class="menu1" nowrap>&nbsp;' + this.aElements[i][1] + '</td><td class="menu1" align="right"><img src="' + cPath +  (bHasChildren ? 'menu/pfeil.gif' : 'leer.gif') + '" width="9" height="18" 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) cHtml += '<tr><td class="menu0"><img src="' + cPath + 'leer.gif" width="' + (this.nWidth - 9-5) + '" height="1" alt=""/></td><td class="menu0"></td></tr>';
			
			cHtml += '</table>';
		}
		return (cHtml);
	};


	this.updatePosition = function() {
		var aPos = this.getPosition();
		if (aPos) {
			var aClip = new Array (0, 0, this.nWidth, this.nElementHeight * this.aElements.length);
			if (aPos.length > 2) aClip = aPos.slice (2, 6);
			for (var i=1; i<2; i++) 
				this.aLayers[i].clipp (aClip[0], aClip[1], (i==1 ? 0 : aClip[2]), aClip[3]);
			for (var i=0; i<this.aLayers.length; i++) {
				this.aLayers[i].moveTo (aPos[0], aPos[1]);
				this.aLayers[i].set ('visibility', true);
			}
		}	
	};



	this.BMenu_mo = this.mo;
	this.mo = function (nElem, bOver) {
		if (!_aMs[0].bSuspended) this.BMenu_mo (nElem, bOver);
		return(true);
	}

}


