<!--
/*
scrollAndLink.js
Version 1


*/

// STUFF NOT REALLY TO TOUCH

// HEIGHT, WIDTH, TOP POSITION AND LEFT POSITION OF THE SCROLLER
var ScrollerWidth = 291
var ScrollerHeight = 137 
var ScrollerLeft = 332;
var ScrollerTop = 360;

// THE SPEED OF THE "STEPS" TAKEN BY THE SCROLLING ACTION
// mlNews" style="position:absolute; left:332px; top:360px; width:291px; height:137px; z-index:4; visibility: visible"> 
var ScrollStepSpeed = 75;

// THE SIZE OF THE "STEPS" TAKEN BY THE SCROLLING ACTION
var ScrollStepSize = 1;

// THE AMOUNT OF TIME TO DISPLAY EACH HYPERLINK IN THE SCROLLER
var DisplayInterval = 2500;


// AMOUNT OF "WHITESPACE" TO THE LEFT AND TO THE TOP OF EACH HYPERLINK...RELATIVE TO THE CORRESPONDING <DIV> OR <LAYER> THAT HOLDS EACH HYPERLINK
var PaddingLeft = 10;
var PaddingTop = 10;

// HOW MANY TIMES WILL THE ENTIRE SET OF HYPERLINKS CYCLE THROUGH?
var ScrollCycleCount = 10;

// WHERE WILL THE NEW PAGE BE OPENED?
// FOR EXAMPLE, IF USING FRAMES, YOU MAY WANT TO SET OpenNewPageHere = ' TARGET="_top" '
var OpenNewPageHere = ' TARGET="_new"'

// THE NAME OF THE DHTML STYLE CLASS THAT WILL BE APPLIED TO THE SCROLLING HYPERLINKS
var ClassStyleName = ' '

// IS THE CURRENT BROWSER NETSCAPE NAVIGATOR OR INTERNET EXPLORER?
var NN4=(document.layers);
var IE4=(document.all);
if (!document.all && document.getElementById) {
	IE4 = true;
	var NN6=true;
	}


// ANY ADDITIONAL INFORMATION THAT GOES IN FRONTOF THE HYPERLINK
// CAN GO HERE.
var LinkPrefix =' ';

var TheItemURL = 0
var TheItemText = 1


// IS THE SCROLLER GOING TO CYCLE ONLY A FIXED NUMBER OF LOOPS?
var LoopingFixedNumberOfTimes = (ScrollCycleCount > 0);


//-----------------------------------------------------------------
function LaunchScroller()
{
	
	HyperlinkCount = 0;	

	if(ScrollItemsCount == 0)	
		return;	

	if(!window.ScrollItemURL)
		return;
	
	
	if(LoopingFixedNumberOfTimes)
		loopCount=0;

	for(i=0; i<ScrollItemsCount; i++)
	{
		ScrollItemTextAndURL[i] = [LinkPrefix+ScrollItemURL[i], ScrollItemText[i]];
	}

	
	if(NN4)
	{
		CreateItemContainersForNN();
	}
	else
	{
		if (NN6){
			CreateItemContainersForIE();}
		else{
			CreateItemContainersForIE();}
	}


	LoadHyperlinksIntoScroller();
	
	SetItemVisibility(0, true);
	
	CurrentItem=0;
	
	timeoutID = window.setTimeout("ScrollControl()", DisplayInterval);
}
//-----------------------------------------------------------------
function ScrollItemContainer(i)
{
	//-----------------------------------------------------------------
	//	RETURN A REFERENCE TO THE DIV OR LAYER CORRESPONDING TO THE
	//	NUMBER PASSED IN THROUGH i
	//-----------------------------------------------------------------	
	if (NN6) {
		// Use getElementBYID to get to the element
		ReferenceToItemContainer = document.getElementById("ContainerItem"+i).style;	
	}
	else {
		ReferenceToItemContainer = eval("ContainerItem" + i +  ((IE4)?".style":""));
	}
	return ReferenceToItemContainer
}
//-----------------------------------------------------------------
function SetItemVisibility(n, show)
{
	//-----------------------------------------------------------------
	//	SHOW OR HIDE AN ITEM CONTAINER
	//-----------------------------------------------------------------	

	var TheScrollItemContainer = ScrollItemContainer(n);
	TheScrollItemContainer.visibility=(show)?"visible":"hidden";
}
function ScrollControl()
{
	//-----------------------------------------------------------------
	//	CONTROL WHETHER OR NOT THE SCROLLER WILL CONTINUE TO SCROLL
	//-----------------------------------------------------------------


	var temp = CurrentItem;
	CurrentItem = (temp == ScrollItemTextAndURL.length-1)?0:temp+1;

	if(CurrentItem==1)
		loopCount++;
	
	if(LoopingFixedNumberOfTimes&&(loopCount>=ScrollCycleCount))
		return;
	
	StartScrollingHyperlinks(temp, CurrentItem);
}

