// navigator.js
// global navigation functions
// Copyright (c) 2002 ESIRION AG. All rights reserved. 
//
// creation: dirk.oppelt@esirion.com 
//
// mod: 28.05.2002 function makeEntryline() fixed for Mozilla 1.0 'out of memory' bug 
// mod: 10.06.2002 function check_activestatus() changed for noframe-Sites 
//                 function updateMenu() changed for noframe-Sites 
//                 function do_open() bugfixed 
// mod: 04.07.2002 function check_activestatus() fixed: not closing inactive tree  
// mod: 05.02.2003 zusammenfuehrung mit switcher
// mod: 20.03.2003 initialContent mit eingebetteten Modulen ermoeglicht
// mod: 08.01.2004 Steven Wood: added function FMG_printDocument to print content frame

ie=ns4=w3c=op=kq=mz=false;

function FMG_printDocument()
{	
	
if(top.fContent.frames.length>0)printWin = top.fContent.frames[0];
else printWin = top.fContent;

// 	window.frames.fContent.focus();
//	window.frames.fContent.print();

var userPlatform;
	userPlatform = window.navigator.platform.toLowerCase();
	if(document.all && navigator.appVersion.substring(22,23)==5 && userPlatform.indexOf('mac') == 0) {
		printWin.focus();
		alert ("Um diese Seite zu drucken, klicken Sie bitte in das Inhaltsfenster. \nDanach drücken Sie bitte Apfel + p. "); 
	}else if(document.all && navigator.appVersion.substring(22,23)==4 && userPlatform.indexOf('mac') == 1) {
		printWin.focus();
		var OLECMDID_PRINT = 6;
		var OLECMDEXECOPT_DONTPROMPTUSER = 2;
		var OLECMDEXECOPT_PROMPTUSER = 1;
		var browserObj = '<object id="browserObj1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
		printWin.document.body.insertAdjacentHTML('beforeEnd',browserObj);
		browserObj1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER);
		browserObj1.outerHTML = ''; 
		}else {
		printWin.focus(); 
		printWin.print();
	}


}



function getBrowser() {
	if(navigator.userAgent.indexOf('Opera') != -1) op=true;
	//else if(navigator.userAgent.indexOf('Konqueror') != -1) kq=true; //konqueror kann das mittlerweile
	else if(navigator.userAgent.indexOf('Konqueror') != -1) mz = true;
	else if(navigator.userAgent.indexOf('Gecko') != -1) mz = true;
	else if(document.all) ie=true;
	else if(document.layers) ns4=true;
	else if(document.getElementById) w3c=true;
}
getBrowser();
// w3c=true;
// alert('ie: '+ie+'\nns4: '+ns4+'\nw3c: '+w3c+'\nop: '+op+'\nkq: '+kq+'\nmz: '+mz);

var content;
var contentFrame;

var pages = new Array();
var pageAll = new Array();
var updatetimeout = new Array();

var menuContent = new Array();
var activeDoc = '~~~';

var menuStorage = new Array();
var activeMenu = -1;
var mixmenu = new Array();
var initialContent;
var masterEntryID = -1;

// **************************************************************************************

function init() {
	menuID = parseInt(arguments[0]);

	if(mixmenu[menuID]) for(var i=0; i<mixmenu[menuID].length; i++) activateMenu(mixmenu[menuID][i]);

	if(arguments.length > 1) { // mixed menu
		myargs = new Array();
		for(var i=0; i<arguments.length; i++) myargs[i] = parseInt(arguments[i]);
		for(var i=0; i<myargs.length; i++) {
			mixmenu[myargs[i]] = new Array();
			for(var j=0; j<myargs.length; j++) {
				if(myargs[j] != myargs[i]) mixmenu[myargs[i]][mixmenu[myargs[i]].length] = myargs[j];
			}
			if(i) {
				menu[myargs[i]] = new Array();
				menu[myargs[i]] = menu[myargs[i]].concat(menu[menuID]);
				setTimeout('init('+myargs[i]+')',i*100);
			}
		}
	}

	if(!getAsArrayLength(pages)) { // Page-Liste aufbauen
		for(var i=0; i<menu.length; i++) {
			if(!menu[i]) break;
			for(var j=0; j<menu[i].length; j++) {
				pages[entryGet(i, j,'docID')] = i + '~~' + j;
			}
		}
	}
	if(self.menuAll && menuAll.length) {
		if(!getAsArrayLength(pageAll)) {
			for(var i=0; i<menuAll.length; i++) {
				for(var j=0; j<menuAll[i].length; j++) {
					pageAll[menuAll[i][j].split('~~')[2]] = i + '~~' + j;
					if(menuAll[i][j].split('~~')[3]!='') pageAll[menuAll[i][j].split('~~')[3]] = i + '~~' + j;
				}
			}
		}
	}

	activeDoc='~~~';
	activateMenu(menuID);
}

