$(document).ready(documentInit);

function documentInit()
{
    var timerTime = 500;
    
    $('#languageBar a').click(function(){
        
        $.post(
            // Url to post to
            'http://www.jibr.lan/index/language/', 
            // Data to post
            {
                'language'  :  $(this).attr('rel')
            }, 
            // Callback
            function(e){
                $('#wrapper').fadeOut(500, function(){
                    $(this).remove();
                    $('body').load(
                        location.href + ' #wrapper', 
                        '',
                        function(){
                            $('#wrapper').hide().fadeIn(500, function(){
                                documentInit();
                            })
                        }
                    );
                });
            },
        "text");

        return false;

    });

    $('.languageLink').hover(function(){
        // Hovered
        $('#languageBar ul').stop().slideDown();
    }, function(){
        // Hover Out
        t = setTimeout(function(){ $('#languageBar ul').stop().slideUp(); }, timerTime); 
    })
    
    $('#languageBar ul').hover(function(){
       clearTimeout(t); 
    }, function(){
        t = setTimeout(function(){ $('#languageBar ul').stop().slideUp(); }, timerTime); 
    });
}

