/*------------------------------------------------------------------ Author: Jay Contonio Last change: 2008-12-19 -------------------------------------------------------------------*/ // current_menu holds the current dropdown menu var current_menu; // timer is the timeout variable for the dropdown menu var timer; // The current nav item var currentNavItem; /* Setup dropdowns ------------------------------------------------------------------ */ function setupDropDowns() { dropdown_menus = $('.subnav'); dropdown_menus.each(function() { $(this).mouseover(function() { clearTimeout(timer); }); }); dropdown_menus.each(function() { $(this).mouseout(function() { collapseMenu(this,10); }); }); } /* Dropdown functionality ------------------------------------------------------------------ */ function toggleMenu(navItem,element) { // Clear out any timer clearTimeout(timer); // If there is a menu already visible, hide it if(current_menu) { current_menu.hide(); $(currentNavItem.firstChild).removeClass('highlight'); } // Set the current navigation item currentNavItem = navItem; // Position that sucker var offset = $(navItem).offset(); var xPos = offset.left; $(element).css({ left: xPos + 'px' }); // Set the hover on the navigation item $(currentNavItem.firstChild).addClass('highlight'); // Show the menu $(element).show(); // set this menu as the current_menu current_menu = $(element); // TURNING OFF THE TIMED HIDE AS REQUESTED ON 9/8/09 // var collapse = function() { // collapseMenu(current_menu); // } // timer = setTimeout(collapse, 0); } function collapseMenu(element,length) { if(!length) length = 1000; var collapse = function() { $(element).fadeOut('fast'); $(currentNavItem.firstChild).removeClass('highlight'); } timer = setTimeout(collapse, length); }