// Länge assoziativer Arrays ermitteln
function getAsArrayLength(AsArray) {
	var x=0;
	for(var i in AsArray) x++;
	return x;
}

// Homepage definieren
// wenn Rootentry = Cat, 1. Menu-Eintrag als Homepage;
// wenn Rootentry = Page+Cat, Rootentry als Homepage;
// wenn Bookmark oder DirectURL, das als Homepage
function getInitialContent(menuID) {
	if(!initialContent) {
		if(homepage[menuID].split('~~')[1] == 0) {
			for(var i=0; menu[menuID].length; i++) {
				if(menu[menuID][i].split('~~')[1] == 2 || menu[menuID][i].split('~~')[1] == 1) {
					initialContent = contentpath + entryGet(menuID,i,'docID');
					break;
				}
				else if(menu[menuID][i].split('~~')[1] == 3 || menu[menuID][i].split('~~')[1] == 4) {
					loadparams = "?Open&docid=" + entryGet(menuID,i,'docID') + "&external=" + contentpath + entryGet(menuID,i,'docURL');
					initialContent = contentpath + '../externalcontent.html' + loadparams;
					break;
				}
			}
		}
		else initialContent = contentpath + homepage[menuID].split('~~')[2];
	}
	if(location.href.indexOf('!Open&')!=-1) {
	  initialContent = contentpath + location.href.substr(self.location.href.indexOf('!Open&')+6,32);
	}
	if(location.href.indexOf('DirectURL=')!=-1) {
	  initialContent = contentpath + location.href.substr(self.location.href.indexOf('DirectURL=')+10,32);
	}
	if(location.href.indexOf('bookmark=')!=-1) {
	  initialContent = contentpath + location.href.substr(self.location.href.indexOf('bookmark=')+9,32);
	}
	return initialContent;
}

// Homepage setzen
function setInitialContent(menuID) {
	if(!contentFrame) contentFrame = self.frames['fContent'];
	contentFrame.location.href = getInitialContent(menuID);
}

// Menu in default-Zustand setzen
function activateMenu(menuID) {
	if(getParam(menuID,'expanded') == 1) openAll(menuID);
	else closeAll(menuID);
	makeMenu(menuID);
}

// Menucontent leeren
function resetMenucontent(menuID) {
	if(!mTemplateLine[menuID] || !mTemplateLine[menuID].length) return;
	menuContent[menuID] = new Array();
	for(var i=0; i<mTemplateLine[menuID].length; i++) menuContent[menuID][i]='';
}

// ist Entry Category?
function isCat(menuID,entryID) {
	var ac = entryGet(menuID,entryID,'action');
	if(ac == 0 || ac == 1 || ac == 3 || ac == 4 || ac == 5 || ac == 8) return true;
	else return false;
}

// Öffnen eines Eintrages; nur bei Cat
function do_open(menuID,entryID,noclose) {
	if(!getParam(menuID,'keep_open') && !entryGet(menuID,entryID,'opened')) {
		closeAll(menuID);
		for(var i=0; i<entryGet(menuID,entryID,'level'); i++) {
			if(isCat(menuID,getLevelEntryID(menuID,entryID,i))) entrySet(menuID,getLevelEntryID(menuID,entryID,i),'opened',1);
		}
	}
	if(isCat(menuID,entryID)) {
		if(!noclose && getParam(menuID,'closeable')) entryGet(menuID,entryID,'opened') ? entrySet(menuID,entryID,'opened',0) : entrySet(menuID,entryID,'opened',1);
		else entrySet(menuID,entryID,'opened',1)
	}
}

