<!--

//function to control the top news area
//
//assumes ArticleDataArray has been initialised with the data to display
//doTopNews() needs to be called on an interval basis - this should be set up on the page code
//data is written to a page element with ID = topnewstextarea
//currentTopNewsMessage holds the index of the current item

var currentTopNewsAreaBottom = 50;
var currentTopNewsAreaHTML;
var wipeDelay = 10;
var wipeInterval;



function doTopNews()
{
	var totalItems = ArticleDataArray.length;
	if (currentTopNewsMessage > (totalItems - 1))
		currentTopNewsMessage = totalItems - 1;
		
	var itemSummaryToDisplay = ArticleDataArray[currentTopNewsMessage].summary.slice(0,100);
	itemSummaryToDisplay = itemSummaryToDisplay.replace(/\n/," ");
	
	var HTMLString;
	
	HTMLString = "<span class=\"topnewsheadlinetext\"><strong><a href=\"/announcementdisplay.aspx?articleref=" 
				+ ArticleDataArray[currentTopNewsMessage].articleref
				+ "\" class=\"maintextlink\">"
				+ ArticleDataArray[currentTopNewsMessage].title
				+ "</a></strong></span><span class=\"topnewsheadlinetextsmall\"> - posted "
				+ ArticleDataArray[currentTopNewsMessage].dateadded;
	HTMLString += "<br>" + itemSummaryToDisplay + " [<a href=\"/announcementdisplay.aspx?articleref=" 
				+ ArticleDataArray[currentTopNewsMessage].articleref
				+ "\" class=\"maintextlink\">click for details</a>]</span>";
	
	currentTopNewsAreaHTML = HTMLString;
	doTopWipeStart();
		
	//move to next item
	currentTopNewsMessage ++;
	if (currentTopNewsMessage > (totalItems - 1))
		currentTopNewsMessage = 0;

}// end doTopNews

function doTopWipeStart()
{
	wipeInterval = setInterval("doTopWipe(-1)", wipeDelay);
}

function doTopWipeChangeText()
{
	var topNewsDiv = get_findObj("topnewstextarea");
	topNewsDiv.innerHTML = currentTopNewsAreaHTML;
	
	wipeInterval = setInterval("doTopWipe(1)", wipeDelay);

}

function doTopWipe(step)
{
	//does a wipe of the top section
	//step is distance to move bottom edge per cycle
	
	var stepCount;
	
	var topNewsDivHolder = get_findObj("mainpageinfobar");
	if( !topNewsDivHolder )
	{
		return;
	}
	if( topNewsDivHolder.style )
	{
		topNewsDivHolder = topNewsDivHolder.style;
	} 
	currentTopNewsAreaBottom += step;
	topNewsDivHolder.clip =  "rect(0px 750px " + currentTopNewsAreaBottom + "px 0px)";
	
	if ((currentTopNewsAreaBottom == 0) && (step<0))
	{
		// end of close up
		clearInterval(wipeInterval);
		doTopWipeChangeText();
		
	}
	else if ((currentTopNewsAreaBottom == 50) && (step>0))
	{
		// end of open up
		clearInterval(wipeInterval);
	}

}

function doDelay(milliWait)
{
	//wait for milliseconds
	var milliStart = new Date();
	var milliNow;
	do
	{
		milliNow = new Date();
	}while(milliNow.getTime() < (milliStart.getTime() + milliWait))
	
}
		

//-->
