///////////////////////////////////////////////////////////////////////
//
//	scroll.js: Klasse um Text in einem Layer zu scrollen
//
//	Konstruktor:
//	<script language="JavaScript" src="path/to/scroll.js"></script> 
//	<script language="JavaScript" type="text/javascript">
//		var scroll = new scroll(100,5);
//	</script> 
//
//	Uebergabeparameter: Geschwindigkeit, Scrolleinheit.
//
//	Um die Browser zu checken: <body onLoad="scroll.init();">
//
//	Aufruf der Action:
//
//	Text runterscrollen:
//	<a href="#" onMouseOver="scroll.moveUp('scrollWindow','scrollContent');" onMouseOut="scroll.destroyTimer();">moveUp</a><br>
//
//	Text hochscrollen:
//	<a href="#" onMouseOver="scroll.moveDown('scrollWindowDiv','scrollContentDiv');" onMouseOut="scroll.destroyTimer();">moveDown</a>
//
//	Auf einmal springen (hoch/runter):
//	<a href="javascript:scroll.ganzHoch('scrollWindowDiv','scrollContentDiv');">ganzHoch</a><br>
//	<a href="javascript:scroll.ganzRunter('scrollWindowDiv','scrollContentDiv');">ganzRunter</a><br>
//
//	Ralf Weber 19.06.2001
////////////////////////////////////////////////////////////////////////////


function scroll(speed,move,fastmove){

this.nn4 = (document.layers) ? true : false;
this.nn6 = ( (document.getElementById) && (!document.all) ) ? true : false;
this.ie = (document.all) ? true : false;

this.speed = speed;
this.move = move;
this.fastmove = fastmove
var timer;

//	methoden

this.init = init;
this.destroyTimer = destroyTimer;
this.moveUp = moveUp;
this.moveDown = moveDown;
this.ganzHoch = ganzHoch;
this.ganzRunter = ganzRunter;
this.fastMoveUp = fastMoveUp;
this.fastMoveDown = fastMoveDown;
}


function init(){

    if (this.nn4) this.layer = document.layers;
	if (this.ie) this.layer = document.all;
}

function destroyTimer() {
	if (this.timer) {
		clearTimeout(this.timer);
	}
}


function moveUp(parentId,childId) {

	if(this.ie) {
	
		var windowHoehe = parseInt(this.layer[parentId].style.top);
		var contentHoehe = parseInt(this.layer[childId].scrollHeight);
		var offsetHoehe = contentHoehe - windowHoehe;
	
		var oben = parseInt(this.layer[childId].style.top);
			if ( (oben + offsetHoehe) > 0 ) {
				this.layer[childId].style.top = oben - this.move;
			}
	}
	
	if(this.nn6) {
		var windowHoehe = parseInt(document.getElementById(parentId).style.top);
		var contentHoehe = parseInt(document.getElementById(childId).offsetHeight);
		var offsetHoehe = contentHoehe - windowHoehe;
			
		var oben = parseInt(document.getElementById(childId).style.top);	
			if ( (oben + offsetHoehe) > 0 ) {
				document.getElementById(childId).style.top =  oben - this.move;
			}
	}

		
	if(this.nn4) {
		var windowHoehe = this.layer[parentId].top;
		var contentHoehe = this.layer[parentId].document.layers[childId].document.height;
		var offsetHoehe = contentHoehe - windowHoehe;

		var oben = this.layer[parentId].document.layers[childId].top;
			if ( (oben + offsetHoehe) > 0 ) {
				this.layer[parentId].document.layers[childId].top = oben - this.move;
			}

	}
	
this.timer = setTimeout("scroll.moveUp('"+parentId+"','"+childId+"')",this.speed);

}


function moveDown(parentId,childId) {

	if(this.ie) {
	
		var windowHoehe = parseInt(this.layer[parentId].style.top);
		var contentHoehe = parseInt(this.layer[childId].scrollHeight);
		var offsetHoehe = contentHoehe - windowHoehe;
	

		var oben = parseInt(this.layer[childId].style.top);
		
			if ( oben < 0 ) {
				this.layer[childId].style.top = oben + this.move;
			}

	}
		
	if(this.nn6) {
		var windowHoehe = parseInt(document.getElementById(parentId).style.top);
		var contentHoehe = parseInt(document.getElementById(childId).offsetHeight);
		var offsetHoehe = contentHoehe - windowHoehe;
		
		var oben = parseInt(document.getElementById(childId).style.top);	
			if ( oben < 0 ) {
				document.getElementById(childId).style.top =  oben + this.move;
			}
	}

	
		if(this.nn4) {
		var windowHoehe = this.layer[parentId].top;
		var contentHoehe = this.layer[parentId].document.layers[childId].document.height;
		var offsetHoehe = contentHoehe - windowHoehe;

		var oben = this.layer[parentId].document.layers[childId].top;
			if ( oben < 0 ) {
				this.layer[parentId].document.layers[childId].top = oben + this.move;
			}
	}
	this.timer = setTimeout("scroll.moveDown('"+parentId+"','"+childId+"')",this.speed);
}

