// --------------------------------------------------------------
// GALLERY (HTML) v0.2 : by James Hartcher
// Copyright © 2008 Internet Design Studios, All Rights Reserved
// --------------------------------------------------------------


// Declare Variables
var PhotoCurrent = 0;
var PhotoInterval = null;
var PhotoFolder = null;
var Photos = new Array();
var Descriptions = new Array();

// Change Image (Method)
function ChangeImage(id) {

	// Deactive Old Photo
	document.getElementById('GalleryPhoto_'+PhotoCurrent).className = 'Option';

	// Change Photo
	document.getElementById('GalleryPhoto').src = '../Gallery/Image.asp?Type=Preview&Folder=' + PhotoFolder + '&FileName=' + Photos[id];;
	document.getElementById('GalleryPhoto_'+id).className = 'Current';

	// Change Description
	document.getElementById('GalleryPhoto_Description').innerHTML = Descriptions[id];

	// Remember Photo
	PhotoCurrent = id;

}

function ToggleSlideShow() {
	if (PhotoInterval == null) {
		SlideShow();
		document.getElementById('SlideShowControl').innerHTML = '<img src="../gallery/images/stop-btn.gif" width="83" height="11" border="0" />';
	} else {
		clearTimeout(PhotoInterval);
		PhotoInterval = null;
		document.getElementById('SlideShowControl').innerHTML = '<img src="../gallery/images/play-btn.gif" width="83" height="11" border="0" />';
	}
}

function SlideShow() {
	if (PhotoInterval != null) { NextImage() };
	PhotoInterval = setTimeout('SlideShow()',2500);
}

function NextImage() {
	PhotoID = PhotoCurrent + 1;
	if (PhotoID >= Photos.length) {
		PhotoID = 1;
	}
	ChangeImage(PhotoID);
}

function PrevImage() {
	PhotoID = PhotoCurrent - 1;
	if (PhotoID < 1) {
		PhotoID = Photos.length - 1;
	}
	ChangeImage(PhotoID);
}
