
var theCharacterTimeout = 50;
var theStoryTimeout     = 5000;
var theWidgetOne        = "_";
var theWidgetTwo        = "-";
var theWidgetNone       = "";
var theLeadString       = "";

var theSummaries = new Array();
var theSiteLinks = new Array();
var theItemCount = 20;
theSummaries[0] = "13/05/2008 - New leaflet to assist disabled rail travellers launched";
theSiteLinks[0] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997851";
theSummaries[1] = "09/05/2008 - ATOC says ORR decision on Network Rail fine is \"Disappointing\" and \"A missed opportunity\"";
theSiteLinks[1] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997850";
theSummaries[2] = "06/05/2008 - Eurostar and ATOC announce through fares to continental Europe are now available from over 130 towns and cities";
theSiteLinks[2] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997849";
theSummaries[3] = "24/04/2008 - ATOC announces simpler rail fares";
theSiteLinks[3] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997848";
theSummaries[4] = "18/04/2008 - Gwyneth Dunwoody MP was a good friend of the Railway Industry says ATOC";
theSiteLinks[4] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997847";
theSummaries[5] = "10/04/2008 - Britain\'s railways used by record numbers of people in 2007";
theSiteLinks[5] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997846";
theSummaries[6] = "17/03/2008 - Easter travel advice for rail passengers";
theSiteLinks[6] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997845";
theSummaries[7] = "14/03/2008 - ATOC comments on NAO Report and announces new train delay information service for passengers";
theSiteLinks[7] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997844";
theSummaries[8] = "07/03/2008 - Easter travel advice for rail passengers from train operators";
theSiteLinks[8] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997843";
theSummaries[9] = "03/03/2008 - East Coast Main Line RUS offers \"clear vision\" says ATOC";
theSiteLinks[9] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997842";
theSummaries[10] = "28/02/2008 - ATOC comments on ORR Report on engineering overruns";
theSiteLinks[10] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997841";
theSummaries[11] = "14/02/2008 - ATOC announces new management team";
theSiteLinks[11] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997840";
theSummaries[12] = "31/01/2008 - ATOC comments on Department for Transport announcement on station improvements";
theSiteLinks[12] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997839";
theSummaries[13] = "30/01/2008 - Time to get a move on says ATOC-DfT Rolling Stock Strategy";
theSiteLinks[13] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997836";
theSummaries[14] = "29/01/2008 - Train Operators welcome publication of Railway Pensions Commission Report";
theSiteLinks[14] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997838";
theSummaries[15] = "24/01/2008 - ATOC Comments on National Passenger Survey";
theSiteLinks[15] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997835";
theSummaries[16] = "21/01/2008 - ATOC responds to Liberal Democrats research on fares";
theSiteLinks[16] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997834";
theSummaries[17] = "03/01/2008 - ATOC comments on engineering overrun on West Coast Main Line";
theSiteLinks[17] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997833";
theSummaries[18] = "01/01/2008 - ATOC statement on January fares rises";
theSiteLinks[18] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997832";
theSummaries[19] = "19/12/2007 - ATOC rebutts TSSA claims on rail fares";
theSiteLinks[19] = "http://www.atoc-comms.org/dynamic/atocpress-story.php?atoc=997831";

// Ticker startup
function startTicker()
{
  document.getElementById('ticker').innerHTML = 'LATEST ATOC NEWS:&nbsp;<a title="News Ticker" id="tickerAnchor" href="#" class="tickl"></a>';
	// Define run time values
	theCurrentStory     = -1;
	theCurrentLength    = 0;
	theAnchorObject     = document.getElementById("tickerAnchor");
	runTheTicker();
}
// Ticker main run loop
function runTheTicker()
{
	var myTimeout;
	// Go for the next story data block
	if(theCurrentLength == 0)
	{
		theCurrentStory++;
		theCurrentStory      = theCurrentStory % theItemCount;
		theStorySummary      = theSummaries[theCurrentStory].replace(/&quot;/g,'"');
		theTargetLink        = theSiteLinks[theCurrentStory];
		theAnchorObject.href = theTargetLink;
		thePrefix 	     = "<span class=\"tickls\">" + theLeadString + "</span>";
	}
	// Stuff the current ticker text into the anchor
	theAnchorObject.innerHTML = thePrefix +
	theStorySummary.substring(0,theCurrentLength) + whatWidget();
	// Modify the length for the substring and define the timer
	if(theCurrentLength != theStorySummary.length)
	{
		theCurrentLength++;
		myTimeout = theCharacterTimeout;
	}
	else
	{
		theCurrentLength = 0;
		myTimeout = theStoryTimeout;
	}
	// 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;
	}
}