
function CheckBrowser()
{
  var a, b, v, NS, NS4, NS5, NS6, IE, IE4, IE5, IE6, MIN, WIN32;
  a = navigator.platform;
  this.a = a;
  b = navigator.appName ;
  if(b == "Netscape")
    this.b = "NS";
  else if(b == "Microsoft Internet Explorer")
    this.b = "IE";
  else this.b = b;
  this.v = parseInt(navigator.appVersion);
  this.NS = (this.b == "NS" && this.v >=4);
  this.NS4 = (this.b == "NS" && this.v ==4);
  this.NS5 = (this.b == "NS" && this.v ==5);
  this.NS6 = (this.b == "NS" && this.v >=5);
  this.IE = (this.b == "IE" && this.v >=4);
  this.IE4 = (navigator.userAgent.indexOf('MSIE 4')>0);
  this.IE5 = (navigator.userAgent.indexOf('MSIE 5')>0)||(navigator.userAgent.indexOf('MSIE 6')>0);
  this.IE6 = (navigator.userAgent.indexOf('MSIE 6')>0);
  this.MIN = (this.NS || this.IE);
  this.WIN32 = (a == "Win32");
  this.MAC = (a.indexOf("Mac") >= 0);
}



var _SlideShowObjects;
_SlideShowObjects = new Array();

function SlideShow(imageId, timer)
{
	var isBrowser;
	var imageId;
	var _images;
	var timer;
	var _timeout;
	var _ssoIndex;
	var currIndex;
	var displayType;
	var RANDOM;
	var FORWARD;
	var REVERSE;

	var AttachImage;
	var Play;
	var Next;
	var Back;
	var Stop;
	var Random;

	this.isBrowser = new CheckBrowser();
	this.RANDOM = 0;	
	this.FORWARD = 1;
	this.REVERSE = 2;

	this.imageId = imageId;
	this.timer = timer;
	this.displayType = displayType;
	this._images = new Array();
	this.currIndex = 0;

	this.AttachImage = SlideShow_AttachImage;
	this.Play = SlideShow_Play;
	this.Next = SlideShow_Next;
	this.Back = SlideShow_Back;
	this.Stop = SlideShow_Stop;
	this.Random = SlideShow_Random;
	
	this._ssoIndex = _SlideShowObjects.length;
	_SlideShowObjects[_SlideShowObjects.length] = this;
}

function SlideShow_AttachImage(imageSrc)
{
	this._images[this._images.length] = new Image();
	this._images[this._images.length - 1].src = imageSrc;
}

function SlideShow_Play(type)
{
	switch(type)
	{
		case this.RANDOM:
			this.Random();
			break;
		case this.REVERSE:
			this.Back();
			break;
		default:
			this.Next();
			break;
	}
	this._timeout = window.setTimeout("_SlideShowObjects[" + this._ssoIndex + "].Play(" + type + ");", this.timer);
}

function SlideShow_Stop()
{
	window.clearTimeout(this._timeout);
}

function SlideShow_Next()
{
	if(this._images.length == 0)
		return;
	if(this.currIndex >= this._images.length)
		this.currIndex = 0;
	if(this.isBrowser.IE && document.images[this.imageId].filters[0])
		document.images[this.imageId].filters[0].Apply();
	if(document.images[this.imageId])
		document.images[this.imageId].src = this._images[this.currIndex].src;
	if(this.isBrowser.IE && document.images[this.imageId].filters[0])
		document.images[this.imageId].filters[0].Play()
	this.currIndex++;
}

function SlideShow_Back()
{
	if(this._images.length == 0)
		return;
	if(this.currIndex < 0)
		this.currIndex = this._images.length - 1;
	if(this.isBrowser.IE && document.images[this.imageId].filters[0])
		document.images[this.imageId].filters[0].Apply();
	if(document.images[this.imageId])
		document.images[this.imageId].src = this._images[this.currIndex].src;
	if(this.isBrowser.IE && document.images[this.imageId].filters[0])
		document.images[this.imageId].filters[0].Play()
	this.currIndex--;	
}

function SlideShow_Random()
{
	var num;
	num = parseInt(Math.random() * 100) % this._images.length;
	document.images[this.imageId].filters[0].Apply();
	if(this.isBrowser.IE && document.images[this.imageId].filters[0])
		document.images[this.imageId].filters[0].Apply();
	if(document.images[this.imageId])
		document.images[this.imageId].src = this._images[this.currIndex].src;
	if(this.isBrowser.IE && document.images[this.imageId].filters[0])
		document.images[this.imageId].filters[0].Play()
}