// alle öffnen
function openAll(menuID) {
	for(var i=0; i<menu[menuID].length; i++) {
		if(menu[menuID][i+1] && entryGet(menuID,i+1,'level') == entryGet(menuID,i,'level')+1 && isCat(menuID,i)) entrySet(menuID,i,'opened',1)
	}
}

// alle schließen 
function closeAll(menuID) {
	for(var i=0;i<menu[menuID].length;i++) entrySet(menuID,i,'opened',0);
}

// entryID des ParentEntry 
function getParent(menuID,entryID) {
	for(var i=entryID; i>0; i--) if(menu[menuID][i-1] && entryGet(menuID,i-1,'level') == entryGet(menuID,entryID,'level')-1) return i-1;
	return -1;
}

function getGlobalParent(menuID,entryID) {
	for(var i = entryID;i>0;i--) if(menuAll[menuID][i-1] && parseInt(menuAll[menuID][i-1].split('~~')[4]) == parseInt(menuAll[menuID][entryID].split('~~')[4])-1) return i-1;
	return -1;
}

// entryID des Parents auf definiertem Level
function getLevelEntryID(menuID,entryID,level) {
	var parents = new Array();
	var thisentry = entryID;
	while(entryGet(menuID,thisentry,'level')) {
		parents[entryGet(menuID,thisentry,'level')] = thisentry;
		thisentry = getParent(menuID,thisentry);
	}
	parents[0] = thisentry;
	return parents[level];
}

// Menu erzeugen 
function makeMenu(menuID) {

	if(!menu[menuID] || !menu[menuID].length) return;
	resetMenucontent(menuID);
	var thisType = getParam(menuID,'menutype');
	for(var i=0;i<menu[menuID].length;i++) {
		if(thisType == 0) menuContent[menuID][0] += makeEntryline(menuID,i);
		else menuContent[menuID][entryGet(menuID,i,'level')] += makeEntryline(menuID,i);
		thisLevel = entryGet(menuID,i,'level');
		if(menu[menuID][i+1] && entryGet(menuID,i+1,'level') == thisLevel+1) { // hat submenu
			if(!entryGet(menuID,i,'opened')) while(entryGet(menuID,i+1,'level') > thisLevel) i++;
		}
	}
	setMenu(menuID);
}


// Menu-Eintrag erzeugen
function makeEntryline1(menuID,entryID) {
	menutemplate = mTemplateLine[menuID][entryGet(menuID,entryID,'level')];
	entryline = menutemplate.split('<entry-id>').join(menuID +','+ entryID);
	entryline = entryline.split('<entry-label>').join(entryGet(menuID,entryID,'label'));
	
	if(getParam(menuID,'menutype') == 0 && entryline.indexOf('<entry-imgsrc>') != -1) {  //twist-images
		if(entryGet(menuID,entryID,'level') != entryGet(menuID,entryID+1,'level')-1) entryline = entryline.split('<entry-imgsrc>').join(imgblank.src);
		else {  //Subentries
			if(entryGet(menuID,entryID,'opened')) {
				if(active[entryGet(menuID,entryID,'level')]==entryID) entryline = entryline.split('<entry-imgsrc>').join(switcherframe.imgopen_a.src);
				else entryline = entryline.split('<entry-imgsrc>').join(switcherframe.imgopen_n.src);
			}
			else {
				if(active[entryGet(menuID,entryID,'level')]==entryID) entryline = entryline.split('<entry-imgsrc>').join(switcherframe.imgclose_a.src);
				else entryline = entryline.split('<entry-imgsrc>').join(switcherframe.imgclose_n.src);
			}
		}
	}

	
}



