/*
 * Superfish - jQuery menu widget
 *
 * Copyright (c) 2007 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 * Last updated: 15/3/07
 */

// enhanced suckerfish-style menu plugin by Joel Birch, edited by Mathias Bank

(function($){
$.fn.superfish = function(o){
        var defaults = {
                hoverClass : "sfhover",
                delay : 250,
                animation : {"opacity":"show"},
                downAnimation: {"opacity":"hide"},
                speed : "normal",
                downSpeed : "fast"
        };
        var over = function(){
                var $$ = $(this);
                clearTimeout(this.sfTimer);
                if (!$$.is("."+o.hoverClass)) {
                        $$.addClass(o.hoverClass)
                                .children("ul").animate(o.animation,o.speed)
                                        .end()
                                .siblings().removeClass(o.hoverClass);
                }
        };
        var out = function(){
                var $$ = $(this);
                this.sfTimer=setTimeout(function(){$$.removeClass(o.hoverClass)
                                                                        .children("ul")
                                                                        .animate(o.downAnimation,o.downSpeed)
                                                                        .end();
                                                                        },
                                                                o.delay);
        };
        o = $.extend(defaults, o || {});
        $("li[ul]",this)
                .hover(over,out)
                .find("a")
                        .focus(function(){ $(this).parents("li[ul]").each(over); })
                        .blur(function(){ $(this).parents("li[ul]").each(out); });
        return this;
};

})(jQuery); 