oh=null;
if(window.onload)
	var oh=window.onload;
	
//window.onload=firstrun;

var timer=null;

var scrollers={"ticker":new Ticker("ticker")};
var speed=40;

function firstrun()
{
	if(oh)
		oh();
	
	for(var s in scrollers)
		scrollers[s].initialize();
	startScrollers();
}

function Ticker(id)
{
	this.id=id;
	this.ready=false;
	this.stopped=false;
	this.y=0;
}

Ticker.prototype.initialize=function()
{
	this.scroller=document.getElementById(this.id);
	this.items=this.scroller.getElementsByTagName('div');
	//for(var j=0;j<this.items.length;j++)
	//{
		//this.items.item(j).style.position='relative';
		//alert(this.items.item(j).offsetTop);
	//}
	this.maxHeight=this.scroller.parentNode.offsetHeight;
	this.selfHeight=this.scroller.offsetHeight;
	this.scroller.style.top=this.y+'px';
	this.ready=true;
}

	
Ticker.prototype.stop=function()
{
	if(!this.ready)
		return;
	
	this.stopped=true;
}	

Ticker.prototype.start=function()
{
	if(!this.ready)
		return;
	
	this.stopped=false;
}	

Ticker.prototype.scroll=function()
{
	if(!this.ready)
		return;
	
	
	if(this.y+this.selfHeight>0)
	{
		if(this.y<=0)
		{
			for(var j=0;j<this.items.length;j++)
			{
				if(this.y+this.items.item(j).offsetTop==0)
				{
					this.stop();
					window.setTimeout('scrollers["'+this.id+'"].start()',2000);
				}
			}
		}
		this.y=this.y-1;
	}
	else
	{	
		this.stop();
		this.y=this.maxHeight+1;
		window.setTimeout('scrollers["'+this.id+'"].start()',0);
	}	
	this.scroller.style.visibility='hidden';
	this.scroller.style.top=this.y+'px';
	this.scroller.style.visibility='visible';
}

function startScrollers()
{
	if(timer==null)
		timer=window.setInterval('scroll()',speed);
}

function scroll()
{
	for(var s in scrollers)
	{	
		if(!scrollers[s].stopped)
			scrollers[s].scroll();
	}	
}