// Menu-Eintrag erzeugen 
function makeEntryline(menuID,entryID) {
	if(mTemplateLine[menuID][entryGet(menuID,entryID,'level')] != '') {
		menutemplate = mTemplateLine[menuID][entryGet(menuID,entryID,'level')];
		entryline = menutemplate.split('<entry-id>').join(menuID +','+ entryID);
		entryline = entryline.replace(/<entry-label>/g, entryGet(menuID,entryID,'label'));
		

		/* image stuff, steven*/

		if(getParam(menuID,'menutype') == 0 && entryline.indexOf('<entry-imgsrc>') != -1) {  //twist-images
			if(entryGet(menuID,entryID,'level') != entryGet(menuID,entryID+1,'level')-1) {  // Page
				if(entryGet(menuID,entryID,'docID') == activeDoc){
					entryline = entryline.split('<entry-imgsrc>').join(imgpage_a.src);
					//alert("makeEntryLine,menutype = "+menuID+ " " +entryID+" entryline="+entryline);
					}
				else entryline = entryline.split('<entry-imgsrc>').join(imgpage_n.src);
			}
			else {  //Subentries
				if(entryGet(menuID,entryID,'opened')) {
					if(entryGet(menuID,entryID,'docID') == activeDoc) {
						entryline = entryline.split('<entry-imgsrc>').join(imgopen_a.src);
						//alert("makeEntryLine,menutype = "+menuID+ " " +entryID+" entryline="+entryline);
						}

					else entryline = entryline.split('<entry-imgsrc>').join(imgopen_n.src);
				}
				else {
					if(entryGet(menuID,entryID,'docID') == activeDoc){
						entryline = entryline.split('<entry-imgsrc>').join(imgclose_a.src);
						//alert("makeEntryLine,menutype = "+menuID+ " " +entryID+" entryline="+entryline);
						}
					else entryline = entryline.split('<entry-imgsrc>').join(imgclose_n.src);
				}
			
			}
		

		}
		


	//pathinfo + mousetext
		if(entryline.indexOf('<doc-pathinfo>') != -1) entryline = entryline.split('<doc-pathinfo>').join(parent.getGlobalPathinfo(entryGet(menuID,entryID,'docID')));
		if(entryGet(menuID,entryID,'mousetext')) {
			mousefunction = 'onMouseover=\"mtshow(\'' +entryGet(menuID,entryID,'mousetext')+ '\');\" onMouseout=\"mthide();\"';
			entryline = entryline.split('<mousetext>').join(mousefunction);
			entryline = entryline.split('<infotext>').join(entryGet(menuID,entryID,'mousetext'));
		}
		else entryline = entryline.split('<mousetext>').join('');

		 //steven
		/*
		thisclass = 'entry-n';		
		if(entryGet(menuID,entryID,'opened')) thisclass = 'entry-o';
		if(entryGet(menuID,entryID,'docID') == activeDoc) thisclass = 'entry-a'; 
		if(menuID==100) if(entryGet(menuID,entryID,'opened')) thisclass = 'entry-o';  //Takeda
		entryline = entryline.split('<entry-class>').join(thisclass+entryGet(menuID,entryID,'level'));
		
		if(entryGet(menuID,entryID,'opened')) thisclass = 'active';
		*/
		
		thisclass = 'entry-n0';		
		//if(entryID == masterEntryID && activeMenu == menuID) thisclass = 'active'; 
		entryline = entryline.split('<entry-class>').join(thisclass);

                // fag, 2007-05-09: colors
                var colorsuffix;
                // die leeren Eintraege ueberspringen
                if (entryGet(menuID, entryID, 'label').match('^<level\\s+.*>$'))
                    colorsuffix = 'empty';
                else
                    colorsuffix = getColorObjectByMenuIDs(menuID, entryID).classsuffix;
                entryline = entryline.split('<entry-active-class>').join('active-'+colorsuffix);
                thisclass = 'active-empty';
                if (entryID == masterEntryID && activeMenu == menuID) thisclass = 'active-'+colorsuffix;
                entryline = entryline.split('<entry-color-class>').join(thisclass);
	}
	else entryline = '';
	return entryline + '\n';
}

// Menu zusammensetzen und ausgeben 
function setMenu(menuID) {
	for(var i=0; i<mTemplateLine[menuID].length; i++) {
		menuout = mTemplateStart[menuID][i];
		menuout += menuContent[menuID][i];
		menuout += mTemplateEnd[menuID][i];
		storeMenu(menuout, menuID, i);
	}
	updateMenu(menuID);
}

