var upAndDown2 = new Class({        
        Implements: [Events, Options],  
        options: {
          containerHeight: 245
        },
        initialize: function(container){
          var params = Array.link(arguments, {'options': Object.type, 'element': $defined});
          this.setOptions(params.options || { });
          this.container = $$(container);          
          this.size = this.container.getParent()[0].getScrollSize();
          this.height = this.container.getParent()[0].getSize();
          this.initItems();
        },
        initItems: function(){
          this.upButton = this.container.getParent().getParent().getChildren(".up-down")[0].getChildren(".button-up")[0];
          this.upButton.addClass('button-up-disabled');
          this.downButton = this.upButton.getPrevious();
          if (this.size.y <= this.height){
            this.downButton.addClass('button-down-disabled');
          };
          this.initButtons();
        },
        
        initButtons: function(){
          var max = 3000;
          if(this.size.y < this.height.y*2) max=1000;
          if(this.size.y < this.height.y*1.1) max=700;
          var cont = this.downButton.getParent().getParent().getChildren(".window")[0].getChildren(".up-down-list")[0];
          cont.set("tween", {duration: max, onComplete: function(){
            if(cont.get('tween')[0].to[0].value < 0){
              cont.getParent().getParent().getChildren(".up-down")[0].getChildren(".button-down")[0].addClass("button-down-disabled");
            };
            if(cont.get('tween')[0].to[0].value == 0){
              cont.getParent().getParent().getChildren(".up-down")[0].getChildren(".button-up")[0].addClass("button-up-disabled");
            };
          }});
          cont.tween("top", -cont.getScrollSize()[0].y+this.height.y);
          cont.get('tween')[0].pause();
          
          this.upButton.addEvent('mousedown',function(e){
            if(this.upButton.hasClass('button-up-disabled')){
              if(cont.get('tween')[0].to[0].value < 0){
                if(cont.getStyle("top")[0].toFloat() > -this.size.y/3) cont.get("tween")[0].options.duration = 1000;
                else cont.get("tween")[0].options.duration = max;
                cont.tween("top", 0);
              }
              else cont.get("tween")[0].resume();
              this.downButton.removeClass("button-down-disabled");
            };
            e.stop();
          }.bind(this));
          this.upButton.addEvent('mouseup',function(e){
            cont.get('tween')[0].pause();
          }.bind(this));
          this.upButton.addEvent('click',function(e){
            e.stop();
          }.bind(this));
          
          this.downButton.addEvent('mousedown',function(e){
            if(this.downButton.hasClass('button-down-disabled')){
              if(cont.get('tween')[0].to[0].value == 0){
                if(cont.getStyle("top")[0].toFloat() < (-this.size.y+this.height.y)*2/3) cont.get("tween")[0].options.duration = 1000;
                else cont.get("tween")[0].options.duration = max;
                cont.tween("top", -cont.getScrollSize()[0].y+this.height.y);
              }
              else{
                
                cont.get("tween")[0].resume();
              };
            this.upButton.removeClass("button-up-disabled");
            };
            e.stop();
          }.bind(this));
          this.downButton.addEvent('mouseup',function(e){
            cont.get('tween')[0].pause();
          }.bind(this));
          this.downButton.addEvent('click',function(e){
            e.stop();
          }.bind(this));
        }
});