var iSum;
if(!iSum) iSum = {};

iSum.imageRotator = function(imgArr,srcImg)
{
	this.interval = 1000;
	this.random_display = 0;
	this.image_index=0;
	if(imgArr)
		this.image_list = imgArr;
	else
		this.image_list = new Array();
	this.number_of_image = this.image_list.length;
	if(typeof srcImg == 'string')
		this.image  = document.getElementById(srcImg);
	else
		this.image=srcImg;
};

iSum.imageRotator.generate = function(x,y) {
	var range = y - x + 1;
	return Math.floor(Math.random() * range) + x;
};
iSum.imageRotator.prototype.getNextImage = function() {
	if (this.random_display) {
		this.image_index = iSum.imageRotator.generate(0, this.number_of_image-1);
	}
	else {
		this.image_index = (this.image_index+1) % this.number_of_image;
	}
	var new_image = this.image_list[this.image_index];
	return(new_image);
};
iSum.imageRotator.prototype.rotateImage = function() {
	var _self = this;
	var new_image = this.getNextImage();
	this.image.src = new_image;
	setTimeout(function(){_self.rotateImage()}, this.interval);
};

