
function MyBillBoard(MyBillBoardLastMessage,MyCurrentPos,MyBillBoardMessageNo,MyRepsToGo)
{

var MyScrollerWidth = 65;	// How wide the text is on the panel


var CurrentMessageToDisplayNo = MyBillBoardMessageNo; 					// Number of message array
var MyLastStringDisplayed = MyBillBoardLastMessage;   					// Last portion of string displayed
var CurrReps = MyRepsToGo;							  					// Current repetitions of current message already executed

// Get values from main function 
var CurrentMessageToDisplay = BillBoardMessage[MyBillBoardMessageNo];  // Text of current message to animate
var CurrentMessageToDisplayReps = BillMessReps[MyBillBoardMessageNo];  // Repetitions of the current message
var MyCurrentAnimation = BillMessAnim[MyBillBoardMessageNo];
var MyTotBillMessages = TotBillBoardMessages;


var BillMessLength = CurrentMessageToDisplay.length;

var Blanks = '';
var MyStringToShow = '';
var CurrentCharacter = '';


//-------------------------------------------------------------------------------------------------//
// ANIMATION 1 - The Scroller

	if (MyCurrentAnimation==1)
	{
		var TheTimeToWait = 120;	// Time to wait before next animation
		
		if (MyCurrentPos > BillMessLength)
		{
			MyCurrentPos = 0;
			CurrReps = CurrReps - 1;
		}

		CurrentCharacter = CurrentMessageToDisplay.substr(MyCurrentPos,1);
	
		if (MyLastStringDisplayed.length<=MyScrollerWidth)
		{
			MyLastStringDisplayed = MyLastStringDisplayed + CurrentCharacter;
		
			for (var x = 1; x <= MyScrollerWidth-MyLastStringDisplayed.length; x++)
   			{
   				Blanks = Blanks + '&nbsp;';
   			}		
			MyStringToShow = Blanks + MyLastStringDisplayed;
		}
		else
		{
			MyLastStringDisplayed = MyLastStringDisplayed.substr(2,MyScrollerWidth-1) + CurrentCharacter;
			MyStringToShow = MyLastStringDisplayed;
		}
	}
	
//-------------------------------------------------------------------------------------------------//
// ANIMATION 2 - The Blinker

	if (MyCurrentAnimation==2)
	{
		var TheTimeToWait = 1000;	// Time to wait before next animation
		
		if (MyCurrentPos==0)
		{
			MyCurrentPos = 1;
		}
		
		if (MyCurrentPos==1)
		{
			MyStringToShow = CurrentMessageToDisplay;
		}
		else
		{
			MyCurrentPos = 0;
			CurrReps = CurrReps - 1;
			MyStringToShow = '&nbsp;';
		}
		
	}
	
	
//-------------------------------------------------------------------------------------------------//
// ANIMATION 3 - STATIC

	if (MyCurrentAnimation==3)
	{
		var TheTimeToWait = 1000;	// Time to wait before next animation
		
		if (MyCurrentPos==0)
		{
			MyCurrentPos = 1;
		}
		
		if (MyCurrentPos==1)
		{
			MyStringToShow = CurrentMessageToDisplay;
		}
		else
		{
			MyCurrentPos = 0;
			CurrReps = CurrReps - 1;
			MyStringToShow = CurrentMessageToDisplay;
			//MyStringToShow = '&nbsp;';
		}
		
		
	}




//-------------------------------------------------------------------------------------------------//




	MyCurrentPos = MyCurrentPos + 1;
	
	document.getElementById('TugaScroller').innerHTML = MyStringToShow;
	document.close;
	
	if (CurrReps>=1)
	{
		//cmd ="ScrollTheMessage('" + PassedString + "'," + NewScroll + ")";
		cmd ="MyBillBoard('" + MyLastStringDisplayed + "'," + MyCurrentPos + "," + CurrentMessageToDisplayNo + "," + CurrReps + ")";
	
		TheTimer= setTimeout(cmd,TheTimeToWait);
		
	}
	else
	{
		CurrentMessageToDisplayNo = CurrentMessageToDisplayNo + 1;
		if (CurrentMessageToDisplayNo>MyTotBillMessages)
		{
			CurrentMessageToDisplayNo = 1;
		}
		
		cmd ="MyBillBoard('',0," + CurrentMessageToDisplayNo + "," + BillMessReps[CurrentMessageToDisplayNo] + ")";
		TheTimer= setTimeout(cmd,TheTimeToWait); 
	}
	
	


}
