var host = 'www.movetonight.com';

/* HEURE EN TEMPS REEL */
/* ------------------- */
function date_heure(id)
{
        date = new Date;
        annee = date.getFullYear();
        moi = date.getMonth();
        mois = new Array('Janvier', 'F&eacute;vrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Ao&ucirc;t', 'Septembre', 'Octobre', 'Novembre', 'D&eacute;cembre');
        j = date.getDate();
        jour = date.getDay();
        jours = new Array('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi');
        h = date.getHours();
        if(h<10)
        {
                h = "0"+h;
        }
        m = date.getMinutes();
        if(m<10)
        {
                m = "0"+m;
        }
        s = date.getSeconds();
        if(s<10)
        {
                s = "0"+s;
        }
        resultat = ''+jours[jour]+' '+j+' '+mois[moi]+' '+annee+' - '+h+':'+m+':'+s;
        document.getElementById(id).innerHTML = resultat;
        setTimeout('date_heure("'+id+'");','1000');
        return true;
}

/* CHANGEMENT BACKGROUND */
/* --------------------- */
function Background(BackgroundId)
{
	
    var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhr.open("GET", 'http://'+host+'/functions.php?Do=ChgBackground&Background='+BackgroundId+'', false);
    xhr.send(null);
		
}

/* INFOBULLE */
/* --------- */
function GetId(id)

{

return document.getElementById(id);

}

var i=false; // La variable i nous dit si la bulle est visible ou non

 

function move(e) {

  if(i) {  // Si la bulle est visible, on calcul en temps reel sa position ideale

    if (navigator.appName!="Microsoft Internet Explorer") { // Si on est pas sous IE

    GetId("curseur").style.left=e.pageX + 5+"px";

    GetId("curseur").style.top=e.pageY + 10+"px";

    }

    else { // Modif proposé par TeDeum, merci à  lui

    if(document.documentElement.clientWidth>0) {

GetId("curseur").style.left=20+event.x+document.documentElement.scrollLeft+"px";

GetId("curseur").style.top=10+event.y+document.documentElement.scrollTop+"px";

    } else {

GetId("curseur").style.left=20+event.x+document.body.scrollLeft+"px";

GetId("curseur").style.top=10+event.y+document.body.scrollTop+"px";

         }

    }

  }

}

 

function montre(text) {

  if(i==false) {

  GetId("curseur").style.visibility="visible"; // Si il est cacher (la verif n'est qu'une securité) on le rend visible.

  GetId("curseur").innerHTML = text; // on copie notre texte dans l'élément html

  i=true;

 }

}

function cache() {

if(i==true) {

GetId("curseur").style.visibility="hidden"; // Si la bulle est visible on la cache

i=false;

}

}

document.onmousemove=move; // dès que la souris bouge, on appelle la fonction move pour mettre à jour la position de la bulle.


/* CONCOURS */
/* -------- */
function Concours(ConcoursId)
{
	
    var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhr.open("GET", 'http://'+host+'/functions.php?Do=Concours&ConcoursId='+ConcoursId+'', false);
    xhr.send(null);
	
	document.getElementById('ParticiperConcours'+ConcoursId+'').innerHTML=xhr.responseText;
	
}

/* ACTUALISATION USER ONLINE */
/* ------------------------- */
function UserOnline()
{
	
    var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhr.open("GET", 'http://'+host+'/counter.php', false);
    xhr.send(null);
	
	document.getElementById('online').innerHTML=xhr.responseText;
	
}

setTimeout('UserOnline();','45000');


/* MISE A JOUR DES CLUBS */
/* --------------------- */
function NotGoInClub(ClubId)
{
	
    var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhr.open("POST", 'http://'+host+'/functions.php?Do=NotGoInClub&ClubId='+ClubId+'', false);
    xhr.send(null);
	
	document.getElementById('ClubCheck'+ClubId+'').innerHTML=xhr.responseText;
	
}

function GoInClub(ClubId)
{
	
    var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhr.open("POST", 'http://'+host+'/functions.php?Do=GoInClub&ClubId='+ClubId+'', false);
    xhr.send(null);
	
	document.getElementById('ClubCheck'+ClubId+'').innerHTML=xhr.responseText;
	
}


