var TopMenu = new Class({
    initialize: function(element){
        var ShowMenuTimer, HideMenuTimer;
        new Asset.image('/templates/ionitnew/images/top_menu_background_hovered.png');
        $(element).getChildren().each(function(el){
            if (el.get('tag') == 'li') {
                $(el).getChildren().each(function(el2){
                    if (el2.get('tag') == 'a') {
                        el2.setStyle('text-decoration', 'none');
                    }
                    if (el2.get('tag') == 'ul') {
                        el.addEvents({
                            mouseover: function(){
                                this.HideMenuTimer = $clear(this.HideMenuTimer);
                                var ShowMenu = function(){
                                    el.setStyle('background-image', 'url(/templates/ionitnew/images/top_menu_background_hovered.png)');
                                    el2.setStyle('display', 'block');
                                }
                                this.ShowMenuTimer = ShowMenu.delay(300);
                            },
                            mouseout: function(){
                                this.ShowMenuTimer = $clear(this.ShowMenuTimer);
                                var HideMenu = function(){
                                    el.setStyle('background-image', 'none');
                                    el2.setStyle('display', 'none');
                                }
                                this.HideMenuTimer = HideMenu.delay(100);
                            }
                        });
                    }
                });
            }
        });
        return this;
    }
});

var LeftMenu = new Class({
    initialize: function(element){
        $(element).getChildren().each(function(el){
            if (el.get('tag') == 'li') {
                $(el).getChildren().each(function(el2){
                    if (el2.get('tag') == 'a') {
                        el2.setStyle('text-decoration', 'none');
                        var img = el2.getPrevious();
                        el2.addEvents({
                            mouseover: function(){
                                img.set('src', '/templates/ionitnew/images/left_menu_point_hovered.png');
                                img.set('alt', '>');
                            },
                            mouseout: function(){
                                img.set('src', '/templates/ionitnew/images/left_menu_point.png');
                                img.set('alt', '-');
                            }
                        });
                    }
                });
            }
        });
        return this;
    }
});

var CheckConnectionButton = new Class({
    initialize: function(element){
        new Asset.image('/templates/ionitnew/images/check_connection_possibility_hovered.png');
        $(element).addEvents({
            mouseenter: function(){
                this.set('src', '/templates/ionitnew/images/check_connection_possibility_hovered.png');
            },
            mouseleave: function(){
                this.set('src', '/templates/ionitnew/images/check_connection_possibility.png');
            }
        });
        return this;
    }
});

window.addEvent('domready', function(){
    new TopMenu($('top-menu'));
    new LeftMenu($('left-menu'));
    new CheckConnectionButton($('conn_button'));
});

