
// WebTicker by Mioplanet
// www.mioplanet.com

tickerObject = document.getElementById("ticker");
tickerContent = tickerObject.innerHTML;
 
tickerRTL = false;
tickerSpeed = 2;
tickerPaused = false;

ticker_start();

function ticker_start() {
	
	var tickerSupported = false;
	tickerWidth = tickerObject.style.width;
	var img = "<img src=\"immagini/spacer.gif\" width="+tickerWidth+" height=\"1\">";

	// Firefox
	/*if (navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1) {
		tickerObject.innerHTML = "<TABLE  cellspacing='0' cellpadding='0' width='100%'><TR><TD nowrap='nowrap'>"+img+"<SPAN style='"+tickerStyle+"' ID='tickerBody' width='100%'>&nbsp;</SPAN>"+img+"</TD></TR></TABLE>";
		tickerSupported = true;
	}
	// IE
	if (navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Opera")==-1) {
		tickerObject.innerHTML = "<DIV nowrap='nowrap' style='width:100%;'>"+img+"<SPAN style='"+tickerStyle+"' ID='tickerBody' width='100%'></SPAN>"+img+"</DIV>";
		tickerSupported = true;
	}*/
	
	// UNIVERSAL (Verlok)
	tickerObject.innerHTML = "<div style=\"white-space:nowrap\">"+img+"<span id='tickerBody' width='100%'>&nbsp;</span>"+img+"</div>";
	tickerSupported = true;
	
	if(!tickerSupported) tickerObject.outerHTML = ""; else {
		tickerObject.scrollLeft = tickerRTL ? tickerObject.scrollWidth - tickerObject.offsetWidth : 0;
		document.getElementById("tickerBody").innerHTML = tickerContent;
		tickerObject.style.display="block";
		tickerTick();
	}
}

function tickerTick() {
	if(!tickerPaused) tickerObject.scrollLeft += tickerSpeed * (tickerRTL ? -1 : 1);
	if(tickerRTL && tickerObject.scrollLeft <= 0) tickerObject.scrollLeft = tickerObject.scrollWidth - tickerObject.offsetWidth;
	if(!tickerRTL && tickerObject.scrollLeft >= tickerObject.scrollWidth - tickerObject.offsetWidth) tickerObject.scrollLeft = 0;
	window.setTimeout("tickerTick()", 50);
}
