
// WebTicker by Mioplanet
// www.mioplanet.com

var elements = document.getElementById('tickers').getElementsByTagName('div');
restart = 1;
i=0;
	
var div_id = "news_bar";
var TICKER_CONTENT = document.getElementById(elements.item(i).id).innerHTML;
TICKER_RIGHTTOLEFT = false;
TICKER_SPEED = 2;
TICKER_STYLE = "font-family:Arial; font-size:12px; color:#000000";
TICKER_PAUSED = false;

ticker_start(TICKER_CONTENT);

function ticker_start(TICKER_CONTENT) {
	var tickerSupported = false;
	TICKER_WIDTH = document.getElementById(div_id).style.width;
	var img = "<img src='images/blank.gif' width='"+TICKER_WIDTH+"' height='0'>";

		document.getElementById(div_id).innerHTML = "<TABLE  cellspacing='0' cellpadding='0' width='100%'><TR><TD nowrap='nowrap'>"+img+"<SPAN style='"+TICKER_STYLE+"' ID='TICKER_BODY' width='100%'> </SPAN>"+img+"</TD></TR></TABLE>";
		tickerSupported = true;

	//div_id="TICKER_BODY";	
	
	if(!tickerSupported) document.getElementById(div_id).outerHTML = ""; else {
		document.getElementById(div_id).scrollLeft = TICKER_RIGHTTOLEFT ? document.getElementById(div_id).scrollWidth - document.getElementById(div_id).offsetWidth : 0;
		document.getElementById("TICKER_BODY").innerHTML = TICKER_CONTENT;
		document.getElementById(div_id).style.display="block";
		TICKER_tick();
	}
}

function TICKER_tick() {
	while(1==1){
	//div_id="TICKER_BODY";	
	if(!TICKER_PAUSED) document.getElementById(div_id).scrollLeft += TICKER_SPEED * (TICKER_RIGHTTOLEFT ? -1 : 1);
	if(TICKER_RIGHTTOLEFT && document.getElementById(div_id).scrollLeft <= 0) document.getElementById(div_id).scrollLeft = document.getElementById(div_id).scrollWidth - document.getElementById(div_id).offsetWidth;
	if((!TICKER_RIGHTTOLEFT && document.getElementById(div_id).scrollLeft >= (
	document.getElementById(div_id).scrollWidth - document.getElementById(div_id).offsetWidth)) || restart == 0 )
	{
	restart = 1;
	document.getElementById(div_id).scrollLeft = 0;
	i++;
	if(i== elements.length) {i=0}
	var TICKER_CONTENT = document.getElementById( elements.item(i).id).innerHTML;
	window.setTimeout(function(){ticker_start(TICKER_CONTENT)}, 30 );
	break;
	}
	window.setTimeout(function(){TICKER_tick()}, 30);
	break;
	}
	
}
function n_new(idx){
restart = 0;
if(i!=0) {i=i-idx} else {if(idx!=0) i=-1};
}

