

Scrollable2 = Class.create();
Object.extend(Scrollable2.prototype, {
	  initialize: function(element,options) {
		this.element = $(element);
		this.position=0;
		this.rightSlidePE=null;
		this.downSlidePE=null;
		
		
		var orig_style = {	
							overflow:this.element.getStyle("overflow"),
							width:this.element.getStyle("width")
						 };
		this.element.setStyle({overflow:"",width:""});
		
		this.full_width=this.element.getDimensions().width;							
		this.element.setStyle(orig_style);
		
		this.options = Object.extend({
			speed:0.02
			
		}, arguments[1] || {});

	  },
	  startUp: function(porps){
		this.notify("startUp");
		this.stopDown();
		this.rightSlidePE=new PeriodicalExecuter(function(pe) {
			this.element.scrollLeft-=4;

			if(this.element.offsetWidth<this.full_width){
				if(this.element.scrollLeft>0){
					this.notify("scrollingUp");
					
				}else{
					this.notify("endScrollingUp");
					this.stopUp();
				}
			}
		}.bind(this), this.options.speed);
	  },
	  stopUp: function(){
		this.notify("stopRight");
		if(this.rightSlidePE!=null) this.rightSlidePE.stop();
	  },
	  startDown: function(props){
		 
		this.notify("startDown");
		this.stopUp();
		
		this.downSlidePE=new PeriodicalExecuter(function(pe) {
			this.element.scrollLeft+=4;
			
			if(this.element.offsetWidth<this.full_width){
				
				if(this.full_width-this.element.offsetWidth>this.element.scrollLeft){
					this.notify("scrollingDown");
					
				}else{
					this.notify("endScrollingDown");
					this.stopDown();
				}
				
			}
		}.bind(this), this.options.speed);
	  },
	  stopDown: function(){
		this.notify("stopDown");
		if(this.downSlidePE!=null) this.downSlidePE.stop();
	  }
  }
 );
//this.notify("afterAdded");
Object.Event.extend(Scrollable2);