if (!document.loadHandlers)
{
	document.loadHandlers=new Array();
	document.loadHandlers[0]='initializeMenu';
	document.lastLoadHandler=0;
}
else
{
	document.lastLoadHandler++;
	document.loadHandlers[document.lastLoadHandler]='initializeMenu';
}
window.onload=initializeAll;
function errorTrap(){return true;}
window.onerror=errorTrap;

function makeTransparent(op,opObj,vis,ns,ie,frc)
{
	if(op||frc)
	{
		if(ns)opObj.style.MozOpacity = vis?op+'%':'';
		if(ie)opObj.style.filter=vis?"alpha(opacity="+op+")":"";
	}
}

function showDelayed(nmenu,objId,step)
{
	var obj=nmenu.popupFrame.document.getElementById(objId);
	var objBg=nmenu.popupFrame.document.getElementById(objId+'bgWnd');
	if(nmenu.showDelayedTimeout){nmenu.showDelayedTimeout=null;clearTimeout(nmenu.showDelayedTimeout);}
	var max=nmenu.popupOpacity?nmenu.popupOpacity:100;
	if(obj)makeTransparent((nmenu.fadingSteps-step)*max/nmenu.fadingSteps,obj,1,1,1,1);
	if(objBg)makeTransparent(100,objBg,0,0,nmenu.bBitmapPopups,1);
	if(step<=0)return;
	setTimeout("showDelayed("+nmenu.name+",'"+objId+"',"+(step-1)+")", nmenu.bShowDel/nmenu.fadingSteps);
}

function createMenuItem(nmenu,popup,id,itemLink,itemText,popupArray,levelAttribs,bLast,popupHeight,parent)
{
	var itemType=0;
	if(itemText&&itemText.indexOf("(^1)")!=-1)itemType=1;
	if(itemText&&itemText.indexOf("(^2)")!=-1)itemType=2;
	var itemWnd=nmenu.popupFrame.document.createElement("DIV");
	popup.appendChild(itemWnd);
	if(mac)
	{
		var brWnd=nmenu.popupFrame.document.createElement("BR");
		popup.appendChild(brWnd)
	}
	addEvent(itemWnd,"mouseover",onItemOver,false);
	addEvent(itemWnd,"mouseout",onItemOut,false);
	addEvent(itemWnd,"mousedown",onItemClick,false);
	addEvent(itemWnd,"dblclick",onItemClick,false);
	itemWnd.owner=popup;
	itemWnd.id=id;
	with (itemWnd.style)
	{
		position="absolute";
		if(itemType==2)top=popupHeight-nmenu.scrollHeight;
		else top=popupHeight;
		if(itemLink){cursor=(!IE4||version>=6)?"pointer":"hand";}
		else{cursor="default";}
		color=levelAttribs [3];
		if (!nmenu.bBitmapPopups)
		{
			if (!bLast)
			{
				borderBottomColor=nmenu.borderCol;
				borderBottomWidth=nmenu.sep;
				borderBottomStyle="solid";
			}
		}
		else left=nmenu.popupLeftPad+nmenu.vertSpace;
		if (!itemType)padding=nmenu.vertSpace;
		paddingLeft=nmenu.popupLeftPad+nmenu.vertSpace;
		paddingRight=(nmenu.popupRightPad<nmenu.iconSize?nmenu.iconSize:nmenu.popupRightPad)+nmenu.vertSpace;
		fontSize=levelAttribs[0];
		fontWeight=(levelAttribs[1])?"bold":"normal";
		fontStyle=(levelAttribs[2])?"italic":"normal";
		fontFamily=levelAttribs[6];
		textAlign=(nmenu.popAlign==1?'center':(nmenu.popAlign==2?'right':'left'));
		setRealWidth(itemWnd,nmenu.bBitmapPopups?nmenu.curPopupWidth-nmenu.popupLeftPad-nmenu.popupRightPad-2*nmenu.vertSpace:nmenu.curPopupWidth,2*nmenu.bord);
	}
	if (popupArray)itemWnd.popupArray=popupArray;
	if(itemType>0)
	{
		var arrow=nmenu.popupFrame.document.createElement("IMG");
		itemWnd.appendChild(arrow);
		var arrowSrc;
		if (nmenu.imgFolder&&nmenu.imgFolder.indexOf('/')!=0)arrowSrc=unescape(absPath)+nmenu.imgFolder;
		else arrowSrc=nmenu.imgFolder;
		arrow.src=arrowSrc+"/scroll"+((itemType==1)?"up":"down")+".gif";
		itemWnd.style.textAlign="center";
		itemWnd.style.display="none";
	}
	else itemWnd.innerHTML=itemText;
	if(itemLink&&itemLink.indexOf(':/')==-1&&itemLink.indexOf(':\\')==-1&&itemLink.indexOf('/')!=0)itemWnd.url=unescape(absPath)+itemLink;
	else itemWnd.url=itemLink;
	itemWnd.dispText=itemText;
	if (popupArray)
	{
		var expandArrow=nmenu.popupFrame.document.createElement("IMG");
		itemWnd.appendChild(expandArrow);
		var expandArrowSrc;
		if (nmenu.imgFolder&&nmenu.imgFolder.indexOf('/')!=0)expandArrowSrc=unescape(absPath)+nmenu.imgFolder;
		else expandArrowSrc=nmenu.imgFolder;
		expandArrow.src=expandArrowSrc+"/sxicona.gif";
		with (expandArrow.style)
		{
			width=nmenu.iconSize;
			height=nmenu.iconSize;
			position="absolute";
			var itemRect=getClientRect(nmenu,itemWnd);
			top=(itemRect.bottom-itemRect.top)/2-nmenu.iconSize/2-2;
			left=itemWnd.offsetWidth-nmenu.iconSize-1;
		}
	}
	return itemWnd.offsetHeight;
}

