var RTSA_scrollTimer = null;
var RTSA_scrollTimeout = 5;
var RTSA_scrollStep = 4;

function RTSA_startScroll(key, direction) {
   var id = 'rtsa_scroll_container_' + key;
   if (!$(id)) {
      return false;
   }
   
   if (RTSA_scrollTimer == null) {
      RTSA_scrollTimer = setInterval("RTSA_onScrollTimeout('" + direction + "', '" + id + "')", RTSA_scrollTimeout);
   }
}

function RTSA_stopScroll() {
   if (RTSA_scrollTimer != null) {
      clearInterval(RTSA_scrollTimer);
      RTSA_scrollTimer = null;
   }
}

function RTSA_onScrollTimeout(direction, key) {
   if ('down' == direction) {
      RTSA_scrollDown(key);
   } else if('up' == direction) {
      RTSA_scrollUp(key);
   }
}

function RTSA_scrollUp(id) {
   if (!$(id)) {
      return false;
   }
   $(id).scrollTop -= RTSA_scrollStep;
}

function RTSA_scrollDown(id) {
   if (!$(id)) {
      return false;
   }
   $(id).scrollTop += RTSA_scrollStep;
}