/*
Klick auf Menueintrag
- Action-IDs:
0:  Category only 
1:  Page + Category 
2:  Page only 
3:  ext. Structure, Page + Category  
4:  ext. Structure, Page 
5:  Clone Page + Category 
6:  Clone Page 
7:  int. Link, Content Window 
8:  ext. Link + Category 
9:  ext. Link, new Window 
10: ext. Link, same Window 
11: ext. Link, Content Window 
12: Link thru JS-Script 

- Parameter:
menuID, entryID, nicht laden (nur ausklappen), nicht ausklappen (nur laden), nicht zuklappen, klick kommt aus MixedMenu 
*/
function entryclick(menuID,entryID,noload,noopen,noclose,ismixedmenu) {
	
	if(menuID == 0)masterEntryID = entryID;
	else masterEntryID = -1;

	/* steven 04.11.05 | workaround fuer seiten ohne doc_id, etwa von FMGShowProject.
	   in diesem fall soll das menu beim wegnavigieren von der seite mittels der browser-history aktualisiert werden
	   also aendern wir die activeDoc, damit die funktion check_activestatus() das menu anpasst.
	 */
	if (window.frames[4]) if (!window.frames[4].doc_id) {
		//alert("current page does not have a doc_id! setting activeDoc to -1");
		activeDoc = -1;
	}
	/* ende workaround */


	//alert("active Entry = " + masterEntryID);
	//alert("active Menu = " + activeMenu);

	if(!ismixedmenu) if(menuID >= 100) { //Mixmenu? Root-Menu klicken
		entryclick(menuID-100,entryID,noload,noopen,noclose,ismixedmenu);
		return;
	}
	if(!ismixedmenu && activeMenu != menuID) { //Menuwechsel? Altes Menu schließen
		if(activeMenu != -1) init(activeMenu);
		activeMenu = menuID;
	}
	var action = entryGet(menuID,entryID,'action');
	var externalpath = '';
	if(!noopen && action != 9) do_open(menuID,entryID,noclose);
	if(self.isIntranet && isIntranet==true && action != 0 && action != 3 && action != 4 && action != 8 && action != 9) parent.fActionbar.location.assign(contentpath + '../systemcontentview/X_actionbar.html');
	if(action != 0) {
		if(!noload) {
			switch (action) {
				case 1: //Page+Category
				case 2: //Page only
				case 5: //Clone Page+Category
				case 6: //Clone Page only
				self.contentFrame.location.href = contentpath + entryGet(menuID,entryID,'docID');
				break;
				
				case 7: //int. Link + Content Window
				self.contentFrame.location.href = contentpath + entryGet(menuID,entryID,'docURL').split('internallink:\/\/').join('');
				break;
				
				case 8: //ext. Link + Category
				case 9: //ext. Link, new Window
				window.open(entryGet(menuID,entryID,'docURL'));
				break;
								
				case 10: //ext. Link, same Window
				top.location.href = entryGet(menuID,entryID,'docURL');
				break;
				
				case 3: //ext. Structure Page + Category 
				case 4: //ext. Structure Page 
				externalpath = contentpath;
				case 11: //ext. Link, Content Window
				loadparams = "?Open&docid=" + entryGet(menuID,entryID,'docID') + "&external=" + externalpath + entryGet(menuID,entryID,'docURL');
				self.contentFrame.location.href = contentpath + '../externalcontent.html' + loadparams;
				break;				

				case 12: //Link thru JS-Script
				call_js(entryGet(menuID,entryID,'docURL'));
				break;		
				
				default:
				break;
			}
			activeDoc = entryGet(menuID,entryID,'docID');
		}
	}
	if(action != 9) makeMenu(menuID);
	if(!ismixedmenu && mixmenu.length && mixmenu[menuID]) {  // andere MixMenus syncronisieren
		for(var i=0; i<mixmenu[menuID].length; i++) entryclick(mixmenu[menuID][i],entryID,noload,noopen,noclose,1);
	}
	if(action == 0 && getParam(menuID,'load_first_page') && menu[menuID][entryID+1] && !noload) { // erste Page laden 
		var openentry=entryID+1;
		while(entryGet(menuID,openentry,'action')==0) entrySet(menuID,openentry++,'opened',1);
		if(op) setTimeout('entryclick('+menuID+','+openentry+')',500);
		else entryclick(menuID,openentry);
	}
}

