// www.telering.at navigation; (c) 09 2003 - 04 2004
// vers.: 1.05
// author: mass:werk; n.landsteiner; <www.masswerk.at>
// for pjure media Marketing Services GmbH; <www.pjure.com>
// all rights reserved - any usage without the author's positive permission prohibited
// v.1.04 adding support for grafical bottom-line; updated v.105

// naming conventions:
// all global entity names start with (m|M)enu
// function args:
// d: div-id; mid: menu-id; eid: element-id; s: string; x,y: coors; n: ordination/num.index
// script includes auto-call: menuPreload();

var menus=new Array();
var menuCurrentObjId=new Array();
var menuImages=new Array();
var menuActiveElement=new Array();
var menubarActiveElement=-1;
var menubarDefTabNr=-1;
var menuTimer=null;
var menuPosX=new Array();
var menuPosY=new Array();
var menuCache=new Array();
var menubarPos=new Array();
var menuDivId=new Array();
var menuNS4Hl=new Array();
var menuNS4Ol=new Array();
var menuNS4Bg=new Array();
var menusBottomline=new Array();
var menuBottomActiveElement=-1;
var menuBottomTabShown=-1;
var menuBottomShowing=false;
var menuBottomHidding=false;
var menuBottomTimer=null;
var menuBottomResetTimer=null;
var menuBottomLastY;
var menuBottomOffset;
var menuBottomToShow=-1; // for MSIE/Mac OSX bugfix only

var isKonqueror=false;
var isMsie=false;
var isMsieMac=false;
var isMsieMacClassic=false;
var isMsieMac50Classic=false;
var isMsieMacOSX=false;
var isNS6=false;
var menuBottomMacIE50Offset=0;
var menuBottomNS4On=false;
var menuBottomMacIE50On=false;

// special browser preliminaries (MSIE/Mac, NS6, NS4)

if (navigator.userAgent.indexOf('MSIE')>=0) {
    isMsie=true;
}

if (navigator.userAgent.indexOf('Konqueror')>=0) {
    isKonqueror=true;
}

if ((navigator.userAgent.indexOf('MSIE')>=0) && (navigator.platform=='MacPPC')) {
	isMsieMac=true;
	for (var i=0; i<navigator.plugins.length; i++) {
		if (navigator.plugins[i].name.indexOf('Carbon.cfm')>=0) {
			isMsieMacOSX=true;
			break
		}
	};
	if (isMsieMacOSX==false) {
		isMsieMacClassic=true;
		if ((isMsieMacClassic) && (navigator.userAgent.indexOf('MSIE 5.0')>=0)) {
			isMsieMac50Classic=true;
			// workaround for nested table bug
			menubarTop-=112;
			if (menuBottomMacIE50On) menuBottomMacIE50Offset=17
		}
	}
}
else if ((navigator.userAgent.indexOf('Gecko')>-1) && (navigator.userAgent.indexOf('Netscape6')>-1) && (navigator.userAgent.indexOf('compatible')<0)) {
	isNS6=true
}

// data constructors

function MenuNode(parentid, id, display, url) {
	this.id=id;
	this.display=display;
	this.url=url;
	this.children=[];
	this.parentid='';
	if ((parentid) && (menus[parentid])) {
		menus[parentid].children[menus[parentid].children.length]=this; // work-around for MSIE missing push
		menus[parentid+'/'+id]=this;
		this.parentid=parentid
	}
	else if (parentid=='') {
		menus[id]=this
	}
	else {
		if(menuDebug) alert('no such parent menu, parent-id: '+parentid);
	}
}

function MenuBottomNode(display, url) {
	this.display=display;
	this.url=url;
	menusBottomline[menusBottomline.length]=this; // work-around for MSIE missing push
}


// path identification (return id of active tab of any known object)

function menuGetTabId(searchid) {
	if (menus[searchid]) {
		// is menu-node - seek top entry in menubar
		var lastid='';
		var m=menus[searchid];
		while (m.parentid) {
			lastid=m.id;
			m=menus[m.parentid]
		};
		return lastid
	}
	else {
		// no menu - must be page, test for subnode
		var nodeid=searchid.substring(0,searchid.lastIndexOf('/'));
		if (menus[nodeid]) {
			return menuGetTabId(nodeid)
		}
		else {
			if(menuDebug) alert('no such menu-node, id: '+id);
			return ''
		}
	}
}


// init

function menuInit() {
	var divs=new Array();
	// collect layers
	for (var i=menuStartLevel; i<=menuMaxLevel; i++)  divs[divs.length]=menuDivPrefix+i;
	divs[divs.length]=menubarDiv;
	divs[divs.length]=menuBottomDiv;
	divs[divs.length]=menuBottomContentDiv;
	if (document.layers) {
		for (var i=menuStartLevel; i<=menuMaxLevel; i++) {
			divs[divs.length]=menuNS4HlPrefix+i;
			divs[divs.length]=menuNS4OlPrefix+i;
			divs[divs.length]=menuNS4BgPrefix+i
		};
		divs[divs.length]=menubarNS4Hl;
		divs[divs.length]=menubarNS4Ol
	};
	var divsLoaded=true;
	for (var i=0; i<divs.length; i++) {
		if (menuDivExists(divs[i])==false) {
			divsLoaded=false;
			break
		}
	};
	if (divsLoaded) menuStart()
	else setTimeout('menuInit()',200)
}

function menuStart() {
	for (var i=menuStartLevel; i<=menuMaxLevel; i++)  menuDivId[i]=menuDivPrefix+i;
	if (document.layers) {
		menuSetVisibility('staticmenu',0);
		for (var i=menuStartLevel; i<=menuMaxLevel; i++) {
			menuNS4Hl[i]=menuNS4HlPrefix+i;
			menuNS4Ol[i]=menuNS4OlPrefix+i;
			menuNS4Bg[i]=menuNS4BgPrefix+i
		}
	};
	if (self.menubarActiveTab) {
		var mc=menus[menuRootId].children;
		for (var i=0; i<mc.length; i++) {
			if (mc[i].id==menubarActiveTab) {
				menubarDefTabNr=i;
				break;
			}
		}
	};
	if (document.layers) {
		window.setTimeout('menubarNS4Write()',500);
		window.setTimeout('menubarSetDefault()',700);
		if ((menuBottomNS4On) && (menuBottomOn)) window.setTimeout('menuBottomActivate()',500);
		return

	}
	else if (isMsieMacClassic) {
		window.setTimeout('menubarWrite()',600);
		window.setTimeout('menubarSetDefault()',800);
		if (menuBottomOn) {
			if ((isMsieMac50Classic) && (menuBottomMacIE50On==false)) return;
			window.setTimeout('menuBottomActivate()',600)
		};
		return
	}
	else {
		menubarWrite()
	};
	if ((window.opera) || (isNS6) || (isKonqueror)) {
		// opera, NS6 center fix
		menuDivMove(menubarDiv,menuGetCenterX(menubarWidth),menubarTop);
	};
	window.setTimeout('menubarSetDefault()',10);
	if (menuBottomOn) menuBottomActivate();
}

// functions & handlers

