//** all levels navigational menu- (c) dynamic drive dhtml code library: http://www.dynamicdrive.com //** script download/ instructions page: http://www.dynamicdrive.com/dynamicindex1/ddlevelsmenu/ //** usage terms: http://www.dynamicdrive.com/notice.htm //** july 7th, 08'- creation date //** july 16th, 08'- updated to v 1.3: //1) adds "side bar" orientation option. //2) drop down menus now auto adjust their positioning if too close to either right or bottom window edges. //3) enhanced iframe shim "coverage" on the page. //** july 19th, 08'- updated to v 1.31: drop down menu now positions at top of window edge if there's neither room downwards or upwards to settle. //** aug 13th, 08'- v1.32: moved "rel" attribute from menu's
  • elements to inner , for validation reasons //** sept 10th, 08'- updated to v 1.4: //1) added optional "sliding" animation when sub menus are revealed. //2) arrow images now dynamically positioned, instead of relying on css's "right" property //** oct 11th, 08'- updated to v 1.5: //1) sliding animation behavior tweaked //2) added ability to disable iframeshim, customize speed of sliding animation //** dec 23rd, 08'- updated to v 2.0: //1) animation speed refined to be function of time (ie: 1 sec) //2) added two animations that can be individually enabled/disabled- "slide in" and "fade in". //3) script now automatically moves html for all sub menus to the end of the page, to avoid any containership issues if they are nested in other elements. //** jan 12, 09'- updated to v 2.1: //1) added ability to disable the arrow images from the top level items (see option "showarrow") //2) for top level menu items containing a span element (for sliding doors technique), arrow images are inserted inside span. var ddlevelsmenu={ enableshim: true, //enable iframe shim to prevent drop down menus from being hidden below select or flash elements? (tip: disable if not in use, for efficiency) arrowpointers:{ downarrow: ["images/arrow-down.gif", 11,7], //[path_to_down_arrow, arrowwidth, arrowheight] rightarrow: ["images/arrow-right.gif", 12,12], //[path_to_right_arrow, arrowwidth, arrowheight] showarrow: {toplevel: true, sublevel: true} //show arrow images on top level items and sub level items, respectively? }, hideinterval: 200, //delay in milliseconds before entire menu disappears onmouseout. effects: {enableswipe: true, enablefade: true, duration: 500}, httpsiframesrc: "blank.htm", //if menu is run on a secure (https) page, the iframe shim feature used by the script should point to an *blank* page *within* the secure area to prevent an ie security prompt. specify full url to that page on your server (leave as is if not applicable). ///no need to edit beyond here//////////////////// topmenuids: [], //array containing ids of all the primary menus on the page topitems: {}, //object array containing all top menu item links subuls: {}, //object array containing all uls lastactivesubul: {}, //object object containing info for last mouse out menu item's ul topitemsindex: -1, ulindex: -1, hidetimers: {}, //object array timer shimadded: false, nonff: !/firefox[\/\s](\d+\.\d+)/.test(navigator.useragent), //detect non ff browsers getoffset:function(what, offsettype){ return (what.offsetparent)? what[offsettype]+this.getoffset(what.offsetparent, offsettype) : what[offsettype] }, getoffsetof:function(el){ el._offsets={left:this.getoffset(el, "offsetleft"), top:this.getoffset(el, "offsettop")} }, getwindowsize:function(){ this.docwidth=window.innerwidth? window.innerwidth-10 : this.standardbody.clientwidth-10 this.docheight=window.innerheight? window.innerheight-15 : this.standardbody.clientheight-18 }, gettopitemsdimensions:function(){ for (var m=0; m0){ this.shimmy.topshim.style.left=scrollx+"px" this.shimmy.topshim.style.top=scrolly+"px" this.shimmy.topshim.style.width="99%" this.shimmy.topshim.style.height=topgap+"px" //distance from top window edge to top of menu item } if (bottomgap>0){ this.shimmy.bottomshim.style.left=scrollx+"px" this.shimmy.bottomshim.style.top=header._offsets.top + header._dimensions.h +"px" this.shimmy.bottomshim.style.width="99%" this.shimmy.bottomshim.style.height=bottomgap+"px" //distance from bottom of menu item to bottom window edge } } }, hideshim:function(){ this.shimmy.topshim.style.width=this.shimmy.bottomshim.style.width=0 this.shimmy.topshim.style.height=this.shimmy.bottomshim.style.height=0 }, buildmenu:function(mainmenuid, header, submenu, submenupos, istoplevel, dir){ header._master=mainmenuid //indicate which top menu this header is associated with header._pos=submenupos //indicate pos of sub menu this header is associated with header._istoplevel=istoplevel if (istoplevel){ this.addevent(header, function(e){ ddlevelsmenu.hidemenu(ddlevelsmenu.subuls[this._master][parseint(this._pos)]) }, "click") } this.subuls[mainmenuid][submenupos]=submenu header._dimensions={w:header.offsetwidth, h:header.offsetheight, submenuw:submenu.offsetwidth, submenuh:submenu.offsetheight} this.getoffsetof(header) submenu.style.left=0 submenu.style.top=0 submenu.style.visibility="hidden" this.addevent(header, function(e){ //mouseover event if (!ddlevelsmenu.iscontained(this, e)){ var submenu=ddlevelsmenu.subuls[this._master][parseint(this._pos)] if (this._istoplevel){ ddlevelsmenu.css(this, "selected", "add") cleartimeout(ddlevelsmenu.hidetimers[this._master][this._pos]) } ddlevelsmenu.getoffsetof(header) var scrollx=window.pagexoffset? window.pagexoffset : ddlevelsmenu.standardbody.scrollleft var scrolly=window.pageyoffset? window.pageyoffset : ddlevelsmenu.standardbody.scrolltop var submenurightedge=this._offsets.left + this._dimensions.submenuw + (this._istoplevel && dir=="topbar"? 0 : this._dimensions.w) var submenubottomedge=this._offsets.top + this._dimensions.submenuh //sub menu starting left position var menuleft=(this._istoplevel? this._offsets.left + (dir=="sidebar"? this._dimensions.w : 0) : this._dimensions.w) if (submenurightedge-scrollx>ddlevelsmenu.docwidth){ menuleft+= -this._dimensions.submenuw + (this._istoplevel && dir=="topbar" ? this._dimensions.w : -this._dimensions.w) } submenu.style.left=menuleft+"px" //sub menu starting top position var menutop=(this._istoplevel? this._offsets.top + (dir=="sidebar"? 0 : this._dimensions.h) : this.offsettop) if (submenubottomedge-scrolly>ddlevelsmenu.docheight){ //no room downwards? if (this._dimensions.submenuh