function Scroller()
{
	this.content = '';
	this.body = '';
	this.bodyArray = new Array();
	this.counter = 0;
	this.scroller1_y = 0;
	this.scroller2_y = 0;
	this.typerbg = new Array();
	this.typerbg[0] = '';
	this.typerbg[1] = 'url(../imgs/li_bg_grey.gif) no-repeat';
	this.typer = 3;
	this.typerCounter = 1;
	this.carat = 0;
	this.paused = 0;
	this.start = '';
	this.layerStart = '';
	this.layerEnd = '';
	this.end = '';
	this.addItem = addScrollerItem;
	this.showContent = showScrollerContent;
	this.scroll = scrollIt;
}

var useragent = navigator.userAgent.toLowerCase();
if (useragent.indexOf('mac'))
{
	var isMac = true;
}
else
{
	var isMac = false;
}

function addScrollerItem(url,text)
{
	thisID = this.bodyArray.length;
	this.bodyArray[thisID] = new Array();
	this.bodyArray[thisID][0] = url;
	this.bodyArray[thisID][1] = text;
	//this.bodyArray[thisID][0] = '<a href="' + url + '">' + text + '</a></li>';
	this.counter++;
}




function checkIt(string)
{
	var useragent = navigator.userAgent.toLowerCase();
	place = useragent.indexOf(string) + 1;
	return place;
}

if (checkIt('mac'))
{
	isMac = true;
}
else
{
	isMac = false;
}

function showScrollerContent()
{
	var thisCounter = 0;
	for (a=1; a<=2; a++)
	{
		this.body += '<div id="scrollerContent' + a + '" style="position: relative;"><ul>';
		for (b=0; b<this.counter; b++)
		{
			this.body += '<li class="newsContainerList' + (((thisCounter++) % 2) + 1) + '"><a href="' + this.bodyArray[b][0] + '" style="height: 17px; width: 500px;" target="_top">' + this.bodyArray[b][1] + '</a></li>';
		}
		this.body += '</ul></div>';
	}
	this.content = 	this.start + 
					this.body + 
					this.end;
	
	document.getElementById("newsScrollerContainer").innerHTML = this.content;
	if (isMac)
	{
		document.getElementById('newsScrollerTyperLink').href = this.bodyArray[3][0];
		document.getElementById('newsScrollerTyperLink').innerHTML = this.bodyArray[3][1];
	}
	
}
	
function scrollIt()
{
	if (newsScroller.scroller1_y % 17 == 0 && newsScroller.paused == 0)
	{
		newsScroller.paused = 1;
		if ((0 - newsScroller.scroller1_y) == newsScroller.counter * 17)
		{
			newsScroller.scroller1_y = 0;
		}
		if ((0 - newsScroller.scroller2_y) == newsScroller.counter * 17)
		{
			newsScroller.scroller2_y = 0;
		}
		newsScroller.timeOut = setTimeout('typeIt()',10);
	}
	else if (newsScroller.paused == 1)
	{
		newsScroller.paused = 0;
		document.getElementById('newsScrollerTyperLink').innerHTML = '';
		document.getElementById('newsScrollerTyper').style.background = newsScroller.typerbg[newsScroller.typerCounter %2];
		newsScroller.typerCounter++;
		
	}
	if (newsScroller.paused == 0)
	{
		newsScroller.scroller1_y -= 1;
		newsScroller.scroller2_y -= 1;
		document.getElementById('scrollerContent1').style.top = newsScroller.scroller1_y;
		document.getElementById('scrollerContent2').style.top = newsScroller.scroller2_y;
		newsScroller.timeOut = setTimeout('scrollIt()',10);
	}
}

function typeIt()
{
	document.getElementById('newsScrollerTyperLink').href = newsScroller.bodyArray[newsScroller.typer][0];
	if (newsScroller.carat < newsScroller.bodyArray[newsScroller.typer][1].length)
	{
		document.getElementById('newsScrollerTyperLink').innerHTML += newsScroller.bodyArray[newsScroller.typer][1].substring(newsScroller.carat, newsScroller.carat+1);
		newsScroller.carat++;
		newsScroller.timeOut = setTimeout('typeIt()',50);
	}
	else
	{
		newsScroller.carat = 0;
		if (newsScroller.typer == newsScroller.counter -1)
		{
			newsScroller.typer = 0;
		} 
		else
		{
			newsScroller.typer++;
		}
		newsScroller.timeOut = setTimeout('scrollIt()',2000);
	}
	
}