lux.menu = { };

lux.menu.show = function () {
    $("#menu").show();
    $("#menu_button").unbind(".menu_toggle").bind("click.menu_toggle", lux.menu.hide);
    return false;
};

lux.menu.hide = function () {
    $("#menu").hide();
    $("#menu_button").unbind(".menu_toggle").bind("click.menu_toggle", lux.menu.show);
    return false;
};

$(function () {
    $("#menu_button").fadeIn(500);
    lux.menu.hide();

    $("div#menu h3").each(function (i, h3) {
        $(h3).next("ul").hide();
        $(h3).css({ cursor: 'pointer' });
        var state = '+'
        $(h3).next("ul").slideUp(0);
        var indicator = $('<span class="open-close-indicator"></span>');
        indicator.text(state);
        $(h3).prepend(indicator);
        $(h3).click(function () {
            if (state == '+') {
                $(h3).next("ul").slideDown();
                state = "-";
            } else {
                $(h3).next("ul").slideUp();
                state = "+";
            }
            indicator.html(state);
        });
    });

    if (jQuery.url.param("menu")) {
        lux.menu.show();
        $("div#menu h3." + jQuery.url.param("menu")).click();
    } else {
        $("div#menu h3.open").click();
    }
});
