//Thanks to http://www.neale-wade.cambs.sch.uk/ticker.htm

// Pause added -PM
// Target added - PM

// Ticker startup
function start_ticker()
{
	// Define run time values
	theCurrentStory     = -1;
	theCurrentLength    = 0;
	// Locate base objects
	if (document.getElementById) {	
		    theAnchorObject     = document.getElementById("tickerAnchor");	    
			runTheTicker();  
 
		 }
	else {
            document.write("<style>.ticki{display:none;}.ticko{border:0px; padding:0px;}</style>");
            return true;
	}
}
// Ticker main run loop
function runTheTicker()
{

	if (pause_ticker == false)
		{
	
			var myTimeout; 		 
			// Go for the next story data block
			if(theCurrentLength == 0)
			{
				theCurrentStory++;
				theCurrentStory      = theCurrentStory % no_of_leads;
				theStorySummary      = lead[theCurrentStory].replace(/&quot;/g,'"');		
				theTargetLink        = lead_link[theCurrentStory];
				theAnchorObject.href = theTargetLink;
				theAnchorObject.target = lead_target[theCurrentStory];
				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 puts either a - or a _ in front of the leading letter until it gets to the end of the string
// DEpending on whether it is odd or even (modulus (%) on div by 2 = 1 
function whatWidget()
{
	if(theCurrentLength == theStorySummary.length)
	{
		return theWidgetNone;
	}

	if((theCurrentLength % 2) == 1)
	{
		return theWidgetOne;
	}
	else
	{
		return theWidgetTwo;
	}
}

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

var lead = new Array();
var lead_link = new Array();
var lead_target = new Array();

var pause_ticker = false





