var DropdownMenu = new Class({

    initialize: function(element)
    {
        $A($(element).childNodes).each(function(el) {
            if(el.nodeName.toLowerCase() == 'li') {
                $A($(el).childNodes).each(function(el2) {

                    if(el2.nodeName.toLowerCase() == 'ul') {
                        $(el2).hide = function () {
                            return this.setStyle('display', 'none');
                        };

                        $(el2).show = function () {
                            return this.setStyle('display', 'block');
                        };

                        el.addEvent('mouseenter', function() {
                            el2.show();

                            var parentNode = el2;

                            while (parentNode.get('tag') != 'div') {
                                if (parentNode.get('tag') == 'li') {
                                    parentNode.addClass('valhallaNavbarItemFocused');
                                }

                                parentNode = parentNode.getParent();
                            };

                            if (window.navigator.platform.indexOf('Win') == -1) {
                                $$('.flash').each(function (flash) {
                                    flash.setStyle('visibility', 'hidden');
                                });
                            }

                            return false;
                        });

                        el.addEvent('mouseleave', function() {
                            el2.hide();

                            var parentNode = el2;

                            while (parentNode.get('tag') != 'div') {
                                if (parentNode.get('tag') == 'li') {
                                    parentNode.removeClass('valhallaNavbarItemFocused');
                                }

                                parentNode = parentNode.getParent();
                            };

                            if (window.navigator.platform.indexOf('Win') == -1) {
                                $$('.flash').each(function (flash) {
                                    flash.setStyle('visibility', 'visible');
                                });
                            }
                        });

                        new DropdownMenu(el2);
                    }
                });
            }
        });
        return this;
    }
});