/*
© All rights reserved
Madmedia Communication
geneau@videotron.ca
*/

//-------------------------------------------------------
	function cScrollingText(aText, iNumberOfLinesShowing, sObjectName, iScrollSpeed, sMethodForWrittingTextWithoutBrakets)
	{
		this.pTextArray = aText;
		this.pNumberOfLinesShowing = iNumberOfLinesShowing;
		this.pLineCounter = iNumberOfLinesShowing;
		this.pLastLineNumber = this.pTextArray.length;
		this.pContent = "";
		this.pPermission = false;
		this.pObjectName = sObjectName;
		this.pScrollSpeed = iScrollSpeed;
		this.pMethodForShowingText = sMethodForWrittingTextWithoutBrakets;
		
		this.mScrollUp = fScrollUp;
		this.mScrollDown = fScrollDown;
		this.mStartingText = fStartingText;
		this.mScrollToLine = fScrollToLine;
	}
//-------------------------------------------------------
	function fScrollToLine(iLineNum)
	{
		this.pContent = "";
		this.pLineCounter = this.pNumberOfLinesShowing;
		var tStartCount = null;
	
		if (iLineNum > (this.pTextArray.length - this.pNumberOfLinesShowing))
		{
			this.pLineCounter = this.pTextArray.length;
			tStartCount = (this.pTextArray.length - this.pNumberOfLinesShowing);
		}
		else
		{
			tStartCount = iLineNum - 1;
			this.pLineCounter += iLineNum - 1;
		}

		for (x = tStartCount; x < (tStartCount + this.pNumberOfLinesShowing); x++)
		{
				this.pContent += this.pTextArray[x];
		}
		
		eval(this.pMethodForShowingText + "(this.pContent)");
	}
//-------------------------------------------------------
	function fStartingText()
	{
		this.pContent = "";
		this.pLineCounter = this.pNumberOfLinesShowing;
		
		for (x = 0; x < this.pNumberOfLinesShowing; x++)
		{
			if (this.pTextArray[x] == null)
			{
				break;
			}
			
			this.pContent += this.pTextArray[x];
		}
		
		eval(this.pMethodForShowingText + "(this.pContent)");
	}
//-------------------------------------------------------
	function fScrollUp()
	{
		if (!this.pPermission || this.pLineCounter >= this.pLastLineNumber)
		{
			return;
		}
		
		this.pContent = "";
		this.pLineCounter++;
		
		for (x = this.pLineCounter - this.pNumberOfLinesShowing; x < this.pLineCounter; x++)
		{
			this.pContent += this.pTextArray[x];
		}
		
		eval(this.pMethodForShowingText + "(this.pContent)");
		setTimeout(this.pObjectName + ".mScrollUp()", this.pScrollSpeed);
	}
//-------------------------------------------------------
	function fScrollDown()
	{
		if (!this.pPermission || this.pLineCounter == this.pNumberOfLinesShowing)
		{
			return;
		}
		
		this.pContent = "";
		this.pLineCounter--;
		
		for (x = this.pLineCounter - this.pNumberOfLinesShowing; x < this.pLineCounter; x++)
		{
			this.pContent += this.pTextArray[x];
		}
		
		eval(this.pMethodForShowingText + "(this.pContent)");
		setTimeout(this.pObjectName + ".mScrollDown()", this.pScrollSpeed);
	}
//-------------------------------------------------------

/*

<script src = "../scripts/oScrollingText.js" language="JavaScript"><!--// Version 5 //--></script>
<script language="JavaScript"><!--
//-------------------------------------------------------

	// Details d'utilisation

	// var oScrollingText = new cScrollingText(aText, iNumberOfLinesShowing, sObjectName, iScrollSpeed, sMethodForWrittingTextWithoutBrakets);
	
	// oScrollingText.pPermission = true;
	
	//	oScrollingText.mScrollUp();
	//	oScrollingText.mScrollDown();
	//	oScrollingText.mStartingText();
	// oScrollingText.mScrollToLine(iLineNum);

//-------------------------------------------------------
//--></script>

*/