function menuPreload() {
	// menu images
	for (var i=0; i<menuImageNames.length; i++) {
		var n=menuImageNames[i];
		menuImages[n]=new Image();
		menuImages[n].src=menuImgPath+n+'.gif'
	};
	// top animation images
	if (menuAnimationOn) {
		var n=menuAnimationPrefix+menuAnimationDefault;
		menuImages[n]=new Image();
		menuImages[n].src=menuAnimationPath+n+menuAnimationExtension;
		for (var i=menuAnimationFirst; i<=menuAnimationLast; i++) {
			n=menuAnimationPrefix+i;
			menuImages[n]=new Image();
			menuImages[n].src=menuAnimationPath+n+menuAnimationExtension
		}
	};
	// grafic bottom-line
	if ((self.menuBottomGrafics) && (self.menuBottomGraficsNames)) {
		for (var i=0; i<menuBottomGraficsNames.length; i++) {
			var nref=menuBottomGraficsNames[i];
			if (typeof nref == 'object') {
				for (var k=0; k<nref.length; k++) {
					var n=nref[k];
					if (menuImages[n]) continue;
					menuImages[n]=new Image();
					menuImages[n].src=menuBottomGraficsPath+n+menuBottomGraficsExtension
				}
			}
		}
	}
}

// f & h - menubar

function menubarWrite() {
	var tabwidth=10;
	var tabheight=18;
	var s='<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%" HEIGHT="'+tabheight+'"><TR HEIGHT="'+tabheight+'"><TD ALIGN="center" WIDTH="100%" HEIGHT="'+tabheight+'"><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="'+menubarWidth+'"><TR HEIGHT="'+tabheight+'"><TD BGCOLOR="'+menubarBgColorInactive+'" NOWRAP HEIGHT="'+tabheight+'"><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" HEIGHT="'+tabheight+'"><TR HEIGHT="'+tabheight+'">\n<TD WIDTH="1"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"></TD>\n';
	for (var i=0; i<menus[menuRootId].children.length; i++) {
		var mbid=menubarDiv+'_'+i;
		var mbe=menus[menuRootId].children[i];
		var mouseaction='onmouseover="menubarSetActive('+i+')" onmouseout="menubarLeave()"';
		var tabmouseaction='onmouseover="menubarHold()" onmouseout="menubarLeave()"';
		s+='<TD ID="'+mbid+'_0" '+tabmouseaction+'><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="'+tabwidth+'" HEIGHT="'+tabheight+'" NAME="'+mbid+'_left"><\/TD><TD ID="'+mbid+'_1" VALIGN="bottom" NOWRAP><A HREF="'+mbe.url+'" '+mouseaction+' CLASS="'+menubarCssClass+'" ID="'+mbid+'_link" NAME="'+mbid+'_link">'+mbe.display+'<\/A><\/TD><TD ID="'+mbid+'_2" '+tabmouseaction+'><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="'+tabwidth+'" HEIGHT="'+tabheight+'" NAME="'+mbid+'_right"><\/TD>\n'
	};
	s+='<\/TR><\/TABLE><\/TD><\/TR><\/TABLE><\/TD><\/TR><\/TABLE>';
	menuDivWrite(menubarDiv,s);
	menuDivMove(menubarDiv,0,menubarTop);
	menuSetVisibility(menubarDiv,1);
}

function menubarSetActive(n) {
	if (menuTimer) menuDisableTimeout();
	// hook for top animation
	if (menuAnimationOn) {
		var imgnr=menuAnimationFirst+n;
		if (imgnr>menuAnimationLast) imgnr=menuAnimationLast;
		menuTopAnimationSet(imgnr)
	};
	// set tabs
	var eid=menubarDiv+'_'+n;
	if (menubarActiveElement!=n) {
		if (menubarActiveElement>=0) menubarSetTab(menubarActiveElement, 0);
		menubarSetTab(n, 1);
		menubarActiveElement=n
	};
	// show menu
	var mobj=menus[menuRootId].children[n];
	if ((mobj) && (mobj.children.length)) {
		var offset;
		if (document.layers) {
			offset=menubarNS4GetTabX(n)
		}
		else {
			var ofstobj=menuGetObjectOffset(eid+'_0');
			offset=ofstobj[0];
		};
		if (offset) {
			menuShow(menuRootId+'/'+mobj.id, menuStartLevel, offset-1, menuTop)
		}
		else {
			if (menuDebug) alert('no offset calculated menubar tab #'+n+' ('+eid+'_1)');
		}
	}
	else {
		menuHide()
	}
}

function menubarLeave() {
	if (menuTimer) menuDisableTimeout();
	menuTimer= setTimeout('menubarReset()',menuHideDelay);
}

function menubarReset() {
	if (menuTimer) menuDisableTimeout();
	if (menubarActiveElement>=0) {
		 menuHide();
		 menubarSetTab(menubarActiveElement, 0);
		 menubarActiveElement=-1
	};
	if (menuAnimationOn) {
		menuTopAnimationSet(menuAnimationDefault)
	};
	menuTimer= setTimeout('menubarSetDefault()',menubarResetDelay);
}

function menubarSetDefault() {
	if (menubarDefTabNr>=0) {
		menubarSetTab(menubarDefTabNr,1);
		menubarActiveElement=menubarDefTabNr;
	}
}

function menubarHold() {
	if (menuTimer) menuDisableTimeout();
}

function menuTopAnimationSet(imgnr) {
	if ((document.images) && (menuImages[menuAnimationPrefix+imgnr]) && (menuImages[menuAnimationPrefix+imgnr].complete)) {
		if ((document.layers) && (menuAnimationNS4TargetLayer) && (document.layers[menuAnimationNS4TargetLayer]) && (document.layers[menuAnimationNS4TargetLayer].document.images[menuAnimationTargetId])) {
			document.layers[menuAnimationNS4TargetLayer].document.images[menuAnimationTargetId]=menuImages[menuAnimationPrefix+imgnr].src
		}
		else if (document.images[menuAnimationTargetId]) {
			document.images[menuAnimationTargetId].src=menuImages[menuAnimationPrefix+imgnr].src
		}
		else {
			if (menuDebug) alert('could not find animation target image '+menuAnimationTargetId);
		}
	}
}

function menubarSetTab(n,active) {
	if (document.layers) {
		menubarNS4SetTab(n,active);
		return
	};
	var fg, bg, tableft, tabright;
	var eid=menubarDiv+'_'+n;
	if (active) {
		fg=menubarFgColorActive;
		bg=menubarBgColorActive;
		tableft=menuImages.menubartab_l;
		tabright=menuImages.menubartab_r
	}
	else {
		fg=menubarFgColorInactive;
		bg=menubarBgColorInactive;
		tableft=menuImages.spacer;
		tabright=menuImages.spacer
	};
	menuSetColor(eid+'_1', fg, bg);
	menuSetColor(eid+'_link', fg, bg);
	var dimgn=eid+'_left';
	if ((document.images[dimgn]) && (tableft)) document.images[dimgn].src=tableft.src;
	dimgn=eid+'_right';
	if ((document.images[dimgn]) && (tabright)) document.images[dimgn].src=tabright.src;
}

// f & h - menus