function setRealWidth(wnd,width,borderWidth)
{
	wnd.style.width=width-borderWidth;
	if (wnd.offsetWidth>width-borderWidth) wnd.style.width=width-parseInt(wnd.style.paddingLeft)-parseInt(wnd.style.paddingRight);
}

function createPopupFromCode(nmenu,arrayName,level,ownerMenu)
{
	var popupName=arrayName+"popup";
	var popup=nmenu.popupFrame.document.getElementById(popupName);
	if (popup)return popup;
	var levelAttribs;
	if(level>0)nmenu.curPopupWidth=nmenu.popupWidth;
	if (level > nmenu.maxlev) {levelAttribs = eval ("nmenu.lev" + nmenu.maxlev) ;} else {levelAttribs = eval ("nmenu.lev" + level) ;}
	popup=nmenu.popupFrame.document.createElement("DIV");
	nmenu.popupFrame.document.body.appendChild(popup);
	popup.id=popupName;
	popup.ownerMenu=ownerMenu;
	popup.level=level;
	popup.highlightColor=levelAttribs[5];
	popup.normalColor=levelAttribs[3];
	popup.highlightBgColor=levelAttribs[7];
	popup.normalBgColor=levelAttribs[4];
	popup.scrVis=false;
	with (popup.style)
	{
		zIndex=maxZ;
		position="absolute";
		width=nmenu.curPopupWidth;
		if (!nmenu.bBitmapPopups)
		{
			borderColor=nmenu.borderCol;
			backgroundColor=levelAttribs[4];
			borderWidth=nmenu.bord;
			borderStyle="solid";
		}
		else backgroundColor="";
	}
	popup.nmenu=nmenu;
	addEvent(popup,"mouseout",onPopupOut,false);
	addEvent(popup,"mouseover",onPopupOver,false);

	var popupHeight=0;
	if (nmenu.bBitmapPopups)
	{
		var source=document.getElementById('menubg4');
		if (source)
		{
			var imel=nmenu.popupFrame.document.createElement("IMG");
			popup.appendChild(imel);
			imel.src=source.src;
			imel.id=popup.id+"openingImg"
			imel.style.position="absolute";
			imel.style.top=0;
			makeTransparent(nmenu.popupOpacity,imel,1,0,1,0);
			popupHeight+=nmenu.popupOpenHeight;
		}
	}

	var bgWnd=nmenu.popupFrame.document.createElement("DIV");
	popup.appendChild(bgWnd);
	bgWnd.id=popup.id+"bgWnd";
	bgWnd.style.position="absolute";
	bgWnd.style.top=nmenu.popupOpenHeight;
	bgWnd.style.width=nmenu.curPopupWidth-2*nmenu.bord;
	bgWnd.innerHTML="<font size='1'>&nbsp;</font>";
	if (nmenu.bBitmapPopups)
	{
		var source=document.getElementById('menubg5');
		if (source) bgWnd.style.backgroundImage="url("+source.src+")";
	}
	else
	{
		bgWnd.style.backgroundColor=levelAttribs[4];
	}

	var array=eval(arrayName);
	var arrayItem;
	createMenuItem(nmenu,popup,popup.id+"scrollUp","javascript:scrollUp("+nmenu.name+",'"+popup.id+"');","(^1)",null,levelAttribs,true,popupHeight,bgWnd);
	for(arrayItem=0;arrayItem<array.length/3;arrayItem++)
	{
		var popupArray=(array[arrayItem*3+2])?(arrayName+"_"+parseInt(arrayItem+1)):null;
		popupHeight+=createMenuItem(nmenu,popup,null,array[arrayItem*3+1],array[arrayItem*3],popupArray,levelAttribs,(arrayItem == array.length/3-1),popupHeight,bgWnd);
	}
	createMenuItem(nmenu,popup,popup.id+"scrollDown","javascript:scrollDown("+nmenu.name+",'"+popup.id+"');","(^2)",null,levelAttribs,true,popupHeight,bgWnd);
	var bottomImgHeight=0;
	if (nmenu.bBitmapPopups)
	{
		var source=document.getElementById('menubg6');
		if (source)
		{
			var imel=nmenu.popupFrame.document.createElement("IMG");
			popup.appendChild(imel);
			imel.src=source.src;
			imel.id=popup.id+"closingImg";
			imel.style.position="absolute";
			imel.style.top=popupHeight-1;
			makeTransparent(nmenu.popupOpacity,imel,1,0,1,0);
			bottomImgHeight=imel.offsetHeight;
			popupHeight+=bottomImgHeight;
		}
	}
	popup.style.height=popupHeight+nmenu.bord*2+bottomImgHeight;
	popup.maxHeight=popupHeight+nmenu.bord*2+bottomImgHeight;
	bgWnd.style.height=popupHeight-nmenu.popupOpenHeight-bottomImgHeight;
	makeTransparent(nmenu.popupOpacity,bgWnd,1,0,nmenu.bBitmapPopups,0);
	makeTransparent(nmenu.popupOpacity,popup,1,1,!nmenu.bBitmapPopups,0);
	if(popup.offsetHeight>popupHeight+nmenu.bord*2+bottomImgHeight){popup.style.height=popupHeight;nmenu.bIncBorder=false;popup.maxHeight=popupHeight;}
	return popup;
}

