

//Constants
//The X Location where news should sit and wait
var Scrolling_WaitLoc = 10;
//The X Location where the div tag will begin
var Scrolling_StartLoc = -60;
//The X Location where the div tag will end, after this it's moved to StartLoc
var Scrolling_EndLoc = 60;
//How long a news items should wait in the middle
var Scrolling_WaitTime = 3000;
//Value used for recalling the movement function (1 = fastest, higher value = slower)
var Scrolling_MoveTime = 1;

//Starting location for news 1 div (it appears first)
var Scrolling_News1Loc = Scrolling_WaitLoc;
//Starting location for news 2 div (it starts queued up top)
var Scrolling_News2Loc = Scrolling_StartLoc;

//Define news arrays
var Scrolling_HeadlinesArray = new Array();
var Scrolling_BlurbsArray = new Array();
var Scrolling_DatesArray = new Array();
var Scrolling_IDArray = new Array();
var Scrolling_NewsItemsCount = 0;



//The index of the current news item being views
var Scrolling_CurrentNewsIndex = 0;

//These will be our reference for refering the divs
var Scrolling_NewsWindow1_ref;
var Scrolling_NewsWindow2_ref;
var Scrolling_MainWindow_ref;

//This used to stop the scrolling for the user to click on the news
//Changed when the mouse enters the window
var Scrolling_StopScrolling = false;

function Scrolling_BeginScroll()
{
	//Dont do anything if there's no news
	if (Scrolling_NewsItemsCount == 0)
	{
		return;
	}

	//Create a ref for IE and NS so they are easier to refer to later
	if (document.all)
	{
		Scrolling_NewsWindow1_ref = Scrolling_NewsWindow1;
		Scrolling_NewsWindow2_ref = Scrolling_NewsWindow2;
		Scrolling_MainWindow_ref = Scrolling_MainWindow;
	}
	else
	{
		Scrolling_NewsWindow1_ref = document.getElementById("Scrolling_NewsWindow1");
		Scrolling_NewsWindow2_ref = document.getElementById("Scrolling_NewsWindow2");
		Scrolling_MainWindow_ref = document.getElementById("Scrolling_MainWindow");
	}

	//Prime the divs with news items
	//If there is only one news item then both divs get the one item
	if (Scrolling_NewsItemsCount == 1)
	{
		Scrolling_SetNewsContent(Scrolling_NewsWindow1_ref, 0);
		Scrolling_SetNewsContent(Scrolling_NewsWindow2_ref, 0);
		Scrolling_CurrentNewsIndex = 0;
	}
	else
	{
		Scrolling_SetNewsContent(Scrolling_NewsWindow1_ref, 0);
		Scrolling_SetNewsContent(Scrolling_NewsWindow2_ref, 1);
		
		if (Scrolling_NewsItemsCount == 2)
			Scrolling_CurrentNewsIndex = 1;
		else
			Scrolling_CurrentNewsIndex = 2;
	}

	//Begin the movement loop
	setTimeout(Scrolling_MoveText, 1);
}

function Scrolling_MoveText()
{
	//If either divs have hit the 'wait' spot then call a function to get things started again later and
	//return out now to wait
	if (Scrolling_News1Loc == Scrolling_WaitLoc || Scrolling_News2Loc == Scrolling_WaitLoc)
	{
		setTimeout(Scrolling_ContinueScroll, Scrolling_WaitTime);
		return;
	}
	
	//Increment the var which is used for the locations of the divs
	Scrolling_News1Loc += 1;
	Scrolling_News2Loc += 1;
	
	//If news 1 div has reached the end then fill it with content from the next news item
	//and move it to the start position
	if (Scrolling_News1Loc > Scrolling_EndLoc)
	{
		Scrolling_News1Loc = Scrolling_StartLoc;
		Scrolling_SetNewsContent(Scrolling_NewsWindow1_ref, Scrolling_CurrentNewsIndex);
		Scrolling_CurrentNewsIndex = Scrolling_CurrentNewsIndex + 1;
	}
		
	//If news 2 div has reached the end then fill it with content from the next news item
	//and move it to the start position
	if (Scrolling_News2Loc > Scrolling_EndLoc)
	{
		Scrolling_News2Loc = Scrolling_StartLoc;
		Scrolling_SetNewsContent(Scrolling_NewsWindow2_ref, Scrolling_CurrentNewsIndex);
		Scrolling_CurrentNewsIndex = Scrolling_CurrentNewsIndex + 1;
	}
	
	//If we've exhausted all news items then start again
	if (Scrolling_CurrentNewsIndex == Scrolling_NewsItemsCount)
			Scrolling_CurrentNewsIndex = 0;
	
	//Set the location of the divs now
	Scrolling_NewsWindow1_ref.style.top = Scrolling_News1Loc;
	Scrolling_NewsWindow2_ref.style.top = Scrolling_News2Loc;
	
	//Call this function again to keep things moving
	setTimeout(Scrolling_MoveText, Scrolling_MoveTime);
}

