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

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

FPRotator.prototype.start = function(){
	this.isRunning = true;
	var _owner = this;
	this.timeout=setTimeout( function(){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='';
		if ( this.sStyle=="style1") _item_index.style.display = 'block';
	}

	_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=this.sSelectedClass;
		if ( this.sStyle=="style1") _item_index.style.display = 'none';
	}
	this.iCurrent = iCurrent;

}

FPRotator.prototype.go = function( iCurrent ){
	this.show( iCurrent );
	this.stop();
}



function 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(){rotate(_owner)} , _owner.iDelay );
}
