var timeoutID; // global variable to hold the timer
var int;
var dir="h";
var a;
function scrollDivLeft(inc,dir) { 
  if (timeoutID) clearTimeout(timeoutID); 
  var theDiv=document.getElementById('scrollholder'); 
theDiv.scrollLeft+=inc;
	(theDiv.scrollLeft==3170) ? scrollDivRight(-2,"h") : timeoutID = setTimeout("scrollDivLeft(2,'" + dir + "')", 50); // do it again in 20 miliseconds
}

function scrollDivRight(inc,dir) { 
clearInterval(a);
  if (timeoutID) clearTimeout(timeoutID); 
  var theDiv=document.getElementById('scrollholder'); 
theDiv.scrollLeft+=inc;
   	(theDiv.scrollLeft==0) ? scrollDivLeft(2,"h") : timeoutID = setTimeout("scrollDivRight(-2,'" + dir + "')", 50); // do it again in 20 miliseconds
}

function stopScroll() { //
  if (timeoutID) clearTimeout(timeoutID); // if we have a timerID clear it
}