//==============================================================================//
// Configure here                                                               //
//==============================================================================//

var pause 		= -700;		// Pause. The lower, the longer. -- -700 = ok
var interval 	= 5;		// The timer interval. Note: a very low interval  -- 5 = standaard
var scrollcounter = 0;		// (like:don't use 1 or 2) may decrease system performance. 
var totallines = 38;				


//==============================================================================//
// End configuring variables                                                    //
//==============================================================================//
var steps 		= 1;		// Amount of steps to scroll each interval.
var sync 		= -350; 	// counter to trigger the scroll and the pause.

function init_scrolling()
{
  var div = document.getElementById("scrollPage");

  x = div.childNodes[0].cloneNode(true); // Duplicate page1.
  div.appendChild(x);			 // Attach the duplicate to the bottom of the scrollPage div.
  scroll();				 // Start to scroll.
}

function scroll()
{
  var div = document.getElementById("scrollPage");
  var current_scroll = totallines * div.clientHeight;

  if (sync > -1)
  {
    //div.scrollTop += steps;
	div.scrollTop += steps;
  }
  //sync += steps;
  sync += 0.645;

  if (sync >= div.clientHeight)
  {
    sync = pause / steps;
    scrollcounter = scrollcounter + 1;
  }


//  var current_scroll = (div.scrollHeight - div.scrollTop) - div.clientHeight;
//var current_scroll = (div.scrollHeight - div.scrollTop) - div.clientHeight;
	 var current_scroll = current_scroll - div.clientHeight;
if (current_scroll <= 0)
 {
   div.scrollTop = 0;
 }

if(scrollcounter==38)
  {
    scrollcounter = 0;
    div.scrollTop = 0;
  }

  //parent.scrollcount.innerHTML = current_scroll + " | " + scrollcounter;
  
  setTimeout("scroll()", interval);
}