function menuCreate(id, level) {
	var cols, leftcorner, rightcorner, leftcornerwidth, rightcornerwidth, isSub, mid;
	if (menus[id]==null) {
		if (menuDebug) alert('no such menu: '+id);
		return null
	};
	isSub=menuIsSub(level);
	mid=menuDivId[level];
	if (isSub) {
		cols=5;
		leftcorner='menu_dl2.gif';
		rightcorner='menu_dr2.gif';
		leftcornerwidth=10;
		rightcornerwidth=21
	}
	else {
		cols=7;
		leftcorner='menu_dl1.gif';
		rightcorner='menu_dr1.gif';
		leftcornerwidth=13;
		rightcornerwidth=14
	};
	var leftmargin=leftcornerwidth-1;
	var rightmargin=rightcornerwidth-1;
	var defaultaction= 'onmouseover="menuHold(\''+mid+'\')" onmouseout="menuLeave()"';
	var s='<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">\n';
	s+='<TR><TD HEIGHT="1" COLSPAN="'+cols+'" BGCOLOR="'+menuFrameColor+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD><\/TR>\n';
	if (!isSub) {
		s+='<TR><TD WIDTH="1" HEIGHT="6" BGCOLOR="'+menuFrameColor+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD><TD COLSPAN="'+(cols-2)+'" HEIGHT="4" BGCOLOR="'+menuBgColorInactive+'" '+defaultaction+'><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD><TD WIDTH="1" HEIGHT="6" BGCOLOR="'+menuFrameColor+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD><\/TR>\n'
	};
	for (var i=0; i<menus[id].children.length; i++) {
		var me=menus[id].children[i];
		var eid=mid+'_'+i;
		var menuaction ='onmouseover="menuSetActive('+level+','+i+'); window.status=\''+me.url+'\'; return true" onmouseout="menuLeave(); window.status=\'\'; return true" onclick="menuGo(\''+me.url+'\')"';
		s+='<TR BGCOLOR="'+menuBgColorInactive+'" ID="'+eid+'"><TD WIDTH="1" HEIGHT="1" BGCOLOR="'+menuFrameColor+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD><TD ID="'+eid+'_0" WIDTH="'+leftmargin+'" CLASS="'+menuCssClass+'" '+menuaction+'>&nbsp;<\/TD>';
		s+='<TD HEIGHT="15" VALIGN="bottom" ID="'+eid+'_link" CLASS="'+menuCssClass+'" NOWRAP '+menuaction+'>'+me.display+'<\/TD>';
		if (!isSub) {
			s+='<TD WIDTH="13" ID="'+eid+'_1" CLASS="'+menuCssClass+'" '+menuaction+'>&nbsp;<\/TD>';
			if (me.children.length>0) {
				s+='<TD ID="'+eid+'_2" CLASS="'+menuCssClass+'" '+menuaction+'><IMG SRC="'+menuImgPath+'menu_arrow_lo.gif" WIDTH="9" HEIGHT="15" NAME="menuarrow_'+eid+'"><\/TD>'
			}
			else {
				s+='<TD ID="'+eid+'_2" CLASS="'+menuCssClass+'" '+menuaction+'><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD>'
			}
		};
		s+='<TD ID="'+eid+'_3" WIDTH="'+rightmargin+'" CLASS="'+menuCssClass+'" '+menuaction+'>&nbsp;<\/TD><TD WIDTH="1" HEIGHT="1" BGCOLOR="'+menuFrameColor+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD><\/TR>\n'
	};
	s+='<TR><TD HEIGHT="4" WIDTH="'+leftcornerwidth+'" COLSPAN="2" ROWSPAN="2"><IMG SRC="'+menuImgPath+leftcorner+'" WIDTH="'+leftcornerwidth+'" HEIGHT="4"><\/TD><TD HEIGHT="3" COLSPAN="'+(cols-4)+'" BGCOLOR="'+menuBgColorInactive+'" '+defaultaction+'><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="3"><\/TD><TD HEIGHT="4" WIDTH="'+rightcornerwidth+'" COLSPAN="2" ROWSPAN="2"><IMG SRC="'+menuImgPath+rightcorner+'" WIDTH="'+rightcornerwidth+'" HEIGHT="4"><\/TD><\/TR>\n';
	s+='<TR><TD HEIGHT="1" COLSPAN="'+(cols-4)+'" BGCOLOR="'+menuFrameColor+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD><\/TR><\/TABLE>\n\n';
	if (menuCaching) menuCache[id]=s;
	return s
}

function menuShow(id, level, pX, pY, pW) {
	if (document.layers) {
		menuNS4Show(id, level, pX, pY, pW);
		return
	};
	var isSub=menuIsSub(level);
	var mid=menuDivId[level];
	menuSetVisibility(mid,0);
	menuActiveElement[level]='';
	menuDivWrite(mid, ((menuCaching) && (menuCache[id]))? menuCache[id] : menuCreate(id, level) );
	menuCurrentObjId[level]=id;
	var w=menuGetDivWidth(mid);
	var maxX=menuGetWinWidth();
	var x;
	if (isSub) {
		x=pX+pW-1;
		if ((maxX>0) && (w>0) && (x+w>maxX)) x=pX+1-w;
	}
	else {
		x=pX;
		if ((maxX>0) && (w>0) && (x+w>maxX)) x=maxX-w;
	};
	menuDivMove(mid, x, pY);
	menuPosX[level]=x;
	menuPosY[level]=pY;
	if ((document.all) && (!(document.getElementById)) && (document.all[mid])) {
		// ie4 clip bug-fix
		var mw=document.all[mid].children[0].offsetWidth;
		var mh=document.all[mid].children[0].offsetHeight;
		menuDivSetClip(mid, 0,0, mw,mh)
	};
	menuSetVisibility(mid,1);
	if (level<menuMaxLevel) menuHide(level+1);
}

function menuIsSub(level) {
	return (level>menuStartLevel)? true: false;
}

function menuGo(url) {
	if (url) {
		if (url.indexOf('http:')==0) {
			var win=window.open(url,'');
			if (window.focus) win.focus();
		}
		else if (url.indexOf('jav'+'asc'+'ript:')==0) {
			void(eval(url.substring(11)));
		}
		else {
			window.main.location.href=url
		}
	}
}

function menuSetActive(level, n) {
	if (menuTimer) menuDisableTimeout();
	var mid=menuDivId[level];
	var eid=mid+'_'+n;
	if (document.layers) {
		if (menuActiveElement[level]==n) return;
		if (menuActiveElement[level]>=0) menuNS4SetEntryColor(level, menuActiveElement[level], 0);
		menuNS4SetEntryColor(level, n, 1);
		menuActiveElement[level]=n
	}
	else {
		if (menuActiveElement[level]==eid) return;
		menuSetEntryColor(eid, 1);
		if (menuActiveElement[level]) menuSetEntryColor(menuActiveElement[level], 0);
		menuActiveElement[level]=eid
	};
	// show submenu
	var pm=menus[menuCurrentObjId[level]];
	if ((level<menuMaxLevel) && (pm.children[n].children.length>0)) {
		var pathid=(pm.parentid)? pm.parentid+'/'+pm.id+'/'+pm.children[n].id : pm.id+'/'+pm.children[n].id;
		var y= menuPosY[level]+n*menuItemHeight;
		if (level==menuStartLevel) y+=menuSubOffset;
		var w= (document.layers)? menuGetDivWidth(menuNS4Bg[level]) : menuGetDivWidth(mid);
		menuShow(pathid, level+1, menuPosX[level], y, w);
		return
	};
	if (level<menuMaxLevel) menuHide(level+1);
}

function menuSetEntryColor(eid, active) {
	var bg, fg, imgobj;
	if (active) {
		fg=menuFgColorActive;
		bg=menuBgColorActive;
		imgobj=menuImages.menu_arrow_hi
	}
	else {
		fg=menuFgColorInactive;
		bg=menuBgColorInactive;
		imgobj=menuImages.menu_arrow_lo
	};
	menuSetColor(eid, fg, bg);
	menuSetColor(eid+'_link', fg, bg);
	if (document.images['menuarrow_'+eid]) document.images['menuarrow_'+eid].src=imgobj.src;
	if (window.opera) {
		for (var i=0; i<4; i++) menuSetColor(eid+'_'+i, fg, bg);
	}
}

function menuLeave() {
	menuTimer= setTimeout('menubarReset()',menuHideDelay);
}

