
/*************************************************
Quizz Tournament - Requête Ajax: Jquery - Fonction vérification -
 **************************************************/

var site= "prod/";   
var b=0;
var pass= 0;
var timers;
var num_question;
var num_tournoi_var;
var nb_inscrit_rdv = 0;
var etat_test = 0;
var encours=0;  
var pop_las;
var etatBlocNotification = '';  
var son;
var son2;
soundManager.url = site+"libs/swf/";
soundManager.debugMode = true;
soundManager.flashVersion = 9;
soundManager.useFlashBlock = false;
    



function chargeNext(num) //Recharge le tournois suivant pour colone de droite bloc "prochain tournois"
{	
    $.ajax({
        type: "GET",
        url: site+"global/next_tournament/next_tournoi.php",
        success: function(data){
            document.getElementById("nextTournoi").innerHTML = data;
        }
    });	
}

function decrement_joker(joker_nb) //Retire un joker lorsque l'on clique sur le bouton (au niveau de l'affichage)
{
    document.getElementById('question1').className = "off";
    document.getElementById('question3').className = "off";
    document.getElementById('question2').className = "off";
    document.getElementById('question4').className = "off";

    document.getElementById("SaveAccount").innerHTML ='<a href="javascript:" onclick="javascript:return false;" class="off">Valider</a>';
    document.getElementById("question1").href = "#";
    document.getElementById("question2").href = "#";
    document.getElementById("question3").href  = "#";
    document.getElementById("question4").href  = "#";

    document.getElementById("NbJoker").innerHTML = "x"+joker_nb;
}

function question_erreur(b){
    $.ajax({
        type: "GET",
        url: site+"modules/jeu_quizz/question_erreur.php",
        data: "numquestion="+b,
        success: function(data){
        //alert(data);
        }
    });
}


function Info(num) //Récuperer et savoir quel question a été selectionné s'appel sur le bouton de la question
{	

    document.getElementById("SaveAccount").innerHTML = "<a href='javascript:valid()'>Valider</a>";

    num_question = num;
    question ='c'+num;




    document.getElementById('question1').className = "";
    document.getElementById('question2').className = "";
    document.getElementById('question3').className = "";
    document.getElementById('question4').className = "";

    document.getElementById('question'+num).className = "Active";

}


function focusBarre() 
{
    //fait clinotter les tournois
    resteB = $('#NexTnInsc').countdown('getTimes');	
    
    if(resteB == "0,0,0,0,0,0,10" || resteB == "0,0,0,0,0,1,0")
    {

        var premier_son;
        premier_son = soundManager.createSound(
        {
            id : "premier_son",
            url : site+"audio/beep.mp3" // Attention pas de virgule ici !
        });
        premier_son.play();
        
           
        var idNextTournoi = $('div.part_3 input').val();
        pop_las = window.open("TestCar.php?module=jeu_quizz&action=quizz&hourDeb="+idNextTournoi,"popup_jeu"+idNextTournoi,"menubar=no, status=no, scrollbars=no, menubar=no, width=905, height=640");
        if(pop_las.window.focus){
            pop_las.window.focus();
        }
        $('div.part_3').css({
            "background-color": "#9CD020"
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#333"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#9CD020"
            });
            $(this).dequeue();
        })	
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#333"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#9CD020"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#333"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#9CD020"
            });
            $(this).dequeue();
        })			
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#333"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#9CD020"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#333"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#9CD020"
            });
            $(this).dequeue();
        })		
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#333"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#9CD020"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#333"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#9CD020"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#333"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#9CD020"
            });
            $(this).dequeue();
        })		
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#9CD020"
            });
            $(this).dequeue();
        })		
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#333"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#9CD020"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#333"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#9CD020"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#333"
            });
            $(this).dequeue();
        })
        .delay(200).queue(function () {
            $(this).css({
                "background-color": "#9CD020"
            });
            $(this).dequeue();
        })	
        
    }
    
    
}
function info_bas_popup() //Envoie toutes les 5sec le timestamp du server
{
    $.ajax({
        url: site+"MS_popup.php",
        dataType: "text",
        cache: false,
        success: function(data){
            document.getElementById('info_bas').className =   data;
        }
    });
} 


function info_bas() //Envoei toutes les 5sec le timestamp du server
{
    $.ajax({
        url: site+"MS.php",
        dataType: "text",
        cache: false,
        success: function(data){
            chain = data;
            chain = chain.split("-");
            document.getElementById('info_bas').className =   chain[0];

            if(chain[1] != "")
            {
                $('#contenu_barre').html(chain[1]);
                if($('#contenu_barre div').hasClass('new_notif') !=false)
                {
                    var premier_son;
                    premier_son = soundManager.createSound(
                    {
                        id : "premier_son",
                        url : site+"audio/beep.mp3" // Attention pas de virgule ici !
                    });
                    premier_son.play();
    
                    
                    $('#contenu_barre div.new_notif').css({
                        "background-color": "#9CD020"
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#333"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#9CD020"
                        });
                        $(this).dequeue();
                    })	
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#333"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#9CD020"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#333"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#9CD020"
                        });
                        $(this).dequeue();
                    })			
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#333"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#9CD020"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#333"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#9CD020"
                        });
                        $(this).dequeue();
                    })		
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#333"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#9CD020"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#333"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#9CD020"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#333"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#9CD020"
                        });
                        $(this).dequeue();
                    })		
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#9CD020"
                        });
                        $(this).dequeue();
                    })		
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#333"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#9CD020"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#333"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#9CD020"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#333"
                        });
                        $(this).dequeue();
                    })
                    .delay(200).queue(function () {
                        $(this).css({
                            "background-color": "#9CD020"
                        });
                        $(this).dequeue();
                    })	 			

                }
            }
            else
            {
                $('div.barre_notification').addClass('hide'); 
            }

        }
    });
}    


function listing_player() //pendant le deroulement du jeu liste col droite les joueurs refresh a chaque nouvelle question
{
    $.ajax({
        url: site+"modules/jeu_quizz/listing_player.php?id_tournoi="+num_tournoi_var,	
        cache: false,
        success: function(data){
            document.getElementById('Col2Jeu').innerHTML = data;
        }
    });
}

function refresh_next_tournament() //refresh les tournois
{
    $.ajax({
        url: site+"libs/ajax/next_tournament/next_tournoi_init.php",	
        dataType: "script",
        success: function(data){

        }
    });
}
function refresh_tournament_table()
{
    $.ajax({
        url: site+"libs/ajax/next_tournament_table/s",	
        dataType: "script",
        success: function(data){
        }
    });
}


