var timer = 2.5;

var photos = [
    ['GA54S-A1--MadelinearchFPWeb', ''],
    ['CurlySnowmenFPweb', ''],
    ['GAI01S-A3-TR--AngelicTrioFPWEb', ''],
    ['GS38C1--Well-BalancedSantaFPWEb', ''],
    ['GS39S-X14--SantasportraitFPWeb', ''],
	['IngridHeadShotFPWeb', ''],
	['GS53W--SantasWarehouseFPWeb', ''],
    ['GS59W-X28--FashionPlateSantaFPWeb', ''],
    ['GS59W1--FancyPeppermintPaisleyFPWeb', ''],
    ['MN14W--PoppiesandPodsFPWeb', ''],
    ['MN15W--ButterfliesFPWeb', 'n'],
	['IngridHeadShotFPWeb', ''],
	['NA01S1-N1--ThreeWiseMenFPWeb', ''],
    ['SS64S--FroggyFlingFPWeb', ''],
    ['SS68W--This Little PiggyFPWeb', ''],
    ['SS69W--BabyShoesFPWEb', ''],
    ['SS76C--BigBotFPWeb', ''],
	['IngridHeadShotFPWeb', ''],
	['SS88W8--MerryFairiesScatterFPWeb', ''],
    ['SS89W--Rock-A-ByeBabyFPWEb', ''],
    ['SS91W--EasterDuckyScatterFPWeb', ''],
    ['WN46W--DownhillSnowmenFPWeb', ''],
    ['WN48C-W4b--SnowButtonsFPWEb', '']
];

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 = 'images/' + photos[count][0] + '.jpg';
}

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();
      };
    }
  }
}
