function expandMenuNS (menuId,e,dItem){clearTimeout(contentPage.document.getElementById (menuId).collapseTime);}
function collapseMenuNS (menuId){}

brPage.addEventListener ("load",onCreated,false);
onReady();

function chgVisib(obj,bVis)
	{
	obj.style.display = (bVis) ? "" : "none";
	obj.activeId = null;
	}

function onItemClick()
	{
	if (sepFrame && openSameFrame)
		{
		cntPage = eval("parent.frames."+cntFrame); cntPage.location.href=this.itemLink;
		omo=mout;mout=false;bMenuActive=false;
		if (activeMenu) {activeMenu.bActive=false;itemId=activeMenu;closeMenu(itemId);}
		mout=omo;
		}
	else
		{
		contentPage.location.href = this.itemLink;
		}
	prevActiveItem = null ;
	}

function onDocClick()
	{
	if (!bMenuActive && activeMenu!=null && !activeMenu.bActive)
		{
		itemId = activeMenu;
		closeMenu(itemId);
		}
	prevActiveItem = null ;
	}
function onUnload() {readyStatus=0; onReady(); loadStatus = 0; contentPage.dummyprop=1;setTimeout("waitReady()",50);}

function onOver(evt)
	{
	this.bActive = true;
	bMenuActive = true;
	activeMenu = this;
	if (this.collapseTime)
		{
		clearTimeout(this.collapseTime);
		this.collapseTime=null;
		}
	}

function onOut(evt)
	{
	this.bActive = false;
	bMenuActive = false;
	contentPage.status = "";
	if (mout) smCollapseTime = setTimeout("closeMenu(activeMenu)",100);
	}

function onOverItem(evt)
	{
	this.style.backgroundColor = this.brCont.itemHlBgCol;
	this.style.color = this.brCont.fontHlCol;
	contentPage.status = this.itemLink;
	this.brCont.activeId = this;

	if (this.brCont.bExp) closeSubmenus(this.brCont,this);
	if (this.bParent)
		{
		horOffset = (this.brCont.popupWidth - this.brCont.levelOffset);
		this.childX = this.brCont.offsetLeft + horOffset;
		this.childY = this.offsetTop + 6 + bord;
		ensureVisib(this.child,this.childX, this.childY);
		this.brCont.bExp = true;
		this.brCont.visibleChild = this.child;
		if (this.child.style.display=="none")
			chgVisib(this.child, true);
		}
	}

function onItemOut(evt)
	{
	this.style.backgroundColor = this.brCont.itemBgCol;
	this.style.color = this.brCont.fontCol;
	}

function onReady()
	{
	if(readyStatus)
		{
		for(i=1; i<lev0menus; i++)
			{
			cur = eval("mnu"+i);
			clearTimeout(cur.collapseTime);
			cur.collapseTime=null;
			}
		clearTimeout(smCollapseTime);
		}
	lev0menus = 1;
	readyStatus = 0;
	createStatus = 0;
	bMenuActive = false;
	activeMenu = null;
	smCollapseTime = null;
	}

function onCreated()
	{
	setTimeout("onCreate();",1);
	}

function onCreate()
	{
	loadStatus = 1;
	if (sepFrame)
		{
		contentPage = parent.frames[contentFrame];
		contentPage.window.addEventListener ("unload",onUnload, false);
		}
	else
		{
		contentPage = window;
		}
	contentPage.nav = window;
	if (!mout)
		contentPage.document.addEventListener ("mousedown",onDocClick, false);
	  else
	createStatus = 1;
	topZ = 0;
	elements=contentPage.document.getElementsByTagName("*");
	for (z=0;z<elements.length;z++)
		{
		oldEl = elements[z];
		topZ = Math.max(oldEl.style.zIndex,topZ)
		}
	while(eval("window.mn" + lev0menus))
		{
		create(0,false,lev0menus);
		lev0menus++
		}
	status = ""
	readyStatus = 1;
	createStatus = 0;
	}

function waitReady()
	{
	if (contentPage.dummyProp!=1)
		{
		onReady();
		onCreate();
		}
	else
		{
		setTimeout("waitReady()",50);
		}
	}

function setMenuTree(obj,bPopup,mnuPar)
	{
	if (obj.lev > maxlev) {levArr = eval ("lev" + maxlev) ;} else {levArr = eval ("lev" + obj.lev) ;}
	obj.popupWidth = popupWidth ;
	obj.fontCol = levArr [4] ;
	obj.fontHlCol = levArr [6] ;
	obj.itemBgCol = levArr [5] ;
	obj.itemHlBgCol = levArr [8] ;
	obj.popupBorderCol = borderCol ;
	if (!bPopup)
		{
		obj.rootId = obj ;
		obj.first = obj ;
		}
	else
		{
		obj.rootId = mnuPar.rootId ;
		}
	obj.itemCount = obj.array.length/3;
	obj.bPopup = bPopup;
	obj.itemIter = 0;
	}

