Menu={
    RowHoverIn:function(row){
        section = row.children('a');
        submenu = row.children('.submenu');
        container = row.closest('ul');
        if(container.hasClass('rootmenu')){
            if(section.offset().left + submenu.outerWidth()<$('#othermenu').offset().left+980){
                submenu.css({
                    'top' :section.offset().top + section.outerHeight() - 1 + 'px',
                    'left':section.offset().left - 1 + 'px'
                });
            }
            else{
                 submenu.css({
                    'top':section.offset().top + section.outerHeight() - 1 + 'px',
                    'left':section.offset().left + section.outerWidth() - submenu.outerWidth() + 1 + 'px'
                });
            }
            if(submenu.outerWidth()<=section.outerWidth()){
                submenu.width(section.outerWidth());
            }
        }else{
            if(section.offset().left + section.outerWidth() + submenu.outerWidth()<$('#othermenu').offset().left+980){
                submenu.css({
                    'top':section.offset().top - section.closest('.submenu').offset().top,
                    'left':section.outerWidth() + 'px'
                });
            }
            else{
                 submenu.css({
                    'top':section.offset().top - section.closest('.submenu').offset().top,
                    'left':-section.outerWidth().left + 'px'
                });
            }
        }
        section.addClass('select_section');
        submenu.addClass('openedMenu');
        row.addClass('select_row');        
    },
    RowHoverOut:function(row){
        section = row.children('a');
        submenu = row.children('.submenu');
        row.removeClass('select_row');
        section.removeClass('select_section');
        submenu.removeClass('openedMenu');
    },
    CloseAllSection:function(){        
        $('#othermenu .select_row').removeClass('select_row');
        $('#othermenu .select_section').removeClass('select_section');
        $('#othermenu .openedMenu').removeClass('openedMenu');
    },
    realMenuWidth:0,
    VisableContent:0,
    ToogleMenuContent:function(){
        if(Menu.VisableContent == 0){
            Menu.VisableContent = 1;
            $('#othermenu>ul').stop().animate({'margin-left':-Menu.realMenuWidth+1, 'width':Menu.realMenuWidth*2},1000);
            $('#other_menu_sweecher').css({'background-position':'top right'});
        }else{
            Menu.VisableContent = 0;
            $('#othermenu>ul').stop().animate({'margin-left':0, 'width':Menu.realMenuWidth},1000);
            $('#other_menu_sweecher').css({'background-position': 'top left'});
        }
    },
    InitializeMenu:function(){
        $('#othermenu a').click(Menu.CloseAllSection);
        $('#othermenu li').hover(
            function(){Menu.RowHoverIn($(this));},
            function(){Menu.RowHoverOut($(this));}
        );
        $('#othermenu>ul>li').each(function(){
            nrmw=$(this).outerWidth() + Menu.realMenuWidth;
            if(nrmw <= 970){
                Menu.realMenuWidth = nrmw;
            }
            else if(nrmw <= 1000 && $(this).next().length == 0){
                Menu.realMenuWidth = nrmw;                
                return false;
            }
            else{
                ms=$('#other_menu_sweecher');
                ms.css({'display': 'block'});
                ms.click(Menu.ToogleMenuContent);
                return false;
            }
        });
        $('#othermenu>ul').width(Menu.realMenuWidth+1);
        $('#othermenu').width(Menu.realMenuWidth+1);
    }
}
