// xMenu4, Cascading menus from nested ULs! Copyright (C) 2002,2003,2004,2005 Michael Foster (cross-browser.com) This code is distributed under the terms of the LGPL (gnu.org)
function xDef(){ for(var i=0;i<arguments.length;++i){ if(typeof (arguments[i])=="undefined"){ return false; } } return true; } function xStr(s){ for(var i=0;i<arguments.length;++i){ if(typeof (arguments[i])!="string"){ return false; } } return true; } function xNum(){ for(var i=0;i<arguments.length;++i){ if(isNaN(arguments[i])||typeof (arguments[i])!="number"){ return false; } } return true; } function xGetElementById(e){ if(typeof (e)=="string"){ if(document.getElementById){ e=document.getElementById(e); }else{ if(document.all){ e=document.all[e]; }else{ e=null; } } } return e; } function xGetComputedStyle(e,p,i){ if(!(e=xGetElementById(e))){ return null; } var s,v="undefined",dv=document.defaultView; if(dv&&dv.getComputedStyle){ s=dv.getComputedStyle(e,""); if(s){ v=s.getPropertyValue(p); } }else{ if(e.currentStyle){ v=e.currentStyle[xCamelize(p)]; }else{ return null; } } return i?(parseInt(v)||0):v; } function xHasPoint(e,x,y,t,r,b,l){ if(!xNum(t)){ t=r=b=l=0; }else{ if(!xNum(r)){ r=b=l=t; }else{ if(!xNum(b)){ l=r; b=t; } } } var eX=xPageX(e),eY=xPageY(e); return (x>=eX+l&&x<=eX+xWidth(e)-r&&y>=eY+t&&y<=eY+xHeight(e)-b); } function xLeft(e,iX){ if(!(e=xGetElementById(e))){ return 0; } var css=xDef(e.style); if(css&&xStr(e.style.left)){ if(xNum(iX)){ e.style.left=iX+"px"; }else{ iX=parseInt(e.style.left); if(isNaN(iX)){ iX=xGetComputedStyle(e,"left",1); } if(isNaN(iX)){ iX=0; } } }else{ if(css&&xDef(e.style.pixelLeft)){ if(xNum(iX)){ e.style.pixelLeft=iX; }else{ iX=e.style.pixelLeft; } } } return iX; } function xTop(e,iY){ if(!(e=xGetElementById(e))){ return 0; } var css=xDef(e.style); if(css&&xStr(e.style.top)){ if(xNum(iY)){ e.style.top=iY+"px"; }else{ iY=parseInt(e.style.top); if(isNaN(iY)){ iY=xGetComputedStyle(e,"top",1); } if(isNaN(iY)){ iY=0; } } }else{ if(css&&xDef(e.style.pixelTop)){ if(xNum(iY)){ e.style.pixelTop=iY; }else{ iY=e.style.pixelTop; } } } return iY; } function xMoveTo(e,x,y){ xLeft(e,x); xTop(e,y); } function xScrollLeft(e,_1c){ var _1d=0; if(!xDef(e)||_1c||e==document||e.tagName.toLowerCase()=="html"||e.tagName.toLowerCase()=="body"){ var w=window; if(_1c&&e){ w=e; } if(w.document.documentElement&&w.document.documentElement.scrollLeft){ _1d=w.document.documentElement.scrollLeft; }else{ if(w.document.body&&xDef(w.document.body.scrollLeft)){ _1d=w.document.body.scrollLeft; } } }else{ e=xGetElementById(e); if(e&&xNum(e.scrollLeft)){ _1d=e.scrollLeft; } } return _1d; } function xScrollTop(e,_20){ var _21=0; if(!xDef(e)||_20||e==document||e.tagName.toLowerCase()=="html"||e.tagName.toLowerCase()=="body"){ var w=window; if(_20&&e){ w=e; } if(w.document.documentElement&&w.document.documentElement.scrollTop){ _21=w.document.documentElement.scrollTop; }else{ if(w.document.body&&xDef(w.document.body.scrollTop)){ _21=w.document.body.scrollTop; } } }else{ e=xGetElementById(e); if(e&&xNum(e.scrollTop)){ _21=e.scrollTop; } } return _21; } function xHeight(e,h){ if(!(e=xGetElementById(e))){ return 0; } if(xNum(h)){ if(h<0){ h=0; }else{ h=Math.round(h); } }else{ h=-1; } var css=xDef(e.style); if(e==document||e.tagName.toLowerCase()=="html"||e.tagName.toLowerCase()=="body"){ h=xClientHeight(); }else{ if(css&&xDef(e.offsetHeight)&&xStr(e.style.height)){ if(h>=0){ var pt=0,pb=0,bt=0,bb=0; if(document.compatMode=="CSS1Compat"){ var gcs=xGetComputedStyle; pt=gcs(e,"padding-top",1); if(pt!==null){ pb=gcs(e,"padding-bottom",1); bt=gcs(e,"border-top-width",1); bb=gcs(e,"border-bottom-width",1); }else{ if(xDef(e.offsetHeight,e.style.height)){ e.style.height=h+"px"; pt=e.offsetHeight-h; } } } h-=(pt+pb+bt+bb); if(isNaN(h)||h<0){ return; }else{ e.style.height=h+"px"; } } h=e.offsetHeight; }else{ if(css&&xDef(e.style.pixelHeight)){ if(h>=0){ e.style.pixelHeight=h; } h=e.style.pixelHeight; } } } return h; } function xWidth(e,w){ if(!(e=xGetElementById(e))){ return 0; } if(xNum(w)){ if(w<0){ w=0; }else{ w=Math.round(w); } }else{ w=-1; } var css=xDef(e.style); if(e==document||e.tagName.toLowerCase()=="html"||e.tagName.toLowerCase()=="body"){ w=xClientWidth(); }else{ if(css&&xDef(e.offsetWidth)&&xStr(e.style.width)){ if(w>=0){ var pl=0,pr=0,bl=0,br=0; if(document.compatMode=="CSS1Compat"){ var gcs=xGetComputedStyle; pl=gcs(e,"padding-left",1); if(pl!==null){ pr=gcs(e,"padding-right",1); bl=gcs(e,"border-left-width",1); br=gcs(e,"border-right-width",1); }else{ if(xDef(e.offsetWidth,e.style.width)){ e.style.width=w+"px"; pl=e.offsetWidth-w; } } } w-=(pl+pr+bl+br); if(isNaN(w)||w<0){ return; }else{ e.style.width=w+"px"; } } w=e.offsetWidth; }else{ if(css&&xDef(e.style.pixelWidth)){ if(w>=0){ e.style.pixelWidth=w; } w=e.style.pixelWidth; } } } return w; } function xPageX(e){ var x=0; e=xGetElementById(e); while(e){ if(xDef(e.offsetLeft)){ x+=e.offsetLeft; } e=xDef(e.offsetParent)?e.offsetParent:null; } return x; } function xPageY(e){ var y=0; e=xGetElementById(e); while(e){ if(xDef(e.offsetTop)){ y+=e.offsetTop; } e=xDef(e.offsetParent)?e.offsetParent:null; } return y; } function xAddEventListener(e,eT,eL,cap){ if(!(e=xGetElementById(e))){ return; } eT=eT.toLowerCase(); if(e.addEventListener){ e.addEventListener(eT,eL,cap||false); }else{ if(e.attachEvent){ e.attachEvent("on"+eT,eL); }else{ var o=e["on"+eT]; e["on"+eT]=typeof o=="function"?function(v){ o(v); eL(v); }:eL; } } } function xEvent(evt){ var e=evt||window.event; if(!e){ return; } this.type=e.type; this.target=e.target||e.srcElement; this.relatedTarget=e.relatedTarget; if(xDef(e.pageX)){ this.pageX=e.pageX; this.pageY=e.pageY; }else{ if(xDef(e.clientX)){ this.pageX=e.clientX+xScrollLeft(); this.pageY=e.clientY+xScrollTop(); } } if(xDef(e.offsetX)){ this.offsetX=e.offsetX; this.offsetY=e.offsetY; }else{ if(xDef(e.layerX)){ this.offsetX=e.layerX; this.offsetY=e.layerY; }else{ this.offsetX=this.pageX-xPageX(this.target); this.offsetY=this.pageY-xPageY(this.target); } } this.keyCode=e.keyCode||e.which||0; this.shiftKey=e.shiftKey; this.ctrlKey=e.ctrlKey; this.altKey=e.altKey; if(typeof e.type=="string"){ if(e.type.indexOf("click")!=-1){ this.button=0; }else{ if(e.type.indexOf("mouse")!=-1){ this.button=e.button; } } } } var xMnuMgr=new xMenuManager(); function xMenuManager(){ this.activeMenu=null; this.firstLd=true; this.menus=new Array(); this.q=new Array(); this.qlen=0; this.add=function(xm){ this.activeMenu=xm; this.menus[this.menus.length]=xm; }; this.load=function(){ var i; for(i=0;i<this.menus.length;++i){ this.menus[i].load(); } if(this.firstLd){ this.firstLd=false; xAddEventListener(document,"mousemove",xmDocOnMousemove,false); } }; this.paint=function(){ var i; for(i=0;i<this.menus.length;++i){ this.menus[i].paint(); } }; } function xmDocOnMousemove(_3c){ var m,e,t; e=new xEvent(_3c); t=e.target; while(t&&!xDef(t.xmIdx)){ t=t.offsetParent; } if(t&&xDef(t.xmIdx)){ m=xMnuMgr.menus[t.xmIdx]; if(m!=xMnuMgr.activeMenu){ xMnuMgr.activeMenu.deactivateAll(); } xMnuMgr.activeMenu=m; }else{ if(xMnuMgr.activeMenu){ xMnuMgr.activeMenu.deactivateAll(); } } if(xMnuMgr.activeMenu){ xMnuMgr.activeMenu.onMousemove(e); } } function xMenu4(_3e,_3f,_40,_41,_42,_43,_44,_45,_46,_47,_48,_49,_4a,_4b,_4c,_4d,_4e,_4f){ this.ele=xGetElementById(_3e); this.active=null; this.item=null; this.ori1=_40?1:2; this.ori2=2; this.abs=_3f; this.ofsX=_41; this.ofsY=_42; this.lblClp=_43; this.boxClp=_44; this.clsBar=_45; this.clsBox=_46; this.clsBarLbl=_47; this.clsBarLblHvr=_48; this.clsBarItm=_49; this.clsBarItmHvr=_4a; this.clsBoxLbl=_4b; this.clsBoxLblHvr=_4c; this.clsBoxItm=_4d; this.clsBoxItmHvr=_4e; this.ignoreClassName=_4f; } xMenu4.prototype.traversePre=function(oUL,_51,bLI,_53){ if(!_53){ _53=0; } var _54=oUL.nodeName.toUpperCase()=="UL"; if(bLI||_54){ this[_51](oUL,_53); if(_54){ ++_53; } } var c=oUL.firstChild; while(c){ if(c.nodeName.toUpperCase()=="UL"||c.nodeName.toUpperCase()=="LI"){ this.traversePre(c,_51,bLI,_53); } c=c.nextSibling; } }; var thisIndex; xMenu4.prototype.load=function(){ for(var i=0;i<xMnuMgr.menus.length;++i){ if(this==xMnuMgr.menus[i]){ thisIndex=i; break; } } this.traversePre(this.ele,"loadUL"); this.traversePre(this.ele,"loadLI",true); }; xMenu4.prototype.loadUL=function(ele,_58){ ele.xmLvl=_58; ele.isBox=true; ele.xmIdx=thisIndex; if(_58==0){ ele.xmLbl=null; ele.xmObj=this; }else{ var li=ele.parentNode; ele.xmLbl=li; ele.xmLbl.xmBox=ele; ele.xmLbl.isLbl=true; } }; xMenu4.prototype.loadLI=function(ele,_5b){ ele.xmLvl=_5b; ele.xmIdx=thisIndex; if(ele.nodeName.toUpperCase()=="LI"&&!ele.isLbl){ ele.isItm=true; } }; xMenu4.prototype.paint=function(){ this.applyAllCss(); this.traversePre(this.ele,"paintV"); }; xMenu4.prototype.paintV=function(oUL,_5d){ if(_5d>0){ oUL.style.visibility="hidden"; var li=oUL.xmLbl; var ori=_5d==1?this.ori1:this.ori2; if(this.abs){ if(ori==1){ xMoveTo(oUL,li.offsetLeft,xHeight(li.parentNode)+this.ofsY); }else{ if(ori==2){ xMoveTo(oUL,li.offsetLeft+xWidth(li)+this.ofsX,li.offsetTop); } } }else{ if(ori==1){ xMoveTo(oUL,xPageX(li),xPageY(li)+xHeight(li)+this.ofsY); }else{ if(ori==2){ xMoveTo(oUL,xWidth(li.parentNode)+this.ofsX,li.offsetTop); } } } }else{ oUL.style.visibility="visible"; } }; xMenu4.prototype.activate=function(oUL){ if(oUL){ if(oUL.xmLvl>0){ this.applyLICss(oUL.xmLbl,true); oUL.style.visibility="visible"; } this.active=oUL; } }; xMenu4.prototype.deactivate=function(oUL){ if(oUL){ if(oUL.xmLvl>0){ oUL.style.visibility="hidden"; this.applyLICss(oUL.xmLbl,false); } this.active=oUL.xmLvl==1?null:(oUL.xmLbl?oUL.xmLbl.parentNode:null); } }; xMenu4.prototype.deactivateAll=function(){ this.traversePre(this.ele,"deactivate"); this.active=null; }; xMenu4.prototype.applyAllCss=function(){ this.traversePre(this.ele,"applyAllCssV",true); }; xMenu4.prototype.applyAllCssV=function(ele){ if(ele.isBox){ this.applyULCss(ele); }else{ this.applyLICss(ele); } }; xMenu4.prototype.applyULCss=function(oUL){ if(oUL&&xStr(oUL.className)){ if(oUL.xmLvl==0){ oUL.className=this.clsBar; }else{ oUL.className=this.clsBox; } } }; xMenu4.prototype.applyLICss=function(oLI,_65){ if(oLI&&oLI.xmLvl>0&&xStr(oLI.className)&&(this.ignoreClassName==""||(this.ignoreClassName!=""&&oLI.className!=this.ignoreClassName))){ if(_65){ if(oLI.xmLvl==1){ oLI.className=oLI.isLbl?this.clsBarLblHvr:this.clsBarItmHvr; }else{ oLI.className=oLI.isLbl?this.clsBoxLblHvr:this.clsBoxItmHvr; } }else{ if(oLI.xmLvl==1){ oLI.className=oLI.isLbl?this.clsBarLbl:this.clsBarItm; }else{ oLI.className=oLI.isLbl?this.clsBoxLbl:this.clsBoxItm; } } } }; xMenu4.prototype.onMousemove=function(evt){ var ele=evt.target; while(ele&&!ele.isLbl&&!ele.isBox&&!ele.isItm){ ele=ele.parentNode; } if(!ele){ if(this.active&&!xHasPoint(this.active,evt.pageX,evt.pageY,this.boxClp[0],this.boxClp[1],this.boxClp[2],this.boxClp[3])){ this.deactivateAll(); } }else{ if(ele.isLbl){ if(ele.xmBox!=this.active){ if(this.active&&ele.parentNode!=this.active){ this.deactivate(this.active); }else{ this.activate(ele.xmBox); } } }else{ if(ele.isBox||ele.isItm){ var box=ele; if(ele.isItm){ box=ele.parentNode; } if(this.active&&box!=this.active){ if(!xHasPoint(this.active.xmLbl,evt.pageX,evt.pageY,this.lblClp[0],this.lblClp[1],this.lblClp[2],this.lblClp[3])&&!xHasPoint(this.active,evt.pageX,evt.pageY,0,null,null,null)){ this.deactivate(this.active); } } } } } if(ele&&ele.isItm){ if(ele!=this.item){ if(this.item){ this.applyLICss(this.item,false); } this.applyLICss(ele,true); this.item=ele; } }else{ if(this.item){ this.applyLICss(this.item,false); this.item=null; } } }; var firstDbgMsg=true; function dbgMsg(msg){ if(firstDbgMsg){ firstDbgMsg=false; xGetElementById("dbg").innerHTML="<p>"+msg+"</p>"; }else{ xGetElementById("dbg").innerHTML+="<p>"+msg+"</p>"; } } var page_menus=new Array(); if(document.getElementById){ window.onload=xOnload; } function xOnload(){ var me=null; for(index in page_menus){ me=xGetElementById(page_menus[index].id); if(xDef(me.nodeName,me.firstChild,me.nextSibling)){ var _6b=new xMenu4(me,true,true,0,0,[-3,-10,-6,-10],[-30,null,null,null],"menu","submenu","menu_Itm","menu_ItmHvr","menu_Itm","menu_ItmHvr","submenu_Itm","submenu_ItmHvr","submenu_Itm","submenu_ItmHvr","selected"); xMnuMgr.add(_6b); } } paint_menu(); } function paint_menu(){ xMnuMgr.load(); xMnuMgr.paint(); }


