// Check IE vs. NS
var n = (document.layers) ? 1:0
var ie = (document.all) ? 1:0

// Global vars declarations
var range = "";
var styleObj = "";
var speed = 3;
var mutex = 0;

var ymaxOne = 0;
var yminOne = 0;
var xplaceOne = 0;
var yplaceOne = 0;

var ymaxTwo = 0;
var yminTwo = 0;
var xplaceTwo = 0;
var yplaceTwo = 0;

var ymaxThree = 0;
var yminThree = 0;
var xplaceThree = 0;
var yplaceThree = 0;

if (ie) {
	range = "all.";
	styleObj = ".style";
}

function shiftTo(obj, x, y) {
	if (n) {
		obj.moveTo(x,y);
	} else {
		obj.pixelLeft = x;
		obj.pixelTop = y;
	}
}

function getObject(obj) {
	var theObj = eval("document." + range + obj + styleObj);
	return theObj;

	// Result in IE: document.all.OBJ.style
	// Result in NS: document.OBJ
} 

function scrollUp(strName) {
	if (ie) strObjName = strName;
	if (n) strObjName = strName + "Clipping.document." + strName;

	// In IE, newsid would be: news
	// In NS, newsid would be: newsClipping.document.news

	var theObj = getObject(strObjName); // Result: "document.all.news.style" (IE) "document.newsClipping.document.news" (NS)

	if (mutex == 1) {
		if (eval("yplace" + strName + " < " + "ymax" + strName)) {
			eval("yplace" + strName + " = yplace" + strName + "+ speed");
			if (eval("yplace" + strName + ">" + "ymax" + strName)) eval("yplace" + strName + "=" + "ymax" + strName);
			shiftTo(theObj, eval("xplace"+strName), eval("yplace"+strName));
			setTimeout("scrollUp('" + strName + "')",50);
		}
	}
}

function scrollDown(strName) {
	if (ie) strObjName = strName;
	if (n) strObjName = strName + "Clipping.document." + strName;

	// In IE, newsid would be: news
	// In NS, newsid would be: newsClipping.document.news

	var theObj = getObject(strObjName); // Result: "document.all.news.style" (IE) "document.newsClipping.document.news" (NS)

	if ( mutex == 1) {
		if (eval("yplace" + strName + ">" + "ymin" + strName)) {
			eval("yplace" + strName + "=yplace" + strName + "-speed");
			if (eval("yplace" + strName + "<" + "ymin" + strName)) eval("yplace" + strName + "=" + "ymin" + strName);
			shiftTo(theObj, eval("xplace"+strName), eval("yplace"+strName));
			setTimeout("scrollDown('" + strName + "')",50);
		}
	}
}

function initScrollers(strName) {
	if (ie) strObjName = strName;
	if (n) strObjName = strName + "Clipping.document." + strName;
	
	// In IE, newsid would be: news
	// In NS, newsid would be: newsClipping.document.news

	theObj = getObject(strObjName); // Result: "document.all.news.style" (IE) "document.newsClipping.document.news" (NS)
	if (n) {
		ymin = (theObj.clip.height - 100) * -1;
	} else {
			styleObj = "";
			theObj = getObject(strObjName);  // Result: "document.all.news" (IE)
			eval("ymin" + strName + "=" + ((theObj.offsetHeight - getParentObjectHeight(strName)) * -1));
			styleObj = ".style";
	}
}

function getParentObjectHeight(strName) {
	if (n) {
		theObj = eval("document." + strName + "Clipping");
		strHeight = theObj.height
		intHeight = strHeight.substr(0, strHeight.length-2);
		intHeight = intHeight * 1;
	}
	
	if (ie) {
		theObj = eval("document.all." + strName + "Clipping.style");
		strHeight = theObj.height
		intHeight = strHeight.substr(0, strHeight.length-2);
		intHeight = intHeight * 1;
	}

	return intHeight;
}

// Init
if (document.layers) {
	origWidth = innerWidth;
	origHeight = innerHeight;
}

function reDo() {
	if (innerWidth != origWidth || innerHeight != origHeight)
	location.reload();
}
if (document.layers) onresize = reDo;
