/** * YOUDS MEDIA © 2008 * Drop Down Navigation **/ //set some vars var sImageDir='images/buttons/nav/blue/'; var bLinkClicked=false; var bMenuOpened=false; // IE fix var TridentFix = new Class({ tridentFix: function(item){ item.addEvents({ 'mouseover':function(){ this.addClass('iehover'); }, 'mouseout':function(){ this.removeClass('iehover'); } }); } }); /* YOUDS MEDIA © 2008 - http://www.youds.com First level management - updated from previous script All this does is turn the buttons a different colour and clears timers when a mouseover is met, to immediately close any open sub menus */ //do button highlighting (seperate to opening) function navMouseOver (oLink,bClear) { if (!oLink || bLinkClicked) return false; if (!bClear) clearSubTimers('new',0); //clears all menu's var sLoc = 'url('+sImageDir+'under.gif) no-repeat left bottom' oLink.style.background = sLoc; oLink.innerHTML=oLink.innerHTML+'' $(oLink).addClass('ht'); } function navMouseOut (oLink) { if (!oLink || bLinkClicked) return false; var sLoc = 'url('+sImageDir+'nav.gif) repeat-x bottom' $(oLink).removeClass('ht'); oLink.style.background = sLoc; sLinkText=oLink.innerHTML; iLinkTextMarker=sLinkText.indexOf('<'); if (iLinkTextMarker > 0) oLink.innerHTML=sLinkText.substr(0,iLinkTextMarker); } //function to find from anywhere below function navFindOpener (oMenu) { if (oMenu.parentNode.id == 'mainNav') oMenuParent = oMenu; else if (oMenu.parentNode.parentNode.id == 'mainNav') oMenuParent = oMenu.parentNode; else if (oMenu.parentNode.parentNode.parentNode.parentNode.id == 'mainNav') oMenuParent = oMenu.parentNode.parentNode.parentNode; else if (oMenu.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id == 'mainNav') oMenuParent = oMenu.parentNode.parentNode.parentNode.parentNode.parentNode; return oMenuParent.firstChild; } function navDeHighlightOthers (oMainMenuLink,bLeaveHighlighted,bDeHighlightAll) { oMainMenuLinks = $$('div#links ul#mainNav li a.ht'); if (bDeHighlightAll) clearSubTimers('new',0); for (a=0,b=oMainMenuLinks.length;a= 1) this.menu.addClass('sub_submenu'); // class for deeper levels - in case :P // set menu to hidden doSubHide(this.menu) /* hook up menu's parent with event to trigger menu */ this.menu.pel.addEvents(this.parentEvents); // get menu's child elements var children = this.menu.getChildren(); // loop through children children.each(function(item,index){ // declare some variables var fChild, list; /* fChild = first child - which should be an A tag list = submenu UL */ fChild = item.getFirst(); list = fChild.getNext('ul'); // check if IE, if so apply fix if(Browser.Engine.trident) this.tridentFix(item); // if the menu item has a sub_submenu if(list){ /* create marker for menu item that has a sub_submenu this is to show persistence and where you are in the menu tree */ var count = new Element('span').set('html','\»').addClass('counter'); item.adopt(count); // stuff it inside li //count.fade('hide'); // hide it item.mel = list; // mel = menu element item.count = count; // attach count accessor to menu item list.pel = item; // pel = parent element // create new subMenu with depth incremented new SubMenu(list,this.depth+1); } },this); //bound to this for trident fix }, // menu parent mouse events parentEvents: { 'mouseover': function(){ /* if it has a count accesor then fade it in */ if (this.count) iAction=1; else iAction=0; if (this.count) {//sub menu opener if (oTimeoutRef[1] && oTimeoutRef[1]['menu']) { oSubSubMenu=oTimeoutRef[1]['menu']; clearSubTimers(oSubSubMenu,1,false); oSubShow(oSubSubMenu,1); } } clearSubTimers(this.mel,iAction); oSubShow(this.mel); }, 'mouseout': function(){ /* if it has a count accesor then fade it out */ if (this.count) iAction=1; else iAction=0; setSubTimers(this.mel,oSubHide(this.mel),iAction); if (!this.count) { //close last opened sub_submenu if (oTimeoutRef[1] && oTimeoutRef[1]['menu']) { oSubSubMenu=oTimeoutRef[1]['menu']; clearSubTimers(oSubSubMenu,1,false); setSubTimers(oSubSubMenu,oSubSubHide(oSubSubMenu),1); } } } } }); // timer management for submenu and sub_submenu var oTimeoutRef = [{},{},{},{}]; function clearSubTimers (menu,iAction){ if (oTimeoutRef[iAction] && (menu == oTimeoutRef[iAction]['menu'])){ clearTimeout(oTimeoutRef[iAction]['timer']); } else { if (oTimeoutRef[iAction] && oTimeoutRef[iAction]['menu']) oTimeoutRef[iAction]['menu'].setStyle('display','none'); if (oTimeoutRef[iAction]) clearTimeout(oTimeoutRef[iAction]['timer']); } } function setSubTimers (menu,timer,iAction){ oTimeoutRef[iAction]['timer']=timer; oTimeoutRef[iAction]['menu']=menu; }