var UCLA_scrollTimer = null;
var UCLA_scrollTimeout = 5;
var UCLA_scrollStep = 4;

function UCLA_startScroll(key, direction) {
   var id = 'ucla_scroll_container_' + key;
   if (!$(id)) {
      return false;
   }
   
   if (UCLA_scrollTimer == null) {
      UCLA_scrollTimer = setInterval("UCLA_onScrollTimeout('" + direction + "', '" + id + "')", UCLA_scrollTimeout);
   }
}

function UCLA_stopScroll() {
   if (UCLA_scrollTimer != null) {
      clearInterval(UCLA_scrollTimer);
      UCLA_scrollTimer = null;
   }
}

function UCLA_onScrollTimeout(direction, key) {
   if ('down' == direction) {
      UCLA_scrollDown(key);
   } else if('up' == direction) {
      UCLA_scrollUp(key);
   }
}

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

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