//-------------------------------------------------------
// ---=== Scrolling Notice Board ===---
// Author: Luke Gowen <lukeg@w3c2.com.au>
// Version: 1.0.0b (021203)
//
// COPYRIGHT © 2002 W3C2. All Rights Reserved.
// This code should not be used without the express
// permission of W3C2 - http://www.w3c2.com.au/
//-------------------------------------------------------

var SNB_Loaded = false;
var SNB_FrameObj;
var SNB_ContentObj;
var SNB_ScrollSpeed = SNB_NormalSpeed;
var SNB_NumItems = SNB_ScrollingItems.length;

function SNB_ShowScroll() {
	var scrollHTML = "";
	SNB_BrowserObj = new SNB_Browser();
	for (var i = 0; i < 3; i++) {	// output items 3 times
		for (var j = 0; j < SNB_NumItems; j++) {
			scrollHTML += SNB_ScrollingItems[j];
			if (i != 2 || j != SNB_NumItems - 1)
				scrollHTML += "<br><br>";
		}
	}
	if (SNB_BrowserObj.ns4) {
		scrollHTML = "<font face='" + SNB_FontFamily + "' color='" + SNB_FontColour + "' size='1'>" + scrollHTML + "</font>";
		document.write(
			"<table width='" + SNB_ScrollWidth + "' height='" + SNB_ScrollHeight + "' cellpadding='0' cellspacing='0' border='0'>" +
			"<tr><td><ilayer id='refLayer' width='" + SNB_ScrollWidth + "' height='" + SNB_ScrollHeight + "' bgcolor='" + SNB_BackgroundColour + "'></ilayer></td></tr></table>" +
			"<layer id='frameLayer' visibility='hidden' width='" + (SNB_ScrollWidth - 10) + "' height='" + SNB_ScrollHeight + "' bgcolor='" + SNB_BackgroundColour + "'>" +
			"<layer id='contentLayer' width='" + (SNB_ScrollWidth - 10) + "'>" + scrollHTML + "</layer></layer>");
	}
	else {
		scrollHTML = "<span style='font-family:" + SNB_FontFamily + "; font-size:" + SNB_FontSize + "px; color:" + SNB_FontColour + ";'>" + scrollHTML + "</span>"
		document.write(
			"<div id='frameLayer' style='position:relative; overflow:hidden; width:" + SNB_ScrollWidth + "px; height:" + SNB_ScrollHeight  + "px; background-color:" + SNB_BackgroundColour + ";'>" +
			"<div id='contentLayer' style='visibility:hidden; position:absolute; padding-left:10px; padding-right:10px;' align='left'>" + scrollHTML + "</div></div>");
	}
}

function SNB_Browser () {
	this.dom = (document.getElementById) ? true : false;
	this.ie4 = (document.all && !this.dom) ? true : false;
	this.ns6 = (navigator.userAgent.indexOf("Netscape") != -1) ? this.dom : false;
	this.ns4 = (document.layers && !this.dom) ? true : false;
	this.valid = (this.dom || this.ie4 || this.ns4) ? true : false;
}

function SNB_Frame(layerId) {
	this.el = (SNB_BrowserObj.dom) ? document.getElementById(layerId) : (SNB_BrowserObj.ie4) ? document.all[layerId] : (SNB_BrowserObj.ns4) ? eval("document." + layerId) : 0;
	this.css = (SNB_BrowserObj.dom) ? document.getElementById(layerId).style : (SNB_BrowserObj.ie4) ? document.all[layerId].style : (SNB_BrowserObj.ns4) ? eval("document." + layerId) : 0;
	if (SNB_BrowserObj.ns4) {
		this.el.clip.width = SNB_ScrollWidth;
		this.el.clip.height = SNB_ScrollHeight;
		this.el.left = this.x = document.refLayer.pageX + 10;
		this.el.top = this.y = document.refLayer.pageY;
	}
	else
		this.x = this.y = 0;
	this.height = (!SNB_BrowserObj.ns4) ? this.el.offsetHeight : this.el.clip.height;
	this.el.onmouseover = SNB_FrameOver;
	this.el.onmouseout = SNB_FrameOut;
	eval("this.obj = this");
}

function SNB_Content(layerId, frameId) {
	this.el = (SNB_BrowserObj.dom) ? document.getElementById(layerId) : (SNB_BrowserObj.ie4) ? document.all[layerId] : (SNB_BrowserObj.ns4) ? eval("document." + frameId + ".document." + layerId) : 0;
	this.css = (SNB_BrowserObj.dom) ? document.getElementById(layerId).style : (SNB_BrowserObj.ie4) ? document.all[layerId].style : (SNB_BrowserObj.ns4) ? eval("document." + frameId + ".document." + layerId) : 0;
	this.height = (!SNB_BrowserObj.ns4) ? this.el.offsetHeight : this.el.clip.height;
	this.x = this.y = 0;
	this.Move = SNB_MoveLayer;
	this.MoveUp = SNB_MoveLayerUp;
	this.MoveDown = SNB_MoveLayerDown;
	eval("this.obj = this");
}

function SNB_FrameOver() {
	SNB_ScrollSpeed = SNB_MouseOverSpeed;
}

function SNB_FrameOut() {
	SNB_ScrollSpeed = SNB_NormalSpeed;
}

function SNB_MoveLayer(x, y) {
	this.x = x;
	this.y = y;
	this.css.left = x + "px";
	this.css.top = y + "px";
}

function SNB_MoveLayerUp() {
	if (this.y < -this.height)
		this.y = SNB_FrameObj.height;
	this.Move(0, this.y - SNB_ScrollSpeed);
	setTimeout("SNB_ContentObj.MoveUp()", SNB_RefreshInterval);
}

function SNB_MoveLayerDown() {
	if (this.y > SNB_FrameObj.height)
		this.y = -this.height;
	this.Move(0, this.y + SNB_ScrollSpeed);
	setTimeout("SNB_ContentObj.MoveDown()", SNB_RefreshInterval);
}

function SNB_InitScroller() {
	SNB_FrameObj = new SNB_Frame("frameLayer");
	SNB_ContentObj = new SNB_Content("contentLayer", "frameLayer");
	SNB_ContentObj.y = SNB_StartPosition / 2;
	SNB_ContentObj.css.visibility = "visible";
	SNB_Loaded = true;
	SNB_StartScroll();
}

function SNB_StartScroll() {
	if (SNB_Loaded) {
		if (SNB_ScrollUp)
			SNB_ContentObj.MoveUp();
		else
			SNB_ContentObj.MoveDown();
	}
}
