animBackgroundHelper = null;

var animBackground = Class.create();
animBackground.prototype = {
	initialize : function (element) {
		if (element != null) {
			this.images = element.getElementsByTagName('img');
			for (i=0; i < this.images.length; i++) {
				if(i != 0) {
					$(this.images[i]).setOpacity(0);
					this.images[i].style.zIndex = 2;
				}
				else {
					$(this.images[i]).setOpacity(100);
					this.images[i].style.zIndex = 3;
					this.images[i].style.display = "block";
				}
			}
			this.actual = 0;
			if(this.images.length != 1) {
				new PeriodicalExecuter(this.changeImage,4);
			}
			animBackgroundHelper = this;
		}
	},
	changeImage : function () {
		images = animBackgroundHelper.images;
		if(animBackgroundHelper.actual == images.length -1) {
			animBackgroundHelper.images[0].style.display = "block";
			animBackgroundHelper.images[animBackgroundHelper.actual].style.zIndex = 2;
			animBackgroundHelper.images[0].style.zIndex = 3;
			ex9 = new Animator({transition: Animator.makeEaseOut(3),duration: 2000});
			ex9.addSubject(new NumericalStyleSubject(animBackgroundHelper.images[animBackgroundHelper.actual], 'opacity', 1, 0));
			ex9.addSubject(new NumericalStyleSubject(animBackgroundHelper.images[0], 'opacity', 0, 1));
			ex9.play();
			animBackgroundHelper.actual = 0;
		}
		else {
			animBackgroundHelper.images[animBackgroundHelper.actual +1].style.display = "block";
			animBackgroundHelper.images[animBackgroundHelper.actual].style.zIndex = 2;
			animBackgroundHelper.images[animBackgroundHelper.actual + 1].style.zIndex = 3;
			ex9 = new Animator({transition: Animator.makeEaseOut(3),duration: 2000});
			ex9.addSubject(new NumericalStyleSubject(animBackgroundHelper.images[animBackgroundHelper.actual], 'opacity', 1, 0));
			ex9.addSubject(new NumericalStyleSubject(animBackgroundHelper.images[animBackgroundHelper.actual + 1], 'opacity', 0, 1));
			ex9.play();
			animBackgroundHelper.actual ++;
		}		
	}
}