﻿jQuery( function( $ ){
    var menuOver = [false, false, false, false, false];
    $('#main_nav a img').each(function(index){
        var $img = $(this);
        var menu_id = '#menu_' + $img.attr('id');
        $img.hover(function(){
            $img.css('border-bottom-color', '#A3B5BC');
            $(menu_id).fadeIn('fast');
            menuOver[index] = true;
        },function(){
            menuOver[index] = false;
            setTimeout(function(){
                if( ! menuOver[index]){
                    $img.css('border-bottom-color', '#FFFFFF');
                    $(menu_id).fadeOut('fase');
                }
            }, 25);
        });

        $(menu_id).hover(function(){
            swap_over($img);
            $img.css('border-bottom-color', '#A3B5BC');
            $(menu_id).fadeIn('fast');
            menuOver[index] = true;
        },function(){
            menuOver[index] = false;
            setTimeout(function(){
                if( ! menuOver[index]){     
                    swap_up($img);
                    $img.css('border-bottom-color', '#FFFFFF');
                    $(menu_id).fadeOut('fast');
                }
            }, 25);      
        }); 
     }); 
     
    $('.newsList li').hover(function(){
        $(this).css('listStyleImage', 'url(/portals/shared/images/arrowBulletOver.gif)');
    },
    function(){
        $(this).css('listStyleImage', 'url(/portals/shared/images/arrowBullet.gif)');
    });

    $('li.btnNews').hover(function(){
        var $this = $(this);
        if( ! $this.hasClass('active')){
            $this.addClass('hover');
        }
    },
    function(){
        $(this).removeClass('hover');
    }).click(function(){
        var $this = $(this);
        $('li.btnNews.active').not($this).removeClass('active activeCursor');
        $this.addClass('active activeCursor');
        var leftValue = '0px';
        switch($this.attr('id')){
            case 'btnNews' :
                leftValue = '-275px';
                break;
            case 'btnDYK' :
                leftValue = '-550px';
                break;
        }
        
        $('#newsListContainer').animate({left:leftValue}, 500);
    });   
});    


