(function($) { $.fn.menu = function(b) { var c, item, httpAdress; b = jQuery.extend({ Speed: 220, autostart: 1, autohide: 1 }, b); c = $(this); item = c.children("ul").parent("li").children("h4"); httpAdress = window.location; item.addClass("inactive"); function _item() { var h4 = $(this); if (b.autohide) { h4.parent().parent().find(".active").parent("li").children("ul").slideUp(b.Speed / 1.2, function() { $(this).parent("li").children("h4").removeAttr("class"); $(this).parent("li").children("h4").attr("class", "inactive") }) } if (h4.attr("class") == "inactive") { h4.parent("li").children("ul").slideDown(b.Speed, function() { h4.removeAttr("class"); h4.addClass("active") }) } if (h4.attr("class") == "active") { h4.removeAttr("class"); h4.addClass("inactive"); h4.parent("li").children("ul").slideUp(b.Speed) } } item.unbind('click').click(_item); if (b.autostart) { c.children("h4").each(function() { if (this.href == httpAdress) { $(this).parent("li").parent("ul").slideDown(b.Speed, function() { $(this).parent("li").children(".inactive").removeAttr("class"); $(this).parent("li").children("h4").addClass("active") }) } }) } } })(jQuery);