﻿var aTickerObj;
var currentPressRelease;
var currentLength;
var pressReleaseSummary;

var intCharacterTimeout = 50;
var intStoryTimeout = 3000;
var strWidgetOne = "_";
var strWidgetTwo = "-";
var strWidgetNone = "";

function startTicker(aTickerID)
{
	
	currentPressRelease = -1;
	currentLength = 0;
	
	aTickerObj = document.getElementById(aTickerID);
  if (aTickerObj) { runTheTicker(); }
  
}

function runTheTicker()
{
	var myTimeout;  
	
	// Process Next Press Release
	if(currentLength == 0) {
		currentPressRelease++;
		currentPressRelease = currentPressRelease % pressReleases.length;
		pressReleaseSummary = pressReleases[currentPressRelease][0];		
		aTickerObj.href = pressReleases[currentPressRelease][1];
		aTickerObj.setAttribute("onclick","javascript: pageTracker._trackPageview('" + pressReleases[currentPressRelease][0].replace(/&apos;/g,"\'") + "');");		
		}
	
	// Insert PR Data Into Anchor
	aTickerObj.innerHTML = pressReleaseSummary.substring(0,currentLength) + getWidget();
	
	// Modify the length for the substring and define the timer
	if(currentLength != pressReleaseSummary.length)
	{
		currentLength++;
		myTimeout = intCharacterTimeout;
	}
	else
	{
		currentLength = 0;
		myTimeout = intStoryTimeout;
	}
	
	setTimeout("runTheTicker()", myTimeout);
	
}

function getWidget()
{
	if(currentLength == pressReleaseSummary.length)
	{
		return strWidgetNone;
	}

	if((currentLength % 2) == 1)
	{
		return strWidgetOne;
	}
	else
	{
		return strWidgetTwo;
	}
}