// ASM SCROLLER 2.0 - (c) 2000 Brent Gustafson
// Adapted by mediaLINK 10.09.2001 - Version 3


//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 ns4M = ((document.layers) && (navigator.appVersion.indexOf("Mac") > -1)) ? 1:0;  //N4M
var ie4 = (document.all) ? 1:0					// E4M (no support for clipping), E4.5M, E4W, 

//initializing variables
var range = "";
var cap = "";
var mutex = "stop";
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 = 10;
var scrolltimeout = 10;

msg1 = "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.";
msg2 = "Your browser doesn't support this function. Netscape or Microsoft Internet Explorer Version 4 or higher are required.";


//basic-browser-check
if (w3c || ns4 || ie4) {
}else{
	alert(msg1);
}




//-----the script

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 scrollTop() {
	var theObj = getObject(newsId);
	if (yplace < ymax) {
		yplace = ymax;
		shiftTo(theObj, xplace, yplace);
	}
}


function scrollUp() {
	if (mutex == "up"){
		var theObj = getObject(newsId);
		if (yplace < ymax) {
			yplace = yplace + speed;
			if (yplace > ymax) yplace = ymax;
			shiftTo(theObj, xplace, yplace);
			setTimeout("scrollUp()",scrolltimeout);
		}
	}
}

  
function scrollDown() {
	if (mutex == "down"){
		var theObj = getObject(newsId);
		if (yplace > ymin) {
			yplace = yplace - speed;
			if (yplace < ymin) yplace = ymin;
			shiftTo(theObj, xplace, yplace);
			setTimeout("scrollDown()",scrolltimeout);
		}
	}
}


function scrolling(dir){
	if (w3c || ns4 || ie4) {
 		mutex = dir; 
		if (mutex == "up") scrollUp();
		if (mutex == "down") scrollDown();
		if (mutex == "top") scrollTop();
	}else{
		alert(msg2);
	}
}


//-----initialisation
function redrawScreen() {
	location.reload();
	return false;
}

function init() {
	if (w3c) {
		range = "getElementById(\"";
		cap = "\")";
		theObj = getObject(newsClipId);
		newsHeight = parseInt(theObj.offsetHeight);
		theObj = getObject(newsId);
		ymin = (parseInt(theObj.offsetHeight) - newsHeight) * -1;
	}
	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;

	}
	else if (ie4) {
		range = "all.";
		theObj = getObject(newsClipId);
		newsHeight = theObj.offsetHeight;
		theObj = getObject(newsId);
		ymin = (theObj.offsetHeight - newsHeight) * -1;
	}
}