function menuHide(level) {
	if (menuTimer) menuDisableTimeout();
	if (level==null) level=menuStartLevel;
	menuSetVisibility(menuDivId[level],0);
	if (document.layers) {
		menuSetVisibility(menuNS4Bg[level],0);
		menuSetVisibility(menuNS4Ol[level],0);
		menuSetVisibility(menuNS4Hl[level],0);
		//if (menuActiveElement[level]>=0) menuNS4SetEntryColor(level, menuActiveElement[level], 0);
		menuActiveElement[level]=-1
	}
	else {
		if (menuActiveElement[level]) menuSetEntryColor(menuActiveElement[level], 0);
		menuActiveElement[level]=''
	};
	menuCurrentObjId[level]='';
	if (level<menuMaxLevel) menuHide(level+1);
}

function menuSetInactive(level) {
	if (document.layers) {
		if (menuActiveElement[level]>=0) menuNS4SetEntryColor(level, menuActiveElement[level], 0);
		menuActiveElement[level]=-1
	}
	else {
		if (menuActiveElement[level]) menuSetEntryColor(menuActiveElement[level], 0);
		menuActiveElement[level]=''
	};
	if (level<menuMaxLevel) menuHide(level+1);
}

function menuHold() {
	if (menuTimer) menuDisableTimeout();
	menuSetInactive(menuStartLevel)
}

function menuDisableTimeout() {
	if (menuTimer) {
		clearTimeout(menuTimer);
		//menuTimer=null
	}
}


// ns4 display functions

function menubarNS4Write() {
	var tabwidth=10;
	var tabheight=16;
	var s='<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%" HEIGHT="'+tabheight+'"><TR><TD ALIGN="center" WIDTH="100%"><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="'+menubarWidth+'"><TR><TD BGCOLOR="'+menubarBgColorInactive+'" NOWRAP><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>\n<TD WIDTH="1"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD>\n';
	for (var i=0; i<menus[menuRootId].children.length; i++) {
		var mbid=menubarDiv+'_'+i;
		var mbe=menus[menuRootId].children[i];
		s+='<TD><ILAYER NAME="'+mbid+'" HEIGHT="'+tabheight+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="'+tabwidth+'" HEIGHT="'+tabheight+'"></ILAYER><\/TD><TD VALIGN="bottom" NOWRAP CLASS="'+menubarCssClass+'"><A HREF="'+mbe.url+'" CLASS="'+menubarCssClass+'">'+mbe.display+'<\/A><\/TD><TD><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="'+tabwidth+'" HEIGHT="'+tabheight+'"><\/TD>\n'
	};
	s+='<TD><ILAYER NAME="'+menubarDiv+'_'+menus[menuRootId].children.length+'" HEIGHT="'+tabheight+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="'+tabwidth+'" HEIGHT="'+tabheight+'"></ILAYER><\/TD>';
	s+='<\/TR><\/TABLE><\/TD><\/TR><\/TABLE><\/TD><\/TR><\/TABLE>';
	menuDivWrite(menubarDiv,s);
	menuDivMove(menubarDiv,0,menubarTop);
	menuSetVisibility(menubarDiv,1);
	s='<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR>\n';
	for (var i=0; i<menus[menuRootId].children.length; i++) {
		var mouseaction='onmouseover="menubarSetActive('+i+')" onmouseout="menubarLeave()"';
		var w=menubarNS4GetTabX(i+1)-menubarNS4GetTabX(i);
		s+='<TD><A HREF="'+menus[menuRootId].children[i].url+'" '+mouseaction+'><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="'+w+'" HEIGHT="'+tabheight+'" BORDER="0"><\/A><\/TD>\n'
	};
	s+='<\/TR><\/TABLE>';
	menuDivWrite(menubarNS4Ol,s);
	menuDivMove(menubarNS4Ol,menubarNS4GetTabX(0),menubarTop);
	menuSetVisibility(menubarNS4Ol,1);
}

function menubarNS4SetTab(n, active) {
	if (active) {
		var tabwidth=10;
		var tabheight=16;
		var mbe=menus[menuRootId].children[n];
		var s= '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD><IMG SRC="'+menuImgPath+'menubartab_l.gif" WIDTH="'+tabwidth+'" HEIGHT="'+tabheight+'"><\/TD><TD HEIGHT="'+tabheight+'" VALIGN="bottom" BGCOLOR="'+menubarBgColorActive+'" NOWRAP CLASS="'+menubarCssClassNS4Active+'">'+mbe.display+'<\/TD><TD><IMG SRC="'+menuImgPath+'menubartab_r.gif" WIDTH="'+tabwidth+'" HEIGHT="'+tabheight+'"><\/TD><\/TR><\/TABLE>';
		menuDivWrite(menubarNS4Hl,s);
		menuDivMove(menubarNS4Hl, menubarNS4GetTabX(n), menubarTop);
		menuSetVisibility(menubarNS4Hl,1);
	}
	else {
		menuSetVisibility(menubarNS4Hl,0);
	}
}

function menubarNS4GetTabX(n) {
	var eid=menubarDiv+'_'+n;
	if ((document.layers[menubarDiv]) && (document.layers[menubarDiv].document.layers[eid])) {
		return document.layers[menubarDiv].document.layers[eid].pageX
	}
	else {
		return 0
	}
}

function menuNS4GetEntry(text, active) {
	var cl=(active)? 'menuLinkNS4Hi':'menuLinkNS4Lo';
	return '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TD HEIGHT="'+menuItemHeight+'" CLASS="'+cl+'" VALIGN="bottom">'+text+'<\/TD><\/TR><\/TABLE>'
}

function menuNS4Create(id,level) {
	var mid=menuDivId[level];
	if (menus[id]==null) {
		if (menuDebug) alert('no such menu: '+id);
		return null
	};
	var s='';
	for (var i=0; i<menus[id].children.length; i++) {
		var me=menus[id].children[i];
		var eid=mid+'_'+i;
		s+='<LAYER NAME="'+eid+'" TOP="'+(i*15)+'" LEFT="0">'+menuNS4GetEntry(me.display, 0)+'<\/LAYER>\n'
	};
	s+='<LAYER NAME="'+mid+'_arrows" TOP="0" LEFT="0"><\/LAYER>\n'
	if (menuCaching) menuCache[id]=s;
	return s
}

function menuNS4WriteArrows(mid,id) {
	var s='<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">\n';
	var w=1;
	for (var i=0; i<menus[id].children.length; i++) {
		var me=menus[id].children[i];
		if (me.children.length>0) {
			var eid=mid+'_'+i;
			s+='<TR><TD><IMG SRC="'+menuImgPath+'menu_arrow_lo.gif" WIDTH="9" HEIGHT="15" NAME="menuarrow_'+eid+'"><\/TD><\/TR>';
			w=9
		}
		else {
			s+='<TD HEIGHT="15"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD><\/TR>'
		}
	};
	s+='<\/TABLE>';
	menuNS4InnerLrWrite(mid, mid+'_arrows', s);
	return w
}

