/*
	JUUCE TickerTape
	
	This HTML must be present:
		<div id="newsScroll">
			<div id="tickerTape"></div>
		</div>

	This CSS must be present:
		#tickerTape { overflow:hidden;width:auto;white-space:nowrap; }
		
	Significant testing in Internet Explorer 6.0.2900, Internet Explorer 7.0.5730, Internet Explorer 8 Beta 2, Firefox 3.0.5, Opera 9.63 and
	Safari 3.2
	
	IE6 can be temperamental, but no more than with other JS. Dynamic line length is only reported accurately when inline, but IE6/7
	render inline objects incorrectly, so we need to switch stuff around. The rest is all rather simple.
	
	Ensure you load this file first, then defer (for IE), somewhere at the end of your HTML document:
	    tapeArray.push ("First line...");
    	tapeArray.push ("...second line...");
    	tapeArray.push ("...third line!");
	    tickertape_go();
	    
	Only standard JS is used. No innerHTML() nonsense here.

*/

var tapeArray = new Array();
var tapeLink = new Array();
var tapeIndex = 0;
var tapeWidth;
function tickertape() {
	document.getElementById('tickerTape').style.marginLeft = (parseInt(document.getElementById('tickerTape').style.marginLeft) - 1) + 'px';
	if (parseInt(document.getElementById('tickerTape').style.marginLeft) > tapeWidth * -1) {
		setTimeout("tickertape()", 30);
	} else {
		tapeIndex++;
		if (tapeIndex > tapeArray.length - 1) {
			tapeIndex = 0;
		}
		tickertape_start(tapeArray[tapeIndex]);
	}
}
function tickertape_start(str) {
	document.getElementById('tickerTape').style.marginLeft = document.getElementById('newsScroll').offsetWidth+'px';
	while(document.getElementById('tickerTape').hasChildNodes()) {
		document.getElementById('tickerTape').removeChild(document.getElementById('tickerTape').lastChild);
	}
	if (tapeLink[tapeIndex]=="") {
		document.getElementById('tickerTape').appendChild(document.createTextNode(str));
	} else {
		var link = document.createElement('a');
		link.setAttribute('href', tapeLink[tapeIndex]);
		document.getElementById('tickerTape').appendChild(link).appendChild(document.createTextNode(str));
	}
	document.getElementById('tickerTape').style.display='inline';
	tapeWidth = parseInt(document.getElementById('tickerTape').offsetWidth);
	document.getElementById('tickerTape').style.display='block';
	setTimeout("tickertape()", 10);
}

function tickertape_go() {
	setTimeout("tickertape_start(tapeArray[tapeIndex])",1000);
}
