//Image rotator
var rotatorInst;

function imageRotator( imgObj,imgsArr, callbackFunc, interval){
	this.imgObj = imgObj;
	this.imgsArr = imgsArr;
	this.callback = callbackFunc;
	this.interval = interval;
	
	this.currentImageIndex = 0;
	
	rotatorInst = this;
	
	this.start();
}
imageRotator.prototype.start = function(){
	this.intervalId = window.setInterval(rotator_changeImg, this.interval )
}
function rotator_changeImg(){
	
	rotatorInst.currentImageIndex++;
	if(rotatorInst.currentImageIndex >= rotatorInst.imgsArr.length)
		rotatorInst.currentImageIndex = 0;
		
	//alert(rotatorInst.currentImageIndex);
	
	if(rotatorInst.imgObj.filters)
		rotatorInst.imgObj.filters.item(0).apply();
	rotatorInst.imgObj.src = rotatorInst.imgsArr[rotatorInst.currentImageIndex].image.src;
	if(rotatorInst.imgObj.filters)
		rotatorInst.imgObj.filters.item(0).play();
	
	rotatorInst.callback(rotatorInst.imgsArr[rotatorInst.currentImageIndex]);
}