$(document).ready(function()
{
    var oImg = $('#marcheGraph img:first');
    refreshImage(oImg, 30);
    
    $('#container').append('<div id="infoBulle"></div>');
    overIndice();
    gestionMiniCadre();
    refreshBlocs();
});

function overIndice()
{
    $('.info').mouseenter(function(){
        var html = $(this).children('div').html();
        $('#infoBulle').html(html);
        var top = this.offsetTop;
        var left = this.offsetLeft;
        $('#infoBulle').css('top', top+365);
        $('#infoBulle').css('left', left+20);
        $('#infoBulle').show(300);
        $('#infoBulle').css('z-index', '100');
    }).mouseleave(function(){
        $('#infoBulle').hide();
    });
}


function gestionMiniCadre()
{
    $('#etatsunis').draggable({handle: $('#etatsunis h5:first'), containment: 'parent'});
    $('#europe').draggable({handle: $('#europe h5:first'), containment: 'parent'});
    $('#asie').draggable({handle: $('#asie h5:first'), containment: 'parent'});


    $('.miniCadre h5 a').click(function()
    {
        var corps = $(this).parent('h5').parent('.miniCadre').children('div.corps')

        if (corps.css('display') == 'none')
        {
            corps.slideDown();
            $(this).attr('class', 'moins');
        }
        else
        {
            corps.slideUp();
            $(this).attr('class', 'plus');
        }

        return false;
    });
}

function refreshBlocs()
{
    var page = getPage();
    loadAjax(page+'&blocajax=1', 'indices', 15);
    loadAjax(page+'&blocajax=4', 'palmaresLight', 30);
    loadAjax(page+'&blocajax=6', 'palmaresLightSBF120', 30);
    loadAjax(page+'&blocajax=3', 'flashInfoMarch', 120);
    loadAjax(page+'&blocajax=5', 'infos', 120);
}