function closePopup(nmenu,popupId)
{
	if(popupId.indexOf('_')==-1){var hideWnd=nmenu.popupFrame.document.getElementById('HideItem');if(hideWnd)hideWnd.style.visibility='visible';}
	if(nmenu.scrollTimeout){nmenu.scrollTimeoutStr=null;clearTimeout(nmenu.scrollTimeout);}
	var popup=nmenu.popupFrame.document.getElementById(popupId);
	if(popup)
	{
		if(popup.expandedWnd)closePopup(nmenu,popup.expandedWnd.id);
		if(popup.ownerMenu)popup.ownerMenu.expandedWnd=null;
		popup.style.visibility="hidden";
		popup.style.display="none";
	}
	if(nmenu.activePopup&&nmenu.activePopup.id==popupId)nmenu.activePopup=null;
}

function absToRel(rect,refx,refy)
{
	var retval=new rct(rect.left-refx,rect.top-refy,rect.right-refx,rect.bottom-refy);
	return retval;
}

function openPopup(nmenu,popup,x,y,bDontMove,refWnd)
{
	if(popup.id.indexOf('_')==-1){var hideWnd=nmenu.popupFrame.document.getElementById('HideItem');if(hideWnd)hideWnd.style.visibility='hidden';}
	if(nmenu.activePopup&&nmenu.activePopup.id==popup.id)return;
	popup.style.left=x;
	popup.style.top=y;
	popup.style.display="";
	popup.style.visibility="visible";
	var popupRect=getClientRect(nmenu,popup);
	var browserRect=getBrowserRect(nmenu.popupFrame);
	var bResize=(popup.offsetHeight<popup.maxHeight);

	if (popupRect.right>browserRect.right)
	{
		if(refWnd.id&&refWnd.id.indexOf('top')==-1)popup.style.left=Math.max(0,refWnd.offsetLeft-popup.offsetWidth+nmenu.levelOffset);
		else popup.style.left=browserRect.right-popup.offsetWidth-5;
	}
	var wnd1=nmenu.popupFrame.document.getElementById(popup.id+"scrollDown");
	var wnd2=nmenu.popupFrame.document.getElementById(popup.id+"scrollUp");
	var cv=mac?15:(nmenu.bIncBorder?3:20);
	if (((popupRect.bottom>browserRect.bottom)||bResize)&&!NS60)
	{
		var newtop=browserRect.bottom-popup.offsetHeight-cv;
		if(!nmenu.menuHorizontal)bDontMove=false;
		if (newtop<0||bDontMove||bResize)
		{
			if(nmenu.sepFrame&&!nmenu.openSameFrame&&nmenu.menuPos==3)popup.style.top=Math.max(browserRect.top,newtop);
			var minNum=Math.min(popup.maxHeight,browserRect.bottom-popup.offsetTop-cv-(nmenu.bIncBorder?0:nmenu.bord*2));
			popup.scrVis=(minNum!=popup.maxHeight);
			setPopupHeight(nmenu,popup,browserRect.top,minNum);
		}
		else popup.style.top=newtop;
	}
	wnd1.style.display=popup.scrVis?"":"none";
	wnd2.style.display=popup.scrVis?"":"none";
	if(nmenu.bShowDel&&!mac)showDelayed(nmenu,popup.id,nmenu.fadingSteps);
}

