function FPRotator( sId, sSelectedClass, iDelay ){
	this.sId = sId;
	this.aItems = new Array();
	this.iCurrent = 0;
	this.isRunning = false;
	this.sSelectedClass = sSelectedClass;
	this.iDelay = iDelay;
}

FPRotator.prototype.add = function( sId ){
	this.aItems.push( sId );
}

FPRotator.prototype.start = function(){

	this.isRunning = true;
	var _owner = this;
	this.timeout=setTimeout( function(){fp_rotate(_owner)} , _owner.iDelay);

}

FPRotator.prototype.stop = function(){

	clearTimeout( this.timeout );
	this.isRunning = false;

}

FPRotator.prototype.show = function( iCurrent ){


	if ( iCurrent<0 || ( iCurrent>=this.aItems.length) ) iCurrent = 0;

	_item = document.getElementById( this.aItems[this.iCurrent] );
	if ( null != _item ){
		_item.style.display = 'none';
	}
	_item_index = document.getElementById( this.aItems[this.iCurrent] + '_index' );
	if ( null != _item_index ){
		_item_index.className='';
	}

	_item = document.getElementById( this.aItems[iCurrent ] );
	if ( null != _item ){
		_item.style.display = 'block';
	}
	_item_index = document.getElementById( this.aItems[iCurrent] + '_index' );
	if ( null != _item_index ){
		_item_index.className='selected';
	}
	this.iCurrent = iCurrent;

}

FPRotator.prototype.go = function( iCurrent ){

	this.show( iCurrent );
	this.stop();

}

function fp_rotate( _owner ){

	if ( !_owner.isRunning ) return;

	$iNewCurrent = _owner.iCurrent+1;
	if ( $iNewCurrent == _owner.aItems.length ) $iNewCurrent = 0;

	_owner.show( $iNewCurrent );

	clearTimeout( _owner.timeout );
	_owner.timeout=setTimeout( function(){fp_rotate(_owner)} , _owner.iDelay );

}