// MenuInhalt (HTML) speichern
function storeMenu(content,menuID,level) {
	if(!menuStorage[menuID] || !menuStorage[menuID].length) menuStorage[menuID] = new Array();
	menuStorage[menuID][level] = content;
}

// MenuInhalt (HTML) auslesen
function getMenu(menuID,level) {
	if(level==0 && menuID==0 && self.showLogin) menuTop = loginButton;
	else menuTop = '';
	if(menuStorage[menuID] && menuStorage[menuID].length && menuStorage[menuID][level]) return menuTop + menuStorage[menuID][level];
	else return '';
}


// Menu-Inhalt gepuffert in Browser ausgeben
function updateMenu(menuID) {
	if(!top.frames.length) return;
	if(updatetimeout[menuID]) clearTimeout(updatetimeout[menuID]);
	updatetimeout[menuID] = setTimeout('updateMenu1('+menuID+')',50);
}

function updateMenu1(menuID) {
	for(var i=0; i<mOutput[menuID].length; i++) {
		targetframe = eval(mOutput[menuID][i].split('~~')[0]);
		targetdiv = mOutput[menuID][i].split('~~')[1];

		menulabel = '';
		/*
		//Labels für Favoriten und Pers. Links ausgeben, proprietär!
		menulabel = '';
		if(targetframe==fLeftnav && getMenu(menuID,i) != '') {
			if(targetdiv == 'm1') menulabel = label_favoriten;
			if(targetdiv == 'm2') menulabel = label_perslinks;
		}
		//end Labels
		*/

		if(ie) {
			if(targetframe.document.all[targetdiv]) targetframe.document.all[targetdiv].innerHTML = menulabel + getMenu(menuID,i);
		}
		else if(w3c || mz) {
			if(targetframe.document.getElementById(targetdiv)) targetframe.document.getElementById(targetdiv).innerHTML = getMenu(menuID,i);
		}
		else if(ns4 || op) {
			targetframe.location.reload();
		}
		else if(kq) {
			targetframe.document.location.href = targetframe.document.location.href;
		}
	}
}

// Doc nach docID laden
function loadDoc(docID) {
	var thismenu = getMenuEntryID(docID, 'menu');
	var thisentry = getMenuEntryID(docID, 'entry');
	if(thismenu == -1 || thisentry == -1) self.contentFrame.location.href = contentpath + docID;  //nur laden? nix ändern?
	else entryclick(thismenu,thisentry);
}

// Eintragswerte zu docID finden
function getMenuEntryID(docID, IDtype) {
	if(pages[docID]) {
		if(IDtype == 'menu') return pages[docID].split('~~')[0];
		if(IDtype == 'entry') return pages[docID].split('~~')[1];
	}
	else return -1;
}

// Pfad zu docID ausgeben
function getPathinfo(docID, pathdelimiter) {
	if(pathdelimiter) var delimiter = pathdelimiter;
	else var delimiter = ' / ';

	var thismenu = getMenuEntryID(docID, 'menu');
	var thisentry = getMenuEntryID(docID, 'entry');
	var pathinfo = '';
	do {
		pathinfo = entryGet(thismenu, thisentry, 'label') + (pathinfo != '' ? delimiter + pathinfo : '');
		thisentry = getParent(thismenu, thisentry);
	}
	while(thisentry != -1);
	return pathinfo;
}

// Pfad zu docID auch außerhalb der Favoriten
function getGlobalPathinfo(docID, pathdelimiter) {
	if(pathdelimiter) var delimiter = pathdelimiter;
	else var delimiter = ' / ';
	if(!pageAll[docID]) return '';

	var thismenu = pageAll[docID].split('~~')[0];
	var thisentry = pageAll[docID].split('~~')[1];
	var pathinfo = '';
	do {
		pathinfo = menuAll[thismenu][thisentry].split('~~')[0] + (pathinfo != '' ? delimiter + pathinfo : '');
		thisentry = getGlobalParent(thismenu, thisentry);
	}
	while(thisentry != -1);
	return pathinfo;
}