function refresh_tournament() //refresh les tournois
{
    $.ajax({
        url: site+"modules/tournois/tournoi_init.php",	
        cache: false,
        success: function(data){
            document.getElementById('tournament_r').innerHTML = data;
        }
    });
}

//a chaque question refresh les jokers (durant la phase de jeu)
function joker_refresh()
{
    $.ajax({
        url: site+"modules/jeu_quizz/joker.php?id_tournoi="+num_tournoi_var,	
        cache: false,
        success: function(data){
            document.getElementById('joker').innerHTML = data;
        }
    });
}

//initialise les variables necessaires stockés chez le client pour pouvoir lancer le tournoi
function init_tournoi(idcat,typetournoi) 
{
    $.ajax({
        type: "GET",
        url: site+"modules/jeu_quizz/init_tournoi.php",
        data: "numtournoi="+idcat+"&type_tournoi="+typetournoi,
        cache: false,
        success: function(data){
            document.getElementById("shortly").innerHTML = data;
            //Créer l'affichage du jeu
            launch_game();
        }
    });
}

//lorsque le timstamp est = a l'heure du lencement est à 0 lancé le tournoi
function launch_game()
{
    $.ajax({
        url: site+"modules/jeu_quizz/launch_game.php",	
        cache: false,
        success: function(data){
            document.getElementById('Container').innerHTML = data;
            //Lance le jeu
            start();
        }
    });
}

//Lancement du tournoi apres le temps d'attente des 15sec
function start() 
{
    document.getElementById('Interface_container').style.visibility = "visible";
    document.getElementById('loader').style.visibility = "hidden";

    goLoad();
    var now =  document.getElementById('info_bas').className;
    now = parseInt(now);

    var shortly = new Date(now * 1000);  
    shortly.setSeconds(shortly.getSeconds() + 12.5);

    setTimeout('Count()',1000);
    $('#shortly').countdown({
        until: shortly, 
        onExpiry: liftOff, 
        onTick: watchCountdown
    }); 
}


//LOADER JEU	
function posLoader()
{
    var Position = document.getElementById('loader').className;
    document.getElementById('loader').style.backgroundPosition=Position+"px 0px";
}
function Mouv(){
    var Posi = document.getElementById('loader').className;
    if(Posi>-2387) Posi -= 217; else  Posi = 0;
    parseInt(Posi);
    document.getElementById('loader').className=Posi;
}

function goLoad(){
    setInterval("Mouv()",50);
    setInterval("posLoader()",50);

}


function SaveInfo(s,jok) //enregistre les infos et fait les actions necessaire pour savoir si la reponse est bonne ou fausse
{
    
    
    $.ajax({
        type: "GET",
        url: site+"modules/jeu_quizz/addQuest.php",
        data: "questi="+question+"&times="+time+"&id="+s+"&jokers="+jok+"&id_tournoi="+num_tournoi_var,
        success: function(data)
        {
            document.getElementById("SaveAccount").innerHTML = "<a href='javascript:' onclick='javascript:return false;' class='off'>Valider</a>";
            document.getElementById("question1").href = "#";
            document.getElementById("question2").href = "#";
            document.getElementById("question3").href  = "#";
            document.getElementById("question4").href  = "#";

            num = num_question;
            question ='c'+num;

            if(num == "1")
            {
                document.getElementById('question'+num).className = "Active";
                document.getElementById('question3').className = "off";
                document.getElementById('question2').className = "off";
                document.getElementById('question4').className = "off";
            }

            else if(num == "2")
            {
                document.getElementById('question'+num).className = "Active";
                document.getElementById('question1').className = "off";
                document.getElementById('question3').className = "off";
                document.getElementById('question4').className = "off";
            }

            else if(num == "3")
            {
                document.getElementById('question'+num).className = "Active";
                document.getElementById('question1').className = "off";
                document.getElementById('question2').className = "off";
                document.getElementById('question4').className = "off";
            }

            else if(num == "4")
            {
                document.getElementById('question'+num).className = "Active";
                document.getElementById('question1').className = "off";
                document.getElementById('question2').className = "off";
                document.getElementById('question3').className = "off";
            }


        }
    });
    

}


function NextQuestion(y) //Passe à la question suivante
{
    $.ajax({
        type: "GET",
        url: site+"modules/jeu_quizz/question.php?id_tournoi="+num_tournoi_var,
        data: "id="+y,
        success: function(data){
            document.getElementById("quest").innerHTML = data;
        }
    });
}


function Count()
{
    document.getElementById('loader').style.visibility = "visible";
    var now =  document.getElementById('info_bas').className;
    now = parseInt(now);

    var pomme = new Date(now * 1000);  
    pomme.setSeconds(pomme.getSeconds() + 12.5);
    $('#shortly').countdown('change', {
        until: pomme
    }); 

    NextQuestion(b);
    joker_refresh();
    setTimeout("listing_player()",100);


}


function watchCountdown(periods) { 
    $('#loader').text(periods[6]); 
    time = periods[6];
}


//affiche la bonne réponse a la fin des 12 seconde de la question
function liftOff() { 
    if(pass == 0)
    {
        non_valid();
    }
    document.getElementById("loader").style.visibility = "hidden";

    $.ajax({
        type: "GET",
        url: site+"modules/jeu_quizz/question_valid.php",
        data: "id="+b,
        success: function(data){
            //alert(data);	
            num_question = "";
            document.getElementById(data).className = "ActiveGreen";
        }
    });	


    $.ajax({
        type: "GET",
        url: site+"modules/jeu_quizz/timestamp.php",
        data: "id="+b,
        success: function(data){

            check_Time2(data,1);

        }
    });	

    pass = 0;

//vide la question	
} 


//s'execute a la fin des 20 seconde de la question
function time_quest()
{
    document.getElementById("quest").innerHTML= "";


    $.ajax({
        type: "GET",
        url: site+"modules/jeu_quizz/check_next.php?id_tournoi="+num_tournoi_var,
        dataType: "script",
        success: function(data){
            b++;
            pass = 0;
            setTimeout('Count()',1500);
        }
    });	

}



function check_number_player(num_tournoi)
{
    $.ajax({
        type: "GET",
        dataType: "script",
        url: site+"modules/jeu_quizz/check_num_player.php",
        data: "hourDeb="+num_tournoi,
        success: function(data){
        }
    });	
}


