﻿function XMLMarquee()
{
	this.marqueewidth = document.getElementById("XMLMarquee").offsetWidth
	this.mouseoverBol = 0 //Boolean to indicate whether mouse is currently over ticker (and pause it if it is)

	//Specify the marquee's marquee speed (larger is faster 1-10)
	var MarqueeScrollInterval = 20
	//Speed of marquee onMousever
	this.pausespeed = 0

	this.actualwidth = document.getElementById("MarqueeWidth").offsetWidth
	
	var instanceOfMarquee = this
	this.MarqueeText = document.getElementById("MarqueeTextHolder")
	this.MarqueeText.onmouseover = function() { instanceOfMarquee.Pause() }
	this.MarqueeText.onmouseout = function() { instanceOfMarquee.ClearPause() }
	
	clearTimeout(this.scrolltimer)
	// Center the text.
	this.MarqueeText.style.left = (parseInt(this.marqueewidth) - parseInt(this.actualwidth)) / 2 + "px"
	this.scrolltimer = setInterval(function() { instanceOfMarquee.ScrollMarquee() }, MarqueeScrollInterval)
}

XMLMarquee.prototype.ScrollMarquee = function()
{
	if (this.mouseoverBol == 0) //if mouse is not currently over ticker, scroll it
	{
		if (parseInt(this.MarqueeText.style.left) > (this.actualwidth * (-1) + 8))
			this.MarqueeText.style.left = parseInt(this.MarqueeText.style.left) - 1 + "px"
		else
			this.MarqueeText.style.left = parseInt(this.marqueewidth) + 8 + "px"
	}
}

XMLMarquee.prototype.ClearPause = function()
{
	this.mouseoverBol = 0
	clearTimeout(this.pausetimer)
}

XMLMarquee.prototype.Pause = function()
{
	this.mouseoverBol = 1
	var instanceOfMarquee = this
	this.pausetimer = setInterval(function() { instanceOfMarquee.ClearPause() }, 5000)
}

