    // Variables
    var yr      	= 0;
    var mo      	= 0;
    var da      	= 0;
    var hr      	= 0;
    var min     	= 0;
    var sec     	= 0;
    var difTime   	= 0;

    function initCompteur(serverTime, toYear, toMonth, toDay, toHours, toMinutes, toSeconds, element)
    {

        yr  			= toYear;
        mo  			= toMonth;
        da  			= toDay;
        hr  			= toHours;
        min 			= toMinutes;
        sec 			= toSeconds;
		var today		= new Date();
		var localTime	= Math.round(today.getTime()/1000);
		serverTime		= serverTime>0 ? serverTime : localTime;
		difTime			= localTime - serverTime;
		myelement = document.getElementById(element);
    }


    function loadCompteur()
    {

        var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
        // 2Â°) Changez les deux textes ci-dessous. Le premier pour annoncer l'Ã©vÃ¨nement, le second qui s'affichera Ã  la fin du compte Ã  rebours.
        
        var message_on_occasion = 'Tirage en cours';
		
		var today		= new Date();
		var localTime	= Math.round(today.getTime()/1000);
        
		today=new Date((localTime-difTime)*1000);
        var todayy=today.getYear();
		
		if (todayy < 1000) {
			
			todayy += 1900;
		}
		
		if (navigator.userAgent.indexOf("Opera") != -1) {
	
			if (todayy < 1000) {
			
				todayy += 1900;
			}
		}
		
        var todaym		= today.getMonth();
        var todayd		= today.getDate();
        var todayh		= today.getHours();
        var todaymin	= today.getMinutes();
        var todaysec	= today.getSeconds();
        var todaystring = montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec;
		
        futurestring = montharray[mo-1]+" "+da+", "+yr+" "+hr+":"+min+":"+sec;
        dd	  		 = Date.parse(futurestring) - Date.parse(todaystring);
        dday  		 = Math.floor(dd/(60*60*1000*24)*1);
        dhour 		 = Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
        dmin  		 = Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
        dsec  		 = Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
        //if on day of occasion
        if((dday<=0)&&(dhour<=0)&&(dmin<=0)&&(dsec<=1)&&(todayd==da)){
            if (document.layers){
                document.countdownnsmain.document.countdownnssub.document.write(message_on_occasion);
                document.countdownnsmain.document.countdownnssub.document.close();
            }
            else if ((document.all)||(document.getElementById))
            crosscount.innerHTML=message_on_occasion;
            return;
        }
        //if passed day of occasion
        else if (dday<=-1){

            myelement.innerHTML = "L'évènement est déjà  arrivé ! ";
            return;
        } else {

        	if (dmin < 10) {
           
            	dmin = '0' + dmin;
        	}
        
	        if (dsec < 10) {

    	        dsec = '0' + dsec;
        	}
			
            myelement.innerHTML = dhour + ' h ' + dmin + ' m ' + dsec + ' s';
        }
        
		setTimeout('loadCompteur()', 1000);
    }
