var images = [];
var currentImage = 0;
var display;

function initSlideshow () {
	display = $('#slideshow-display')[0];
	$('#slideshow-display').load(nextImage);
	var date = new Date(); // grabbing the date as of this second it gets run
$.ajax({
   type: "GET",
   url: "images/slideshow/imagelist.php?_="+date.getTime(), //add the time stamp and specified format to the end
   dataType: "json",
   cache: false,
   contentType: "application/json",
   success: function(data) {
     images = data;
	 showImage();
   },
   error: function(xhr, status, error) {
     alert(xhr.status);
   }
});
}

function nextImage () {
	setTimeout("showImage();", 2000);
}

function showImage () {
	if (currentImage === images.length) {
		currentImage = 0;
	}
	if (images[currentImage] != null) {
		display.src = 'images/slideshow/' + images[currentImage];
	}
	currentImage += 1;
};

