var Rotator = Class.create({
	data: null,
	speed: 5,
	current: 0,
	rotate: true,
	rand: false,
	container: '.introSub .element .textElement',
	selector: '.introSub .element .textElement img',
	initialize: function(){
			if( !$('adminbar') ){
				this.getImages();
			}
	},
	getImages: function(){
		$$(this.container)[0].hide();
		this.data = $$(this.selector);
		this.data.each( function(image,index){ 
			image.id = 'image_'+index;
			if( index!= 0 )
				image.hide();
		});
		if(this.rand)
			this.setRandomImage();
		if(this.rotate)
			setTimeout('ImageRotator.showNext()',this.speed*1000);
		$$(this.container)[0].show();
	},
	setRandomImage: function(){
		var randnum = Math.floor(Math.random()*(this.data.length));
		this.current=randnum;
		$('image_'+randnum).show();
	},
	showNext: function(){
		Effect.Fade('image_'+this.current)
		if( this.current >= ($$(this.selector).length-1) ){
			this.current = 0;
		}else{
			++this.current;
		}
		Effect.Appear('image_'+this.current);
		setTimeout('ImageRotator.showNext()',this.speed*1000);
	}
});

document.observe('dom:loaded',function(){ ImageRotator = new Rotator(); });