function Headlines(containerId, isBulletin, headlines)
{
	this.headlineArea = document.getElementById(containerId);
	this.headlineIndex = 0;	
	this.headlines = headlines;
	this.timeout = Headlines.FadeTimeout;
	
	if(isBulletin)
	{
		this.headlineArea.innerHTML = this.headlines[0];
	}
	else
	{
		if(this.headlines && this.headlines.length > 0)
		{
			var thunk = this;
			setTimeout(function() 
			{
				thunk.fade(1, 0);
			}, this.timeout);
		}
	}	
}

Headlines.prototype.fade = function(direction, step)
{
	this.headlineArea.style.color = Headlines.Shade[step];

	if(step <= 0)
	{
		direction = 1;
		this.changeHeadline();
	}
	else if(step >= Headlines.Shade.length)
	{
		direction = -1;
		this.timeout = Headlines.PauseTimeout;
	}

	step = step + direction;
	
	var thunk = this;
	setTimeout(function()
	{
		thunk.fade(direction, step)
	}, this.timeout);

	if(this.timeout == Headlines.PauseTimeout)
	{
		this.timeout = Headlines.FadeTimeout;
	}	
}

Headlines.prototype.changeHeadline = function()
{
	if(this.headlineIndex == this.headlines.length)
	{
		this.headlineIndex = 0;
	}	

	this.headlineArea.innerHTML = this.headlines[this.headlineIndex];
	this.headlineIndex++;
}

Headlines.FadeTimeout = 15;
Headlines.PauseTimeout = 4000;
Headlines.Shade = new Array("EEEEEE", "CECECE", "CCCCCC", "9F9F9F", "999999", 
	"666666", "3F3F3F", "333333", "0F0F0F", "000000");