function Scrolling_ContinueScroll()
{
	if (Scrolling_StopScrolling)
	{
		setTimeout(Scrolling_ContinueScroll, 500);
		return;
	}

	//Increment the var which is used for the locations of the divs
	Scrolling_News1Loc += 1;
	Scrolling_News2Loc += 1;
	
	//Set the location of the divs now
	Scrolling_NewsWindow1_ref.style.top = Scrolling_News1Loc;
	Scrolling_NewsWindow2_ref.style.top = Scrolling_News2Loc;
	
	//Call the move function again to start the news moving again after the wait period
	setTimeout(Scrolling_MoveText, Scrolling_MoveTime);
}

function Scrolling_SetNewsContent(tag, news_index)
{
	tag.innerHTML = "<a class='BroadcastClient' href='javascript:Scrolling_ViewNews(" + Scrolling_IDArray[news_index] + ");'><span class='NewsTitle'>" + Scrolling_HeadlinesArray[news_index] + "</span></a>";
	
	tag.innerHTML += "<br><span class='NewsBlurb'>" + Scrolling_BlurbsArray[news_index] + " <a class='BroadcastClient' href='javascript:Scrolling_ViewNews(" + Scrolling_IDArray[news_index] + ");'>[more]</a></span>";
}

var Scrolling_bgcolor = "";
function Scrolling_MouseEntersDiv()
{
	Scrolling_bgcolor = Scrolling_MainWindow_ref.style.backgroundColor;
	Scrolling_StopScrolling = true;
	Scrolling_MainWindow_ref.style.backgroundColor = "#DFEFFB";
}

function Scrolling_MouseExitsDiv()
{
	Scrolling_StopScrolling = false;
	Scrolling_MainWindow_ref.style.backgroundColor = Scrolling_bgcolor;
}

function Scrolling_ViewNews(WBI)
{
	window.open("http://webcast.rowlett.com//viewnews.aspx?WBI=" + WBI, "ViewNews", "menubar=no,location=no,status=no,toolbar=no,width=500, height=400, scrollbars=yes");
}

document.writeln("<link rel=STYLESHEET href='http://webcast.rowlett.com//BroadcastClient.css' type='text/css'>");
	
document.writeln("<div id='Scrolling_MainWindow' class='MainWindow' onmouseover='Scrolling_MouseEntersDiv();' onmouseout='Scrolling_MouseExitsDiv();' style='overflow:hidden; position:relative; width:199; height:70'>");

document.writeln("<div id='Scrolling_NewsWindow1' class='NewsItem'  style='text-align:left; position:absolute; top:10; left:10'></div>")
document.writeln("<div id='Scrolling_NewsWindow2' class='NewsItem'  style='text-align:left; position:absolute; top:-60; left:10'></div>")


document.writeln("</div>");


document.writeln("<div id='Scrolling_ArchiveLinkDiv' class='ArchiveWindow' style='width:199; height:16'>");
document.writeln("<a class='BroadcastClient' style='color: #FFFFFF;' href='http://webcast.rowlett.com//archives.aspx'>View News Archives >>></a>&nbsp;");
document.writeln("</div>");


window.onload = Scrolling_BeginScroll;

