var seconds = null;
var timer = null;
function updateSecondsBeforeTirageTombola() {
    if (seconds==null) {
	var url = "./admin/index.php";
	var parameters = "obj=JsonPublicTombola&action=secondsBeforeTirage";

	var res = Ajax.makeRequestSynchroneJson(url, parameters);
	if (res==null) return;

	seconds = res['seconds'];
	if (seconds<=0) {
	    var div = document.getElementById('idSecondsBeforeTirageTombola');
	    if (div==null) return;
	    div.innerHTML = "aucun tirage programmé, désolé...";
	    return;
	}
	timer = setInterval('updateSeconds()', 1000);
    }
}

function updateSeconds() {
    var div = document.getElementById('idSecondsBeforeTirageTombola');
    if (div==null) return;

    if (seconds>0) {
	div.innerHTML = Date.secondsToStr(seconds);
	seconds--;
    } else div.innerHTML = "... Etes-vous l'heureux gagnant ?";
}
