var scroller = new Class({
  // Hilfsfunktion init
  initialize:function() {
    this.top=0;
    // element height with margin-bottom
    this.step=113;
    this.compute=0;
    this.topevent=0;
    this.downevent=1;
    // elements to display
    this.displaycnt=4;
    //alert('init');
    this.border=((this.step*this.displaycnt*-1)+this.step);
  },
	myinit: function(items,options){
		// default werte setzen
    this._count=items.length;
    this._debug=false;
    $('scr-up-t').set( {'styles': {'display':'none'}});
    $('scr-up-b').set( {'styles': {'display':'none'}});    
    
    $('scroll-up-t').set( {'styles': {'background-image':'url(/fileadmin/res/img/up-no.gif)'}});
    $('scroll-up-b').set( {'styles': {'background-image':'url(/fileadmin/res/img/up-no.gif)'}});
   
    // werte ueberschreiben mit parametern in options
		if(options) for(var o in options) this[o]=options[o];

	},
  slide: function(direction){
  // 0 = up, 1 = down
  
  if(direction > 0){this.compute=this.top-this.step;}
  else {this.compute=this.top+this.step;}
  
 // alert(this.top+'--'+this.compute);
  $('scroll-content').set('morph',{
                               duration: 1000, 
                               transition: Fx.Transitions.Back.easeInOut
                              }
                      ).morph({ 'top': [this.top, this.compute]});   
  this.top=this.compute;
  this.chkevent();
  return false;
  },
  chkevent:function(){

  if(this.top < 0)
     {

     if(this.topevent == 0){
           $('scr-up-t').set( {'styles': {'display':'block'}});
           $('scr-up-b').set( {'styles': {'display':'block'}});       
           $('scroll-up-t').set( {'styles': {'background-image':'url(/fileadmin/res/img/up.gif)'}});
           $('scroll-up-b').set( {'styles': {'background-image':'url(/fileadmin/res/img/up.gif)'}});           
           this.topevent=1;
           }
     if(this.top < this.border && this.downevent==1)
          {
          $('scr-down-t').set( {'styles': {'display':'none'}});
          $('scr-down-b').set( {'styles': {'display':'none'}});
          $('scroll-down-t').set( {'styles': {'background-image':'url(/fileadmin/res/img/down-no.gif)'}});
          $('scroll-down-b').set( {'styles': {'background-image':'url(/fileadmin/res/img/down-no.gif)'}});          
          this.downevent=0;          
          }
          else if(this.top >= this.border && this.downevent==0){
          $('scr-down-t').set( {'styles': {'display':'block'}});
          $('scr-down-b').set( {'styles': {'display':'block'}});
          $('scroll-down-t').set( {'styles': {'background-image':'url(/fileadmin/res/img/down.gif)'}});
          $('scroll-down-b').set( {'styles': {'background-image':'url(/fileadmin/res/img/down.gif)'}});          
          this.downevent=1;                    
          }
     }
     else if(this.top==0 && this.topevent==1){
         $('scr-up-t').set( {'styles': {'display':'none'}});
         $('scr-up-b').set( {'styles': {'display':'none'}});
         $('scroll-up-t').set( {'styles': {'background-image':'url(/fileadmin/res/img/up-no.gif)'}});
         $('scroll-up-b').set( {'styles': {'background-image':'url(/fileadmin/res/img/up-no.gif)'}});         
         this.topevent=0;
     }

  }
                   
});


var sobj = new scroller();



function startUp(){
sobj.myinit($('scroll-content').getChildren(),{'debug':true});
// setze action
$('scr-up-t').addEvent('click',function() {return sobj.slide(0);});
$('scr-up-b').addEvent('click',function() {return sobj.slide(0);});
$('scr-down-t').addEvent('click',function() {return sobj.slide(1);});
$('scr-down-b').addEvent('click',function() {return sobj.slide(1);});
// blur objekt
$('scr-up-t').addEvent('focus',function() {this.blur();});
$('scr-down-t').addEvent('focus',function() {this.blur();});
$('scr-up-b').addEvent('focus',function() {this.blur();});
$('scr-down-b').addEvent('focus',function() {this.blur();});
}

