/////////////////////////////////////////////////////////////////////////
//
//	JAVASCRIPT code to display scrolling news items without using 
//	MS specific marquee tag - NB see also ticker.css
//
//	25/10/07	v1.00	The original code
//
/////////////////////////////////////////////////////////////////////////
//
//	This JAVASCRIPT code may be freely copied for use on your own
//	site, with changes if you so wish.  All I ask is that you leave 
//	an acknowledgement (this heading?) in the code, and maybe drop me
//	an email to let me know that you are using it.  E&OE
//
//	If you do notice any errors, I'd appreciate an email telling me.
//	
//	Andy Judge
//	Webmaster, St James the Greater, Leicester
//	andy@adlibitum.co.uk 
//
/////////////////////////////////////////////////////////////////////////



// TICKER DATA...

var TickerText = new Array () ;		// used to hold messages to display
var TickerCount = 0 ;				// count of messages

var TickerWidth = 770 ;				// width of ticker

var TickerCurrent = 0 ;				// currently displayed message
var TickerPos = 0 ;				// current position
var TickerDelay = 100 ;				// mS between moves
var TickerMove = 70 ;				// px to move
var TickerPause = 5000 ;			// delay in centre
var TAid = 0 ;					// interval ID
var TCid = 0 ;					// timeout ID




// EXTERNAL FUNCTIONS...

function AddTicker(Message)
	{
	TickerText[TickerCount++] = Message ;
	}

function StartTicker()
	{
	TickerCurrent = TickerCount ;		// force ChangeTicker to use first
	ChangeTicker() ;
	}
	
	


// INTERNAL FUNCTIOMNS...
	
function ChangeTicker()
	{
	TickerCurrent++ ;
	if (TickerCurrent >= TickerCount) TickerCurrent = 0 ;
	
	TickerPos = TickerWidth ;
	document.getElementById("Ticker").innerHTML = TickerText[TickerCurrent] ;
	document.getElementById("Ticker").style.left = TickerPos + 'px' ;
	TAid = setInterval("AnimateTicker()", TickerDelay) ;
	}

function AnimateTicker()
	{
	TickerPos = TickerPos - TickerMove ;
	if ( (TickerPos < TickerMove) && (TickerPos > 0) )
		TickerPos = 0 ;

	if (TickerPos < -TickerWidth)
		{
		clearInterval(TAid) ;	
		ChangeTicker() ;
		} 
	else
		{
  		document.getElementById('Ticker').style.left = TickerPos + 'px' ;
		if (TickerPos == 0)
			{
			clearInterval(TAid) ;	
			TCid = setTimeout("RestartTicker()", TickerPause);
			} 
  		}
	}

function RestartTicker()
	{
	TAid = setInterval("AnimateTicker()", TickerDelay) ;
	}

	