function create(lev,bPopup,mnuId,mnuPar)
	{
	menu = createMenuTag("mnu" + mnuId);
	menu.array = eval ("window.mn"+mnuId)
	menu.lev=lev;
	setMenuTree(menu,bPopup,mnuPar);
	menu.style.width=menu.popupWidth;

	var curypos=0;
	while (menu.itemIter < menu.itemCount)
		{
		menu.itemIter++;
		if (++stPos == stStr.length) stPos = 0 ;
		window.status = "Loading menu... " + stStr [stPos] ;
		curId = "item" + mnuId + "_" + menu.itemIter;
		nMnuItem = (menu.itemIter-1)*3 ;
		itemText = menu.array[nMnuItem];
		bParent = menu.array[nMnuItem + 2];
		var addText = contentPage.document.createElement("DIV");
		if (menu.id=="" || lev > maxlev) {levArr = eval ("lev" + maxlev) ;} else {levArr = eval ("lev" + lev) ;}
		with(addText)
			{
			id = curId;
			with(style)
				{
				if (menu.isTree && !bParent) paddingRight = vertSpace+iconSize;
				color = menu.fontCol;
				fontSize = levArr [0];
				fontWeight = (levArr [2]) ? "bold" : "normal";
				fontStyle = (levArr [3]) ? "italic" : "normal";
				fontFamily = levArr [7];
				padding = vertSpace+"px";
				borderBottomWidth = sep + "px";
				borderBottomColor = "black";
				borderBottomStyle = "solid";
				backgroundColor = menu.itemBgCol;
				width = (menu.popupWidth-(bord*2));
				}
			innerHTML = itemText;
			}
		menu.appendChild(addText);
		if(bParent)
			{
			addIm=contentPage.document.createElement("IMG");
			with(addIm)
				{
				src=unescape(absPath)+imgFolder+"/arr1.gif";
				with(style)
					{
					position="absolute";
					width=iconSize+"px";
					height=iconSize+"px";
					var tp=curypos+addText.offsetHeight/2-iconSize/2;
					top=tp+"px";
					var lt=popupWidth-vertSpace-iconSize;
					left=lt+"px";
					}
				}
			addText.appendChild(addIm);
			create(lev+1,true,mnuId + "_" + menu.itemIter,menu);
			menu = menu.parentMenu;
			}
		curypos+=addText.offsetHeight;
		}
	spanArray = menu.getElementsByTagName ("DIV");
	for (i=0; i<spanArray.length; i++)
		{
		it = spanArray[i];
		it.itemText = menu.array[i*3];
		it.itemLink = 'jump.php?'+menu.array[i*3 + 1];
		it.bParent = menu.array[i*3 + 2];
		it.addEventListener ("mouseover",onOverItem, false);
		it.addEventListener ("mouseout",onItemOut,false);
		it.brCont=menu;
		if (it.bParent)
			{
			it.child = contentPage.document.getElementById("mnu"+it.id.substr(4));
			it.child.parentMenu = menu;
			it.child.parentItem = addText;
			}
		if (it.itemLink)
			{
			it.addEventListener ("click",onItemClick,false);
			it.style.cursor = "pointer";
			}
		}
	menu.lastId = spanArray[spanArray.length-1];
	createItemArr(menu,bPopup,mnuPar);
	}

function createMenuTag(itemId,itemWidth,parentId,conId)
	{
	addTag = contentPage.document.createElement ("DIV");
	addTag.id = itemId;
	addTag.style.position = "absolute";
	contentPage.document.body.appendChild(addTag);
	if (sepFrame && !openSameFrame) eval(itemId + "= contentPage." + itemId);
	return addTag;
	}

function moveTo(xPos,yPos)
	{
	this.style.left = xPos;
	this.style.top = yPos;
	}

function expandMenu(menuId,e,dItem)
	{
	se = document.getElementById (dItem);
	if (!loadStatus) return;
	activeItem = se;
	if (dItem != prevActiveItem) {prevActiveItem = dItem ;} else {return ;}
	if (!createStatus && !readyStatus) onCreate();
	activeItem.menuId = menuId;
	if (!loadStatus || !readyStatus) return true;
	for(i=1; i<lev0menus; i++)
		{
		temp = contentPage.document.getElementById("mnu" + i).first;
		temp.bActive = false;
		if (temp.bExp) closeSubmenus(temp);
		chgVisib(temp, false);
		}
	activeMenu = contentPage.document.getElementById(activeItem.menuId);
	activeMenu.bPopup = false;
	activeMenu.rootId.first = activeMenu;
	if (activeMenu.collapseTime)
		{
		clearTimeout (activeMenu.collapseTime);
		activeMenu.collapseTime=null;
		}
	setXY (dItem);
	if (!sepFrame || openSameFrame)
		{
		xPos=newpx;
		yPos=newpy;
		}
	else
		{
		switch (menuPos)
			{
			case 0:
				xPos = contentPage.document.body.offsetLeft;
				yPos = newpy + contentPage.document.body.offsetTop;
				break;
			case 1:
				xPos = contentPage.document.body.offsetLeft+contentPage.document.body.offsetWidth;
				yPos = newpy + contentPage.document.body.offsetTop;
				break;
			case 2:
				xPos = newpx + contentPage.document.body.offsetLeft;
				yPos = contentPage.document.body.offsetTop;
				break;
			case 3:
				xPos = newpx + contentPage.document.body.offsetLeft;
				yPos = contentPage.document.body.offsetTop + contentPage.document.body.offsetHeight;
				break;
			}
		}
	ensureVisib(activeMenu, xPos, yPos);
	activeMenu.bActive = true;
	chgVisib(activeMenu,true);
	return false;
	}

