document.addEvent('domready', function(){
	Element.implement({
	    resetFormValue : function(){
	    	if(this.get('tag')=='form'){
	    		this.getElements('input[type="text"],textarea').resetFormValue();
	    		return this;
	    	}
	        var def_value = this.get('value');
	        this.addEvents({
	            'focus':function(){
	                var cur_value = this.get('value');
	                if(cur_value == def_value) {
	                    this.set('value', '');
	                }
	            },
	            'blur':function(){
	                var cur_value = this.getProperty('value');
	                if(cur_value == '') {
	                    this.set('value', def_value);
	                }
	            }
	        });
	        return this;
	    }
	});	
});

var Scroller = new Class({
    Implements: [Chain, Events, Options],
    options:{
        scrollClass:'.scroll',
        scrollContainer:'.scroll-container'
    },
    initialize:function(options){
        this.setOptions(options);
        
        this.scrolls = $$(this.options.scrollClass);
        
        var doScroll = null
        this.startScroll();
        
       // $('managers-specials').addEvent('mousein',this.stopScroll());
        //$('managers-specials').addEvent('mouseout',this.startScroll());
     
    },
    
    moveLeft:function(){
		
		el=$$('.scroll')[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);
		*/
		
		
		$$('.scroll').setStyle('margin-left',0);
		var w = $$('.scroll')[0].offsetWidth;
		var myFx = new Fx.Tween(el, {property: 'margin-left',duration:3000});
		myFx.start(w * -1).chain(
			//Notice that "this" refers to the calling object (in this case, the myFx object).
			function(){ 
				first = $$('.scroll')[0];
				$$('.scroll')[0].inject($('scroller-window'),'bottom');//this.options.scrollContainer,'bottom');
				first.style.marginLeft = '0px';							 
			}		
		);	
		
		
    },
    
    startScroll:function(){		
		this.doScroll = this.moveLeft.periodical(3100);
		//console.log('start scroller' + this.doScroll);
    },
        
    stopScroll:function(){
		//console.log('stop scroller - ' + this.doScroll);
		this.doScroll = null;
    }
});