function menuNS4WriteBg(level,w,h) {
	var leftcorner, rightcorner, leftcornerwidth, rightcornerwidth, leftspace, rightspace;
	var isSub=menuIsSub(level);
	if (isSub) {
		cols=5;
		leftcorner='menu_dl2.gif';
		rightcorner='menu_dr2.gif';
		leftcornerwidth=10;
		rightcornerwidth=21
	}
	else {
		cols=7;
		leftcorner='menu_dl1.gif';
		rightcorner='menu_dr1.gif';
		leftcornerwidth=13;
		rightcornerwidth=14;
		h+=menuSubOffset-1
	};
	leftspace=leftcornerwidth-1;
	rightspace=rightcornerwidth-1;
	var s='<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">\n';
	s+='<TR><TD HEIGHT="1" COLSPAN="5" BGCOLOR="'+menuFrameColor+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD><\/TR>\n';
	s+='<TR><TD WIDTH="1" HEIGHT="'+h+'" BGCOLOR="'+menuFrameColor+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD><TD HEIGHT="'+h+'" WIDTH="'+leftspace+'" BGCOLOR="'+menuBgColorInactive+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="'+leftspace+'" HEIGHT="'+h+'"><\/TD>';
	s+='<TD HEIGHT="'+h+'" WIDTH="'+w+'" BGCOLOR="'+menuBgColorInactive+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="'+w+'" HEIGHT="'+h+'"><\/TD>';
	s+='<TD HEIGHT="'+h+'" WIDTH="'+rightspace+'" BGCOLOR="'+menuBgColorInactive+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="'+rightspace+'" HEIGHT="'+h+'"><\/TD><TD WIDTH="1" HEIGHT="'+h+'" BGCOLOR="'+menuFrameColor+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD><\/TR>\n';
	s+='<TR><TD HEIGHT="4" WIDTH="'+leftcornerwidth+'" COLSPAN="2" ROWSPAN="2"><IMG SRC="'+menuImgPath+leftcorner+'" WIDTH="'+leftcornerwidth+'" HEIGHT="4"><\/TD><TD HEIGHT="3" BGCOLOR="'+menuBgColorInactive+'" WIDTH="'+w+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="'+w+'" HEIGHT="3"><\/TD><TD HEIGHT="4" WIDTH="'+rightcornerwidth+'" COLSPAN="2" ROWSPAN="2"><IMG SRC="'+menuImgPath+rightcorner+'" WIDTH="'+rightcornerwidth+'" HEIGHT="4"><\/TD><\/TR>\n';
	s+='<TR><TD HEIGHT="1" WIDTH="'+w+'" BGCOLOR="'+menuFrameColor+'"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD><\/TR><\/TABLE>\n';
	menuDivWrite(menuNS4Bg[level],s)
}

function menuNS4WriteOl(id, level, w) {
	var s='<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">\n';
	var defaultaction='onmouseover="menuHold(); window.status=\'\'; return true" onmouseout="menuLeave(); window.status=\'\'; return true" onclick="return false"';
	if (level==menuStartLevel) {
		s+='<TR><TD><A HREF="#" '+defaultaction+'><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="'+w+'" HEIGHT="'+(menuSubOffset-1)+'" BORDER="0"><\/A><\/TD><\/TR>\n';
	};
	for (var i=0; i<menus[id].children.length; i++) {
		var me=menus[id].children[i];
		var menuaction ='onmouseover="menuSetActive('+level+','+i+')" onmouseout="menuLeave()"';
		s+='<TR><TD HEIGHT="'+menuItemHeight+'"><A HREF="'+me.url+'" '+menuaction+'><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="'+w+'" HEIGHT="'+menuItemHeight+'" BORDER="0"><\/A><\/TD><\/TR>\n'
	};
	s+='<TR><TD><A HREF="#" '+defaultaction+'><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="'+w+'" HEIGHT="4" BORDER="0"><\/A><\/TD><\/TR>\n<\/TABLE>';
	menuDivWrite(menuNS4Ol[level],s)
}

function menuNS4Show(id, level, pX, pY, pW) {
	var leftmargin, rightmargin, topmargin, bottommargin;
	var isSub=menuIsSub(level);
	var mid=menuDivId[level];
	var mbg=menuNS4Bg[level];
	var mol=menuNS4Ol[level];
	var mhl=menuNS4Hl[level];
	menuSetVisibility(mid,0);
	menuSetVisibility(mhl,0);
	menuSetVisibility(mol,0);
	menuSetVisibility(mbg,0);
	menuActiveElement[level]=-1;
	menuDivWrite(mid, ((menuCaching) && (menuCache[id]))? menuCache[id] : menuNS4Create(id, level) );
	var w=0;
	for (var i=0; i<menus[id].children.length; i++) {
		w=Math.max(w,document.layers[mid].document.layers[mid+'_'+i].clip.right)
	};
	var h=menus[id].children.length*menuItemHeight;
	if (level<menuMaxLevel) {
		var aw=menuNS4WriteArrows(mid,id);
		document.layers[mid].document.layers[mid+'_arrows'].moveTo(w+13,0);
		w+=aw+13;
		document.layers[mid].clip.right=w;
	};
	bottommargin=4;
	if (isSub) {
		leftmargin=10;
		rightmargin=21;
		topmargin=1
	}
	else {
		leftmargin=13;
		rightmargin=14;
		topmargin=menuSubOffset
	};
	var molOffset= (isSub)? 5: 0; // overlap for timing work around
	menuNS4WriteBg(level, w, h);
	menuNS4WriteOl(id, level, w+leftmargin+rightmargin+molOffset);
	menuCurrentObjId[level]=id;
	var lrhl=document.layers[mhl];
	lrhl.resizeTo(w+leftmargin+rightmargin,menuItemHeight);
	lrhl.document.bgColor=menuBgColorActive;
	var x;
	var maxX=menuGetWinWidth();
	if (isSub) {
		x=pX+pW-1;
		if ((maxX>0) && (w>0) && (x+w>maxX)) x=pX+1-w;
	}
	else {
		x=pX;
		if ((maxX>0) && (w>0) && (x+w>maxX)) x=maxX-w;
	};
	menuDivMove(mid,x+leftmargin,pY+topmargin);
	menuDivMove(mbg,x,pY);
	menuDivMove(mol,x-molOffset,pY);
	menuPosX[level]=x;
	menuPosY[level]=pY;
	menuSetVisibility(mbg,1);
	menuSetVisibility(mid,1);
	menuSetVisibility(mol,1);
	if (level<menuMaxLevel) menuHide(level+1);
}

function menuNS4SetEntryColor(level, n, active) {
	var mid=menuDivId[level];
	var mhl=menuNS4Hl[level];
	var eid=mid+'_'+n;
	var mobj=menus[menuCurrentObjId[level]].children[n];
	menuNS4InnerLrWrite(mid, eid, menuNS4GetEntry(mobj.display, active));
	if ((menuImages.menu_arrow_hi) && (menuImages.menu_arrow_lo)) {
		if ((document.layers[mid]) && (document.layers[mid].document.layers[mid+'_arrows']) && (document.layers[mid].document.layers[mid+'_arrows'].document.images['menuarrow_'+mid+'_'+n])) {
			document.layers[mid].document.layers[mid+'_arrows'].document.images['menuarrow_'+mid+'_'+n].src=(active)? menuImages.menu_arrow_hi.src : menuImages.menu_arrow_lo.src;
		}
	};
	if (active) {
		var y=menuPosY[level]+menuItemHeight*n;
		y+=(menuIsSub(level))? 1 : menuSubOffset;
		menuDivMove(mhl,menuPosX[level],y);
	};
	menuSetVisibility(mhl,active)
}


// bottomline