function ScrollHyperlinks(){
	//-----------------------------------------------------------------
	//	THIS FUNCTION ACTUALLY DOES THE SCROLLING
	//-----------------------------------------------------------------

	if(NN4)
	{
		ScrollItemContainerFrom.top-=ScrollStepSize;

		if(ScrollItemContainerTo.top-ScrollStepSize<=ScrollItemContainerToTarget)
		{
			ScrollItemContainerTo.top=ScrollItemContainerToTarget;
			clearInterval(intervalID);
			ScrollItemContainerFrom.visibility="hidden";
			timeoutID=setTimeout("ScrollControl()",DisplayInterval);
		}
		else
		{
			ScrollItemContainerTo.top-=ScrollStepSize;
		}
	}
	else
	{
		if (NN6){
			var top = parseInt(ScrollItemContainerFrom.top);
			top-=ScrollStepSize;
			ScrollItemContainerFrom.top=top + "px";
			top=parseInt(ScrollItemContainerTo.top)

			if(top-ScrollStepSize<=parseInt(ScrollItemContainerToTarget))
			{
				ScrollItemContainerTo.top=ScrollItemContainerToTarget;
				clearInterval(intervalID);
				ScrollItemContainerFrom.visibility="hidden";
				timeoutID=setTimeout("ScrollControl()",DisplayInterval);
			}
			else
			{
				top-= ScrollStepSize;
				ScrollItemContainerTo.top=top + "px";
			}

		}
		else {
			ScrollItemContainerFrom.pixelTop-=ScrollStepSize;

			if(ScrollItemContainerTo.pixelTop-ScrollStepSize<=ScrollItemContainerToTarget)
			{
				ScrollItemContainerTo.pixelTop=ScrollItemContainerToTarget;
				clearInterval(intervalID);
				ScrollItemContainerFrom.visibility="hidden";
				timeoutID=setTimeout("ScrollControl()",DisplayInterval);
			}
			else
			{
				ScrollItemContainerTo.pixelTop-=ScrollStepSize;
			}
		}
	}
}
function StartScrollingHyperlinks(ContainerItemFrom,ContainerItemTo){
	//-----------------------------------------------------------------
	//	BEGIN THE PROCESS OF SCROLLING THE HYPERLINKS
	//-----------------------------------------------------------------

	ScrollItemContainerFrom = ScrollItemContainer(ContainerItemFrom);
	ScrollItemContainerTo = ScrollItemContainer(ContainerItemTo);
	
	if(NN4)
	{
		ScrollItemContainerTo.top = ScrollItemContainerFrom.top + ScrollerHeight;
		ScrollItemContainerToTarget = ScrollItemContainerFrom.top;
	}
	else
	{
		if (NN6) {
			var top = parseInt(ScrollItemContainerFrom.top);
			top +=  ScrollerHeight;
			ScrollItemContainerTo.top = top  + "px";
			ScrollItemContainerToTarget = ScrollItemContainerFrom.top;
		}
		else {
			ScrollItemContainerTo.pixelTop = ScrollItemContainerFrom.pixelTop + ScrollerHeight;
			ScrollItemContainerToTarget = ScrollItemContainerFrom.pixelTop;
		}
	}
	

	SetItemVisibility(ContainerItemTo,true);
	intervalID = window.setInterval("ScrollHyperlinks()", ScrollStepSpeed);
}

