
function init(id) {
  var obj = document.getElementById(id);
  if (obj) {
    obj.state = 0;
    obj.timer = null;
    obj.maxVert = obj.scrollWidth - obj.offsetWidth;
  }
}

function scroll_down(id,timer) {
  var obj = document.getElementById(id);
  if (!obj.maxVert) init(id);
  if (timer == undefined) obj.state = 1;
  if ((obj.maxVert > obj.scrollLeft) && (obj.state == 1)) {
    obj.scrollLeft = obj.scrollLeft + 10;
    obj.timer = setTimeout('scroll_down(\''+id+'\',true)',100);
  }
}

function scroll_up(id,timer) {
  var obj = document.getElementById(id);
  if (!obj.maxVert) init(id);
  if (timer == undefined) obj.state = -1;
  if ((obj.scrollLeft > 0) && (obj.state == -1)) {
    obj.scrollLeft = obj.scrollLeft > 10 ? obj.scrollLeft - 10 : 0;
    obj.timer = setTimeout('scroll_up(\''+id+'\',true)',100);
  }
}

function scroll_stop(id) {
  var obj = document.getElementById(id);
  if (obj) {
    if (obj.timer) clearTimeout(obj.timer);
    obj.state = 0;
  }

}
