$(function(){ // on load
    setTimeout('preload_content()', 1000);
    charger_images_loading();
    ajouter_click_event_accueil();
    ajouter_click_event_nav();
    charger_page_selon_hash();
});

function preload_content()
{
    if (loading < 7)
    {
        if (!$images_gauche[loading-1])
        {
            var img1 = new Image();
            $(img1).load(function(){
                $images_gauche[loading-1] = $(this);
                var img2 = new Image();
                $(img2).load(function(){
                    //$images_droite[loading-1] = $(this);
                    loading++;
                    preload_content();
                }).attr('src', 'img/sets/0' + loading + 'b.jpg');
            }).attr('src', 'img/sets/0' + loading + 'a.jpg');
        }
        /*
        else if (!$images_droite[loading-1])
        {
            var img2 = new Image();
            $(img2).load(function(){
                $images_droite[loading-1] = $(this);
                loading++;
                preload_content();
            });
        }
        */
    }
    else // les 6 sets d'image de l'accueil sont loadé
    {
        // on charge les autres pages et on garde l'accueil en mémoire
        
        // partie qui diffère d'une page à l'autre //
        //
        
        
        $('<div/>').load('menu.php #main', function(data){
            $(this).hide();
            $menu = $(this).contents();
            $('<div/>').load('carte.php #main', function(data){
                $(this).hide();
                $carte = $(this).contents();
                var img = new Image();
                $(img).load(function(){
                    $('<div/>').load('index.php #main', function(data){
                        $(this).hide();
                        $home = $(this).contents();
                        /*
                        $('<div/>').load('menu-du-jour.php #main', function(data){
                            $(this).hide();
                            $menu_du_jour = $(this).contents();
                            // autre chose à faire? le faire ici
                        });
                        */
                    });
                }).attr('src', 'img/carte.png');
            });
        });
        
        //
        // Fin de la parti qui diffère d'une page à l'autre
    }
}