function menuBottomWrite(activenr) {
	if (self.menuBottomGrafics) {
		menuBottomGRWrite(activenr);
		return
	};
	var tabheight=18;
	var s='<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%"><TR><TD ALIGN="center" WIDTH="100%"><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="'+menuBottomWidth+'"><TR><TD NOWRAP><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR VALIGN="bottom" HEIGHT="'+tabheight+'">\n';
	for (var i=0; i<menusBottomline.length; i++) {
		var mb=menusBottomline[i];
		var eid=menuBottomDiv+'_'+i;
		s+='<TD WIDTH="1"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"></TD>\n';
		if (activenr==i) {
			s+='<TD WIDTH="10"><IMG SRC="'+menuImgPath+'bottomtab_l_hi.gif" NAME="'+eid+'_left" WIDTH="10" HEIGHT="'+tabheight+'"><\/TD>\n';
			s+='<TD ID="'+eid+'_1" BGCOLOR="'+menuBottomBgActive+'" NOWRAP CLASS="'+menuBottomActiveCssClass+'">'+mb.display+'<\/TD>\n';
			s+='<TD WIDTH="10"><IMG SRC="'+menuImgPath+'bottomtab_r_hi.gif" NAME="'+eid+'_right" WIDTH="10" HEIGHT="'+tabheight+'"><\/TD>\n'
		}
		else {
			var mouseaction='onmouseover="menuBottomSetActive('+i+'); window.status=\''+mb.display+'\'; return true" onmouseout="menuBottomLeave(); window.status=\'\'; return true" onclick="menuBottomShow('+i+'); return false" onfocus="if(this.blur)this.blur();"';
			s+='<TD WIDTH="10" '+mouseaction+'><IMG SRC="'+menuImgPath+'bottomtab_l_lo.gif" NAME="'+eid+'_left" WIDTH="10" HEIGHT="'+tabheight+'"><\/TD>\n';
			s+='<TD ID="'+eid+'_1" BGCOLOR="'+menuBottomBgInactive+'" NOWRAP CLASS="'+menuBottomInactiveCssClass+'"><A HREF="javascript:menuBottomShow('+i+');" '+mouseaction+' CLASS="'+menuBottomInactiveCssClass+'" ID="'+eid+'_link" NAME="'+eid+'_link">'+mb.display+'<\/A><\/TD>\n';
			s+='<TD WIDTH="10" '+mouseaction+'><IMG SRC="'+menuImgPath+'bottomtab_r_lo.gif" NAME="'+eid+'_right" WIDTH="10" HEIGHT="'+tabheight+'"><\/TD>\n'
		}
	};
	s+='<TD WIDTH="1"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD>\n';
	s+='<TD WIDTH="10"><IMG SRC="'+menuImgPath+'bottomtab_l_lo.gif" WIDTH="10" HEIGHT="'+tabheight+'"><\/TD>\n';
	s+='<\/TR><\/TABLE><\/TD>\n';
	s+='<TD WIDTH="100%" BGCOLOR="'+menuBottomBgInactive+'">&nbsp;<\/TD>\n';
	s+='<TD ALIGN="right" NOWRAP><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR VALIGN="bottom" HEIGHT="'+tabheight+'">\n';
	s+='<TD BGCOLOR="'+menuBottomBgInactive+'" NOWRAP CLASS="'+menuBottomInactiveCssClass+'" VALIGN="middle">';
	s+= (activenr>=0)? '<A HREF="javascript:menuBottomHide()" onmouseover="window.status=\'close ...\'; return true" onmouseout="window.status=\'\'; return true"><IMG SRC="'+menuImgPath+'menubottomclose.gif" WIDTH="9" HEIGHT="9" BORDER="0"><\/A>' : '&nbsp;';
	s+='<\/TD>\n';
	s+='<TD WIDTH="10"><IMG SRC="'+menuImgPath+'bottomtab_r_lo.gif" WIDTH="10" HEIGHT="'+tabheight+'"><\/TD>\n';
	s+='<\/TR><\/TABLE><\/TD>\n';
	s+='</TR>\n<TR HEIGHT="1"><TD HEIGHT="1" COLSPAN="3" BGCOLOR="#D4CFC9"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD><\/TR>\n';
	s+='<\/TABLE><\/TD><\/TR><\/TABLE>';
	menuDivWrite(menuBottomDiv,s)
}

function menuBottomContentWrite(url) {
	var s;
	if (url) {
		s='<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%"><TR><TD ALIGN="center"><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="'+menuBottomWidth+'" HEIGHT="'+menuBottomContentHeight+'"><TR><TD BGCOLOR="'+menuBottomContentBg+'"><IFRAME NAME="menuBottomFrame" BORDER="0" FRAMEBORDER="0" FRAMESPACING="0"  WIDTH="'+menuBottomWidth+'" HEIGHT="'+menuBottomContentHeight+'" SRC="'+url+'"><A HREF="'+url+'">'+url+'<\/A><\/IFRAME><\/TD><\/TR><\/TABLE><\/TD><\/TR><\/TABLE>'
	}
	else {
		s='<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%"><TR><TD ALIGN="center"><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="'+menuBottomWidth+'" HEIGHT="'+menuBottomContentHeight+'"><TR><TD BGCOLOR="'+menuBottomContentBg+'">&nbsp;<\/TD><\/TR><\/TABLE><\/TD><\/TR><\/TABLE>'
	};
	menuDivWrite(menuBottomContentDiv,s);
}

function menuBottomSetActive(n) {
	if (menuBottomTimer) menuBottomDisableTimeout();
	if (document.layers) return;
	// set tabs
	var eid=menuBottomDiv+'_'+n;
	if (menuBottomActiveElement!=n) {
		if (menuBottomActiveElement>=0) menuBottomSetTab(menuBottomActiveElement, 0);
		menuBottomSetTab(n, 1);
		menuBottomActiveElement=n
	}
}

function menuBottomLeave() {
	if (menuBottomTimer) menuBottomDisableTimeout();
	if (document.layers) return;
	menuBottomTimer= setTimeout('menuBottomReset()',menuBottomResetDelay);
}

function menuBottomReset() {
	if (menuBottomTimer) menuBottomDisableTimeout();
	if (menuBottomActiveElement>=0) {
		menuBottomSetTab(menuBottomActiveElement, 0);
		menuBottomActiveElement=-1
	};
	if (menuBottomTabShown>=0) menuBottomTimer= setTimeout('menuBottomResetTab()',menuBottomResetDelay);
}

function menuBottomResetTab() {
	if (document.layers) return;
	menuBottomSetTab(menuBottomTabShown, 1);
	menuBottomActiveElement=menuBottomTabShown
}

function menuBottomShow(n) {
	if (menuBottomTimer) menuBottomDisableTimeout();
	if (document.layers) {
		// loading layers is much to instable - just open window
		var win;
		if (menuBottomNS4ShowFullWin) {
			win=window.open(menusBottomline[n].url, 'telering_service')
		}
		else {
			win=window.open(menusBottomline[n].url, 'telering_service', 'width='+menuBottomWidth+',height='+menuBottomContentHeight+',menubar=1,status=1,resizable')
		};
		win.focus();
		menuBottomWrite();
		return
	};
	menuBottomWrite(n);
	menuSetVisibility(menuBottomDiv,1);
	menuBottomOffset=menuBottomLineHeight+menuBottomContentHeight;
	if (menuBottomTabShown>=0) {
		menuBottomContentWrite(menusBottomline[n].url);
		menuSetVisibility(menuBottomContentDiv,1)
	}
	else {
		menuBottomContentWrite(menusBottomline[n].url);
		menuDivSetClip(menuBottomContentDiv,0,0,menuGetWinWidth(),1);
		menuDivMove(menuBottomContentDiv,0,menuBottomLastY+menuBottomLineHeight);
		menuSetVisibility(menuBottomContentDiv,1);
		menuBottomShowing=true;
		menuBottomToShow=n;
	};
	menuBottomTabShown=n
}

function menuBottomHide() {
	if (menuBottomTimer) menuBottomDisableTimeout();
	menuBottomOffset=menuBottomLineHeight;
	menuBottomHidding=true;
	menuBottomContentWrite();
	menuBottomTabShown=-1;
	menuBottomWrite()
}

