

$(document).ready(function(){
    $('.topMenuLink').each(function(){
       $(this).mouseover(function(){
            var MenuId = $(this).attr('rel');
            var Color = MenuColor[MenuId]; 
            if(MenuId != SelectedMenu){
                $(this).attr('style', 'background-color:'+Color+';color: white;');
            }
            manageMenu(MenuId);
            return false;
       });
       $(this).mouseout(function(){
            if($(this).attr('rel') != SelectedMenu){
                $(this).attr('style', 'color:brown;');
            }
       });
    });
    
    $('.topSubMenu').each(function(){
        $(this).bind("mouseleave",function(){
            $(this).hide();
            IdCat = $(this).attr('rel');
            if(SelectedMenu != IdCat){
                var Color = MenuColor[IdCat]; 
                $('#topMenuLink_' + IdCat).attr('style', 'color: brown;');
            }                    
        });  
    });

     $('.topSubMenu').each(function(){
        $(this).bind("mouseenter",function(){
           IdCat = $(this).attr('rel');
           if(SelectedMenu != IdCat){
                var Color = MenuColor[IdCat]; 
                $('#topMenuLink_' + IdCat).attr('style', 'background-color:'+Color+';color: white;');
           }        
        });  
    });   
    
    $('.categoryBtn').each(function(){ 
        $(this).click(function(){
            openSubcategory($(this)); 
        });  
    });
    
    $('#popupOk').click(function(){
        $('#popup').hide('slow');
        $('#opacity').hide();
    });
    
});

function manageMenu(MenuId){
    if(MenuId != 0){
        $('#topSubMenu_'+MenuId).show();   
    }
    $('.topMenuLink').each(function(){
        if($(this).attr('rel') != MenuId){
            $('#topSubMenu_'+$(this).attr('rel')).hide();
        }
    });
}

function openSubcategory(Object){
        var Selected = Object.attr('rel');
        $('#articleList_' + Selected).toggle('slow');
    $('.categoryBtn').each(function(){
        var IdCategory = $(this).attr('rel');
    });
}

function showPopup(Message){
    $('#popupMessage').html(Message);
    $('#popup').show();
    $('#opacity').show();
    setTimeout("$('#popup').hide('slow');$('#opacity').hide();", 10000);
    
}

