/*
	slideshow2.js
	a subclass of the SlideShow class extending it's functions to include passing moving forward and backwards
*/

var SlideShow;

if ( !SlideShow )
	throw new Error("SlideShow class not defined!");
	
function SlideShow2(path, pics, IdTag, time)
{
	SlideShow.call(this, path, pics, IdTag, time);
}

SlideShow2.prototype = new SlideShow();
delete SlideShow2.prototype.path;
delete SlideShow2.prototype.pics;
delete SlideShow2.prototype.el;
delete SlideShow2.prototype.time;

SlideShow2.prototype.constructor = SlideShow2;

SlideShow2.prototype.toString = function()
{
	return this.SlideShow.prototype.toString.apply(this);
}

SlideShow2.prototype.pause = function()
{
	if ( this.timer != null )
	{
		clearInterval(this.timer);
		this.timer = null;
	}
}

SlideShow2.prototype.restart = function()
{
	if ( this.timer == null )
	{
		var obj = this;
		var doChange = function() { obj.changeImage.call(obj); };
		
		this.changeImage();
		this.timer = setInterval(doChange, this.time);	
	}
}

SlideShow2.prototype.changeImageBack = function()
{
	this.ref--;
	
	if ( this.ref == -1 )
		this.ref = this.pics.length - 1;

	this.el.src = this.path + this.pics[this.ref];
}
