var timer = 3;

var photos = [
    ['Movers-1-350', 'A view of the cliffs '],
    ['Movers-2-350', 'A full-moon shining over the sea'],
    ['Movers-3-350', 'A barren, desert landscape with very few trees'],
    ['Movers-4-350', 'A barren, desert landscape with very few trees'],
    ['Movers-5-350', 'A view of the cliffs '],
    ['Movers-6-350', 'A view of the cliffs '],
    ['Movers-7-350', 'A view of the cliffs '],
    ['Movers-8-350', 'A barren, desert landscape with very few trees'],
    ['Movers-9-350', 'A view of the cliffs '],
    ['Movers-10-350', 'A view of the cliffs '],
    ['Movers-11-350', 'A view of the cliffs ']

];

var img, count = 1;

function startSlideshow()
{
  img = document.getElementById('photo');
  window.setTimeout('cueNextSlide()', timer * 1000);
}

function cueNextSlide()
{
  var next = new Image;

  next.onerror = function()
  {
    alert('Failed to load next image');
  };

  next.onload = function()
  {
    img.src = next.src;
    img.alt = photos[count][1];

    img.width = next.width;
    img.height = next.height;

    if (++count == photos.length) { count = 0; }

    window.setTimeout('cueNextSlide()', timer * 1000);
  };

  next.src = 'photos/' + photos[count][0] + '.gif';
}

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();
      };
    }
  }
}

