/*******************************************************************************
Code: JS
********************************************************************************/
var initScroll = false;
var loopScroll = false;
var timerScroll = 0;
if (adjustScrollsteps == 'undefined') { var adjustScrollsteps = 1; }


function scrollLayer(layerID, containerID, scrollbarID, speed) {
	this.id = layerID;
	this.layerObj = (document.getElementById ? document.getElementById(this.id) : document.all ? document.all[this.id] : document.layers[this.id]);
	this.styleObj = (document.getElementById ? this.layerObj.style : document.all ? this.layerObj.style : this.layerObj);
	
	this.scrollHeight = this.layerObj.offsetHeight;
	if (speed > 0) { this.speed = speed; }
	else { this.speed = 10; }
	
	this.containerObj = (document.getElementById ? document.getElementById(containerID) : document.all ? document.all[containerID] : document.layers[containerID]);
	this.containerClipHeight = this.containerObj.offsetHeight;
	  
	// Back-Reference for Timeout
	this.obj = this.id + "Object";
	eval(this.obj + "=this");
	
	// Methods
	this.up = moveAreaUp;
	this.down = moveAreaDown; 
	this.moveArea = moveArea;
	this.scroll = performScroll;
	this.stopScroll = ceaseScroll;
	
	// set Scroll-Layer to left-top
	this.moveArea(0, 0);
	
	// show Scrollbar-Layer and initialise scrolling, if Scrolltext extends Clip-Area of Container-Layer
	if ((this.scrollHeight > this.containerClipHeight) && document.getElementById(scrollbarID)) {
		document.getElementById(scrollbarID).style.visibility = "visible";
		initScroll = true;
	}
} 
	
function moveArea(x, y) {
	this.x = x;
	this.y = y; 
	this.styleObj.left = this.x +"px";
	this.styleObj.top = this.y +"px";
} 
	 
function moveAreaDown(step) {
	if (this.y > -this.scrollHeight + this.containerClipHeight) { 
		this.moveArea(0, (this.y-step));
		if (loopScroll == true) { timerScroll = setTimeout(this.obj + ".down(" + step + ")", this.speed); } 
	} 
}
	 
function moveAreaUp(step) { 
	if (this.y < 0){ 
		this.moveArea(0, (this.y-step)); 
		if (loopScroll == true) { timerScroll = setTimeout(this.obj + ".up(" + step + ")", this.speed); }
	} 
} 
	 
function performScroll(step) {
	if (initScroll == true) { 
		loopScroll = true;
		step = (step * adjustScrollsteps);
		if (step > 0) { this.down(step); } 
		else { this.up(step); } 
	} 
} 
	 
function ceaseScroll() { 
	loopScroll = false; 
	if (timerScroll) { clearTimeout(timerScroll); } 
} 