var _id = 'nav';

var _slideEl = 'ul';

var _duration = 300;

var _hide = true;



$(document).ready(function() {

    $('#' + _id + ' a.open').click(function() {

        if (_hide) hideLevels(this);

        $(this).parent().find(_slideEl).toggle(_duration);

        $(this).parent().toggleClass('active');

        return false;

    });

});



function hideLevels(_this) {

    $('#' + _id + ' li').each(function() {

        var _f = false;

        var _a = $('a', this).each(function(i, _el) {

            if (_el == _this) _f = true;

        });

        if (!_f) {

            $(_slideEl, this).hide(_duration);

            $(this).removeClass('active');

        }

    });

}

function initPage() {

    var divs = document.getElementsByTagName("div");

    for (var i = 0; i < divs.length; i++) {

        if (divs[i].className == "frame") {

            var images = divs[i].getElementsByTagName("img");

            if (images) {

                divs[i].style.width = images[0].offsetWidth + 5 + "px";

                divs[i].parentNode.style.width = images[0].offsetWidth + 13 + "px";

            }

        }

    }

}

if (window.addEventListener) window.addEventListener("load", initPage, false);

else if (window.attachEvent) window.attachEvent("onload", initPage);