function menuBottomSetTab(n,active) {
	if (self.menuBottomGrafics) {
		menuBottomGRSetTab(n,active);
		return
	};
	var fg, bg, tableft, tabright;
	var eid=menuBottomDiv+'_'+n;
	if (active) {
		fg=menuBottomFgActive;
		bg=menuBottomBgActive;
		tableft=menuImages.bottomtab_l_hi;
		tabright=menuImages.bottomtab_r_hi
	}
	else {
		fg=menuBottomFgInactive;
		bg=menuBottomBgInactive;
		tableft=menuImages.bottomtab_l_lo;
		tabright=menuImages.bottomtab_r_lo
	};
	menuSetColor(eid+'_1', fg, bg);
	menuSetColor(eid+'_link', fg, bg);
	document.images[eid+'_left'].src=tableft.src;
	document.images[eid+'_right'].src=tabright.src;
}

function menuBottomDisableTimeout() {
	if (menuBottomTimer) {
		clearTimeout(menuBottomTimer);
		menuBottomTimer=null
	}
}

function menuBottomActivate() {
	menuBottomWrite(-1);
	menuBottomOffset=menuBottomLineHeight;
	menuBottomLastY=menuGetWinHeight()+menuGetScrollY()-menuBottomOffset;
	menuDivMove(menuBottomDiv,0,menuBottomLastY);
	menuSetVisibility(menuBottomDiv,1);
	menuSetVisibility(menuBottomContentDiv,0);
	menuBottomResetTimer=setInterval('menuBottomKeepPos()',20)
}

function menuGetCenterX(w) {
	// opera && ns 6.0-6.1 win center fix; include offset for scrollbars
	if (((window.opera)||(isKonqueror)) && (document.body.scrollHeight>document.body.offsetHeight)) w+=16
	else if ((isNS6) && (document.height>menuGetWinHeight())) w+=16;
	return Math.max(0,Math.floor(menuGetWinWidth()-w)/2)
}

function menuBottomKeepPos() {
	var x=0;
	var y=menuGetWinHeight()+menuGetScrollY()-menuBottomOffset;
	var dy=(y-menuBottomLastY)*menuBottomScrollFactor;
	menuBottomLastY+= (dy > 0)? Math.ceil(dy) : Math.floor(dy);
	if ((window.opera) || (isNS6) || (isKonqueror)) {
		// opera, NS6 center fix
		menuDivMove(menubarDiv,menuGetCenterX(menubarWidth),menubarTop);
		x=menuGetCenterX(menuBottomWidth);
	};
	if (isMsieMac50Classic) menuBottomLastY-=menuBottomMacIE50Offset;
	menuDivMove(menuBottomDiv,x,menuBottomLastY);
	if (menuBottomShowing) {
		menuDivMove(menuBottomContentDiv,x,menuBottomLastY+menuBottomLineHeight);
		var h=menuBottomGetContentVisHeight();
		menuDivSetClip(menuBottomContentDiv,0,0,menuGetWinWidth(),h);
		if (h==menuBottomContentHeight) {
			menuBottomShowing=false;
			if (isMsieMac) {
				// msie 5 mac bugfix (cant move iframe)
				menuBottomContentWrite(menusBottomline[menuBottomToShow].url);
				menuDivSetClip(menuBottomContentDiv,0,0,menuGetWinWidth(),h);
			}
		}
	}
	else if (menuBottomHidding) {
		var h=menuBottomGetContentVisHeight();
		if (h==0) {
			menuSetVisibility(menuBottomContentDiv,0);
			menuBottomHidding=false;
			window.status='';
		}
		else {
			menuDivSetClip(menuBottomContentDiv,0,0,menuGetWinWidth(),h);
			menuDivMove(menuBottomContentDiv,x,menuBottomLastY+menuBottomLineHeight);
		}
	}
	else if (menuBottomTabShown>=0) {
		menuDivMove(menuBottomContentDiv,x,menuBottomLastY+menuBottomLineHeight);
		if ((isMsieMac) && (dy)) {
			// msie 5 mac bugfix (cant move iframe)
			menuBottomContentWrite(menusBottomline[menuBottomToShow].url);
			menuDivSetClip(menuBottomContentDiv,0,0,menuGetWinWidth(),menuBottomGetContentVisHeight());
		}
	}
}

function menuBottomGetContentVisHeight() {
	return menuGetWinHeight()+menuGetScrollY()-(menuBottomLastY+menuBottomLineHeight);
}

// grafical bottom line

function menuBottomGRWrite(activenr) {
	var tabheight=19;
	var innerLineHeight=menuBottomLineHeight-1;
	var blwidth=0;
	var s='<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%"><TR><TD ALIGN="center" WIDTH="100%"><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="'+menuBottomWidth+'"><TR><TD NOWRAP><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR VALIGN="bottom" HEIGHT="'+innerLineHeight+'">\n';
	for (var i=0; i<menusBottomline.length; i++) {
		var mb=menusBottomline[i];
		var eid=menuBottomDiv+'_'+i;
		var grafics=menuBottomGraficsNames[i];
		var rollover=grafics[2];
		var tabwidth=menuBottomGraficsWidths[i];
		s+='<TD WIDTH="1"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"></TD>\n';
		if (activenr==i) {
			s+='<TD WIDTH="'+tabwidth+'"><IMG SRC="'+menuImages[grafics[1]].src+'" NAME="'+eid+'" WIDTH="'+tabwidth+'" HEIGHT="'+innerLineHeight+'"><\/TD>\n'
		}
		else {
			var mouseaction;
			if (rollover) {
				mouseaction='onmouseover="menuBottomSetActive('+i+'); window.status=\''+mb.display+'\'; return true" onmouseout="menuBottomLeave(); window.status=\'\'; return true" onfocus="if(this.blur)this.blur();"';
			}
			else {
				mouseaction='onmouseover="window.status=\''+mb.display+'\'; return true" onmouseout="window.status=\'\'; return true" onfocus="if(this.blur)this.blur();"';
			}
			s+='<TD WIDTH="'+tabwidth+'"><A HREF="javascript:menuBottomShow('+i+');" '+mouseaction+'><IMG SRC="'+menuImages[grafics[0]].src+'" NAME="'+eid+'" WIDTH="'+tabwidth+'" HEIGHT="'+innerLineHeight+'" BORDER="0"><\/A><\/TD>\n';
		};
		blwidth+=menuBottomGraficsWidths[i]+1;
	};
	s+='<TD WIDTH="1"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD>\n';
	var rwidth=menuBottomWidth-blwidth-1;
	s+='<\/TR><\/TABLE><\/TD>\n';
	s+='<TD WIDTH="'+rwidth+'" BACKGROUND="'+menuBottomGraficsPath+menuBottomGraficsBgImage+'" ALIGN="right" NOWRAP VALIGN="bottom">';
	s+='<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR VALIGN="bottom" HEIGHT="'+tabheight+'">\n';
	s+='<TD NOWRAP VALIGN="middle">';
	s+= (activenr>=0)? '<A HREF="javascript:menuBottomHide()" onmouseover="window.status=\'close ...\'; return true" onmouseout="window.status=\'\'; return true"><IMG SRC="'+menuImgPath+'menubottomclose.gif" WIDTH="9" HEIGHT="9" BORDER="0"><\/A>' : '&nbsp;';
	s+='<\/TD>\n';
	s+='<TD WIDTH="10"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="10" HEIGHT="'+tabheight+'"><\/TD>\n';
	s+='<\/TR><\/TABLE><\/TD>\n';
	s+='</TR>\n<TR HEIGHT="1"><TD HEIGHT="1" COLSPAN="2" BGCOLOR="#D4CFC9"><IMG SRC="'+menuImgPath+'spacer.gif" WIDTH="1" HEIGHT="1"><\/TD><\/TR>\n';
	s+='<\/TABLE><\/TD><\/TR><\/TABLE>';
	menuDivWrite(menuBottomDiv,s)
}

