/************************
Scrolling Text
Rev. 1/08/2007

scrollingText(Int [width in pixels], Int [height in pixels], Int [time between scrolls 1000/second], Array [Items to scroll], Int [delay start in seconds])
************************/
function scrollingText(w, h, speed, itemArray, startDelay)
{	
	//Create html
	var html = "";	
	
	//Create main container
	html += "<div style=\"width:"+w+"px;height:"+h+"px;overflow:hidden;position:relative;\" ";
	html += "onmouseover=\"clearInterval(scrollingTextInterval);\" ";
	html += "onmouseout=\"setScrollingTextInterval("+h+","+speed+");\" ";
	html += ">";
		//Create scrolling container1
		html += "<div id=\"scrollingTextScroller1\" style=\"width:"+w+"px;height:auto;position:relative;top:0px;margin:0px;_margin-bottom:20px;padding:0px;\">";
		for(var i=0;i<itemArray.length;i++)
		{
			html += "<p>"+itemArray[i]+"</p>";	
		}
		html += "</div>";
		//Create scrolling container2
		html += "<div id=\"scrollingTextScroller2\" style=\"width:"+w+"px;height:auto;position:relative;top:0px;margin:0px;padding:0px;\">";
		for(var i=0;i<itemArray.length;i++)
		{
			html += "<p>"+itemArray[i]+"</p>";	
		}
		html += "</div>";
	html += "</div>";
	
	document.write(html);
	
	delayIterations = startDelay?startDelay:5;
	delay(h,speed);
	delayInterval = setInterval("delay("+h+","+speed+")",1000);
}
function scrollingTextIterator(h)
{
	var scrollerHeight = document.getElementById("scrollingTextScroller1").offsetHeight;
	var regExTop = /(\d+)(px)/;
	var newTop1 = document.getElementById("scrollingTextScroller1").style.top.replace(regExTop,"$1") - 2;
	var newTop2 = document.getElementById("scrollingTextScroller2").style.top.replace(regExTop,"$1") - 2;
	document.getElementById("scrollingTextScroller1").style.top = newTop1 + "px";
	document.getElementById("scrollingTextScroller2").style.top = newTop2 + "px";
	if(-(newTop1 + 15) > scrollerHeight)
	{
		document.getElementById("scrollingTextScroller1").style.top = (Math.abs(newTop2)) +"px";
	}
	if(-(newTop2 + 50) > scrollerHeight*2)
	{
		document.getElementById("scrollingTextScroller2").style.top = newTop1 +"px";
	}
}
function setScrollingTextInterval(h,speed)
{
	scrollingTextIterator(h);
	scrollingTextInterval = setInterval("scrollingTextIterator("+h+")",speed);
}

function delay(h,speed)
{
	delayIterations--;
	if(delayIterations < 0)
	{
		setScrollingTextInterval(h,speed);
		clearInterval(delayInterval);
	}
}

