var t=null; 
function scroll(theelement, distance) {
 if (!t) {
  var element=document.getElementById(theelement);
  var startheight=element.scrollTop;
  var endheight=element.scrollTop+distance;
  if (endheight < 0) endheight=0;
  scroller(theelement, startheight, endheight, 42, 3);
 }
}

function scroller(theelement, startheight, endheight, maxspeed, softness) {
 var el=document.getElementById(theelement);
 if (el.scrollTop != endheight) {
  var distanceend=Math.abs((endheight - el.scrollTop) / softness);
  var distancestart=Math.abs((startheight - el.scrollTop) / softness); 
  var distance=Math.min(distancestart, distanceend);
  var multiplier;
  if (distance<1) multiplier=Math.abs(distance-1)+1;
  else multiplier=1;
  distance=Math.ceil(distance);
  if (distance==0) distance=1; 
  if (distance>maxspeed) distance=maxspeed;
  if (startheight > endheight) distance=-distance;
  var tempscrolltop=el.scrollTop;
  el.scrollTop+=distance;
  if (tempscrolltop+distance==el.scrollTop)
   t=setTimeout('scroller(\''+theelement+'\','+ 
   startheight+','+endheight+','+maxspeed+','+
   softness+')',Math.round(20 * multiplier));
  else
   t=null;
 }else{
  t=null;
 }
}

var scrollAdd = 96;
var direction = "down";
function newsScroll() {
 var element=document.getElementById('newsContainer');
 var startheight=element.scrollTop;
 var endheight=direction=="down" ? element.scrollTop+scrollAdd : element.scrollTop-scrollAdd;
 var realheight=element.scrollHeight;
 if(endheight >= realheight){ endheight=element.scrollTop-scrollAdd; direction = "up"; }
 if (endheight < 0){ endheight=element.scrollTop+scrollAdd; direction = "down"; }
 scroller('newsContainer', startheight, endheight, 42, 3);
 setTimeout("newsScroll()",10000);
}
