// slideshow.js

// timer for images (in seconds)
var timer = 5;


// array of images
var images = [
  ['../images/images/slideshow/michael_nametag','michael'],
  ['../images/images/slideshow/will_nametag','will'],
  ['../images/images/slideshow/adam_nametag','adam'],
  ['../images/images/slideshow/ulf_nametag','ulf']
];

var img, count = 1;

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


function cueNextSlide()
{
  var next = new Image();
  
  next.onerror = function()
  {
    alert('Unable to load next image');
  };
  
  next.onload = function()
  {
    img.src = next.src;
    img.alt = images[count][1];
    img.width = next.width;
    img.height = next.height;
    
    if (++count == images.length)
    {
      count = 0;
    }
    
    window.setTimeout('cueNextSlide()', timer * 1000);
  };
  
  next.src = '../slideshow/' + images[count][0] + '.jpg';;
}

addLoadEvent(startSlideshow);

