$(document).ready(function(){ 
    $('#navigation ul a.root').mouseenter(function(){
        var id   = $(this).attr('id');
        var left = $(this).position().left - 65;
        var top  = $(this).position().top + $(this).height() + 5;    
        $('#' + id + '_sub').css('top',  top + 'px');
        $('#' + id + '_sub').css('left', left + 'px');  
        $('#' + id + '_sub').show();
        return true;
    })
    
    $('#navigation ul a.root').mouseleave(function(){
        var id = $(this).attr('id');
        $('#' + id + '_sub').hide();
    })
    
    $('#navigation ul ul.opened').mouseenter(function(){
        var id     = $(this).attr('id');
        var parent = id.substr(0, id.length - 4);

        $(this).show();
    })
    $('#navigation ul ul.opened').mouseleave(function(){
        var id     = $(this).attr('id');
        var parent = id.substr(0, id.length - 4);
        $(this).hide();
    })
    
    init();   
    
    $('a').focus(function(){
        $(this).blur();
    });
    
    function init(){
        $('#navigation_sub a.selected').css('border-color', '#E04B00');
        $('#navigation_sub a.selected').parent().prev('li').find('a').css('border-bottom-color', '#E04B00'); 
    }
})

function games(obj, liga){
    $('#shortgames a').removeClass('active');
    $('#shortgames_list').load('/verein/spiele/' + liga, null, function(){ $(obj).addClass('active'); });
    
    
}