function setPopupHeight(nmenu,popup,documentOffset,height)
{
	var wnd2=nmenu.popupFrame.document.getElementById(popup.id+"scrollDown");
	var wnd4=nmenu.popupFrame.document.getElementById(popup.id+"scrollUp");
	var wnd3=nmenu.popupFrame.document.getElementById(popup.id+"bgWnd");
	var wnd1Height=0;
	if(nmenu.bBitmapPopups)
	{
		var wnd1=nmenu.popupFrame.document.getElementById(popup.id+"closingImg");
		var wnd5=nmenu.popupFrame.document.getElementById(popup.id+"openingImg");
		wnd1Height=wnd1.offsetHeight;
		wnd1.style.top=height-1-wnd1Height;
	}
	wnd2.style.zIndex=maxZ+1;
	wnd4.style.zIndex=maxZ+1;
	popup.style.height=height;
	wnd3.style.height=height-nmenu.popupOpenHeight-nmenu.bord*2-wnd1Height;
	wnd2.style.top=height-wnd1Height-nmenu.scrollHeight-(nmenu.bIncBorder?nmenu.bord*2:0);
	scrollPopup(nmenu,popup.id,0);
}

function scrollPopup(nmenu,popupId,dir)
{
	var popup=nmenu.popupFrame.document.getElementById(popupId);
	var popupRect=getClientRect(nmenu,popup);
	var items=popup.getElementsByTagName("DIV");
	var i=(dir>0?0:items.length-1);
	var off=(dir>0?1:-1);
	var bFirst=true;
	var offset=dir*nmenu.scrollStep;
	if(popup.scrVis)
	{
		popupRect.top+=nmenu.scrollHeight;
		popupRect.bottom-=nmenu.scrollHeight;
	}
	popupRect.bottom-=2*nmenu.bord;
	for (;i<items.length&&i>=0;i+=off)
	{
		var item=items[i];
		if (!item.id||(item.id.indexOf("scroll")==-1&&item.id.indexOf("bgWnd")==-1))
		{
			var itemRect=getClientRect(nmenu,item);
			if(bFirst&&dir==0){offset=popup.maxHeight-(item.offsetTop+item.offsetHeight)+(popup.scrVis?nmenu.scrollHeight:0)-(nmenu.bIncBorder?nmenu.bord*2:0);}
			var relRect=absToRel(popupRect,itemRect.left,itemRect.top+offset);
			if (dir>0 && relRect.top<-nmenu.scrollHeight && bFirst) return;
			if (dir<0 && itemRect.bottom+offset<popupRect.bottom-nmenu.scrollHeight && bFirst) return;
			if(offset!=0)item.style.top=item.offsetTop+offset;
			if(!mac)item.style.clip="rect("+relRect.top+","+relRect.right+","+relRect.bottom+","+relRect.left+")";
			if (relRect.bottom<0||relRect.top>item.offsetHeight)
				item.style.visibility="hidden";
			else
				item.style.visibility="visible";
			bFirst=false;
		}
	}
	if(popup.scrPos)popup.scrPos+=offset;
	else popup.scrPos=offset;
}

