// addEvent( object, eventType, function ); // The 'object' parameter should be the object upon which you want the event to be called. // The 'eventType' parameter should hold the name of the event, for example: 'click', 'mouseover', 'load', 'submit', etc. More can be found here. // The 'function' parameter should be a reference to a function that you wish to have called whenever the event fires. One parameter will be passed to 'function' - the event object. // examples: // addEvent( document.getElementById('foo'), 'click', doSomething ); // addEvent( obj, 'mouseover', function(){ alert('hello!'); } ); function addEvent(obj, type, fn) { if (obj.attachEvent) { obj['e' + type + fn] = fn; obj[type + fn] = function(){obj['e' + type + fn]( window.event );} obj.attachEvent( 'on' + type, obj[type + fn] ); } else obj.addEventListener(type, fn, false); } // removeEvent( object, eventType, function ); // removeEvent is virtually identical to addEvent, with the obvious difference: // Instead of the function being added to the event handler, it is removed instead. // All of the above code and parameters applies to this function. function removeEvent(obj, type, fn) { if (obj.detachEvent) { obj.detachEvent('on' + type, obj[type + fn]); obj[type + fn] = null; } else obj.removeEventListener(type, fn, false); } // PageNav - JS necessary to hide the current page's secondary nav // when user hovers over a different menu item // so the different sections don't overlap when they drop-down sfHover = function() { var sfEls = document.getElementById("pageNav").getElementsByTagName("LI"); var pUl = document.getElementById("pageNavUL"); for (var i = 0; i < sfEls.length; i++) { sfEls[i].onmouseover = function() { // only add sfhover class for browsers that recognize attachEvent (IE) if (window.attachEvent) { this.className += " sfhover"; } // if this is a first-level li tag if (this.parentNode == pUl) { // hide all drop down menus except // the one triggering the mouseover hideOthers(this); } } sfEls[i].onmouseout = function() { // only needed for browsers that recognize attachEvent (IE) if (window.attachEvent) { this.className = this.className.replace(new RegExp(" sfhover\\b"), ""); } // if this is a first-level li tag if (this.parentNode == pUl) { // re-display drop-down menu for current page showCurrent(); } } } }