var slideshow = new Array();
var buffer = new Image;
var timeId = null;

function nextTimedSlide () {
    if (action == "play") {
        counter++;
        if (counter >= slideshow.length) {
            counter = 0;
        }
        preloadSlide (counter);x
        timeId = setTimeout ("displayBuffer("+counter+")", timeout);
    }
}
function nextSlide () {
    if (action == "play") {
        counter++;
        if (counter >= slideshow.length) {
            counter = 0;
        }
        loadSlide (counter);
        clearTimeout (timeId);
    }
}
function loadSlide (slideNum) {
    if (action == "play") {
        document.getElementById("slide").src = slideshow[slideNum]['file'];
        document.getElementById("slideDescription").innerHTML = slideshow[slideNum]['description'];
        document.getElementById("slideName").innerHTML = slideshow[slideNum]['name'];
    }
}
function displayBuffer (slideNum) {
    if (action == "play") {
        document.getElementById("slide").src = buffer.src;
        document.getElementById("slideName").innerHTML = slideshow[slideNum]['name'];
        document.getElementById("slideDescription").innerHTML = slideshow[slideNum]['description'];
    }
}
function stopSlideshow () {
    if (action != "stop") {
        loadSlide (begin);
        action = "stop";
        counter = begin;
        clearTimeout (timeId);
    }
}
function pauseSlideshow () {
    if (action == "play") {
        action = "pause";
        clearTimeout (timeId);
    }
}
function playSlideshow () {
    if (action != "play") {
        action = "play";
        nextSlide ();
    }
}
function preloadSlide (slideNum) {
    buffer.src = slideshow[slideNum]['file'];
}
function slideGetUrl () {
    window.location = slideshow[counter-1]['url'];
}
function slidechange (num) {
	begin = 0;
    loadSlide (num);
}
