var actus = null;
var nbact = 0;
var curid = 0;
var timer = null;

function startActus() {
  obtenirAsync("index.php", "m=actus&a=getListeActus&typeReturn=json", _doStartActus, "GET", "json");
}

function _doStartActus( json ) {
  actus = json;
  
  nbact = actus.length;
  if (nbact > 0) {
    displayActu();
  }
}

function displayActu() {
  obtenirAsync("index.php", "m=actus&a=getActu&suppressHeaders=1&id="+actus[curid], _doGetActu, "GET", "html");
}

function _doGetActu( html ) {
  $('#scroll-actus').fadeOut( 'slow', function() {
                                        $("#scroll-actus").html( html );
  							          } );
  $('#scroll-actus').fadeIn( 'slow' );
  if (nbact > 1) {
  	curid = ((curid == (nbact - 1)) ? 0 : curid + 1);
	timer = setTimeout( "displayActu()", 5000);
  }
}

$(window).unload( function() {
                    window.clearTimeout( timer );
                  } );

