$j = jQuery;self.HighlightableBlocks = {    block_class: "list-item",    block_re: /\blist-item\b/,    highlighted_class: "highlighted",    highlighted_re: /\bhighlighted\b/,    init: function() {        var oSelf = self.HighlightableBlocks;        $j(            "div." + oSelf.block_class        ).mouseover(oSelf.activate).mouseout(oSelf.deactivate);    },    destruct: function() {        self.HighlightableBlocks = null;    },    activate: function(event) {        var oSelf = self.HighlightableBlocks;        var oBlock = window.getCausingElement(event);        if (oBlock) {            while (!oBlock.className || !oBlock.className.match(oSelf.block_re)) {                oBlock = oBlock.parentNode;                if (!oBlock) {                    return;                }            }            if (!oBlock.className.match(oSelf.highlighted_re)) {                oBlock.className += " "  + oSelf.highlighted_class            }        }    },    deactivate: function(event) {        var oSelf = self.HighlightableBlocks;        var oBlock = window.getCausingElement(event);        if (oBlock) {            while (!oBlock.className || !oBlock.className.match(oSelf.block_re)) {                oBlock = oBlock.parentNode;                if (!oBlock) {                    return;                }            }            oBlock.className = oBlock.className.replace(oSelf.highlighted_re, "").replace(/\s+/, " ");        }    }}self.CollapsableBlocks = {    button_class: "visibility_toggler",    expanded_class: 'expanded',    collapsed_class: 'collapsed',    expand_all_class: 'expand_all',    collapse_all_class: 'collapse_all',    all_collapsed: false,    init: function() {        var oSelf = self.CollapsableBlocks;        $j("." + oSelf.button_class + " a").click(oSelf.toggle);        $j("." + oSelf.collapse_all_class).click(oSelf.toggle_all);        $j("." + oSelf.expand_all_class).click(oSelf.toggle_all);        $j("." + oSelf.collapsed_class + " .hidable").hide();    },    destruct: function() {        self.CollapsableBlocks = null;    },    toggle: function() {        var oSelf = self.CollapsableBlocks;        var oLink = $j(this);        var oBlock = oLink.parents("." + oSelf.expanded_class + ",." + oSelf.collapsed_class);        oBlock.toggleClass(oSelf.expanded_class).toggleClass(oSelf.collapsed_class);        $j("." + oSelf.collapsed_class + " .hidable").slideUp();        $j("." + oSelf.expanded_class + " .hidable").slideDown();        return false;    },    toggle_all: function() {        var oSelf = self.CollapsableBlocks;        var oLink = $j(this);        oSelf.all_collapsed = !oSelf.all_collapsed;        if (oSelf.all_collapsed) {            oLink.text(gettext("show details"));            oLink.removeClass(oSelf.collapse_all_class).addClass(oSelf.expand_all_class);            $j("." + oSelf.expanded_class).each(function(){                $j(this).removeClass(oSelf.expanded_class).addClass(oSelf.collapsed_class);            });        } else {            oLink.text(gettext("hide details"));            oLink.removeClass(oSelf.expand_all_class).addClass(oSelf.collapse_all_class);            $j("." + oSelf.collapsed_class).each(function(){                $j(this).removeClass(oSelf.collapsed_class).addClass(oSelf.expanded_class);            });        }        $j("." + oSelf.collapsed_class + " .hidable").slideUp();        $j("." + oSelf.expanded_class + " .hidable").slideDown();        return false;    }}self.CollapsableNavigationBlocks = {    button_class: "open_but",    collapsed_re: /\bnav_collapsed\b/,    expanded_re: /\bnav_expanded\b/,    expanded_class: 'nav_expanded',    collapsed_class: 'nav_collapsed',    preinit: function() {        var aCookies = document.cookie.split("; ");        dyn_css_rule(            ".nav_collapsed .hidable",            "display: none;"        );        var i = 0;        var iLen = aCookies.length;        for (i=0; i<iLen; i++) {            var aCookie = aCookies[i].split("=");            var sKey = aCookie[0];            var sValue = aCookie[1];            if (sKey.indexOf("_expanded") == sKey.length - 9) {                if (sValue == "1") {                    dyn_css_rule(                        "#" + sKey.substr(0, sKey.length - 9) + " .hidable",                        "display: block;"                    );                } else {                    dyn_css_rule(                        "#" + sKey.substr(0, sKey.length - 9) + " .hidable",                        "display: none;"                    );                }            }        }    },    init: function() {        var oSelf = self.CollapsableNavigationBlocks;        $j("." + oSelf.button_class).each(function() {            $j(this).click(oSelf.toggle);            var oBlock = $j(this).parents(".categories");            /*            if (oBlock.is("." + oSelf.collapsed_class)) {                oBlock.children(".hidable").hide();            }            */            if (oBlock.attr("id")) {                is_expanded = $j.cookie(oBlock.attr("id") + "_expanded");                if (is_expanded == "1") {                    oBlock.removeClass(                        oSelf.collapsed_class                    ).addClass(                        oSelf.expanded_class                    );                } else if (is_expanded == "0") {                    oBlock.removeClass(                        oSelf.expanded_class                    ).addClass(                        oSelf.collapsed_class                    );                }            }        });    },    destruct: function() {        self.CollapsableNavigationBlocks = null;    },    toggle: function(event) {        var oSelf = self.CollapsableNavigationBlocks;        var $oLink = $j(this);        var oBlock = $oLink.parents(".categories").get(0);        if (oBlock.className.match(oSelf.collapsed_re)) {            oSelf.expand(oBlock);        } else {            oSelf.collapse(oBlock);        }        return false;    },    collapse: function(oBlock) {        var oSelf = self.CollapsableNavigationBlocks;        $oBlock = $j(oBlock);        $oBlock.removeClass(            oSelf.expanded_class        ).addClass(            oSelf.collapsed_class        ).find(".hidable").show().slideUp("normal");        if ($oBlock.attr("id")) {            $j.cookie(                $oBlock.attr("id") + "_expanded",                "0",                {expires: 7, path: "/"}            );        }    },    expand: function(oBlock) {        var oSelf = self.CollapsableNavigationBlocks;        $oBlock = $j(oBlock);        $oBlock.removeClass(            oSelf.collapsed_class        ).addClass(            oSelf.expanded_class        ).find(".hidable").hide().slideDown("normal");        if ($oBlock.attr("id")) {            $j.cookie(                $oBlock.attr("id") + "_expanded",                "1",                {expires: 7, path: "/"}            );        }    }}self.CollapsableNavigationBlocks.preinit();$j(document).ready(function() {    self.HighlightableBlocks.init();    self.CollapsableBlocks.init();    self.CollapsableNavigationBlocks.init();});$j(window).unload(function() {    self.HighlightableBlocks.destruct();    self.CollapsableBlocks.destruct();    self.CollapsableNavigationBlocks.destruct();});