function check_Time(timestamp,nbfois,id_tounois)//si le tournois peux se mancer alors on patiente 10s
{
    var now =  document.getElementById('info_bas').className;
    now = parseInt(now);

    if(now >= timestamp)
    {

        setTimeout("init_tournoi("+id_tounois+",1)",1000);
    }
    else
    {
        nbfois++;
        setTimeout("check_Time("+timestamp+","+nbfois+","+id_tounois+")",500);
    }
}


function check_Time2(timestamp,nbfois)
{
    var now =  document.getElementById('info_bas').className;
    now = parseInt(now);

    if(now >= timestamp)
    {
        setTimeout('time_quest()',1000);
    }
    else
    {
        nbfois++;
        setTimeout("check_Time2("+timestamp+","+nbfois+")",500);
    }
}


function non_valid()
{
    question = "";
    time = 0;
    SaveInfo(b,0);
}

function valid()
{
    pass =1;       
    son2 = soundManager.createSound(
    
        {
                id : "son2",  
                autoPlay : true,
                url : "http://g-crea.com/c/awstudio/projets/quizzT/audio/validation.mp3" // Attention pas de virgule ici !

            }); 
    SaveInfo(b,0); 
    
} 




function pop(num)
{
    pop_las = window.open("TestCar.php?module=jeu_quizz&action=quizz&hourDeb="+num,"popup_jeu"+num,"menubar=no, status=no, scrollbars=no, menubar=no, width=905, height=640");
    if(pop_las.window.focus){
        pop_las.window.focus();
    }
}

function redirection_duel(num)
{        
    window.location.href="TestCar.php?module=jeu_quizz&action=quizz&hourDeb="+num;     
    
}

function jouer_son(nomSon)
{
    
    soundManager.onload = function(){
        son = soundManager.createSound(
    
        {
                id : "son",
                autoPlay : true,
                url : "http://g-crea.com/c/awstudio/projets/quizzT/audio/"+nomSon // Attention pas de virgule ici !

            }); 
    }
}

function pop_duel(id)
{
    jeuEnCours();
    if(encours == 0)    
    {
        if(id == undefined)
        {
            var id = "0";
        }

        var test = window.open("TestCar.php?module=duel_quizz&action=quizz&script="+id,"popup_duel","menubar=no,location=no,resizable=no, status=no, scrollbars=no,width=905, height=640");

    }
    else
    {
        Shadowbox.open(
        {
            content:    'TestCar.php?module=duel_quizz&action=message_duel&mess=jeu_encours',
            player:     "iframe",
            title:      "",
            height:     301,
            width:      538
        });
    }
}

function pop_direct()
{
    window.open("TestCar.php?module=duel_quizz&action=quizz&jeu=direct","popup_duel","menubar=no,location=no,resizable=no, status=no, scrollbars=no,width=905, height=640");
}

function pop_rdv()
{
    window.open("TestCar.php?module=rdv_quizz&action=quizz","popup_rdv","menubar=no,location=no,resizable=no, status=no, scrollbars=no,width=905, height=640");
}

function pop_duel_id(id)
{
    jeuEnCours();
    if(encours == 0)    
    {
        window.open("TestCar.php?module=duel_quizz&action=quizz&id="+id,"popup_duel","menubar=no,location=no,resizable=no, status=no, scrollbars=no,width=905, height=640"); 
    }
    else
    {
        Shadowbox.open(
        {
            content:    'TestCar.php?module=duel_quizz&action=message_duel&mess=jeu_encours',
            player:     "iframe",
            title:      "",
            height:     301,
            width:      538
        });
    }
}


function time_verif()
{
    v = new Date('12 12, 2010 15:00:00');
    $('#2').countdown('change', {
        until:v
    }); 

}

function refresh()
{
    document.location.reload();
}

function deinscrip(id){
    $.ajax({
        url: site+"modules/jeu_quizz/delete_inscription_tournoi.php?id="+id,	
        cache: false,
        success: function(data){
            document.getElementById('popupAlert').innerHTML = data;
            parent.document.getElementById('statut').className = "0";
            parent.location.reload();
        }
    });
}

function deinscrip_token(id){
    $.ajax({
        url: site+"modules/jeu_quizz/delete_inscription_token_tournoi.php?id="+id,	
        cache: false,
        success: function(data){
            document.getElementById('popupAlert').innerHTML = data;
            parent.document.getElementById('statut').className = "0";
            parent.location.reload();
        }
    });
}

function number_player(){
    $.ajax({
        url: site+"modules/jeu_quizz/vues/information_nb_joueur_nok.php",	
        cache: false,
        success: function(data){
            document.getElementById('Container').innerHTML = data;
        }
    });
}


function	inscrip(num1,id)
{
    if(num1==0)
    {
        $.ajax({
            url: site+"modules/jeu_quizz/inscription_tournoi.php?id="+id,	
            dataType: "script",
            cache: false,
            success: function(data){
                document.getElementById('popupAlert').innerHTML = data;
                parent.location.reload();
            }
        }); 
    }
    else
    {
        $.ajax({
            url: site+"modules/jeu_quizz/vues/crediter_vue.php",	
            cache: false,
            success: function(data){
                document.getElementById('popupAlert').innerHTML = data;
            }
        });
    }
}

function inscrip_token(id)
{

    $.ajax({
        url: site+"modules/jeu_quizz/inscription_token_tournoi.php?id="+id,	
        cache: false,
        success: function(data){
            document.getElementById('popupAlert').innerHTML = data;
            parent.location.reload();
        }
    }); 
}


//recharge des onglets
function refresh_onglet(id_tournoi)
{		
    if(id_tournoi == undefined)
        var getVariable = '';
    else
        var getVariable = "numtournoi="+id_tournoi;
    $.ajax({
        type: "GET",
        url: site+"libs/ajax/tournois/onglet_tournoi.php",
        data:  getVariable,
        dataType: "script",
        success: function(data){

        }

    });


}

function change_onglet(num)
{
    if(num == 0)
    {
        document.getElementById('contenu_onglet_gain').style.display = 'block'; 
        document.getElementById('contenu_onglet_joueur').style.display = 'none';
        document.getElementById('tableau_onglet').className = "tableau_onglet_cagnotte";			
        document.getElementById('tableau_onglet').innerHTML = 'Cagnotte<span class="margin_cagnotte"><a href="javascript:change_onglet(1);">Joueurs</a></span>';

    }
    else
    {
        document.getElementById('contenu_onglet_gain').style.display = 'none'; 
        document.getElementById('contenu_onglet_joueur').style.display = 'block'; 
        document.getElementById('tableau_onglet').className = "tableau_onglet_joueur";	
        document.getElementById('tableau_onglet').innerHTML = '<a href="javascript:change_onglet(0);">Cagnotte</a><span class="margin_joueur" onclick="javascript:change_onglet(1);">Joueurs</span>';
    }

    $('.scroll-pane').jScrollPane();
}



