// Control parameters
function titleBar(name)
{
	this.runningState = true;
	this.end;
	this._name = name;
	this.theCharacterTimeout = 40;
	this.theStoryTimeout = 5000;
	this.theWidgetOne = "_";
	this.theWidgetTwo = "-";
	this.theWidgetNone = "";
	this.NS6 = (document.getElementById && !document.all) ? true : false;
	this.theSummaries = new Array();
	this.theSiteLinks = new Array();
	this.theCurrentStory;
	this.theStorySummary;
	this.theTargetLink;
	this.tickerobj;

	// Ticker startup
	this.startTicker = function ST_startTicker(tickerid, sums, links)
	{
		this.tickerobj = document.getElementById(tickerid)
		this.theSummaries = sums;
		this.theSiteLinks = links;
		// Define run time values
		this.theCurrentStory = -1;
		this.theCurrentLength = 0;
		// Locate base objects
		var self = this
		if (document.getElementById)
		{
			setTimeout(function() { self.runTheTicker(); }, 500)
		}
		else
		{
			document.write("<style>.ticki{display:none;}.ticko{border:0px; padding:0px;}</style>");
			return true;
		}
	}
	// Ticker main run loop
	this.runTheTicker = function ST_runTheTicker()
	{
		this.myTimeout;
		// Go for the next story data block
		if (this.theCurrentLength == 0)
		{
			this.theCurrentStory++;
			this.theCurrentStory = this.theCurrentStory % this.theSummaries.length;
			this.theStorySummary = this.theSummaries[this.theCurrentStory];
			this.theTargetLink = this.theSiteLinks[this.theCurrentStory];
		}
		var widget;
		if (this.theCurrentLength == this.theStorySummary.length)
		{
			widget = this.theWidgetNone;
		}
		else if ((this.theCurrentLength % 2) == 1)
		{
			widget = this.theWidgetOne;
		}
		else
		{
			widget = this.theWidgetTwo;
		}
		var mousehandle = ' onmouseover="' + this._name + '.stop()" onmouseout="' + this._name + '.start()" ';
		var textTitle = this.theStorySummary.substring(0, this.theCurrentLength) + widget;
		if (this.theTargetLink)
			this.tickerobj.innerHTML = '<a href="' + this.theTargetLink + '" ' + mousehandle + ' target="_blank" class="ticker">' + textTitle + '</a>';
		else
			this.tickerobj.innerHTML = '<span class="ticker" ' + mousehandle + ' >' + textTitle + '</span>';

		// Modify the length for the substring and define the timer
		if (this.theCurrentLength != this.theStorySummary.length)
		{
			this.theCurrentLength++;
			this.end = false;
			myTimeout = this.theCharacterTimeout;
		}
		else
		{
			this.theCurrentLength = 0;
			this.end = true;
			myTimeout = this.theStoryTimeout;
		}

		// Call up the next cycle of the ticker
		if (this.end == false || (this.end == true && this.runningState))
		{
			var self = this
			this.timer = setTimeout(function() { self.runTheTicker(); }, myTimeout);
		}
	}

	this.start = function ST_start()
	{
		this.runningState = true;
		if (this.end == true)
			window.clearTimeout(this.timer);
		var self = this;
		if (document.getElementById)
		{
			setTimeout(function() { self.runTheTicker(); }, 500);
		}
		else
		{
			document.write("<style>.ticki{display:none;}.ticko{border:0px; padding:0px;}</style>");
			return true;
		}
	}

	this.stop = function ST_stop()
	{
		this.runningState = false;
		if (this.end == true)
			window.clearTimeout(this.timer);
	}
}

function lightup(imageobject, opacity){
    if (navigator.appName.indexOf("Netscape")!=-1&&parseInt(navigator.appVersion)>=5)
    imageobject.style.MozOpacity=opacity/100;
    else if (navigator.appName.indexOf("Microsoft")!=-1&&parseInt(navigator.appVersion)>=4)
    imageobject.filters.alpha.opacity=opacity;
}
