var timer = 3;

var banners = [
    ['/products/cd-nats-2007/th/20070426-72dpi-0004.jpg', ''],
    ['/products/cd-nats-2007/th/20070426-72dpi-0005.jpg', ''],
    ['/products/cd-nats-2007/th/20070426-72dpi-0022.jpg', ''],
    ['/products/cd-nats-2007/th/20070426-72dpi-0044.jpg', ''],
    ['/products/cd-nats-2007/th/20070426-72dpi-0045.jpg', ''],
    ['/products/cd-nats-2007/th/20070426-72dpi-0066.jpg', ''],
    ['/products/cd-nats-2007/th/20070426-72dpi-0095.jpg', ''],
    ['/products/cd-nats-2007/th/20070426-72dpi-0112.jpg', ''],
    ['/products/cd-nats-2007/th/20070426-72dpi-0120.jpg', ''],
    ['/products/cd-nats-2007/th/20070426-72dpi-0126.jpg', ''],
    ['/products/cd-nats-2007/th/20070426-72dpi-0131.jpg', ''],
    ['/products/cd-nats-2007/th/20070426-72dpi-0149.jpg', ''],
    ['/products/cd-nats-2007/th/20070426-72dpi-0158.jpg', ''],
    ['/products/cd-nats-2007/th/20070426-72dpi-0159.jpg', ''],
    ['/products/cd-nats-2007/th/20070426-72dpi-0164.jpg', ''],
    ['/products/cd-nats-2007/th/cd-cover.jpg', 'CD Cover']
];

var img, count = 1;

function startSlideshow()
{
  img = document.getElementById('slideshow');
  window.setTimeout('cueNextSlide()', timer * 1000);
}

function cueNextSlide()
{
  var next = new Image;

  next.onerror = function()
  {
    alert('Failed to load next image');
  };

  next.onload = function()
  {
    if (document.all){
       img.style.filter="blendTrans(duration=2)"
       img.style.filter="blendTrans(duration=crossFadeDuration)"
       img.filters.blendTrans.Apply()      
    }
    img.src = next.src;

    if (document.all){
       img.filters.blendTrans.Play()
    }

    img.alt = banners[count][1];

    img.width = next.width;
    img.height = next.height;
    ++count;
    if (document.all){
      if (count >= (banners.length - 1)) { count = 0; }
    } else {
      if (count >= banners.length) { count = 0; }
    }  

    window.setTimeout('cueNextSlide()', timer * 1000);
  };

  next.src = banners[count][0];
}

addLoadListener(startSlideshow);

function addLoadListener(fn)
{
  if (typeof window.addEventListener != 'undefined')
  {
    window.addEventListener('load', fn, false);
  }
  else if (typeof document.addEventListener != 'undefined')
  {
    document.addEventListener('load', fn, false);
  }
  else if (typeof window.attachEvent != 'undefined')
  {
    window.attachEvent('onload', fn);
  }
  else
  {
    var oldfn = window.onload;
    if (typeof window.onload != 'function')
    {
      window.onload = fn;
    }
    else
    {
      window.onload = function()
      {
        oldfn();
        fn();
      };
    }
  }
}
