var marqueeArray = new Array();
var marqueeEnbaled = true;
function initialiseMarquees(){for (var i=0; i<marqueeArray.length;i++) marqueeArray[i].initialiseMarquee();}
function MarqueeScroller(elementContainerId, elementToScrollId, scrollHeight, scrollDelay, scrollSpeed, overPause)
{
	// Get the element to scroll and it's container
	this.elementToScroll=document.getElementById(elementToScrollId);
	this.elementContainer=document.getElementById(elementContainerId);
	this.elementContainer.marqueeScroller=this;
	this.scrollHeight=scrollHeight;
	this.delayb4scroll=scrollDelay; 
	this.marqueespeed=scrollSpeed;
	this.pauseOnMouseOver=overPause;
	
	this.initialiseMarquee = function()
	{
		this.movespeed=this.marqueespeed;
		this.pausespeed=((!this.pauseOnMouseOver)? this.movespeed: 0);
		this.elementToScroll.style.top=0;
		this.elementContainer.style.height=this.scrollHeight;
		this.marqueeheight=this.elementContainer.offsetHeight;
		this.actualheight=this.elementToScroll.offsetHeight;
		if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1)
		{ 
			// If Opera or Netscape 7x, add scrollbars to scroll and exit
			this.elementToScroll.style.height=this.marqueeheight+"px";
			this.elementToScroll.style.overflow="scroll";
			return;
		}
		// Starts the scroller after the delay period
		var thisObj = this;
		window.setTimeout( function(){ thisObj.startMarquee() }, this.delayb4scroll);	
	}
	this.startMarquee = function()
	{
		var thisObj = this;
		window.setInterval( function(){ thisObj.scrollMarquee() }, 30);	
	}
	this.scrollMarquee = function()
	{
		if (parseInt(this.elementToScroll.style.top)>(this.actualheight*(-1)+8))
		{
			this.elementToScroll.style.top=(parseInt(this.elementToScroll.style.top)-this.movespeed)+"px"
		}
		else
		{
			this.elementToScroll.style.top=(parseInt(this.marqueeheight)+8)+"px"
		}
	}
	
	this.mouseOver = function()
	{
		if (marqueeEnbaled) this.movespeed=this.pausespeed;
	}

	this.mouseOut = function()
	{
		if (marqueeEnbaled) this.movespeed=this.marqueespeed;
	}
}

// Initialise the marquees on page load
if (window.addEventListener && true)
{
	window.addEventListener("load", initialiseMarquees, false)
}
else if (window.attachEvent && true)
{
	window.attachEvent("onload", initialiseMarquees)
}
else if (document.getElementById)
{
	marqueeEnbaled = false;
}
