function autoScrollStart(divID, direction, speed) {
  stopScroll = false;
  if (speed == undefined)
	  speed = 3;
  if (direction == 'down')
    setTimeout(function() { autoScrollDown(divID, speed) },10);
  else
    setTimeout(function() { autoScrollUp(divID, speed) },10);
}

function autoScrollStop() {
  stopScroll = true;
}

function autoScrollUp(divID, speed){
  if ((document.getElementById(divID).scrollTop * 1) >= 0) {
    document.getElementById(divID).scrollTop = (document.getElementById(divID).scrollTop*1) - speed;
    if (!stopScroll)
      setTimeout(function() { autoScrollUp(divID, speed) },10); // si esegue nuovamente dopo 30ms
  }
}
  
function autoScrollDown(divID, speed){
  if (((document.getElementById(divID).scrollHeight*1) -
    (document.getElementById(divID).scrollTop * 1))
    > 
    (document.getElementById(divID).offsetHeight)) {

    document.getElementById(divID).scrollTop = (document.getElementById(divID).scrollTop*1) + speed;
    
   if (!stopScroll)
     setTimeout(function() { autoScrollDown(divID, speed) },10); // si esegue nuovamente dopo 30ms
  }
  
}
function scrollbardetect(outerdiv, innerdiv, scroller){
	var innerheight = document.getElementById(innerdiv).scrollHeight;
	var outerheight = document.getElementById(outerdiv).clientHeight;
	//alert ('inner='+innerheight+' '+'outer='+outerheight);
	if (innerheight >= outerheight){
		document.getElementById(scroller).style.display = 'block';
	}
	else {
	  // alert("No need of scroll");
	  // document.getElementById(scroller).innerHTML = '<div style="width:40px; background-color:gray;">&nbsp;</div>';
	  // document.getElementById(scroller).style.display = 'block';
	}
}