/* TRAINING */
function demarrer_training()
{
    launch_game_training();
    setTimeout("start_training();",1000);

    init_tournoi_training();	
}


function posLoader2()
{
    var Position = document.getElementById("loader").className;
    document.getElementById("loader").style.backgroundPosition=Position+"px 0px";
}
function Mouv2(){
    var Posi = document.getElementById("loader").className;
    if(Posi>-1529) Posi -= 139; else  Posi = 0;
    parseInt(Posi);
    document.getElementById("loader").className=Posi;
}

function goLoad2(){
    setInterval("Mouv2()",50);
    setInterval("posLoader2()",50);
}


function init_tournoi_training()
{

    $.ajax({
        type: "GET",
        url: site+"modules/training_quizz/init_tournoi.php",
        cache: false,
        success: function(data){
            document.getElementById("shortly").innerHTML = data;
        }
    });
}


function launch_game_training()
{
    $.ajax({
        url: site+"modules/training_quizz/launch_game.php",	
        cache: false,
        success: function(data){
            document.getElementById('Container').innerHTML = data;
        }
    });
}

function SaveInfo_training(s,jok)
{

    $.ajax({
        type: "GET",
        url: site+"modules/training_quizz/addQuest.php",
        data: "questi="+question+"&times="+time+"&id="+s+"&jokers="+jok,
        success: function(data){
            document.getElementById("SaveAccount").innerHTML = "<a name='Time' value='Valider' href='javascript:' onclick='javascript:return false;' class='off'>Valider</a>";
            document.getElementById("question1").href = "#";
            document.getElementById("question2").href = "#";
            document.getElementById("question3").href  = "#";
            document.getElementById("question4").href  = "#";

            num = num_question;
            question ='c'+num;

            if(num == "1")
            {
                document.getElementById('question'+num).className = "Active";
                document.getElementById('question3').className = "off";
                document.getElementById('question2').className = "off";
                document.getElementById('question4').className = "off";
            }

            else if(num == "2")
            {
                document.getElementById('question'+num).className = "Active";
                document.getElementById('question1').className = "off";
                document.getElementById('question3').className = "off";
                document.getElementById('question4').className = "off";
            }

            else if(num == "3")
            {
                document.getElementById('question'+num).className = "Active";
                document.getElementById('question1').className = "off";
                document.getElementById('question2').className = "off";
                document.getElementById('question4').className = "off";
            }

            else if(num == "4")
            {
                document.getElementById('question'+num).className = "Active";
                document.getElementById('question1').className = "off";
                document.getElementById('question2').className = "off";
                document.getElementById('question3').className = "off";
            }


        }
    });
}


function NextQuestion_training(y)
{

    $.ajax({
        type: "GET",
        url: site+"modules/training_quizz/question.php",
        data: "id="+y,
        success: function(data){
            document.getElementById("quest").innerHTML = data;
        }
    });
}

function start_training()
{

    pass=0;
    question = "";
    time = 0;


    document.getElementById('Container').style.visibility = "visible";
    document.getElementById('loader').style.visibility = "hidden";

    var now =  document.getElementById('info_bas').className;
    now = parseInt(now);
    // now = new Date(now);
    var shortly = new Date(now * 1000);  
    shortly.setSeconds(shortly.getSeconds() + 12.5);
    $('#main').fadeTo("fast", 0);
    $('#main').fadeTo("fast", 1);	

    setTimeout('Count_training()',100);
    $('#shortly').countdown({
        until: shortly, 
        onExpiry: liftOff_training, 
        onTick: watchCountdown_training
    }); 
}

function Count_training()
{
    document.getElementById('loader').style.visibility = "visible";
    var now =  document.getElementById('info_bas').className;
    now = parseInt(now);
    // now = new Date(now);
    var pomme = new Date(now * 1000);  
    pomme.setSeconds(pomme.getSeconds() + 12.5);
    $('#shortly').countdown('change', {
        until: pomme
    }); 

    NextQuestion_training(b);	
}

function watchCountdown_training(periods) 
{ 
    $('#loader').text(periods[6]); 

    time = periods[6];
}

function liftOff_training() { 


    if(pass == 0)
    {
        non_valid_training();
        document.getElementById("loader").style.visibility = "hidden";

        $.ajax({
            type: "GET",
            url: site+"modules/training_quizz/question_valid.php",
            data: "id="+b,
            success: function(data){
                num_question = "";
                document.getElementById(data).className = "ActiveGreen";


                b++;

                pass = 1;


                //vide la question
                setTimeout('time_quest_training()',2000);
            }
        });	


    }
    else
    {
        valid_training();
        if(time>2){
            document.getElementById("loader").style.visibility = "hidden";

            $.ajax({
                type: "GET",
                url: site+"modules/training_quizz/question_valid.php",
                data: "id="+b,
                success: function(data){
                    num_question = "";
                    document.getElementById(data).className = "ActiveGreen";
                    b++;
                    //vide la question
                    setTimeout('time_quest_training()',2000)
                }
            });	
        }
    }



} 

function time_quest_training()
{

    document.getElementById("quest").innerHTML= "";

    $.ajax({
        type: "GET",
        url: site+"modules/training_quizz/check_next.php",
        data: "id="+b,
        dataType: "script",
        success: function(data){
        }
    });	
    pass=0;
    question = "";
    time = 0;
    setTimeout("Count_training()",100);
}


function non_valid_training()
{
    SaveInfo_training(b,0);
}

function valid_training()
{
    pass =1;
    SaveInfo_training(b,0);
} 


function affHeure(){
    var now =  document.getElementById('info_bas').className;
    now = parseInt(now);
    var clock = new Date(now * 1000); 
    var heure = clock.getHours();
    if (heure<10) {
        heure = "0" + heure
    }
    var minute = clock.getMinutes();
    if (minute<10) {
        minute = "0" + minute
    }
    var seconde = clock.getSeconds();
    if (seconde<10) {
        seconde = "0" + seconde
    }
    document.getElementById("clockAff").innerHTML= heure+":"+minute+":"+seconde;
}


