// protal homepage scrolling news functions
var identifier = 0;
var timeoutChar		= 80;
var tickrtTime		= 4000;
var theWidgetOne	= "_";
var theWidgetTwo	= "-";
var theWidgetNone	= "";
var theLeadString	= "&nbsp;";

var msgTexts		= new Array();
var msgTimes		= new Array();
var msgAgencys		= new Array();
var direction		= new Array();
var links			= new Array();

function directionflipp(direction)
{
	document.getElementById('direction').style.direction	= direction;
}

function setTiArrays(id, tText, tTime, tAgency, dir, url)
{ 
	msgTexts[id]	= tText; 
	msgTimes[id]	= tTime; 
	msgAgencys[id]	= tAgency; 
	direction[id]	= dir;
	links[id]		= url;
}

function initTicker()
{
	theCurrentStory		= 0;
	theCurrentLength	= 0;	
	
	if (document.getElementById) {	
		theAnchorObject	= document.getElementById("tickerAnchor");
		runTic();   		
	} else {
		//document.write("<style>.tickerDiv{display:none;}.ticko{font-family:Verdana;font-size:8pt;color:#6f6c6c;}</style>");
		return true;
	}
}

function runTic()
{
	if (msgTexts.length == 0) return;
	var timeSet;  
	
	if (theCurrentLength == 0) {
		directionflipp(direction[theCurrentStory]);
		
		theStorySummary	= msgTexts[theCurrentStory].replace(/&quot;/g,'"');
		
		if (msgAgencys[theCurrentStory]) {
			theStorySummary	+= ' (' + msgAgencys[theCurrentStory].replace(/&quot;/g,'"') + ')';	
		}
		
		//theAnchorObject.href	= links[theCurrentStory];
	}
	
	theAnchorObject.innerHTML	=  theStorySummary.substring(0,theCurrentLength) + whatWidget();
	
	if (theCurrentLength != theStorySummary.length) {
		theCurrentLength++;
		timeSet = timeoutChar;
	} else {
		theCurrentLength = 0;
		timeSet = tickrtTime;
		
		if (theCurrentStory == (theItemCount - 1)) {
			theCurrentStory	= 0;
		} else {
			theCurrentStory++;
		}
	}
	
	setTimeout("runTic()", timeSet);
}

function whatWidget()
{
	if (theCurrentLength == theStorySummary.length) {
		return theWidgetNone;
	}
	
	if ((theCurrentLength % 2) == 1) {
		return theWidgetOne;
	} else {
		return theWidgetTwo;
	}
}
function AddTimeOffset(originalHours, originalMinutes, addedHours, addedMinutes, addedSign)
{
	if (addedSign.toLowerCase() == 'false')
	{
		var resultingMinutes = (originalMinutes + addedMinutes ) % 60;
		var resultingHours = (((originalMinutes + addedMinutes ) / 60) >= 1) ? 1 : 0;
		resultingHours = (originalHours + addedHours + resultingHours) % 24;
		var resultingTime = ((10 > resultingHours)? '0' + resultingHours : resultingHours) + ':' + ((10 > resultingMinutes) ? '0' + resultingMinutes : resultingMinutes);
		return resultingTime;
	}
	else
	{
		if (addedMinutes > originalMinutes)
		{
			originalMinutes = originalMinutes + 60;
			originalHours--;
		}
		var resultingMinutes = (originalMinutes - addedMinutes ) % 60;
		if (addedHours > originalHours)
		{
			originalHours = originalHours + 24;
		}
		var resultingHours = (originalHours - addedHours) % 24;
		var resultingTime = ((10 > resultingHours)? '0' + resultingHours : resultingHours) + ':' + ((10 > resultingMinutes) ? '0' + resultingMinutes : resultingMinutes);
		return resultingTime;
	}
}
