
// misschien is deze beter (2, origineel 3 images slideshow)
// JavaScript Document van http://www.donkeymagic.co.uk/slideshow/index2.htm

//GENERIC ADDLOAD EVENT FUNCTION
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}




var images = new Array('http://www.ncso.nl/slides/apeldoorn2010A.jpg','http://www.ncso.nl/slides/apeldoorn2010B.jpg','http://www.ncso.nl/slides/apeldoorn2010C.jpg','http://www.ncso.nl/slides/apeldoorn2010D.jpg');
var alttext = new Array('Orkest-plaatjes','Orkest-plaatjes','Orkest-plaatjes','Orkest-plaatjes');

var currentIndex = 0;
var timeOut = 40000;

function startSlideshow() {
    if (!document.getElementsByTagName || !document.getElementById) {
        return false;
    }
    counter();
}

function counter() { 
    if (currentIndex >= images.length) {
        currentIndex = 0;
    }
    if ( currentIndex == 0 && images.length == 1 ) {
        swapImage(0);
    } else {
        var count = currentIndex++;
        swapImage(count,'slideshow','images','alttext');

        window.setTimeout("counter()",timeOut);
    }       
}   

function swapImage(index,target,imglist,altlist) {
    var target = document.getElementById(target);
    var currentsrc =    target.getAttribute('src');
    var imglist = eval(imglist);
    var altlist = eval(altlist);
    var newSrc = imglist[index];
    //if nextimage is different
    if (currentsrc != newSrc) {
        //Change src to swap image
        target.setAttribute('src',newSrc);
        //Change alt text of the image
        target.setAttribute('alt',altlist[index]);
    }
}

addLoadEvent(startSlideshow);