function scrollUp(nmenu,popupId)
{
	scrollPopup(nmenu,popupId,1);
}

function scrollDown(nmenu,popupId)
{
	scrollPopup(nmenu,popupId,-1);
}

function isChildOfActivePopup(nmenu,popup)
{
	var wnd=nmenu.activePopup;
	while(wnd)
	{
		if (wnd.id==popup.id)
			return true;
		wnd=wnd.expandedWnd;
	}
	return false;
}

function onPopupOver()
{
	var nmenu=this.nmenu;
	if (nmenu.activePopup&&nmenu.activePopupTimeout&&isChildOfActivePopup (nmenu,this))clearTimeout(nmenu.activePopupTimeout);
}

function onPopupOut()
{
	var nmenu=this.nmenu;
	onPopupOutImpl(nmenu,this);
}

function onPopupOutImpl(nmenu,popup)
{
	if(nmenu.mout&&nmenu.activePopup&&isChildOfActivePopup(nmenu,popup))
	{
		if(nmenu.activePopupTimeout)clearTimeout(nmenu.activePopupTimeout);
		nmenu.activePopupTimeout=setTimeout("closePopup("+nmenu.name+",'"+nmenu.activePopup.id+"');",nmenu.closeDelay);
	}
}

function rct(left,top,right,bottom)
{
	this.left=left;
	this.top=top;
	this.right=right;
	this.bottom=bottom;
}

function getBrowserRect(doc)
{
	var left=0;
	var top=0;
	var right;
	var bottom;
	if(doc.pageXOffset)left=doc.pageXOffset;
	else if(doc.document.body.scrollLeft)left=doc.document.body.scrollLeft;
	if(doc.pageYOffset)top=doc.pageYOffset;
	else if(doc.document.body.scrollTop)top=doc.document.body.scrollTop;
	if(doc.innerWidth)right=left+doc.innerWidth;
	else if(doc.document.body.clientWidth)right=left+doc.document.body.clientWidth;
	if(doc.innerHeight)bottom=top+doc.innerHeight;
	else if(doc.document.body.clientHeight)bottom=top+doc.document.body.clientHeight;
	var retval=new rct(left,top,right,bottom);
	return retval;	
}

function calcClientRect(nmenu,wnd)
{
	var left=mac?parseInt(document.body.leftMargin):0;
	var top=mac?parseInt(document.body.topMargin):0;
	var right=0;
	var bottom=0;
	var par=wnd;
	while (par)
	{
		left=left+parseInt(par.offsetLeft);
		top=top+parseInt(par.offsetTop);
		if (par.offsetParent==par || par.offsetParent==nmenu.popupFrame.document.body) break;
		par=par.offsetParent;
	}
	right=left+parseInt(wnd.offsetWidth);
	bottom=top+parseInt(wnd.offsetHeight);
	var retval=new rct(left,top,right,bottom);
	return retval;
}

function getClientRect(nmenu,wnd)
{
	if ((mac||DOM)&&wnd.getBoundingClientRect) return wnd.getBoundingClientRect ();
	return calcClientRect(nmenu,wnd);
}

