AT Goodies: News Ticker

Example

Zee News reports Q2 Net Profit of Rs. 59.4 million Microsoft set to launch Mango powered smartphones Matrox to showcase latest products at Inter BEE 2011 HISTORY impresses with 19.8 million viewers on Indian debut WWIL operating profit up by 21% Tata Teleservices unveils growth strategy and Photo Max


Features
HTML Code
<div id="at_ticker">
	<a class="at_ticker_element" href="">Zee News reports Q2 Net Profit of Rs. 59.4 million </a>
	<a class="at_ticker_element" href="">Microsoft set to launch Mango powered smartphones </a>
	<a class="at_ticker_element" href="">Matrox to showcase latest products at Inter BEE 2011 </a>
	<a class="at_ticker_element" href="">HISTORY impresses with 19.8 million viewers on Indian debut </a>
	<a class="at_ticker_element" href="">WWIL operating profit up by 21% </a>
	<a class="at_ticker_element" href="">Tata Teleservices unveils growth strategy and Photo Max </a>			
</div>		
CSS
#at_ticker{border-radius:5px; background:#535353; font:normal 12px verdana; padding:5px 0px 5px 0px; display:inline-block}
.at_ticker_element{margin-right:50px; line-height:18px; color:#fff; text-decoration:none; padding:2px}
.at_ticker_element:Hover{margin-right:50px; text-decoration:underline}
JavaScript
var at_ticker_pos=0;

function at_ticker_start(speed,width){
	at_ticker_pos=width;
	var ele=document.getElementById('at_ticker');

	var at_ticker_contents=ele.innerHTML;			
	ele.style.width=width+"px";
	ele.style.overflow="hidden";
	ele.style.position="relative";
	document.getElementById("at_ticker").innerHTML=""+at_ticker_contents+"";
	at_ticker_tick(speed);
}

function at_ticker_tick(speed){
	at_ticker_pos=at_ticker_pos-1;
	document.getElementById('at_ticker_contents').style.left=at_ticker_pos+"px";			
	setTimeout("at_ticker_tick("+speed+")", speed);

	if(document.getElementById('at_ticker').scrollWidth < Math.abs(document.getElementById('at_ticker_contents').offsetLeft))
	{		
		at_ticker_pos=document.getElementById('at_ticker').clientWidth;
	}
}