var imageShow = new Class({
			
			/* Variables section */
			containerClassName: null,
			containerIdName: null,
			container: null,
			elements: new Array(),
			actualLeft: 0,
			containerWidth: 0,
			containerHeight: 0,
			actualScene: new Array(),
			leftScroller: null,
			rightScroller: null,
			startIdx: null,
			stopIdx: null,
			desiredLength: 0,
			speed: 500,
			
			registry: new Array(),
			
			
			/* Methods section */
			/** Constructor.
			*	A class constructor
			*	@param id string show container
			* @param optional_argument string custom class name
			*/
			initialize: function ( id ) {
				this.containerIdName = id;
				this.container = $(id);
				if( arguments.length > 1 )
				{
					this.containerClassName = arguments[1];
					this.container.className = this.containerClassName;
				}
				if( arguments.length > 2 )
					this.speed = arguments[2];
				
				this.container.setStyles({
					position: 'relative',
					'z-index': '2'
				});
				
				var _images = $ES( 'div', this.containerIdName );
				_images._parent = this;
				_images.each( this.prv_addItem, this );
				
				this.prv_setScene();
			},
			
			/* Private: */
			prv_addItem: function ( imgObj, num ) {
				if( imgObj.parentNode.tagName == 'A' )
					obj = imgObj.parentNode;
				else
					obj = imgObj;
				imgObj.setStyles({
					border: '0px',
					margin: '0px;',
					padding: '0px'
				});
				var cont = new Element('div');
				cont.addClass( 'imageShowElement' );
				cont.setStyles({
					position: 'absolute',
					'z-index': '3',
					float: 'left'
				});
				//var w = obj.offsetWidth;
				var w = obj.getStyle('width').toInt();
				cont.setOpacity( 0 );
				this.elements.push( new Array( cont.adopt( obj.clone() ), w ) );
				obj.remove();
			},
			
			prv_setScene: function () {
				this.containerWidth = this.container.offsetWidth;
				this.startIdx = 0;
				if( this.elements.length > 0 )
				{
					this.elements.each( function ( obj, i ) {
						if( this.actualLeft < this.containerWidth )
						{
							var t_obj = obj[0].clone();
							this.actualScene.push( new Array( t_obj.injectInside( this.container ), obj[1] ) );
							t_obj.setStyles( { left: this.actualLeft +'px' } );
							this.actualLeft += t_obj.offsetWidth;
							t_obj.effect('opacity', {duration: this.speed, transition: Fx.Transitions.linear}).custom(0, 1);
							this.stopIdx = i;
						}
					}, this );
					
				}
				
				if( this.actualLeft >= this.containerWidth )
				{
					this.leftScroller = new Element( 'div' );
					this.leftScroller.addClass( 'imageShowLeftScroller' );
					this.leftScroller.setStyles({ position: 'absolute', left: '0px', cursor: 'pointer', 'z-index': '4' });
					this.leftScroller.setOpacity( 1 );
					this.leftScroller.injectInside( this.container );
					this.leftScroller.onmouseover = function () { this.leftScroller.setOpacity( 1 ); }.bindAsEventListener( this );
					this.leftScroller.onmouseout = function () { this.leftScroller.setOpacity( 1 ); }.bindAsEventListener( this );
					//this.leftScroller.onclick = this.prv_scrollLeft.bindAsEventListener( this );
					this.leftScroller.onclick = this.prv_scrollRight.bindAsEventListener( this );
					this.rightScroller = new Element( 'div' );
					this.rightScroller.addClass( 'imageShowRightScroller' );
					this.rightScroller.setStyles({ position: 'absolute', right: '0px', cursor: 'pointer', 'z-index': '4' });
					this.rightScroller.setOpacity( 1 );
					this.rightScroller.injectInside( this.container );
					this.rightScroller.onmouseover = function () { this.rightScroller.setOpacity( 1 ); }.bindAsEventListener( this );
					this.rightScroller.onmouseout = function () { this.rightScroller.setOpacity( 1 ); }.bindAsEventListener( this );
					//this.rightScroller.onclick = this.prv_scrollRight.bindAsEventListener( this );
					this.rightScroller.onclick = this.prv_scrollLeft.bindAsEventListener( this );
				}
				
				if( t = $('t_imageShow_tip') )
				{
					this.tipContainer = new Element( 'div' ).setStyles( { position: 'relative', height: '0px', 'z-index': '100' } ).setProperty( 'id', 'startingTipsContainer' ).injectBefore( this.container );
					this.tip = new Element( 'div' ).setStyles( { position: 'absolute', 'z-index': '5' } ).setProperty( 'id', 'startingTips' ).injectInside( this.tipContainer );
					t.addClass( 'content' ).injectInside( this.tip );
					//this.tip.effect( 'opacity', { duration: 500 } ).custom( 0, 1 );
					this.tip.isActive = true;
				}
				else
					this.tip = { isActive: false };
				
			},
			
			prv_scrollLeft: function () {
				if( this.registry.length > 0 )
					return false;
				if( this.tip.isActive )
				{
					//this.tip.effect( 'opacity', { duration: 500 } ).custom( 1, 0 );
					this.tip.setStyles( { display: 'none' } );
					this.tip.isActive = false;
				}
				
				this.actualLeft = 0;
				var c_effects = new Array();
				var n_effects = new Array();
				fe_width = this.actualScene[0][1];
				for( var i=1; i<this.actualScene.length; i++ )
				{
					var eff = new Fx.Style(
						this.actualScene[i][0],
						'left',
						{
							duration: this.speed,
							onStart: function (obj) { this.registry.push(obj); }.bind( this ),
							onComplete: function (obj) { this.registry.remove(obj); }.bind( this )
						}
					);
					c_effects.push( new Array( eff, this.actualLeft + fe_width, this.actualLeft ) );
					this.actualLeft += this.actualScene[i][1];
				}
				var nextIdx = this.stopIdx+1;
				while( this.actualLeft < this.containerWidth )
				{
					if( nextIdx >= this.elements.length )
						nextIdx = 0;
					var t_obj = this.elements[nextIdx][0].clone();
					this.actualScene.push( new Array( t_obj.injectBefore( this.leftScroller ), this.elements[nextIdx][1] ) );
					t_obj.setStyles( { left: (this.actualLeft+fe_width)+'px' } );
					var eff = new Fx.Styles(
						this.actualScene[i][0],
						{
							duration: this.speed,
							onStart: function (obj) { this.registry.push(obj); }.bind( this ),
							onComplete: function (obj) { this.registry.remove(obj); }.bind( this )
						}
					);
					n_effects.push( new Array( eff, this.actualLeft + fe_width, this.actualLeft ) );
					this.actualLeft += this.elements[nextIdx][1];
					nextIdx++;
					i++;
				}
				this.startIdx += 1;
				if( this.startIdx == this.elements.length )
					this.startIdx = 0;
				this.stopIdx = nextIdx-1;
				var fe_effect = new Fx.Styles(
					this.actualScene[0][0],
					{
						duration: this.speed,
						onStart: function (obj) { this.registry.push(obj); }.bind( this ),
						onComplete: function (obj) { this.registry.remove(obj); }.bind( this )
					}
				);
				setTimeout( this.cleanAfterScrollLeft.bind(this), 500 );
				fe_effect.custom( { 'left': [0,-1*fe_width], 'opacity': [1,0] } );
				for( var i=0; i<c_effects.length; i++ )
					c_effects[i][0].custom( c_effects[i][1], c_effects[i][2] );
				for( var i=0; i<n_effects.length; i++ )
					n_effects[i][0].custom( { 'left': [n_effects[i][1], n_effects[i][2]], 'opacity': [0, 1] } );
				
				//alert( this.startIdx + " : " + this.stopIdx );
			},
			
			prv_scrollRight: function () {
				if( this.registry.length > 0 )
					return false;
				if( this.tip.isActive )
				{
					//this.tip.effect( 'opacity', { duration: 500 } ).custom( 1, 0 );
					this.tip.setStyles( { display: 'none' } );
					this.tip.isActive = false;
				}
				
				this.startIdx--;
				if( this.startIdx < 0 )
					this.startIdx = this.elements.length - 1;
				var t_obj = this.elements[this.startIdx][0].clone();
				var t_actualScene = new Array();
				for( var i=0; i<this.actualScene.length; i++ )
					t_actualScene[i] = this.actualScene[i];
				
				this.stopIdx = this.startIdx;
				
				var fe_width = this.elements[this.startIdx][1];
				this.actualScene = new Array();
				t_obj.setStyles( { left: (-1*fe_width) + 'px' } );
				this.actualScene.push( new Array( t_obj.injectBefore( t_actualScene[0][0] ), fe_width ) );
				this.actualLeft = fe_width;
				
				var fe_effect = new Fx.Styles(
					t_obj,
					{
						duration: this.speed,
						onStart: function (obj) { this.registry.push(obj); }.bind( this ),
						onComplete: function (obj) { this.registry.remove(obj); }.bind( this )
					}
				);
				
				var c_effects = new Array();
				var n_effects = new Array();
				var n = 0;
				while( this.actualLeft < this.containerWidth )
				{
					this.actualScene.push( t_actualScene[n] );
					var eff = new Fx.Style(
						this.actualScene[n+1][0],
						'left',
						{
							duration: this.speed,
							onStart: function (obj) { this.registry.push(obj); }.bind( this ),
							onComplete: function (obj) { this.registry.remove(obj); }.bind( this )
						}
					);
					c_effects.push( new Array( eff, this.actualLeft - fe_width , this.actualLeft) );
					this.actualLeft += t_actualScene[n][1];
					this.stopIdx++;
					if( this.stopIdx == this.elements.length )
						this.stopIdx = 0;
					n++;
				}
				this.desiredLength = n;
				for( var i=n; i<t_actualScene.length; i++ )
				{
					this.actualScene.push( t_actualScene[i] );
					var eff = new Fx.Styles(
						this.actualScene[i+1][0],
						{
							duration: this.speed,
							onStart: function (obj) { this.registry.push(obj); }.bind( this ),
							onComplete: function (obj) { this.registry.remove(obj); }.bind( this )
						}
					);
					//n_effects.push( new Array( new Fx.Styles( this.actualScene[i+1][0], { duration: 500 } ), this.actualLeft - fe_width , this.actualLeft ) );
					n_effects.push( new Array( eff, this.actualLeft - fe_width , this.actualLeft ) );
					this.actualLeft += t_actualScene[i][1];
				}
				
				setTimeout( this.cleanAfterScrollRight.bind(this), this.speed );
				fe_effect.custom( { 'left': [-1*fe_width,0], 'opacity': [0,1] } );
				for( var i=0; i<c_effects.length; i++ )
					c_effects[i][0].custom( c_effects[i][1], c_effects[i][2] );
				for( var i=0; i<n_effects.length; i++ )
					n_effects[i][0].custom( { 'left': [n_effects[i][1], n_effects[i][2]], 'opacity': [1, 0] } );
			},
			
			cleanAfterScrollLeft: function () {
				this.actualScene[0][0].remove();
				this.actualScene.remove( this.actualScene[0] );
			},
			
			cleanAfterScrollRight: function () {
				if( this.registry.length > 0 )
					setTimeout( this.cleanAfterScrollRight.bind(this), 20 );
				else
				{
					n = this.actualScene.length;
					for( i=n-1; i>this.desiredLength; i-- )
					{
						this.actualScene[i][0].remove();
						this.actualScene.remove( this.actualScene[i] );
					}
				}
			}
			
		});