function CreateItemContainersForIE(){
	//-----------------------------------------------------------------
	// CREATE MULTIPLE DIVs TO BE CONTAINERS FOR THE HYPERLINKS
	//-----------------------------------------------------------------
	var text='<DIV ID="scroller" STYLE="position:absolute;overflow:hidden;top:'+ ScrollerTop +';left:'+ ScrollerLeft +';width:'+ ScrollerWidth +';height:'+ ScrollerHeight +';z-index:10;">';
	
	ItemTextWidth = ScrollerWidth-PaddingLeft;
	
	for(var i=ScrollItemTextAndURL.length-1; i>=0; i--)
	{
		text += '<DIV ID="ContainerItem'+i+'" STYLE="position:absolute;visibility:hidden;top:'+ PaddingTop +';left:'+ PaddingLeft +';width:'+ ItemTextWidth +'"></DIV>';
	}
	
	text += '</DIV>';
	document.body.insertAdjacentHTML("beforeEnd",text);
}




function CreateItemContainersForNN()
{
	//-----------------------------------------------------------------
	// CREATE NETSCAPE LAYERS TO BE CONTAINERS FOR THE HYPERLINKS
	//-----------------------------------------------------------------

	var scroller = new Layer(ScrollerWidth);

	with(scroller)
	{
		clip.right=ScrollerWidth;
		clip.bottom=ScrollerHeight;
		moveTo(ScrollerLeft,ScrollerTop);
		visibility="show";
	}

	for(var i=0; i<ScrollItemTextAndURL.length; i++)
	{
		eval("ContainerItem" + i + "=" + "new Layer(ScrollerWidth-PaddingLeft, scroller)");
		
		with(eval("ContainerItem" + i)) 
		{
			moveTo(PaddingLeft, PaddingTop);
		}
	}
}

function LoadHyperlinksIntoScroller()
{
	//-----------------------------------------------------------------
	// EXTRACT THE TEXT TO BE DISPLAYED AND THE CORRESPONDING URLs
	// FROM THE ARRAY AND BUILD HYPERLINKS. PUT ONE HYPERLINK INTO
	// EACH LAYER (IF NS) OR DIV (IF IE).
	//-----------------------------------------------------------------

	var TheScrollItemContainer;
	for(i=0; i<ScrollItemTextAndURL.length; i++)
	{
		if (NN6) {
			var myElement = document.getElementById("ContainerItem"+i);
			TheScrollItemContainer = myElement;
			}
		else {
			TheScrollItemContainer = eval("ContainerItem"+i);
		}

		// BUILD THE HYPERLINK
		newsStr = "<A " + OpenNewPageHere + ClassStyleName 
		newsStr += " HREF=" + ScrollItemTextAndURL[HyperlinkCount][TheItemURL] + "><b><font face='Verdana' size='1' color='#666666'>" 
		newsStr += ScrollItemTextAndURL[HyperlinkCount][TheItemText] + "</font></b></A>";
		
		newsStr += "<br><font face='Verdana' size='1' color='#666666'>";
		// newsStr += 'This is a load of news item text that will appear below the headline';
		newsStr += ScrollNewsBody[HyperlinkCount];
		newsStr += '</font>';
	
		
		if(NN4)
		{
			with(TheScrollItemContainer.document)
			{
				write(newsStr);
				close();
			}
		}
		else
		{
			TheScrollItemContainer.innerHTML = newsStr;
		}
		
		HyperlinkCount++;
		if(HyperlinkCount == ScrollItemTextAndURL.length)
			HyperlinkCount=0;
	}
}

function ReloadPage()
{
	//-----------------------------------------------------------------
	// REFRESH/RELOAD THE PAGE
	//-----------------------------------------------------------------
	window.location.reload();
}

//-->
