
var REFRESH = null;
var CURRENT_INDEX = 0;

function initSplash()
{
   REFRESH = setInterval("onInterval()", 8000);
}

function onInterval()
{
  var newCount = CURRENT_INDEX + 1;
  if (newCount > 4)
    newCount = 0;
  switchTo(newCount, false);
}

function switchTo(count, quick)
{
  if (quick)
  {
    if (REFRESH != null)
      clearInterval(REFRESH);
  }
  
  var oldCount = CURRENT_INDEX;
  if (oldCount > 4)
    oldCount = 0;
  
  $oldElem = $("t" + oldCount);
  $newElem = $("t" + count);
  
  $oldElem.className = "";
  $newElem.className = "highlighted";
  
  $oldMessage = $("m" + oldCount);
  $newMessage = $("m" + count);
  
  /*if (!quick)
  {
    $oldMessage.fade();
    $newMessage.appear();
  }
  else*/
  {
    $oldMessage.style.display = "none";
    $newMessage.style.display = "block"; 
  }
  
  // TODO until we have new images...
  //$("splash").style.backgroundImage = "url(images/splash" + count + ".jpg)";
  
  CURRENT_INDEX = count;
}