function Info_training(num)
{	

    document.getElementById("SaveAccount").innerHTML = "<a name='Time'  value='Valider' href='javascript:liftOff_training()'>Valider</a>";

    num_question=num;

    question ='c'+num;
    if(num == "1")
    {
        document.getElementById('question'+num).className = "Active";
        document.getElementById('question3').className = "";
        document.getElementById('question2').className = "";
        document.getElementById('question4').className = "";
    }

    if(num == "2")
    {
        document.getElementById('question'+num).className = "Active";
        document.getElementById('question1').className = "";
        document.getElementById('question3').className = "";
        document.getElementById('question4').className = "";
    }

    if(num == "3")
    {
        document.getElementById('question'+num).className = "Active";
        document.getElementById('question1').className = "";
        document.getElementById('question2').className = "";
        document.getElementById('question4').className = "";
    }

    if(num == "4")
    {
        document.getElementById('question'+num).className = "Active";
        document.getElementById('question1').className = "";
        document.getElementById('question2').className = "";
        document.getElementById('question3').className = "";
    }
}

/*TRAINING ACCUEIL */
function demarrer()
{
    setTimeout("launch_game_accueil(1);",100);
    setTimeout("launch_game_accueil(2);",2500);
    setTimeout("start_accueil();",3600);

    init_tournoi_accueil();	
}

function init_tournoi_accueil()
{

    $.ajax({
        type: "GET",
        url: site+"global/accueil_quizz/init_tournoi.php",
        cache: false,
        success: function(data){
            //alert(data);
            document.getElementById("shortly").innerHTML = data;
        }
    });
}


function launch_game_accueil(num)
{
    $.ajax({
        url: site+"global/accueil_quizz/launch_game.php?num="+num,	
        cache: false,
        success: function(data){
            document.getElementById('Container').innerHTML = data;
        }
    });
}

function SaveInfo_accueil(s,jok)
{

    $.ajax({
        type: "GET",
        url: site+"global/accueil_quizz/addQuest.php",
        data: "questi="+question+"&times="+time+"&id="+s+"&jokers="+jok,
        success: function(data){
            //alert(data);
            document.getElementById("SaveAccount").innerHTML = "<a name='Time' value='Valider' href='javascript:' onclick='javascript:return false;' class='off'>Valider</a>";
            document.getElementById("question1").href = "#";
            document.getElementById("question2").href = "#";
            document.getElementById("question3").href  = "#";
            document.getElementById("question4").href  = "#";

            num = num_question;
            question ='c'+num;

            if(num == "1")
            {
                document.getElementById('question'+num).className = "Active";
                document.getElementById('question3').className = "off";
                document.getElementById('question2').className = "off";
                document.getElementById('question4').className = "off";
            }

            else if(num == "2")
            {
                document.getElementById('question'+num).className = "Active";
                document.getElementById('question1').className = "off";
                document.getElementById('question3').className = "off";
                document.getElementById('question4').className = "off";
            }

            else if(num == "3")
            {
                document.getElementById('question'+num).className = "Active";
                document.getElementById('question1').className = "off";
                document.getElementById('question2').className = "off";
                document.getElementById('question4').className = "off";
            }

            else if(num == "4")
            {
                document.getElementById('question'+num).className = "Active";
                document.getElementById('question1').className = "off";
                document.getElementById('question2').className = "off";
                document.getElementById('question3').className = "off";
            }

        }
    });
}
//module=jeu_quizz&action=addQuest&

//module=jeu_quizz&action=question
function NextQuestion_accueil(y)
{

    $.ajax({
        type: "GET",
        url: site+"global/accueil_quizz/question.php",
        data: "id="+y,
        success: function(data){
            document.getElementById("quest").innerHTML = data;
        }
    });
}

function start_accueil()
{
    pass=0;
    question = "";
    time = 0;

    document.getElementById('Container').style.visibility = "visible";
    document.getElementById('loader').style.visibility = "hidden";
    //goLoad();
    var now =  document.getElementById('info_bas').className;
    now = parseInt(now);
    // now = new Date(now);
    var shortly1 = new Date(now * 1000);  
    shortly1.setSeconds(shortly1.getSeconds() + 12.5);
    $('#main').fadeTo("fast", 0);
    $('#main').fadeTo("fast", 1);	

    setTimeout('Count_accueil()',10);
    $('#shortly').countdown({
        until: shortly1, 
        onExpiry: liftOff_accueil, 
        onTick: watchCountdown_accueil
    }); 
}

function Count_accueil()
{
    document.getElementById('loader').style.visibility = "visible";
    var now =  document.getElementById('info_bas').className;
    now = parseInt(now);
    // now = new Date(now);
    var pomme = new Date(now * 1000);  
    pomme.setSeconds(pomme.getSeconds() + 12.5);
    $('#shortly').countdown('change', {
        until: pomme
    }); 
    //valide qu'il a l'acces
    //if(checkUtil($id_util)==true)
    //{
    //xcherche la question

    NextQuestion_accueil(b);	
//}
//else window.replace();
}

function watchCountdown_accueil(periods) { 
    $('#loader').text(periods[6]); 

    time = periods[6];
}

function liftOff_accueil() { 
    if(pass == 0)
    {
        non_valid_accueil();
        document.getElementById("loader").style.visibility = "hidden";

        $.ajax({
            type: "GET",
            url: site+"global/accueil_quizz/question_valid.php",
            data: "id="+b,
            success: function(data){
                num_question = "";
                document.getElementById(data).className = "ActiveGreen";
            }
        });	

        b++;
        pass = 1;


        //vide la question
        setTimeout('time_quest_accueil()',2000);


    }
    else
    {
        valid_accueil();
        if(time>2){

            document.getElementById("loader").style.visibility = "hidden";

            $.ajax({
                type: "GET",
                url: site+"global/accueil_quizz/question_valid.php",
                data: "id="+b,
                success: function(data){
                    num_question = "";
                    document.getElementById(data).className = "ActiveGreen";
                }
            });	

            b++;
            //vide la question
            setTimeout('time_quest_accueil()',2000);

        }
    }




} 

function time_quest_accueil()
{

    document.getElementById("quest").innerHTML= "";

    $.ajax({
        type: "GET",
        url: site+"global/accueil_quizz/check_next.php",
        data: "id="+b,
        dataType: "script",
        success: function(data){
        //alert(data);	
        }
    });	
    pass=0;
    question = "";
    time = 0;
    setTimeout("Count_accueil()",100);
}


function non_valid_accueil()
{
    SaveInfo_accueil(b,0);
}

function valid_accueil()
{
    pass =1;
    SaveInfo_accueil(b,0);
} 