// schneller
function fastMoveUp(parentId,childId) {

	if(this.ie) {

		var windowHoehe = parseInt(this.layer[parentId].style.top);
		var contentHoehe = parseInt(this.layer[childId].scrollHeight);
		var offsetHoehe = contentHoehe - windowHoehe;
	
		var oben = parseInt(this.layer[childId].style.top);
			if ( (oben + offsetHoehe) > 60 ) 
			{
				this.layer[childId].style.top = oben - this.fastmove;
			}
	}
	
	if(this.nn6) {
		var windowHoehe = parseInt(document.getElementById(parentId).style.top);
		var contentHoehe = parseInt(document.getElementById(childId).offsetHeight);
		var offsetHoehe = contentHoehe - windowHoehe;
			
		var oben = parseInt(document.getElementById(childId).style.top);	
			if ( (oben + offsetHoehe) > 60 ) {
				document.getElementById(childId).style.top =  oben - this.fastmove;
			}
	}

		
	if(this.nn4) {
		var windowHoehe = this.layer[parentId].top;
		var contentHoehe = this.layer[parentId].document.layers[childId].document.height;
		var offsetHoehe = contentHoehe - windowHoehe;

		var oben = this.layer[parentId].document.layers[childId].top;
			if ( (oben + offsetHoehe) > 60 ) {
				this.layer[parentId].document.layers[childId].top = oben - this.fastmove;
			}

	}
	
this.timer = setTimeout("scroll.fastMoveUp('"+parentId+"','"+childId+"')",this.speed);

}


function fastMoveDown(parentId,childId) {

	if(this.ie) {
	
		var windowHoehe = parseInt(this.layer[parentId].style.top);
		var contentHoehe = parseInt(this.layer[childId].scrollHeight);
		var offsetHoehe = contentHoehe - windowHoehe;
	

		var oben = parseInt(this.layer[childId].style.top);
		
			if ( oben < 0 ) {
				this.layer[childId].style.top = oben + this.fastmove;
			}

	}
		
	if(this.nn6) {
		var windowHoehe = parseInt(document.getElementById(parentId).style.top);
		var contentHoehe = parseInt(document.getElementById(childId).offsetHeight);
		var offsetHoehe = contentHoehe - windowHoehe;
		
		var oben = parseInt(document.getElementById(childId).style.top);	
			if ( oben < 0 ) {
				document.getElementById(childId).style.top =  oben + this.fastmove;
			}
	}

	
		if(this.nn4) {
		var windowHoehe = this.layer[parentId].top;
		var contentHoehe = this.layer[parentId].document.layers[childId].document.height;
		var offsetHoehe = contentHoehe - windowHoehe;

		var oben = this.layer[parentId].document.layers[childId].top;
			if ( oben < 0 ) {
				this.layer[parentId].document.layers[childId].top = oben + this.fastmove;
			}
	}
	this.timer = setTimeout("scroll.fastMoveDown('"+parentId+"','"+childId+"')",this.speed);
}

function ganzHoch(parentId,childId) {

	if(this.ie) {
		this.layer[childId].style.top = 0;
	}
	
	if(this.nn6) {
		document.getElementById(childId).style.top =  0;
	}

	
	if(this.nn4) {
		this.layer[parentId].document.layers[childId].top = 0;
	}
}

function ganzRunter(parentId,childId) {

	if(this.ie) {
	
		var windowHoehe = parseInt(this.layer[parentId].style.top);
		var contentHoehe = parseInt(this.layer[childId].scrollHeight);
		var offsetHoehe = contentHoehe - windowHoehe;

		this.layer[childId].style.top = -offsetHoehe;
	}

		if(this.nn6) {
		
		var windowHoehe = parseInt(document.getElementById(parentId).style.top);
		var contentHoehe = parseInt(document.getElementById(childId).offsetHeight);
		var offsetHoehe = contentHoehe - windowHoehe;

		document.getElementById(childId).style.top = -offsetHoehe;
	}

	
	if(this.nn4) {
		
		var windowHoehe = this.layer[parentId].top;
		var contentHoehe = this.layer[parentId].document.layers[childId].document.height;
		var offsetHoehe = contentHoehe - windowHoehe;

		this.layer[parentId].document.layers[childId].top = -offsetHoehe;
	}
}	
