/*
 * jQuery DropMenu plugin v1.0
 * File Date: 1/15/2009
 *
 * Copyright (c) 2009 Jim Salyer
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 */

$.fn.extend({
  dropmenu: function(locals)
  {
    // run this script only in Internet Explorer 6
    var els = $(this);
    if (!$.support.cssFloat && !(document.documentElement && typeof(document.documentElement.style.maxHeight) != "undefined"))
    {
      // create the global properties and extend them with the given properties
      var globals = {
        prefix: "dropmenu"
      };
      $.extend(globals, locals);
      
      // loop through each menu item
      els.each(function()
      {
        els.find("li").hover(function()
        {
          // 1. get the item and highlight it
          // 2. check for a sub menu and show it if present
          // 3. highlight the active item link
          var el = $(this);
          el.addClass(globals.prefix + "_active");
          el.children("ul:first").addClass(globals.prefix + "_shown");
          el.children("a:first").addClass(globals.prefix + "_active");
        }, function()
        {
          // 1. get the item and unhighlight it
          // 2. check for a sub menu and hide it if present
          // 3. unhighlight the previously active item link
          var el = $(this);
          el.removeClass(globals.prefix + "_active");
          el.children("ul:first").removeClass(globals.prefix + "_shown");
          el.children("a:first").removeClass(globals.prefix + "_active");
        });
      });
    }
    return els;
  }
});