function Info_accueil(num)
{	
    document.getElementById("SaveAccount").innerHTML = "<a name='Time'  value='Valider' href='javascript:liftOff_accueil()'>Valider</a>";

    num_question = num;
    question ='c'+num;
    if(num == "1")
    {
        document.getElementById('question'+num).className = "Active";
        document.getElementById('question3').className = "";
        document.getElementById('question2').className = "";
        document.getElementById('question4').className = "";
    }

    if(num == "2")
    {
        document.getElementById('question'+num).className = "Active";
        document.getElementById('question1').className = "";
        document.getElementById('question3').className = "";
        document.getElementById('question4').className = "";
    }

    if(num == "3")
    {
        document.getElementById('question'+num).className = "Active";
        document.getElementById('question1').className = "";
        document.getElementById('question2').className = "";
        document.getElementById('question4').className = "";
    }

    if(num == "4")
    {
        document.getElementById('question'+num).className = "Active";
        document.getElementById('question1').className = "";
        document.getElementById('question2').className = "";
        document.getElementById('question3').className = "";
    }

}



function VerifPseudo(pseudo)
{	

    $.ajax({
        type: "GET",
        url: site+"modules/membres/vues/verif_pseudo.php?pseudo="+pseudo,
        success: function(data){
            //alert(data);
            document.getElementById("rechPseudo").innerHTML = data;
        }
    });
}


function afficheStat(id,span) {	

    if(document.getElementById(id).style.display=="none")
    {

        document.getElementById("Sgain").style.display="none";
        document.getElementById("Splace").style.display="none";
        document.getElementById("Sniveau").style.display="none";
        document.getElementById("Sfill").style.display="none";
        document.getElementById("SgainP").style.display="none";
        $(".statPerso").find('a').children().removeClass("active");
        $(".statPerso").find('a').children().removeClass("fleche_haut");


        document.getElementById(id).style.display="block";
        if(span!=undefined)
        {
            $(span).find('label.details').addClass("active"); 
            $(span).find('span.fleche').addClass("fleche_haut");  
        }

    } 
    else 
    {
        document.getElementById(id).style.display="none";
        $(".statPerso").find('a').children().removeClass("active");
        $(".statPerso").find('a').children().removeClass("fleche_haut");		
    }

    $('.scroll-pane').jScrollPane(); //on met à jour notre scroll bar

}

function jeuEnCours()
{
    $.ajax({
        type:"GET",
        url : site + "libs/ajax/duel_quizz/verification_jeu.php",
        async:false,
        success : function(data)
        {
            encours = data; 
        }
    });
}


function confirmation_duel(id,id_dueliste)
{
    jeuEnCours();
    if(encours == 0)    
    {

        if(id_dueliste == undefined)
            id_dueliste = 'confirm';


        //On demande au joueur s'il confirme son duel
        Shadowbox.open(
        {
            content:    'TestCar.php?module=duel_quizz&action=message_duel&mess=confirm&id='+id+'&vs='+id_dueliste,
            player:     "iframe",
            title:      "",
            height:     301,
            width:      538
        });
    }
    else
    {
        Shadowbox.open(
        {
            content:    'TestCar.php?module=duel_quizz&action=message_duel&mess=jeu_encours',
            player:     "iframe",
            title:      "",
            height:     301,
            width:      538
        });
    }

}



function recommencer_duel(message,id,id_dueliste)
{ 

    //On demande au joueur s'il confirme son duel
    Shadowbox.open(
    {
        content:    'TestCar.php?module=duel_quizz&action=message_duel&mess='+message+'&id='+id+'&vs='+id_dueliste,
        player:     "iframe",
        title:      "",
        height:     301,
        width:      538
    });

}

function refresh_search_player(id,id_dueliste,popu)
{
    //On va d'abord consulter si le joueur a assez d'argent pour faire un duel
    $.ajax({
        type: "GET",
        url : site+"libs/ajax/duel_quizz/argent_disponible.php",
        data : "id="+id,
        async: false,
        success : function(data)
        {
            var argent_dispo = data;
            //Il a assez d'argent, il peut lancer le duel
            if(argent_dispo ==1)
            {

                $.ajax({
                    type: "GET",
                    url: site+"libs/ajax/duel_quizz/information_recherche.php?id_dueliste="+id_dueliste,
                    dataType:"script",
                    success: function(data){
                    }
                });
            }

            //Il n'a pas assez d'argent on affiche la vue d'erreur
            else
            {				
                if(popu != undefined)
                {
                    redirection('TestCar.php?module=duel_quizz&action=quizz&where='+id);
                }
                else
                {
                    Shadowbox.open({
                        content:    'TestCar.php?module=duel_quizz&action=message_duel&mess=argent',
                        player:     "iframe",
                        title:      "",
                        height:     301,
                        width:      538
                    });
                }

            }
        }

    })



}

function select_duel(id){

    $.ajax({
        url: site+"libs/ajax/duel_quizz/ajax_selection_duel.php?id="+id,
        cache: false,
        success: function(data){
            document.getElementById('Container').innerHTML = data;
        }
    });
}

function supprimer_liste_duel(id){

    $.ajax({
        url: site+"libs/ajax/duel_quizz/ajax_supprimer_duel.php?id="+id,
        cache: false,
        success: function(data){
            //refresh();
            location.href = "TestCar.php?module=duel_quizz&action=quizz";
        }
    });
}

function supprimer_liste_invitation(id,refuser){


    $.ajax({
        url: site+"libs/ajax/duel_quizz/ajax_supprimer_invitation.php?id="+id,
        cache: false,
        success: function(data){
            if(refuser==2){
                window.close();
            }
            else if(refuser == 1){
                refuser_duel(id);
            }
            else if(refuser == 3){
                refresh();
            }else if(refuser == 0){
                location.href = "TestCar.php?module=duel_quizz&action=quizz";
            }

        }
    });
}

function supprimer_liste_invitation_rdv(id,hote){

    $.ajax({
        url: site+"libs/ajax/rdv_quizz/ajax_supprimer_invitation_rdv.php?id="+id+"&id_hote="+hote,
        cache: false,
        success: function(data){

            refresh();


        }
    });	
}

function check_duel(id){
    $.ajax({
        url: site+"libs/ajax/duel_quizz/ajax_check_duel.php?id="+id,
        cache: false,
        dataType: "script",
        success: function(data){
        }
    });

}

function refuser_duel(id){

    $.ajax({
        url: site+"libs/ajax/duel_quizz/ajax_refuser_duel.php?id="+id,
        cache: false,
        success: function(data){
            refresh();
        }
    });

}

