// ASM SCROLLER 2.0 - (c) 2000 Brent Gustafson, vitaflo.com and assembler.org
// Adapted by mediaLINK 04.01.2001


//browser-functionality-check
var w3c = (document.getElementById) ? 1:0		// N6M, E5M, E5W, E5.5W,
var ns4 = (document.layers) ? 1:0				// N4W, N4.5M, N4.7W
var ie4 = (document.all) ? 1:0					// E4M (no support for clipping), E4.5M, E4W, 

//initializing variables
var range = "";
var cap = "";
var mutex = 0;
var yplace = 0;
var ymax = 0;
var ymin = 0;
var xplace = 0;
var newsHeight = 0;

//parameters to change
var newsId = "news";                   //name of the overall news div
var newsClipId = "newsClipping";       //name of the news clipping div
var speed = 5;
var speedFactor = 1;
var scrolltimeout = 24;
var step = 0;						   //for step-scrolling by screenlength
var steplength = 200;				   //to be adapted to screensize
mes1="This page contains DHTML-content. Your browser probably doesn't display some objects. Please note: Netscape or Microsoft Internet Explorer Version 4 or higher are required.";
mes2="Your browser doesn't support this function. Netscape or Microsoft Internet Explorer Version 4 or higher are required.";

//corrections for Netsacpe
if ((navigator.appName=="Netscape") && (parseInt(navigator.userAgent.substring(8,9)) >= 4)){
	var speedFactor = 1;
	var scrolltimeout = 12; 
}

//basic-browser-check
if ((w3c) || (ns4) || (ie4)) {
}else{
	alert(mes1);
}


//the script

function redrawScreen() {
	location.reload();
	return false
}


function shiftTo(obj, x, y) {
	if (w3c) {
		obj.style.left = x + "px";
		obj.style.top = y + "px";
	}
	else if (ns4) {
		obj.moveTo(x,y);
	} 
	else if (ie4) {
		obj.style.pixelLeft = x;
		obj.style.pixelTop = y;
	}
}


function getObject(obj) {
	var theObj = eval("document." + range + obj + cap);
	return theObj;
} 


function scrollingTop() {
	if ((w3c) || (ns4) || (ie4)) {
		var theObj = getObject(newsId);
		if (yplace < ymax) {
			yplace = ymax;
			shiftTo(theObj, xplace, yplace);
		}
	}else{
		alert(mes2);
	}
}


function scrollUp() {
	if ((w3c) || (ns4) || (ie4)) {
		if (mutex == 1){
			var theObj = getObject(newsId);
			if (yplace < ymax) {
				yplace = yplace + speed;
				if (yplace > ymax) yplace = ymax;
				shiftTo(theObj, xplace, yplace);
				if (step==0){
					setTimeout("scrollUp()",scrolltimeout);
				}
			}
		}
	}else{
		alert(mes2);
	}
}

  
function scrollDown() {
	if ((w3c) || (ns4) || (ie4)) {
		if (mutex == 2){
			var theObj = getObject(newsId);
			if (yplace > ymin) {
				yplace = yplace - speed;
				if (yplace < ymin) yplace = ymin;
				shiftTo(theObj, xplace, yplace);
				if (step==0){
					setTimeout("scrollDown()",scrolltimeout);
				}
			}
		}
	}else{
		alert(mes2);
	}
}


function scrolling(dir,sp,st){
	//window.status = msg; 
	mutex = dir;
  
	if (st==1){
		step=1;
		speed=steplength;
	}else{
		step=0;
		speed=sp*speedFactor;
	}
  
	if (mutex == 1) scrollUp();
	else if (mutex == 2) scrollDown();
}


function init() {
	if (w3c) {
		range = "getElementById(\"";
		cap = "\")";
		theObj = getObject(newsClipId);
		newsHeight = parseInt(theObj.offsetHeight);
		theObj = getObject(newsId);
		ymin = (parseInt(theObj.offsetHeight) - newsHeight) * -1;
		//alert("w3c");
	}
	else if (ns4) {
		//required for N4W (csnsfix alone doesn't succeed)
		window.captureEvents(Event.RESIZE);
		window.onresize = redrawScreen;

		theObj = getObject(newsClipId);
    
		//height of displayed part
		newsHeight = theObj.clip.height;
   
		newsId = newsClipId + ".document." + newsId;
		theObj = getObject(newsId);
    
		//height of not visble part before any scrolling
		ymin = (theObj.clip.height - newsHeight) * -1;
    
		//alert("ns4");
	}
	else if (ie4) {
		range = "all.";
		theObj = getObject(newsClipId);
		newsHeight = theObj.offsetHeight;
		theObj = getObject(newsId);
		ymin = (theObj.offsetHeight - newsHeight) * -1;
		//alert("ie4");
	}
}

