var ROTATE_IMAGES = 1;
var ROTATE_BG_IMAGES = 2;

var _slideShowOut;
var _slideShowImages;
var _slideShowCounter;
var _timeout;

function InitSlideShow(slideShowOutId, slideShowImages)
{
  _slideShowOut = document.getElementById(slideShowOutId);
  _slideShowImages = new Array(slideShowImages.length);
  _slideShowCounter = 0;

  for (var i = 0; i < slideShowImages.length; i++)
  {
    _slideShowImages[i] = new Image();
    _slideShowImages[i].src = slideShowImages[i];
  }
}

function RunSlideShow(action)
{
  if (document.all)
  {
    _slideShowOut.style.filter = "blendTrans(duration=2)";
    _slideShowOut.filters.blendTrans.Apply();
  }
  
  if (action == ROTATE_IMAGES)
  {
    _slideShowOut.src = _slideShowImages[_slideShowCounter].src;
  }
  else if (action == ROTATE_BG_IMAGES)
  {
    _slideShowOut.style.backgroundImage = "url(" + _slideShowImages[_slideShowCounter].src + ")";
  }

  if (document.all)
  {
    _slideShowOut.filters.blendTrans.Play();
  }

  if (++_slideShowCounter >= _slideShowImages.length)
  {
    _slideShowCounter = 0;
  }

  _timeout = setTimeout("RunSlideShow(" + action + ")", 4000);
}

function StopSlideShow()
{
  if (_timeout != null)
  {
    clearTimeout(_timeout);
    _timeout = null;
  }
}
