
		/**
 * Adds and removes classes to a list of links to allow keyboard accessibility
 *
 * @param string dropDownId
 * @param string hoverClass
 * @param int mouseOffDelay
 */
 (function( $ ){

  $.fn.dropdown = function( options ) {  

    var settings = {
      'hoverClass' : 'hover',
      'mouseOffDelay': 150
    };

    return this.each(function() {        
      // If options exist, lets merge them
      // with our default settings
      if ( options ) { 
        $.extend( settings, options );
      }
		var timeouts = Array();
		var dropdownId = $(this).attr('id');
		var hoverClass = settings.hoverClass;
		var mouseOffDelay = settings.mouseOffDelay;
		var self = this;
		if(dropdown = document.getElementById(dropdownId)) {
			var listItems = dropdown.getElementsByTagName('li');
			for(var i = 0; i < listItems.length; i++) {
				listItems[i].onmouseover = function() { 
					closeAll();
					this.className = addClass(this); 
				}
				listItems[i].onmouseout = function() {
					var that = this;
					timeouts[timeouts.length] = setTimeout(function() { that.className = removeClass(that); }, mouseOffDelay);
					this.className = that.className;
				}
				
				var anchor = listItems[i].getElementsByTagName('a');
				anchor = anchor[0];
				anchor.onfocus = function() { tabOn(this.parentNode); }
				anchor.onblur = function() { tabOff(this.parentNode); }
			}
		}
		function closeAll() {
			for(var i in timeouts) {
				clearTimeout(timeouts[i]);
			}
			$("."+hoverClass).removeClass(hoverClass);
		}
		
		function tabOn(li) {
			if(li.nodeName == 'LI') {
				li.className = addClass(li);
				tabOn(li.parentNode.parentNode);
			}
		}
		
		function tabOff(li) {
			if(li.nodeName == 'LI') {
				li.className = removeClass(li);
				tabOff(li.parentNode.parentNode);
			}
		}
		
		function addClass(li) { return li.className + ' ' + hoverClass; }
		function removeClass(li) { return li.className.replace(hoverClass, ""); }
	});
  };
})( jQuery );
