var agendaTimer = null;
var pos = 0;
var count = 0;
var nextnode = null;
var var_agenda_on = 0;

function agenda_off()
{
  clearInterval(agendaTimer);
  var_agenda_on = 0;
}

function agenda_on()
{
  agendaTimer = setInterval("move_agenda_move()", 70);
  var_agenda_on = 1;
}

function rotate_div_agenda()
{
  var child = agenda_get_first_div(document.getElementById('agenda_contain'));
  document.getElementById('agenda_contain').removeChild(child);
  document.getElementById('agenda_contain').appendChild(child);
}

function agenda_get_first_div(div)
{
  noeuds = div.firstChild;
  while (noeuds!=null) {
    if (noeuds.nodeName == "DIV")
       return(noeuds);
    noeuds = noeuds.nextSibling;
  }
  return (null);
}

function move_agenda_move()
{
  if (var_agenda_on == 1)
  {
    var div = document.getElementById('agenda_contain');
    if (div)
    {
      var child = agenda_get_first_div(div);
      if ((child != null) && pos == child.offsetHeight)
      {
        rotate_div_agenda();
        pos = 0;
      }
      div.style.marginTop="-"+pos+"px";
      pos = pos + 1;
    }
    else
    {
	var_agenda_on = 0;
        clearInterval(agendaTimer);
    }
  }
}

function agenda_start_move()
{
  if (agendaTimer != null)
     clearInterval(agendaTimer);
  pos = 0;
  nextnode = agenda_get_first_div(document.getElementById('agenda_contain'));
  var div = document.getElementById('agenda_contain');
  div.style.marginTop="0px";
  if (var_agenda_on == 0)
  {
    agendaTimer = setInterval("move_agenda_move()", 70);
    var var_agenda_on = 1;
  }
}