function message_duel(id_message){
    Shadowbox.open({
        content:    'TestCar.php?module=duel_quizz&action=message_duel&mess='+id_message,
        player:     "iframe",
        title:      "",
        height:     301,
        width:      538
    });
}



function refresh_connecte(){



    var api = $('.actionAtt').jScrollPane().data('jsp');
    api.getContentPane().load( 
        site+"libs/ajax/duel_quizz/ajax_refresh_connecte.php",
        function()
        {
            api.reinitialise();
        }
        );
}

function add_joueur_rdv(id_joueur,num,nom,deja)
{ 
    if(deja == undefined)
        deja = 1;

    var listeINV = document.getElementById("invite_rdv").innerHTML; 
    var NomMod = "'"+nom+"'";
    nb_inscrit_rdv = nb_inscrit_rdv + 1;
    $("#invite_rdv").css('width',nb_inscrit_rdv*79+'px');
    if(num == 1 ){
        image_avatar =	'<div class="avatar_liste" id="'+id_joueur+'"><img src="'+site+'images/avatars/'+id_joueur+'.jpg" onclick="delete_joueur_rdv('+id_joueur+','+num+','+NomMod+')" width="31" height="31" /><br /><label>'+nom+'</label></div>';	 
    }else{
        image_avatar = '<div class="avatar_liste" id="'+id_joueur+'"><img src="'+site+'images/cadre_avatar.jpg" onclick="delete_joueur_rdv('+id_joueur+','+num+','+NomMod+')" width="31" height="31" /><br /><label>'+nom+'</label></div>';
    }

    var nbEx = listeINV.search('id="'+id_joueur+'"');

    if(nbEx==-1)
    {
        document.getElementById("invite_rdv").innerHTML = document.getElementById("invite_rdv").innerHTML+image_avatar;
        document.getElementById("compte").value = document.getElementById("compte").value +id_joueur+"-";
        document.getElementById("compteRech").value = document.getElementById("compteRech").value +id_joueur+"-";
    } 




}

function delete_joueur_rdv(id_joueur,num,nom){
    var compte = document.getElementById("compte").value;
    var compteRech = document.getElementById("compteRech").value;	
    document.getElementById("compte").value = compte.replace(id_joueur+"-", "");
    document.getElementById("compteRech").value = compteRech.replace(id_joueur+"-", "");

    $('#'+id_joueur).remove();

}



function inscrRapid(form,parent2)
{


    $.ajax({
        type: "GET",
        url: site+"libs/ajax/inscription/verif.php",
        data: 'pseudo='+form.pseudo.value+'&mdp='+form.mdp.value+'&email='+form.email.value+'&reglement='+form.reglement.checked,
        async : false,  
        success: function(data){
            if(data == 'ok')
            {				
                erreur = true;
                $(".alerte").addClass("validD");

            }
            else
            {
                $(".alerte").html(data);
            }


            if($('.alerte').hasClass('validD'))
            {
                //On fait une inscription rapide par la popup
                if(parent2 == undefined)
                {
                    //On agrandit la popup		
                    parent.$('#sb-body').animate({
                        'width' :'538px',
                        'height' :'301px'
                    }, 200);

                    parent.$('#sb-wrapper').animate({
                        'width' :'538px'
                    }, 200); 
                    redirection('membres-popup_inscrit.html');
                }
                //On fait une inscription rapide par l'accueil
                else
                {					
                    Shadowbox.open(
                    {
                        content:    'membres-popup_inscrit.html',
                        player:     "iframe",
                        title:      "",
                        height:     301,
                        width:      538
                    });
                }




            //On affiche la popup d'alerte
            // $('#sb-content div.inscription_rapide2').html('');

            //var test = window.open("TestCar.php?module=duel_quizz&action=quizz&script=2","popup_duel","menubar=no,location=no,resizable=no, status=no, scrollbars=no,width=905, height=640");
            }

        }
    });


}

function refreshParent()
{
    parent.location.reload();
}



function affiche(id)
{
    if($("#"+id).css('display') == 'none')
        $("#"+id).show(200);
    else
        $("#"+id).hide(200);	 
}


/****
	Page d'accueil
****/
		
function precedent(nbjeux) 
{	
    if($("#lesjeux").css('marginLeft') != "0px")
        $("#lesjeux").animate({
            "marginLeft": "+=224px"
        }, 500 );    
}  

function suivant(nbjeux)
{
    var nbmarge = nbjeux-4; //Nombre de d�calage possible sachant qu'on ne peut afficher que 4 jeux
    var marge = nbmarge * (-224);  
    marge = marge.toString() +"px";
    if($("#lesjeux").css('marginLeft') != marge)
        $("#lesjeux").animate({
            "marginLeft": "-=224px"
        }, 500 );     
}

function redirection(url)
{
    document.location.href= url; 
}




/****
	Page Jeux
****/
/**
	Dans toutes ces fonctions le param�tre cl renvoie � la classe du jeux
	Ex: Jeux tournois  | cl = "tournois"
		Duel al�atoire | cl = "duel_alea"
**/		

//Envoi directement sur le jeu cliqu� en page d'accueil

function afficher_jeu(numero_go,cl_go)
{
	
    agrandir_image(cl_go,numero_go);
}  

				
//Affiche l'image sur le hover
function afficher_image(cl)
{
    $("#"+cl).children().css("display","block");
}


function cacher_image(cl)
{
    if($("#"+cl).children().hasClass("agrandi") == false)
        $("#"+cl).children().css("display","none");
}