function ensureVisib(obj,defx, defy)
	{
	var nx=defx;
	var ny=defy;
	winBot=contentPage.innerHeight-20;
	botPos=ny+obj.fullHeight;
	winRight=contentPage.innerWidth-20;
	rightPos=nx+parseInt(obj.style.width);
	if (rightPos > winRight)
		{
		if (obj.bPopup)
			{
			parentLeft = parseInt(obj.parentMenu.style.left);
			nx = ((parentLeft - obj.popupWidth) + obj.levelOffset);
			}
		else
			{
			dif = rightPos - winRight;
			nx -= dif;
			}
		}
	if (botPos > winBot)
		{
		dif = botPos - winBot;
		ny -= dif;
		}
	if (nx < 0)
		{
		nx = 5;
		}
	obj.moveTo (nx,ny);
	}

function collapseMenu(menuId)
	{
	if (!loadStatus || !readyStatus) return;
	itemId = contentPage.document.getElementById (menuId);
	itemId.bActive = false;
	if (mout) closePopup(itemId);
	}

function closeMenu(obj)
	{
	smCollapseTime = null;
	if (bMenuActive) return;
	if (obj.bExp) closeSubmenus(obj);
	tempMenu = obj;
	while (tempMenu.bPopup)
		{
		chgVisib(tempMenu,false);
		tempMenu.parentMenu.bActive = false;		
		tempMenu = tempMenu.parentMenu;
		}
	closePopup(tempMenu);
	}

function tf(oldToCnt)
	{
	if (oldToCnt!=toCnt)
		return ;
	closeItem(hideId);
	hideId.collapseTime=null;
	prevActiveItem = null ;
	}

function closePopup(obj)
	{
	hideId = obj;
	if(!mout)
		{
		closeItem(hideId);
		}
	else
		{
		if (obj.collapseTime)
			clearTimeout (obj.collapseTime);
		if (toCnt++ >= closeDelay)
			toCnt = 0 ;
		obj.collapseTime = setTimeout("tf("+toCnt+")",closeDelay);
		}
	}

function closeSubmenus(obj,item)
	{
	tempMenu = obj.visibleChild;
	if (item&&tempMenu.id.substring(3)==item.id.substring(4))
		return;
	while (tempMenu.bExp)
		{
		chgVisib(tempMenu.visibleChild,false);
		tempMenu.bExp = false;
		tempMenu = tempMenu.visibleChild;
		}
	if (!obj.bActive || !obj.bParent || obj.visibleChild != obj.child)
		{
		chgVisib(obj.visibleChild,false);
		obj.bExp = false;
		}
	}

function cancelSelect(){return false}

function createItemArr(obj,bPopup,parMnu,parId)
	{
	obj.addEventListener ("mouseover",onOver, false);
	obj.addEventListener ("mouseout",onOut, false);
	obj.bExp = false;
	obj.bActive = false;
	obj.collapseTime = null;
	obj.levelOffset = levelOffset;
	obj.activeId = null;
	if (bPopup)
		{
		obj.bPopup = true;
		obj.parentMenu = parMnu;
		}
	else
		{
		obj.bPopup = false;
		}
	with (obj.style)
		{
		width = obj.popupWidth;
		borderWidth = bord;
		borderColor = obj.popupBorderCol;
		backgroundColor=obj.itemBgCol;
		borderStyle = "solid";
		}
	zIndex = topZ;
	obj.lastId.style.border="";
	obj.fullHeight = obj.offsetHeight;
	chgVisib(obj,false);
	obj.onselectstart = cancelSelect;
	obj.moveTo = moveTo;
	obj.moveTo(0,0);
	}

function closeItem(obj)
	{
	if (obj.collapseTime)
		{
		clearTimeout (obj.collapseTime);
		obj.collapseTime=null;
		}
	if (!obj.bActive && !bMenuActive)
		chgVisib(obj,false);
	}

function setXY (dItem)
	{
	dItemEl= document.getElementById (dItem)
	if (menuHorizontal) {newpy = dItemEl.offsetHeight + popupOffset ;newpx=0;} else {newpx = dItemEl.offsetWidth + popupOffset ;newpy=0;}
	newpx += dItemEl.offsetLeft ;
	newpy += dItemEl.offsetTop ;
	if((!sepFrame || openSameFrame)) {newpx+=10;newpy+=10;}
	while (dItemEl.offsetParent)
		{
		if (dItemEl.offsetParent == dItemEl || dItemEl.offsetParent == document.body) break ;
		newpx += dItemEl.offsetParent.offsetLeft ;
		newpy += dItemEl.offsetParent.offsetTop ;
		dItemEl = dItemEl.offsetParent ;
		}
	}

function chgBg (it, col)
	{
	}

