// Ticker startup
function startTicker()
{
	// Define run time values
	theCurrentStory     = -1;
	theCurrentLength    = 0;
	// Locate base objects
	if (document.getElementById) {	
		    theMessageObject     = document.getElementById("tickerMessage");
		    theImageObject     = document.getElementById("tickImage");
			runTheTicker();   	
	};
};
// Ticker main run loop
function runTheTicker()
{
	var myTimeout;  
	if(theImageFlashCount < theImageFlashTotalCount)
	{
		// flash the image
		myTimeout = theImageFlashTimeout;
		theImageFlashCount++;
		if(theImageObject.src.indexOf("tickBlank.gif")>-1) {
			 theImageObject.src="/images/tickOn.gif"
		}
		else {
			 theImageObject.src="/images/tickBlank.gif"
		};				
		//alert(theImageObject.src);
	}
	else
	{ 
		if(theImageObject.src.indexOf("tickBlank.gif")>-1) {
			 theImageObject.src="/images/tickOn.gif"
		};
		// Go for the next story data block
		if(theCurrentLength == 0)
		{
			theCurrentStory++;
			theCurrentStory      = theCurrentStory % theItemCount;
			theStorySummary      = theSummaries[theCurrentStory].replace(/&quot;/g,'"');		
			theTargetLink        = theSiteLinks[theCurrentStory];
			thePrefix 	     = theLeadString;
		}
		// Stuff the current ticker text into the anchor
		theMessageObject.innerHTML = '<span class="tickertext">' + thePrefix + 
		theStorySummary.substring(0,theCurrentLength) + whatWidget() + '</span>';
		// Modify the length for the substring and define the timer
		if(theCurrentLength != theStorySummary.length)
		{
			theCurrentLength++;
			myTimeout = theCharacterTimeout;
		}
		else
		{
			theCurrentLength = 0;
			myTimeout = theStoryTimeout;
			theImageFlashCount=0;
		}
	};
	// Call up the next cycle of the ticker
	setTimeout("runTheTicker()", myTimeout);
}
// Widget generator
function whatWidget()
{
	if(theCurrentLength == theStorySummary.length)
	{
		return theWidgetNone;
	}

	if((theCurrentLength % 2) == 1)
	{
		return theWidgetOne;
	}
	else
	{
		return theWidgetTwo;
	}
}
