/* Set configuration variables, then start the slideshow... */
function startSlideshow() {
	/* CONFIGURE SLIDESHOW OPTIONS */
	myLytebox.slideInterval		= 5000;	 // Change value (milliseconds) to increase/decrease the time between "slides"
	myLytebox.showNavigation	= false; // Set to true to display Next/Prev buttons for navigation, false to hide
	myLytebox.showClose			= true;	 // Set to true to display the Close button, false to hide
	myLytebox.showDetails		= true; // Set to true to display image details (caption, count), false to hide
	myLytebox.autoEnd			= true;  // Set to true to automatically close Lytebox after the last image is reached, false to keep open
	/* END CONFIGURATION */
	
	// Start the slideshow...
	myLytebox.myImage = new Image();
	myLytebox.myImage.src = getFirstAnchor();
	myLytebox.myImage.onload = function() {
		myLytebox.intervalID = setInterval("doSlide()", myLytebox.slideInterval);
	}
	myLytebox.start(getFirstAnchor());
	if (!myLytebox.showNavigation || !myLytebox.showClose) { hideLyteboxButtons(); }
}

/* Transition to the next available image in the slideshow, if there is one. */
function doSlide() {
	if (myLytebox.imageArray.length == myLytebox.activeImage + 1) {
		clearInterval(myLytebox.intervalID);
		if (myLytebox.autoEnd) { myLytebox.end(); }
		return;
	} else {
		myLytebox.changeImage(myLytebox.activeImage + 1);
		if (!myLytebox.showNavigation || !myLytebox.showClose) { hideLyteboxButtons(); }
	}
}

/* Return the 1st lytebox "link" on the page (starting point for slideshow) */
function getFirstAnchor() {
	var anchors = myLytebox.doc.getElementsByTagName('a');
	for (var i = 0; i < anchors.length; i++) {
		var relAttribute = String(anchors[i].getAttribute('rel'));
		if (anchors[i].getAttribute('href') && relAttribute.toLowerCase().match('lytebox')) { return anchors[i]; }
	}
}

/* Hides Next/Prev and/or Close buttons and/or Image Details, depending on user preferences */
function hideLyteboxButtons() {
	if (!myLytebox.showNavigation) {  myLytebox.doc.getElementById('hoverNav').style.display = 'none'; }
	if (!myLytebox.showClose) {  myLytebox.doc.getElementById('bottomNavClose').style.display = 'none'; }
	if (!myLytebox.showDetails) {  myLytebox.doc.getElementById('imageDetails').style.display = 'none'; }
}