function menuBottomGRSetTab(n,active) {
	var eid=menuBottomDiv+'_'+n;
	if (active) {
		document.images[eid].src=menuImages[menuBottomGraficsNames[n][2]].src;
	}
	else {
		document.images[eid].src=menuImages[menuBottomGraficsNames[n][0]].src;
	}
}


// basic dynamics

function menuNS4InnerLrWrite(lr1,lr2,s) {
	if ((document.layers[lr1]) && (document.layers[lr1].document.layers[lr2])) {
		var lrd=document.layers[lr1].document.layers[lr2].document;
		lrd.open();
		lrd.write(s);
		lrd.close()
	}
}

function menuSetVisibility(d,v) {
	if (document.layers) {
		if (document.layers[d]) document.layers[d].visibility= (v)? 'show':'hide';
	}
	else if (document.getElementById) {
		var obj=document.getElementById(d);
		if (obj) obj.style.visibility= (v)? 'visible':'hidden';
	}
	else if (document.all) {
		if (document.all[d]) document.all[d].visibility= (v)? 'visible':'hidden';
	}
}

function menuDivMove(d,x,y) {
	if (document.layers) {
		if (document.layers[d]) document.layers[d].moveTo(x,y);
	}
	else if (document.getElementById) {
		var obj=document.getElementById(d);
		if (obj) {
			obj.style.left=x+'px';
			obj.style.top=y+'px'
		}
	}
	else if (document.all) {
		var obj=document.all[d];
		if (obj) {
			obj.style.left=x+'px';
			obj.style.top=y+'px'
		}
	}
}

function menuDivWrite(d,s) {
	if (document.layers) {
		if (document.layers[d]) {
			document.layers[d].document.open();
			document.layers[d].document.write(s);
			document.layers[d].document.close()
		}
	}
	else if (document.getElementById) {
		var obj=document.getElementById(d);
		if (obj) obj.innerHTML=s;
	}
	else if (document.all) {
		if (document.all[d]) document.all[d].innerHTML=s;
	}
}

function menuSetColor(node, color, bg) {
	var obj;
	if (document.getElementById) {
		var obj=document.getElementById(node);
		if ((obj) && (obj.style)) {
			obj.style.backgroundColor=bg;
			obj.style.color=color
		}
	}
	else if (document.all) {
		var obj=document.all[node];
		if ((obj) && (obj.style)) {
			obj.style.backgroundColor=bg;
			obj.style.color=color
		}
	}
}

function menuGetDivWidth(d) {
	if (document.getElementById) {
		var obj=document.getElementById(d);
		if (obj) {
			var w= (obj.children)? obj.children[0].offsetWidth: obj.offsetWidth;
			return parseInt(w,10)
		}
	}
	else if (document.all) {
		var obj=document.all[d];
		if (obj) {
			return parseInt(obj.children[0].offsetWidth,10)
		}
	}
	else if (document.layers) {
		if (document.layers[d]) {
			return parseInt(document.layers[d].clip.right,10);
		}
	};
	return 0;
}

function menuGetWinWidth() {
	if (self.innerWidth) {
		return parseInt(self.innerWidth,10)
	}
	else if ((document.body) && (document.body.clientWidth)) {
		return parseInt(document.body.clientWidth,10)
	}
	else if (self.width) {
		return parseInt(self.width,10)
	}
	else {
		return 0
	}
}

function menuGetWinHeight() {
	if (self.innerHeight) {
		return parseInt(self.innerHeight,10)
	}
	else if ((document.body) && (document.body.clientHeight)) {
		return parseInt(document.body.clientHeight,10)
	}
	else if (self.height) {
		return parseInt(self.height,10)
	}
	else {
		return 0
	}
}

function menuGetScrollY() {
	var y=0;
	if ((document.body) && (document.body.scrollTop)) y=parseInt(document.body.scrollTop)
	else if (window.pageYOffset) y=parseInt(self.pageYOffset);
	return y
}

function menuDivSetClip(d,x1,y1,x2,y2) {
	if (document.getElementById) {
		var obj=document.getElementById(d);
		if (obj) obj.style.clip="rect("+y1+" "+x2+" "+y2+" "+x1+")";
	}
	else if (document.all) {
		if (document.all[d]) document.all[d].style.clip="rect("+y1+" "+x2+" "+y2+" "+x1+")";
	}
	else if (document.layers) {
		if (document.layers[d]) {
			var cl=document.layers[d].clip;
			cl.top=y1;
			cl.bottom=y2;
			cl.left=x1;
			cl.right=x2
		}
	}
}

function menuDivExists(d) {
	if (document.getElementById) {
		var obj=document.getElementById(d);
		return (obj)? true:false;
	}
	else if (document.all) {
		return (document.all[d])? true:false;
	}
	else if (document.layers) {
		if (document.layers[d]) {
			return document.layers[d]? true:false;
		}
	}
	else {
		return false
	}
}



function menuGetObjectOffset(objid) {
	var obj, x, y;
	if (document.getElementById) {
		// dom
		obj=document.getElementById(objid);
		if (!obj) return null;
		x=((obj.firstChild) && (obj.firstChild.offsetLeft))? obj.firstChild.offsetLeft:obj.offsetLeft;
		y=((obj.firstChild) && (obj.firstChild.offsetTop))? obj.firstChild.offsetTop:obj.offsetTop;
		while (obj.offsetParent) {
			obj=obj.offsetParent;
			x+=obj.offsetLeft;
			y+=obj.offsetTop
		};
		// ms ie 5.0 mac bugfix
		if (isMsieMac) {
			if (document.body.leftMargin) x+=parseInt(document.body.leftMargin);
			if (document.body.topMargin) y+=parseInt(document.body.topMargin);
		};
		return [x,y]
	}
	else if (document.all) {
		// ie 4, ie 5.0 alike
		obj=document.all[objid];
		if (!obj) return null;
		x=obj.offsetLeft;
		y=obj.offsetTop;
		if ((obj.offsetParent) && ((obj.offsetParent.offsetTop) || (obj.offsetParent.offsetLeft))) {
			// IE 5 alike
			while (obj.offsetParent) {
				obj=obj.offsetParent;
				x+=obj.offsetLeft;
				y+=obj.offsetTop
			}
		}
		else {
			// IE 4
			while (obj.parentElement) {
				obj=obj.parentElement;
				if (obj.offsetLeft) x+=obj.offsetLeft;
				if (obj.offsetTop) y+=obj.offsetTop;
			}
		};
		return [x,y]
	}
	else if (document.layers) {
		// ns4 - search for named links and top layers
		if (document.links[objid]) {
			return [document.links[objid].x,document.links[objid].y]
		}
		else if (document.layers[objid]) {
			return [document.layers[objid].pageX,document.layers[objid].pageY]
		}
		else {
			return null
		}
	}
	else {
		return null
	}
}


// auto calls

if (document.images) menuPreload();


function fixWidth () {
   if (document.getElementById && !isMsieMac && isMsie && (window.location.hostname != "cms.telering.at") && (window.location.href.search(/\/\.Node\//) < 0) && (window.location.href.search(/webcms/) < 0)) {
	if (document.getElementById("maintable").offsetWidth > 761) {
			document.all.maintable.outerHTML = document.all.maintable.outerHTML;
	}

   } else if(document.layers){
	winW = window.innerWidth
	winH = window.innerHeight
	window.onresize = nsRestore
   }
}

function nsRestore(){
if(winW != window.innerWidth || winH != window.innerHeight){
	location.reload(true)
	}
}

// *eof*
