
// autoplay on or off by default (on == true)
var autoPlayOn = true;

// delay (in milliseconds) for autoplay transition
var autoPlayDelay = 7000;

// this function will be called by the "timeouts" we
// create to automatically advance the slideshow
function advanceSlideshow() {

     if (autoPlayOn == true) {
          // code to advance to next slide
          // (hopefully the below two lines of code are what is needed)
          var myPhoto = new Slideshow(photoId);
          myPhoto.nextPhoto();
          // create a new Timeout for the next advanceSlideshow() call
          myTimeout1 = setTimeout(advanceSlideshow, autoPlayDelay);
     } else {
          //kill the timeoute
          clearTimeout(myTimeout1);
     }

}

// this function will be used to turn autoplay on and off
// this is sort of like a combined start/stop function
function toggleAutoPlay() {

     if (autoPlayOn == true) {
			document.getElementById('autoplaytoggle').innerHTML="Autoplay: Uit";
          //kill the currently executing timeout
          clearTimeout(myTimeout1);
          //toggle the "autoPlayOn" boolean
          autoPlayOn = false;
     } else {
			document.getElementById('autoplaytoggle').innerHTML="Autoplay: Aan";
          autoPlayOn = true;
          myTimeOut1 = setTimeout(advanceSlideshow, autoPlayDelay);
     }

}

// create a new "timeOut" to get the autoplay started
// this will execute "advanceSlideshow()"
// after "autoPlayDelay" milliseconds have passed.
// this could more safely be invoked on body load instead
// of just inline like this.
if (autoPlayOn == true) {
     myTimeout1 = setTimeout(advanceSlideshow, autoPlayDelay);

}
