/*  multislideshow.js

Creates an array of objects that contains the ID of an image and an array of images
to be rotated. This script supports an unlimited number of images per object and each
object does NOT need to have the same number of images.

Reference this script in the "Close HTML" of the page you wish to use it on.
*/

//time interval for swapping images (in sec.)
var timer = 2;		

//full path to directory with the images in them. Full path /DSN... 
var basedir = "../DSN/wwwresortgraphicscom/Content/Images/";

//'true' will randomize the display order of the images, 'false' will display them in order
var randomize = true; 

//'true' will rotate every image at the same time, 'false' does them 1 at a time
var groupswap = false;


//rotator = object array,  Algorithm: new objIMG("imgID",["img1","img2","imgN"])
var rotator = new Array(

new objIMG("ProdGroup1",["indexslideshow/ProdGroup1/ProdGroup1a.jpg","indexslideshow/ProdGroup1/ProdGroup1b.jpg","indexslideshow/ProdGroup1/ProdGroup1c.jpg","indexslideshow/ProdGroup1/ProdGroup1d.jpg","indexslideshow/ProdGroup1/ProdGroup1e.jpg"]),
new objIMG("ProdGroup2",["indexslideshow/ProdGroup2/ProdGroup2a.jpg","indexslideshow/ProdGroup2/ProdGroup2b.jpg","indexslideshow/ProdGroup2/ProdGroup2c.jpg","indexslideshow/ProdGroup2/ProdGroup2d.jpg"]),
new objIMG("ProdGroup3",["indexslideshow/ProdGroup3/ProdGroup3a.jpg","indexslideshow/ProdGroup3/ProdGroup3b.jpg","indexslideshow/ProdGroup3/ProdGroup3c.jpg","indexslideshow/ProdGroup3/ProdGroup3d.jpg","indexslideshow/ProdGroup3/ProdGroup3e.jpg"]),
new objIMG("ProdGroup4",["indexslideshow/ProdGroup4/ProdGroup4a.jpg","indexslideshow/ProdGroup4/ProdGroup4b.jpg","indexslideshow/ProdGroup4/ProdGroup4c.jpg"])

);


//Be sure to seperate each item in the object array with a comma (,).


//no need to edit anything below this point
var imgNum = rotator.length;
var i = 0;

function rotateIMGs()
{
	try {

		if(groupswap) {
			for(i=0; i<imgNum; i++)
				rotator[i].rotate();
		} else {
			rotator[i].rotate();
			
			if(i == (imgNum - 1)) 
				i = 0;
			else 
				i++;
		}

	} catch(e) { }
}



function objIMG(id, aryIMG)
{
	this.ID = id;
	this.aryIMG = aryIMG;
	this.curImg = 0;
	this.reset = false;
	this.nextImg = new Image();
	this.showImg = document.getElementById(id);
}

objIMG.prototype.rotate = function()
{
	if(randomize) {
		this.curImg = getRandInt(this.curImg,this.aryIMG);
	} else {
		this.curImg++;
		if(this.reset) this.curImg = 0;
	}
	
	if(document.all) {
		this.showImg.style.filter="blendTrans(duration=1)";
		this.showImg.filters.blendTrans.Apply();
		this.showImg.filters.blendTrans.Play();
	}
	
	if(this.curImg == (this.aryIMG.length - 1)) {  
		this.showImg.src = basedir + this.aryIMG[this.curImg]; 
		this.reset = true;
	} else {
		this.loadNext();
		this.showImg.src = basedir + this.aryIMG[this.curImg];
		this.reset = false;
	}

}

objIMG.prototype.loadNext = function()
{
	if(this.aryIMG.length > 1 && this.curImg > (this.aryIMG.length - 1)) {
		this.nextImg.src = this.aryIMG[this.curImg + 1];
	}
}

function getRandInt(curINT,curARY)
{
	var tmp = Math.round(Math.random()*(curARY.length - 1));
	
	if(tmp != curINT) {
		return tmp;
	} else {
		return getRandInt(curINT,curARY);
	}
}

setInterval("rotateIMGs()",timer*800);