var scroll_interval         = null;
var scroll_direction        = null;
var scroll_speed            = 20;
var scroll_step             = 5;
var scroll_delta            = 0;
var scroll_position         = 0;
var scroll_element          = null;

function scroller() {
  // hoehenunterschied bestimmen
  if (!scroll_element)   {scroll_element = jQuery('#scroll_content');}
  if (!scroll_delta)     {scroll_delta   = jQuery(scroll_element).height() - jQuery('#scroll_container').height();}
  if (scroll_delta <= 0) {window.clearInterval(scroll_interval);}
   
  switch (scroll_direction) {
    case 'up':
    scroll_position = (scroll_position > (-1 * scroll_delta)) ? scroll_position - scroll_step : (-1 * scroll_delta);
    break;
    
    case 'down':
    scroll_position = (scroll_position < 0) ? scroll_position + scroll_step : 0;
    break;
  }
  jQuery(scroll_element).css({top:scroll_position});
}

jQuery(function() {
  // scroll up
  jQuery('#scroller_btn_up').mouseover(function() {
    if (!scroll_interval) {
      scroll_direction = 'up';
      scroll_interval  = window.setInterval(scroller, scroll_speed);
      scroller();
    }
  });
  // scroll down
  jQuery('#scroller_btn_dwn').mouseover(function() {
    if (!scroll_interval) {
      scroll_direction = 'down'; 
      scroll_interval  = window.setInterval(scroller, scroll_speed);
      scroller();
    }
  });
  jQuery('#scroller_btn_up, #scroller_btn_dwn').mouseout(function() {
    window.clearInterval(scroll_interval);
    scroll_interval = scroll_delta = null;
  });
});
