function newsScroller()
{
	return {
		
		currentObject: 0,
		previousObject: 0,
		fadeTime: 200,
		
		bouncing: false,
		
		objectsCount: 0,
		objectsBlockWidth: 0,
		centerOfObjectsBlock: 0,
		
		imageChanging: false,
		lastImage: -1,
		
		initialize: function( generalObjects, left, right )
		{
			this.generalObjects = $( generalObjects );
			this.left = $( left );
			this.right = $( right );
			
			this.getCount();
			if( this.objectsCount > 0 )
			{
				this.addEvents();
			
				this.update();
			}
		},
		
		getCount: function()
		{
			this.objectsCount = this.generalObjects.length;
			//$( 'span.pages span.total_pages' ).text( this.objectsCount );
		},
		
		update: function()
		{
			if( this.currentObject == 0 )
			{
				$( this.left ).parent().hide();
			}
			else
			{
				$( this.left ).parent().show();
			}
			if( this.currentObject == ( this.objectsCount -1 ) )
			{
				$( this.right ).parent().hide();
			}
			else
			{
				$( this.right ).parent().show();
			}
			this.updateGeneralObject();
			//$( 'span.pages span.page_number' ).text( this.currentObject + 1 );
			this.previousObject = this.currentObject;
		},
		
		updateGeneralObject: function()
		{
			ths = this;
			var top = $( ths.generalObjects[ths.currentObject] ).height();
			if( parseInt( top ) == 0 )
			{
				top = 315;
			}
			$( this.generalObjects[this.previousObject] ).fadeOut( 200 );
			$( this.generalObjects[this.currentObject] ).parent().find( 'a.previous' ).animate( { 'top': ( top / 2 ) - 19 }, 200 );
			$( this.generalObjects[this.currentObject] ).parent().find( 'a.next' ).animate( { 'top': ( top / 2 ) - 19 }, 200 );
			$( this.generalObjects[this.previousObject] ).parent().animate( { 'height': top }, 200 );
			$( this.generalObjects[this.currentObject] ).fadeIn( 200 );
			$( 'div.images_info span.images_info' ).fadeOut( 50,
				function()
				{
					//$( this ).text( $( ths.generalObjects[ths.currentObject] ).children( 'span.caption' ).text() );
					//$( this ).fadeIn( 150 );
				}
			);
		},
		
		addEvents: function()
		{
			var ths = this;
			$( this.left ).click(
				function( event )
				{
					ths.previousObject = ths.currentObject;
					ths.currentObject = ths.currentObject - 1;
					if( ths.currentObject < 0 )
					{
						ths.currentObject = 0;
					}
					else
					{
						ths.update();
					}
					return false;
				}
			);
			
			$( this.right ).click(
				function( event )
				{
					ths.previousObject = ths.currentObject;
					ths.currentObject = ths.currentObject + 1;
					if( ths.currentObject == ths.objectsCount )
					{
						ths.currentObject = ths.objectsCount - 1;
					}
					else
					{
						ths.update();
					}
					return false;
				}
			);
		}
		
	}
}

