/**
 * @author luq <luq_10@o2.pl>
 */
 
var ImageScroll = new Class({
	config: {},
	speed: 2,
	
	/**
	 * @param hash $config
	 *		.elem hash of DOM elements
	 *		.speed int [optional]
	 */
	initialize: function(config){
	
		this.config = config;
		if(config.speed){
			this.speed = config.speed;
		}				
		this.scroller();
	},
	
	scroller: function(){
		var actScroll = this.config.elem.scrollLeft;
		this.config.elem.scrollLeft += this.speed;
		
		if(this.config.elem.scrollLeft == actScroll){
			var first = this.config.elem.getElement('ul li');
			var width = first.getElement('img').getStyle('width').toInt() - this.speed;
			
			this.config.elem.getElement('ul').adopt(first.clone());
			first.destroy();
			
			this.config.elem.scrollLeft -= width;
		}
			
		setTimeout(function(){
			this.scroller();
		}.bind(this),30);
	},
});