//passt Menu zum Content?
function check_activestatus(docID) {

	//alert("running check_activestatus("+docID+")");

	if(docID) {
		var thismenu = getMenuEntryID(docID, 'menu');
		var thisentry = getMenuEntryID(docID, 'entry');
		if(thismenu == -1 || thisentry == -1){
			
			//alert( docID + " not in array, reseting menu");
			//steven: menu 0 zuruecksetzen, nichts markiert
			masterEntryID = -1;
			init(0);		
			
			return;  //nicht im Array? nix ändern?
		}
		if(!mParams[thismenu]){
			return;	//kein Menu definiert?
			//alert("no menu defined");
		}
		else {
			if(activeDoc != docID) {
				if(activeMenu != thismenu && activeMenu != -1) {
					init(activeMenu);
					activeMenu = thismenu;
				}
				activeDoc = docID;
				var openentry = thisentry;
				while(openentry != -1) {
					openentry = getParent(thismenu,openentry)
					if(openentry != -1){
									entrySet(thismenu,openentry,'opened',1);
									//alert("setting entry " + openentry + " in menu " + thismenu + " to opened");
					}
				}
				//alert("do_open(" + thismenu +","+thisentry+",1)");
				do_open(thismenu,thisentry,1)
				makeMenu(thismenu);
				
				//steven
				//entryclick(thismenu,thisentry,1,0,1);
				entryclick(thismenu,thisentry,1);
			}
			else {
				//alert("activeDoc == docID " + activeDoc + "  |  "+ docID + " --> no change!");
			}
		}
	}
	//if(fPathinfo) fPathinfo.set_pathstring(getPathinfo(docID, fPathinfo.pathstring_delimiter));
	if(contentFrame) if(contentFrame.doc_id) if(activeDoc != contentFrame.doc_id) {
																					//alert("doing check_activestatus("+contentFrame.doc_id+")");
																					check_activestatus(contentFrame.doc_id);	//Opera-Bug?
																					}
}


// **************************************************************************************

// Eintrags-Eigenschaften holen
function entryGet(menuID, entryID, type) {
	if(!menu[menuID] || !menu[menuID][entryID]) return;
	menuentry = menu[menuID][entryID].split('~~');
	if(type == 'label')   return menuentry[0];
	if(type == 'action')  return parseInt(menuentry[1]);
	if(type == 'docID')  	return menuentry[2];
	if(type == 'docURL')  return menuentry[3];
	if(type == 'level')   return parseInt(menuentry[4]);
	if(type == 'hilight') return parseInt(menuentry[5]);
	if(type == 'opened')  return parseInt(menuentry[6]);
	if(type == 'mousetext') return menuentry[7];
}

// Eintrags-Eigenschaften setzen
function entrySet(menuID, entryID, type, value) {
	if(!menu[menuID] || !menu[menuID][entryID]) return;
	menuentry = menu[menuID][entryID].split('~~');
	if(type == 'label')   menuentry[0] = value;
	if(type == 'action')  menuentry[1] = value;
	if(type == 'docID')  	menuentry[2] = value;
	if(type == 'docURL')  menuentry[3] = value;
	if(type == 'level')   menuentry[4] = value;
	if(type == 'hilight') menuentry[5] = value;
	if(type == 'opened')  menuentry[6] = value;
	menu[menuID][entryID] = menuentry.join('~~');
}

// Menu-Eigenschaften holen
function getParam(menuID, type) {
	if(!mParams[menuID]) return;
	mparam = mParams[menuID].split('|');
	if(type == 'menutype') 	return parseInt(mparam[0]);
	if(type == 'load_first_page') return parseInt(mparam[1]);
	if(type == 'keep_open') return parseInt(mparam[2]);
	if(type == 'closeable') return parseInt(mparam[3]);
	if(type == 'expanded') 	return parseInt(mparam[4]);
	if(type == 'highlight') return mparam[5];
}