function onItemClick()
{
	var item=this;
	var close=true;
	var nmenu=this.owner.nmenu;
	if (item.url)
	{
		var startPos=item.dispText.indexOf('<!--');
		if (startPos!=-1)
		{
			var endPos = item.dispText.indexOf('-->',startPos);
			var trgFrame = item.dispText.substring (startPos+4,endPos);
			if (trgFrame=="_blank") window.open (item.url);
			else if (trgFrame.indexOf('_')==0) parent.location.href=item.url;
			else eval("parent.frames."+trgFrame).location.href=item.url;
		}
		else
		{
			var find=item.url.indexOf("javascript:");
			if (find!=-1)
				{
				eval(item.url.substring(find));
				if(item.url.indexOf("scroll")!=-1) close=false;
				}
			else
				{
				var mt=item.url.indexOf("mailto:");
				if(mt!=-1)window.top.location=item.url.substring(mt);
				else nmenu.targetFrame.location=item.url;
				}
		}
		if(nmenu.activePopup&&close)closePopup(nmenu,nmenu.activePopup.id);
	}
}

function onNextScroll(nmenu)
{
	if(nmenu.scrollTimeoutStr)
	{
		eval(nmenu.scrollTimeoutStr);
		if(nmenu.scrollTimeout)clearTimeout(nmenu.scrollTimeout);
		nmenu.scrollTimeout=setTimeout("onNextScroll("+nmenu.name+")",nmenu.scrollDelay);
	}
}

function onItemOver()
{
	var item=this;
	var nmenu=this.owner.nmenu;

	var bOp=0;
	if (item.id&&item.id.indexOf("scroll")!=-1)
	{
		nmenu.scrollTimeoutStr=item.url;
		onNextScroll(nmenu);
		return;
	}
	if (item.owner.expandedWnd)
	{
		if(item.popupArray&&item.popupArray+'popup'==item.owner.expandedWnd.id)bOp=1;
		if(!bOp)closePopup(nmenu,item.owner.expandedWnd.id);
	}
	if (item.url&&item.url.indexOf("javascript:")==-1)
		window.status=item.url;
	else
		window.status="";
	item.style.color=item.owner.highlightColor;
	item.style.backgroundColor=item.owner.highlightBgColor;
	makeTransparent(nmenu.popupOpacity,item,1,0,nmenu.bBitmapPopups,0);
	var items=item.owner.getElementsByTagName("DIV");
	var i=0;
	for (;i<items.length;i++)if(item!=items[i]&&(!items[i].id||items[i].id.indexOf("scroll")==-1))
	{
		items[i].style.backgroundColor=nmenu.bBitmapPopups?"transparent":item.owner.normalBgColor;
		items[i].style.color=item.owner.normalColor;
	}
	if (item.popupArray&&!bOp)
	{
		var rect=getClientRect(nmenu,item);
		var x=rect.right-nmenu.levelOffset;
		var y=rect.top;
		var popup=createPopupFromCode(nmenu,item.popupArray,item.owner.level+1,item.owner);
		item.owner.expandedWnd=popup;
		openPopup(nmenu,popup,x,y+2,false,item.owner);
	}
}

function onItemOut()
{
	var item=this;
	var nmenu=this.owner.nmenu;
	if(nmenu.scrollTimeout){nmenu.scrollTimeoutStr=null;clearTimeout(nmenu.scrollTimeout);}
	makeTransparent(nmenu.popupOpacity,item,0,0,nmenu.bBitmapPopups,0);
	if (item.id&&item.id.indexOf("scroll")!=-1) return;
	item.style.color=item.owner.normalColor;
	item.style.backgroundColor=nmenu.bBitmapPopups?"transparent":item.owner.normalBgColor;
}

