var motsanime = Class.create();
motsanime.prototype = {
	initialize : function(sstbl) {
		this.numCourant = 0;
		this.freq = 3;
		this.tblmots = sstbl;
		this.sortis = new Array();
	},
	animate : function() {
		//this.counter = this.counter ? this.counter + 1 : 1;
		var posX = 15 + Math.floor(Math.random() * 50);
		var posY = 5 + Math.floor(Math.random() * 45);
		var fsize = 18 + Math.floor(Math.random() * 10);
		this.tblmots[this.numCourant].setStyle( {
			top : posY + "px",
			left : posX + "px",
			fontSize : fsize + "px"
		});
	
		new Effect.Appear(this.tblmots[this.numCourant], {
			queue : {
				position : 'end',
				scope : 'top'
			}
		});
		new Effect.Fade(this.tblmots[this.numCourant], {
			queue : {
				position : 'end',
				scope : 'top'
			},
			duration : 1,
			from : 1,
			to : 1
		});
		new Effect.Fade(this.tblmots[this.numCourant], {
			queue : {
				position : 'end',
				scope : 'top'
			},
			duration : 1,
			from : 1,
			to : 0
		});
		//this.tblmots[alea].pulsate( { pulses: 1, duration: 1.5 });
		posX = 15 + Math.floor(Math.random() * 50);
		posY = 40 + Math.floor(Math.random() * 45);
		fsize = 18 + Math.floor(Math.random() * 10);
		this.tblmots[this.numCourant+1].setStyle( {
			top : posY + "px",
			left : posX + "px",
			fontSize : fsize + "px"
		});
	
		new Effect.Appear(this.tblmots[this.numCourant+1], {
			queue : {
				position : 'end',
				scope : 'mid'
			}
		});
		new Effect.Fade(this.tblmots[this.numCourant+1], {
			queue : {
				position : 'end',
				scope : 'mid'
			},
			duration : 1,
			from : 1,
			to : 1
		});
		new Effect.Fade(this.tblmots[this.numCourant+1], {
			queue : {
				position : 'end',
				scope : 'mid'
			},
			duration : 1,
			from : 1,
			to : 0
		});
		
		posX = 15 + Math.floor(Math.random() * 50);
		posY = 75 + Math.floor(Math.random() * 45);
		fsize = 18 + Math.floor(Math.random() * 10);
		this.tblmots[this.numCourant+2].setStyle( {
			top : posY + "px",
			left : posX + "px",
			fontSize : fsize + "px"
		});
	
		new Effect.Appear(this.tblmots[this.numCourant+2], {
			queue : {
				position : 'end',
				scope : 'bot'
			}
		});
		new Effect.Fade(this.tblmots[this.numCourant+2], {
			queue : {
				position : 'end',
				scope : 'bot'
			},
			duration : 1,
			from : 1,
			to : 1
		});
		new Effect.Fade(this.tblmots[this.numCourant+2], {
			queue : {
				position : 'end',
				scope : 'bot'
			},
			duration : 1,
			from : 1,
			to : 0
		});
		
		this.numCourant += 3;
		if(this.numCourant + 3 > this.tblmots.length){
			this.numCourant = 0;
		};
	}
};
function init(){
	var tableaudeselemTop = $$('#imganim .motcles');
	var mcstop = new motsanime(tableaudeselemTop);
	pe = new PeriodicalExecuter(mcstop.animate(), mcstop.freq);
	pe.callback = function () {mcstop.animate()};
}
Event.observe(window, 'load', init);
