var Scroller = new Class({
    Implements: [Chain, Events, Options],
    options:{
        scrollClass:'.eventsitem',
        scrollContainer:'eventsitemcontainer'
    },
    
    initialize:function(options){
        this.setOptions(options);
        
        this.scrolls = $$('.eventsitem');
        
        this.doScroll = null;
        this.startScroll();
        
        //$('eventsslider').addEvent('mouseenter',function(){
        //                                            this.stopScroll();
        //                                         }).bind(this);
        //$('eventsslider').addEvent('mouseleave',this.startScroll());
    },
    
    //stopScroll:function(){
	//	console.log('stop scroller - ' + this.doScroll);
		//this.doScroll = null;
    //},
    
        
    startScroll:function(){		
		this.doScroll = this.moveLeft.periodical(5000);
		//console.log('start scroller' + this.doScroll);
    },
    
    moveLeft:function(){
		
		el=$$('.eventsitem')[0];//this.options.scrollClass)[0];
		
		/*
		el.set('tween',{duration:750});
		el.tween('margin-left',-200).chain(function(){
			first = $$('.scroll')[0];
			$$('.scroll')[0].inject($('scroll-window'),'bottom');//this.options.scrollContainer,'bottom');
			first.style.marginLeft = '0px';							 
		});
		
		
		(function(){
			this.inject($('scroller-window'),'bottom');//this.options.scrollContainer,'bottom');
			this.style.marginLeft = '0px';
			//console.log(this.id);
		}).delay(745,el);
		*/
		
		
		$$('.eventsitem').setStyle('margin-left',0);
		var w = $$('.eventsitem')[0].offsetWidth;
		var myFx = new Fx.Tween(el, {property: 'margin-left',duration:1500});
		myFx.start(w * -1).chain(
			//Notice that "this" refers to the calling object (in this case, the myFx object).
			function(){ 
				first = $$('.eventsitem')[0];
				$$('.eventsitem')[0].inject($('eventsitemcontainer'),'bottom');//this.options.scrollContainer,'bottom');
				first.style.marginLeft = '0px';							 
			}		
		);	
		
		
    }        

});