var pos = 0;
function agrandir_image(cl,position,date_tn)
{	
    //On remet toutes les images de la liste en miniature et on les cache pour que le background apparaisse
    //$('#contenu_description').fadeOut('slow');
    var cssObj = {
        'margin-top' : '0',
        'margin-left' : '0',
        'top' : '0',
        'left' : '0',
        'width' : '96px',
        'height' : '84px',
        'z-index' : '10',
        'display' : 'none'
    }	
	
    $("*").removeClass("agrandi");
    $("#liste_jeux").find('img').css(cssObj);
	
	
    //On agrandi l'image sur laquelle on vient de cliquer
    $("#"+cl).find('img').css({
        'display':'block'
    });
    $("#"+cl).children().addClass("agrandi");
    $("#"+cl).children().css({
        'z-index' : '11'
    });  
    $("#"+cl).children().animate({
        marginTop: '-64px', 
        marginLeft: '-66px',
        top: '50%',
        left: '50%',
        width: '139px',
        height: '122px'
    }, 200); 
	
    /**********************************************/
    //On r�cup�re la marge a ajouter
    var marge = (-1358)+(position-2-pos) * 104;   
	
    //On ajoute la marge au curseur
    $("#cursor").animate({			
        marginLeft: marge+"px"
    }, 200);
    /***********************************************/
	
	
    $.ajax({
        type: "GET",
        url: site+"libs/ajax/jeux/afficher_jeu.php",
        data: "jeu="+cl,
        success: function(data)
        {			
				
				
            $('#contenu_description').css({
                "display":"none"
            });
            document.getElementById("contenu_description").innerHTML = data;	
				
				
            //On retire toutes les classes
            $('#contenu_description').removeClass();
				
            //On ajoute la classe correspondante
            $('#contenu_description').addClass(cl);
				
            $('#contenu_description').fadeIn(400);
            $('.contenu_descr').jScrollPane();	 
            if(cl == "tournois")
            {
                var v = new Date();
                v = new Date(date_tn);
                $("#pomme").countdown({
                    until: v, 
                    onExpiry:refresh_next_tournament, 
                    format: "HMS",
                    compact: true
                });
            }
            Shadowbox.setup();
				
				
        }
    });
			
	
}

function popup_inscription()
{
	
    Shadowbox.open(
    {
        content:    'membres-inscription_rapide.html',
        player:     "iframe",
        title:      "",
        height:     349,
        width:      412
    });
}
	

	
	


function jeu_suivant()
{
		
    if($('#jeu_suivant').hasClass('disabled') == false)
    {
        $("#liste_jeux").animate({
            "marginLeft": "-=104px"	
        })
        pos = pos+1;
		
        var position = parseInt($("#cursor").css("margin-left"));
        position = position - 90;
		
        $("#cursor").css({			
            marginLeft: position
        });
    }
}

function jeu_precedent()
{
    if($("#liste_jeux").css('marginLeft') != "0px")
    {
        $("#liste_jeux").animate({
            "marginLeft": "+=104px"	
        })
        pos = pos -1;
    }
}


/****
	Page profil
****/
				

function token_precedent(nbtokens) 
{
    if($("#lestokens").css('marginLeft') != "0px")
        $("#lestokens").animate({
            "marginLeft": "+=284px"
        }, 500 );    
}

function token_suivant(nbtokens)
{
    var nbmarge = nbtokens-3; //Nombre de d�calage possible sachant qu'on ne peut afficher que 4 jeux
    var marge = nbmarge * (-284);  
    marge = marge.toString() +"px";
    if($("#lestokens").css('marginLeft') != marge)
        $("#lestokens").animate({
            "marginLeft": "-=284px"
        }, 500 );     
}			
	
/****
	Page popup amis
****/	

function precedent_rdv()
{
    if($("#invite_rdv").css('marginLeft') != "0px")
        $("#invite_rdv").animate({
            "marginLeft": "+=79px"
        }, 500 ); 
}			
	
function suivant_rdv()
{
	
    var nbinscrit = document.getElementById('invite_rdv').childNodes.length-1;
    var nbmarge = nbinscrit-10; //Nombre de d�calage possible sachant qu'on ne peut afficher que 4 jeux
    var marge = nbmarge * (-79);  
    marge = marge.toString() +"px";
    if($("#invite_rdv").css('marginLeft') != marge)
        $("#invite_rdv").animate({
            "marginLeft": "-=79px"
        }, 500 ); 
	
}



/****
	Page classement 
****/

function affiche_classement(id_div,id_tournoi)
{
    $.ajax({
        type: "GET",
        url: site+"libs/ajax/classement/afficher_classement.php",
        data: "id_tournoi="+id_tournoi,
        async:false,
        success: function(data)
        {					
            
            var api = $('#tournoi-'+id_div+' .scroll-pane').jScrollPane().data('jsp');
            api.getContentPane().html(data);
                                 
            $('#tournoi-'+id_div+' a.actif').removeClass('actif');
            $('#affTournoi'+id_tournoi+'').addClass('actif');
            api.reinitialise();
                                
        }
    });
} 


function display_classement(id_div)
{
    if($('#tournoi-'+id_div+' div.un_classement').css('display') == 'none')
    {		
        $('#tournoi-'+id_div+' div.un_classement').fadeIn(300);
        $('#tournoi-'+id_div+' div.bas_classement').fadeIn(300);
        $('#tournoi-'+id_div+' div.titre_tournoi a').addClass('open');		
    }
    else
    {
        $('#tournoi-'+id_div+' div.un_classement').fadeOut(200);
        $('#tournoi-'+id_div+' div.titre_tournoi a').removeClass('open');
    } 
	
	
}


/*** 
	Barre notification
**/
						
function cacher_barre()
{
	
    if($('div.barre_notification').hasClass('hide') == false)
    {
        $('#barre').fadeOut(500);
        $('#block_notification').css('display','none');
        etatBlocNotification = '';
        $('div.barre_notification').addClass('hide');
        $.ajax({
            type : "GET",
            url : site+"libs/ajax/barre/cacher_barre.php",
            data : "etat="+0, 
            success: function(data){}
        });
    }
    else
    {
        $('#barre').fadeIn(500);
        $('div.barre_notification').removeClass('hide');
        $.ajax({
            type : "GET",
            url : site+"libs/ajax/barre/cacher_barre.php",
            data : "etat="+1, 
            success: function(data){}
        });
    }
		
	
}


function afficher_div_notification(nom)
{
    if(etatBlocNotification == nom)
    {
        $('#block_notification').fadeOut(200);
        etatBlocNotification = ''; 
    }
	
    else
    {
        $.ajax({
            type: "GET",
            url: site+"libs/ajax/barre/contenu_barre.php",
            data: "nom="+nom,
            success: function(data)
            {				
					
                $('#block_notification').css('display','none');
                $('#block_notification').html(data);
                if(nom == 'amis')
                    $('#block_notification').css('left','39px');
                else if(nom == 'invitation')
                    $('#block_notification').css('left','158px');
					
                $('#block_notification').show(300);						
                $('.scroll-paneBas').jScrollPane();
            }
        })
        etatBlocNotification = nom;
    }
	
}

function cacher_notification() 
{
    $('#block_notification').fadeOut(200); 
    etatBlocNotification = '';  
}
	
function resizeShadowbox(id,width,height)
{
	 
    $('#'+id).animate({
        'width' :width+'px',
        'height' : height+'px'
    }, 200);
	
    $('#sb-wrapper').animate({
        'width' :'413px'
    }, 200);
	
	
}