function expandMenu(nmenu,popupId,refWnd,dum,ml,mt,mr,mb)
{
	if(!docLoaded)return;
	if(nmenu.activePopupTimeout)clearTimeout(nmenu.activePopupTimeout);
	if (nmenu.activePopup&&nmenu.activePopup.id!=popupId+"popup")
		closePopup(nmenu,nmenu.activePopup.id);
	if(popupId=='none')return;
	var rect;
	if(refWnd=='coords'){rect=calcClientRect(nmenu,document.getElementById(nmenu.name+'tl'));rect.left=rect.left+ml;rect.top=rect.top+mt;rect.right=rect.left+mr;rect.bottom=rect.top+mb;}else{rect=calcClientRect(nmenu,document.getElementById(refWnd));}
	if(nmenu.bVarWidth&&!nmenu.bBitmapPopups)nmenu.curPopupWidth=rect.right-rect.left+(IE4?nmenu.bord*2:0);
	var x;
	var y;
	if(nmenu.menuHorizontal)
	{
		x=rect.left-nmenu.bord;
		y=rect.bottom+nmenu.popupOffset;
	}
	else
	{
		x=rect.right+nmenu.popupOffset;
		y=rect.top-nmenu.bord;
	}
	if(nmenu.sepFrame&&!nmenu.openSameFrame)
	{
		var brRect=getBrowserRect(nmenu.popupFrame);
		var wRect=getBrowserRect(window);
		switch (nmenu.menuPos)
		{
		case 0:
			x=brRect.left;
			y+=brRect.top-wRect.top;
			break;
		case 1:
			x=brRect.right;
			y+=brRect.top-wRect.top;
			break;
		case 2:
			x+=brRect.left-wRect.left;
			y=brRect.top;
			break;
		case 3:
			x+=brRect.left-wRect.left;
			y=brRect.bottom;
			break;
		}
	}
	var popup=createPopupFromCode(nmenu,popupId,0,null);
	openPopup(nmenu,popup,x,y,true,null);
	nmenu.activePopup=popup;
}

function collapseMenu(nmenu,popupId)
{
	if(!docLoaded)return;
	var popup=nmenu.popupFrame.document.getElementById(popupId+"popup");
	if(popup)onPopupOutImpl(nmenu,popup);
}

function expandMenuNS(nmenu,popupId,e,dItem)
{
}

function collapseMenuNS(nmenu,popupId)
{
}

function findFrame(name)
{
	if(parent.frames[name])return parent.frames[name];
	var i;
	for(i=0;i<parent.frames.length;i++){if(parent.frames[i].frames[name])return parent.frames[i].frames[name];}
}

function onDocClick()
{
	var nmn;
	for(nmn=1;nmn<=lastm;nmn++)
	{
		var nmenu=eval("window.m"+nmn);
		if(nmenu&&nmenu.activePopup)closePopup(nmenu,nmenu.activePopup.id);
	}
}

function initializeMenu()
{
	var nmn;
	for(nmn=1;nmn<=lastm;nmn++)
	{
		var nmenu=eval("window.m"+nmn);
		if(nmenu)
		{
			nmenu.popupFrame=(nmenu.sepFrame&&!nmenu.openSameFrame)?findFrame(nmenu.contentFrame):window;
			nmenu.targetFrame=(nmenu.sepFrame)?findFrame(nmenu.cntFrame):window;
			if(!nmenu.mout)addEvent(nmenu.popupFrame.document,"mousedown",onDocClick,false);
		}
	}
	docLoaded=true;
}

function addEvent(obj,event,fun,bubble)
{
	if (obj.addEventListener)
		obj.addEventListener(event,fun,bubble);
	else
		eval("obj.on"+event+"="+fun);
}

function chgBg(nmenu,item,color)
{
	if (!IE4&&!DOM)return;
	var el=document.getElementById(item);
	var ela=document.getElementById(item+'a');
	if (color==0)
	{
		if(!nmenu.bBitmapScheme)el.style.background=nmenu.tlmOrigBg;
		if(ela)ela.style.color=nmenu.tlmOrigCol;el.style.color=nmenu.tlmOrigCol;
	}
	else
	{
		if(!nmenu.bBitmapScheme&&(color&1))el.style.background=nmenu.tlmHlBg;
		if(ela&&color&2)ela.style.color=nmenu.tlmHlCol;el.style.color=nmenu.tlmHlCol;
	}
}

function initializeAll()
{
	var i;
	for(i=0;i<=document.lastLoadHandler;i++)
	{
		eval(document.loadHandlers[i]+'();');
	}
}

