whenDOMReady(function () {
    var check = /noscript\.css$/;
    if (document.styleSheets !== undefined) {
        var sheets = document.styleSheets;
        for (var i = 0, sheet, len = sheets.length; i < len; i++) {
            sheet = sheets[i];
            if (check.test(sheet.href)) {
                sheet.disabled = true;
            }
        }
    } else {
        var links = document.getElementsByTagName('link');
        for (var i = 0, link; link = links[i]; i++) {
            if (link.type = 'text/css' && check.test(link.href)) {
                link.disabled = true;
            }
        }
    }
    var dls = document.getElementById('menu').getElementsByTagName('dl');
    for (var j = 0, dl, menu, dt; dl = dls[j]; j++) {
        dt = dl.getElementsByTagName('dt')[0];
        menu = new Menu(dl, dt, dl.getElementsByTagName('dd'));
        addEvent(dt, 'click', menu.toogleMenu.bind(menu));
    }
});

function Menu (dl, dt, dds) {
    this.dt = dt;
    this.dl = dl;
    this.dds = dds;
}
Menu.prototype = {
    dl     : null,
    dt     : null,
    dds    : null,
    hide   : false,
    cookie : {
        name : 'show_menu',
        path : '/'
    }
}
Menu.prototype.toogleMenu = function () {
    if (this.hide) {
        this._hide();
        this._cookie(1, new Date().getTime());
    }
    else {
        this._show();
        this._cookie(this.dt.firstChild.nodeValue);
    }
    this.hide = !this.hide;
}
Menu.prototype._show = function () { this.dl.className = 'visible'; }
Menu.prototype._hide = function () { this.dl.className = ''; }
Menu.prototype._del_cookie = function () { }
Menu.prototype._cookie = function (value, expire) {
    document.cookie = this.cookie.name + '=' + escape(value) + ';path=' + this.cookie.path + ((expire) ? ';expires=' + expire : '' );
}