
function smwJSSlideshow(displayRef, imagesPath, statusImage) {
	// set props
	this.displayRef = displayRef;
	this.imagesPath = imagesPath;
	this.statusImage = statusImage;
	this.galleryID = null;
	this.galleryAry = null;
	this.selectedID = 0;

	// set methods
	this.prevImage = smwJSSlideshow_prevImage;
	this.nextImage = smwJSSlideshow_nextImage;
	this.selectGallery = smwJSSlideshow_selectGallery;
	this.showImage = smwJSSlideshow_showImage;
	this.loadSlides = smwJSSlideshow_loadSlides;
}

function smwJSSlideshow_prevImage() {
	if(this.galleryAry != null && this.galleryAry[this.galleryID].length > 1) {
		if(this.selectedID > 0) {
			this.selectedID--;
			this.showImage(this.selectedID);
		} else {	
			this.selectedID = this.galleryAry[this.galleryID].length-1;
			this.showImage(this.selectedID);
		}
	}
}

function smwJSSlideshow_nextImage() {
	if(this.galleryAry != null && this.galleryAry[this.galleryID].length > 1) {
		if(this.selectedID < this.galleryAry[this.galleryID].length-1) {
			this.selectedID++;
			this.showImage(this.selectedID);
		} else {
			this.selectedID = 0;
			this.showImage(this.selectedID);
		}
	}
}

function smwJSSlideshow_selectGallery(galleryID) {
	this.galleryID = galleryID;
	
	if(this.displayRef != null && this.displayRef != "") {
		if(this.galleryAry != null && this.galleryAry[this.galleryID].length > 0) {
			this.showImage(0);
		}
	}
}

function smwJSSlideshow_showImage(imageID) {
	if(this.statusImage != null) {
		this.displayRef.src = this.imagesPath + this.statusImage;
	}

	this.displayRef.src = this.imagesPath + this.galleryAry[this.galleryID][imageID];
}

function smwJSSlideshow_loadSlides(galleryID, imagesAry) {
	if(this.galleryAry == null) {
		this.galleryAry = new Array();
	}

	this.galleryAry[galleryID] = imagesAry;
}
