// JavaScript Document
//Define a variable (pos) to store the current scroll position. 
var pos = 100;
var count = 0;
var timeOuts = new Array(); 
function Scroll(theLayer){
	addThis = true;
	for(i=0;i<timeOuts.length;i++){
		if(timeOuts[theLayer] == theLayer){
			addThis = false;
			break;
		}
	}
	if(addThis){
		timeOuts[theLayer] = theLayer
	}
//document.getElementById('QSTRACE').innerHTML += "Scroll: "+theLayer;
    //get the id of the scrolling text box. 
    //obj=document.getElementById('scrolltextlayer');
    obj=document.getElementById(theLayer);
    //subtract 1 from pos and check pos value using offsetHeight, which retrieves the height of the object relative to the layout. 
    pos -=1; 
    //set a new height value using JavaScript style object.  
	document.getElementById(theLayer).style.top=pos+"px";
	//document.getElementById('scrolltextlayer').style.top=pos+"px";
   if(pos < 0 - obj.offsetHeight) {
	pos = 100;
	}
    //finally the function calls itself using a timeout..
   // window.setTimeout( "Scroll();" ,  30);
    //scroller = window.setTimeout( "Scroll();" ,  60);
	//scroller = window.setTimeout( function(){ Scroll(theLayer);} ,  60);
	timeOuts[theLayer] = window.setTimeout( function(){ Scroll(theLayer);} ,  60);
	//window.setTimeout( function(){ Scroll(theLayer);} ,  60);
    /* if(pos < 0 - obj.offsetHeight+130) {
	document.getElementById('crap').innerHTML = "Fuck: "+pos+", "+obj.offsetHeight;
	pos = 100;
	//return;
	}else{
	document.getElementById('crap').innerHTML = "MOVE: "+pos+", "+obj.offsetHeight;
    //set a new height value using JavaScript style object.     
    obj.style.top=pos;
    //finally the function calls itself using a timeout..
    window.setTimeout( "Scroll();" ,  30);
	} */
}
function ScrollControl(isStop, theLayer){
//document.getElementById('crap'+theLayer).innerHTML = "ScrollControl: "+theLayer;
//document.getElementById('QSTRACE').innerHTML += "ScrollControl: "+theLayer+", "+isStop;

	if(isStop){
		window.clearTimeout (timeOuts[theLayer]);
	}else{
		Scroll(theLayer);
	}
}
