/********************************************************************************************************************************************* * (c) Ger Versluis 2000 version 3.0, 25 november 2000 * * You may use this script on non commercial sites if you make a public link to http://home.planet.nl/~bustamil * * For info write to menus@burmees.nl * * Version 2.0 Added further error checking. Some minor bug fixes. * * Version 2.5 Improved Error checking. Added Border between elements 1/0 * * Version 3.0 added support for DOM * This script featured on Dynamic Drive (http://www.dynamicdrive.com), the DHTMLcode library **********************************************************************************************************************************************/ var AgntUsr=navigator.userAgent.toLowerCase(); var DomYes=(document.getElementById)?1:0; // DOM var NavYes=(AgntUsr.indexOf('mozilla')!=-1&&AgntUsr.indexOf('compatible')==-1)?1:0; // Netscape var ExpYes=(AgntUsr.indexOf('msie')!=-1)?1:0; // IExplorer var Opr5=(AgntUsr.indexOf('opera 5')!=-1||AgntUsr.indexOf('opera/5')!=-1)?1:0; // Opera 5 var DomNav=(DomYes&&NavYes)?1:0; // Netscape 6 up var DomExp=(DomYes&&ExpYes)?1:0; // IExplorer 5 up var Nav4=(NavYes&&!DomYes&&document.layers)?1:0; // Netscape 4 var Exp4=(ExpYes&&!DomYes&&document.all)?1:0; // IExplorer 4 var PosStrt=((NavYes||ExpYes)&&!Opr5)?1:0; // Can start var FirstLocation,SecLocation,DocLocation; var SecWindowWidth,FirstWindowWidth,FirstWindowHeight; var SecLoadAgainWin; var FirstColPos,SecColPos,DocColPos; var InitRecursLevel=0,CreateRecursLevel=0,PosRecursLevel=0; var ShowFlag=0,FirstCreate=1,Loaded=0,Created=0,InitFlag,AcrossFrames=1; var FirstContainer=null,CurrentOver=null,CloseTimer=null; var CenterText,TxtClose,ImgStr; var Ztop=100; var M_StartTop=StartTop,M_StartLeft=StartLeft; var LeftExtra=(DomNav)?LeftPaddng:0; var TopExtra=(DomNav)?TopPaddng:0; var M_Hide=(Nav4)?'hide':'hidden'; var M_Show=(Nav4)?'show':'visible'; var Par=(parent.frames[0])?parent:window; var Doc=Par.document; var Bod=Doc.body; //************ Next line bugfix 4 July 2001 ***************// var Trigger=(parent.frames[0]&&FirstLineFrame==SecLineFrame)?(NavYes)?parent.frames[FirstLineFrame]:parent.frames[FirstLineFrame].document.body:(NavYes)?Par:Bod; WebMasterAlerts=["No such frame: ","Item not defined: ","Item needs height: ","Item needs width: ","Warning-Item doesn't need height: ","Warning-Item doesn't need width: ","Item Oke ","Menu tree oke"]; if(DomNav&&!Opr5)Trigger.addEventListener('load',Go,false); else Trigger.onload=Go; Trigger.onresize=(Nav4)?ReDoWhole:RePos; function cancelselect(){return false} function RePos(){ FirstWindowWidth=(ExpYes)?FirstLocation.document.body.clientWidth:FirstLocation.innerWidth; FirstWindowHeight=(ExpYes)?FirstLocation.document.body.clientHeight:FirstLocation.innerHeight; SecWindowWidth=(ExpYes)?SecLocation.document.body.clientWidth:SecLocation.innerWidth; SecWindowHeight=(ExpYes)?SecLocation.document.body.clientHeight:SecLocation.innerHeight; if(MenuCentered)CalcLeft(); if(MenuVerticalCentered)CalcTop(); PositionMenuStruct(FirstContainer,StartTop,StartLeft)} function UnLoaded(){ if(typeof(CloseTimer)!='undefined'&&CloseTimer)clearTimeout(CloseTimer); //typeoff fix by Martin Renschler Loaded=0; Created=0; var FCStyle=(Nav4)?FirstContainer:FirstContainer.style; FCStyle.visibility=M_Hide} function ReDoWhole(){ Doc.location.reload()} function Check(WhichMenu,NoOf){ var i,Hg,Wd,La,Li,Nof,array,ArrayLoc; ArrayLoc=(parent.frames[0])?parent.frames[FirstLineFrame]:self; for(i=0;i":"align='center'":""; if(NavYes)TxtClose=""+(MenuTextCentered)?"":""}} FirstColPos=(Nav4)?FirstLocation.document:FirstLocation.document.body; SecColPos=(Nav4)?SecLocation.document:SecLocation.document.body; DocColPos=(Nav4)?DocLocation.document:SecLocation.document.body; if (TakeOverBgColor)FirstColPos.bgColor=(AcrossFrames)?SecColPos.bgColor:DocColPos.bgColor; if(FirstCreate){FirstContainer=CreateMenuStructure('Menu',NoOffFirstLineMenus);FirstCreate=0} else CreateMenuStructureAgain('Menu',NoOffFirstLineMenus); PositionMenuStruct(FirstContainer,StartTop,StartLeft); InitFlag=1; Initiate(); InitFlag=0; Created=1; SecLoadAgainWin=(ExpYes)?SecLocation.document.body:SecLocation; SecLoadAgainWin.onunload=UnLoaded; status='Menu ready for use'} function CalcLeft(){ var Size=FirstWindowWidth; if(MenuCentered!='left'){ StartLeft=M_StartLeft; Size-=(FirstLineHorizontal)?(NoOffFirstLineMenus*(eval('Menu1[4]')+BorderWidth)+BorderWidth):(eval('Menu1[4]')+BorderWidth); if(MenuCentered=='right')StartLeft+=Size; else StartLeft+=Size/2}} function CalcTop(){ var Size=FirstWindowHeight; if(MenuVerticalCentered!='top'){ StartTop=M_StartTop; Size-=(FirstLineHorizontal)?(eval('Menu1[3]')+BorderWidth):(NoOffFirstLineMenus*(eval('Menu1[3]')+BorderWidth)+BorderWidth); if(MenuVerticalCentered=='bottom')StartTop+=Size; else StartTop+=Size/2}} function PositionMenuStruct(CntnrPntr,Tp,Lt){ var Topi,Lefti,Hori; var Cntnr=CntnrPntr; var Mmbr=Cntnr.FirstMember; var CntnrStyle=(!Nav4)?Cntnr.style:Cntnr; var MmbrStyle=(!Nav4)?Mmbr.style:Mmbr; var PadLeft=(Mmbr.value.indexOf('<')==-1)?LeftExtra:0; var PadTop=(Mmbr.value.indexOf('<')==-1)?TopExtra:0; var MmbrWidth=(!Nav4)?parseInt(MmbrStyle.width)+PadLeft:MmbrStyle.clip.width; var MmbrHeight=(!Nav4)?parseInt(MmbrStyle.height)+PadTop:MmbrStyle.clip.height; var CntnrWidth=(!Nav4)?parseInt(CntnrStyle.width):CntnrStyle.clip.width; var CntnrHeight=(!Nav4)?parseInt(CntnrStyle.height):CntnrStyle.clip.height; var SubTp,SubLt; PosRecursLevel++; if (PosRecursLevel==1 && AcrossFrames)(!MenuFramesVertical)?Tp=FirstWindowHeight-CntnrHeight+((Nav4)?4:0):Lt=FirstWindowWidth-CntnrWidth; if (PosRecursLevel==2 && AcrossFrames)(!MenuFramesVertical)?Tp=0:Lt=0; if (PosRecursLevel==2 && AcrossFrames){Tp+=VerCorrect;Lt+=HorCorrect} CntnrStyle.top=Cntnr.OrgTop=Tp; CntnrStyle.left=Cntnr.OrgLeft=Lt; if (PosRecursLevel==1 && FirstLineHorizontal){Hori=1; Lefti=CntnrWidth-MmbrWidth-2*BorderWidth;Topi=0} else{Hori=Lefti=0; Topi=CntnrHeight-MmbrHeight-2*BorderWidth} while(Mmbr!=null){ PadLeft=(Mmbr.value.indexOf('<')==-1)?LeftExtra:0; PadTop=(Mmbr.value.indexOf('<')==-1)?TopExtra:0; MmbrStyle=(!Nav4)?Mmbr.style:Mmbr; MmbrWidth=(!Nav4)?parseInt(MmbrStyle.width)+PadLeft:MmbrStyle.clip.width; MmbrHeight=(!Nav4)?parseInt(MmbrStyle.height)+PadTop:MmbrStyle.clip.height; MmbrStyle=(!Nav4)?Mmbr.style:Mmbr; MmbrStyle.left=Lefti+BorderWidth; MmbrStyle.top=Topi+BorderWidth; if(Nav4)Mmbr.CmdLyr.moveTo(Lefti+BorderWidth,Topi+BorderWidth); if(Mmbr.ChildCntnr){ if(Hori){ SubTp=Tp+Topi+MmbrHeight+BorderWidth; SubLt=Lt+Lefti} else{ SubLt=Lt+Lefti+(1-ChildOverlap)*MmbrWidth+BorderWidth; SubTp=Tp+Topi+ChildVerticalOverlap*MmbrHeight} PositionMenuStruct(Mmbr.ChildCntnr,SubTp,SubLt)} (Hori)?Lefti-=(BorderBtwnElmnts)?(MmbrWidth+BorderWidth):(MmbrWidth):Topi-=(BorderBtwnElmnts)?(MmbrHeight+BorderWidth):(MmbrHeight); Mmbr=Mmbr.PrevMember} PosRecursLevel--} function Initiate(){ if(InitFlag) Init(FirstContainer)} function Init(CntnrPntr){ var MemberContainer=CntnrPntr; var Member=MemberContainer.FirstMember; var MCStyle=(Nav4)?MemberContainer:MemberContainer.style; InitRecursLevel++; MCStyle.visibility=(InitRecursLevel==1)?M_Show:M_Hide; while(Member!=null){ if(Member.ChildCntnr) Init(Member.ChildCntnr); Member=Member.PrevMember} InitRecursLevel--} function ClearAllChilds(Pntr,ChldPntr){ var CPCCStyle; while (Pntr){ if(Pntr.ChildCntnr){ CPCCStyle=(Nav4)?Pntr.ChildCntnr:Pntr.ChildCntnr.style; if(Pntr.ChildCntnr!=ChldPntr)CPCCStyle.visibility=M_Hide; ClearAllChilds(Pntr.ChildCntnr.FirstMember,ChldPntr)} Pntr=Pntr.PrevMember}} function GoTo(){ if(this.LinkTxt){ status=''; if(Nav4){ if(this.LowLyr.value.indexOf('SecWindowWidth+LeftScrolled){ if(this.Level==1)SubLt=SecWindowWidth+LeftScrolled-ChildContWidth; else SubLt-=10} while(SubTp+ChildContHeight>TopScrolled+SecWindowHeight){ if(this.Level==1)SubTp=TopScrolled+SecWindowHeight-ChildContHeight; else SubTp-=10} ChCntTL.top=SubTp; ChCntTL.left=SubLt; ChCntTL.visibility=M_Show; ShowFlag=1} status=this.LinkTxt} function CloseMenu(){ if(!Loaded||!Created) return; if(Nav4){if(this.LowLyr.value.indexOf('"; this.innerHTML=MemVal}} if(ExpYes){this.onmouseover=OpenMenu; this.onmouseout=CloseMenu; this.onclick=GoTo} else{this.addEventListener('mouseover',OpenMenu,false); this.addEventListener('mouseout',CloseMenu,false); this.addEventListener('click',GoTo,false)}} function NavMemberSetUp(MmbrCntnr,PrMmbr,WhatMenu,Wdth,Hght){ this.value=eval(WhatMenu+'[0]'); if(LeftPaddng&&this.value.indexOf('<')==-1&&!MenuTextCentered)this.value=' \;'+this.value; if(FontBold)this.value=this.value.bold(); if(FontItalic)this.value=this.value.italics(); this.Overvalue=this.value; this.value=this.value.fontcolor(FontLowColor); this.Overvalue=this.Overvalue.fontcolor(FontHighColor); this.value=CenterText+""+this.value+TxtClose; this.Overvalue=CenterText+""+this.Overvalue+TxtClose; this.LowBack=LowBgColor; this.HighBack=HighBgColor; this.visibility='inherit'; this.ChildCntnr=null; this.PrevMember=PrMmbr; this.bgColor=LowBgColor; this.resizeTo(Wdth,Hght); this.document.write(this.value); this.document.close(); this.CmdLyr=new Layer(Wdth,MmbrCntnr); this.CmdLyr.visibility='inherit'; this.CmdLyr.Level=CreateRecursLevel; this.CmdLyr.LinkTxt=eval(WhatMenu+'[1]'); this.CmdLyr.onmouseover=OpenMenu; this.CmdLyr.onmouseout=CloseMenu; this.CmdLyr.captureEvents(Event.MOUSEUP); this.CmdLyr.onmouseup=GoTo; this.CmdLyr.LowLyr=this; this.CmdLyr.Container=MmbrCntnr; this.CmdLyr.resizeTo(Wdth,Hght); if(this.value.indexOf('":""; this.CmdLyr.ImgLyr.document.write(ImgStr); this.CmdLyr.ImgLyr.document.close()}} function CreateMenuStructure(MenuName,NumberOf){ CreateRecursLevel++; var i,NoOffSubs,Member; var PreviousMember=null; var WhichMenu=MenuName+'1'; var MenuWidth=eval(WhichMenu+'[4]'); var MenuHeight=eval(WhichMenu+'[3]'); var Location=(CreateRecursLevel==1)?FirstLocation:SecLocation; if(DomYes){ var MemberContainer=Location.document.createElement("div"); MemberContainer.style.position='absolute'; MemberContainer.style.visibility='hidden'; Location.document.body.appendChild(MemberContainer)} else if(Nav4) var MemberContainer=new Layer(MenuWidth,Location) else{ WhichMenu+='c'; Location.document.body.insertAdjacentHTML("AfterBegin","