// JavaScript Document
function init()
{
	var r = new rObj('rot',3000);
	///r.addImages("1.jpg","2.jpg","3.jpg","4.jpg");
	var v;
	try{
		v = document.forms[0].elements['lrotimg'].value;
	}catch(e){
		v = "1.jpg,2.jpg,3.jpg,4.jpg";
	}
	if ( v == "") {
		v = "1.jpg";
	}
	r.addImages(v.split(","));
	rObj.start();
}
//rObj.imagesPath = "img/rot/"; rObjs = [];
rObj.imagesPath = "obj/"; rObjs = [];
function rObj(nm,s)
{
	this.speed=s;
	this.ctr=0;
	this.timer=0;
	this.imgObj = document.images[nm];
	this.index = rObjs.length;
	rObjs[this.index] = this;
	this.imgStr = "rObjs[" + this.index + "]";
}
rObj.prototype =
{
/*	addImages: function()
	{
		this.imgObj.imgs = [];
		for (var i=0; i<arguments.length; i++)
  		{
   			this.imgObj.imgs[i] = new Image();
   			this.imgObj.imgs[i].src = rObj.imagesPath + arguments[i];
  		}
 	}*/
	addImages: function(imgs)
	{
		this.imgObj.imgs = [];
		for (var i=0; i<imgs.length; i++)
  		{
   			this.imgObj.imgs[i] = new Image();
   			this.imgObj.imgs[i].src = rObj.imagesPath + imgs[i];
  		}
 	},
 	rotate: function()
 	{
  		if (this.ctr < this.imgObj.imgs.length-1) this.ctr++;
		else this.ctr = 0;
		if ( typeof this.imgObj.filters != "undefined" )
  		{
   			this.imgObj.style.filter = 'blendTrans(duration=1)';
   			if (this.imgObj.filters.blendTrans) this.imgObj.filters.blendTrans.Apply();
  		}
  		this.imgObj.src = this.imgObj.imgs[this.ctr].src;

  		if ( typeof this.imgObj.filters != "undefined" && this.imgObj.filters.blendTrans )
   		this.imgObj.filters.blendTrans.Play();
 	}
}

rObj.start = function()
{
	for (var i=0; i<rObjs.length; i++)
	rObjs[i].timer = setInterval(rObjs[i].imgStr + ".rotate()", rObjs[i].speed);
}
window.onload=function()
{
 init();
}