var ItemRotator = Class.create({
	data: null,
	speed: 8,
	current: 0,
	rotate: true,
	rand: false,
	container: '.banner-table',
	selector: '.banner-table tbody tr',
	initialize: function(){
		//if(!$('adminbar'))
			this.getImages();
	},
	getImages: function(){
		$$(this.container)[0].hide();
		//$$(this.container)[0].style.position='relative';
		this.data = $$(this.selector);
		this.data.each( function(image,index){ 
			image.id = 'item_'+index;
			//image.style.position='absolute';
			//if( index!= 0 )
			image.hide();
		});
		if(this.rand)
			this.setRandomImage();
		if(this.rotate)
			setTimeout('ItemRotate.showNext()',this.speed*1000);
		$$(this.container)[0].show();
	},
	setRandomImage: function(){
		var randnum = Math.floor(Math.random()*(this.data.length));
		this.current=randnum;
		$('item_'+randnum).show();
	},
	showNext: function(){
		Effect.Fade('item_'+this.current)
		if( this.current >= ($$(this.selector).length-1) ){
			this.current = 0;
		}else{
			++this.current;
		}
		Effect.Appear('item_'+this.current);
		setTimeout('ItemRotate.showNext()',this.speed*1000);
	}
});

document.observe('dom:loaded',function(){ ItemRotate = new ItemRotator(); });