

//--- 03/08/2000 --- Jérôme CHAGNOUX
//--- Text scrolling bar ---
//--- These javascripts operates a scroll bar on a text ---
//--- It is based on the use of layers ---

//--- timeoutId: name of the timeout necessary to scroll; using this variable we won't have problems with strange comportment ---
timeoutId=0;
//--- xReference: integer, left coordinate of layer (given in the HTML page) ---
//--- yReference: integer, top coordinate of layer (given in the HTML page) ---
//--- layerName: string, name of the layer on which picture are displayed ---
//--- layerWidth: integer, width of the layer ---
//--- clipLength: integer reprensenting the length of the clip for the layer (given in the HTML page) ---
//--- increment: integer, increment for the deplacement of the picture (given in the HTML page) ---
//--- topClip: integer representing the top of the clip (according to the coordinates of the layer) ---
topClip=0;
//--- bottomClip: integer representing the bottom of the clip (according to the coordinates of the layer) ---
bottomClip=clipLength;
//--- minimum: minimum position for the layer ---
minimum=yReference-(fileListLength-clipLength);
//--- maximum: maximum position for the layer ---
maximum=(fileListLength-clipLength);
//--- yDiv: integer, actual vertical position of the layer ---
yDiv=yReference;
//--- NS4: boolean variable, will be useful to differentiate code between NetScape (NS) & Internet Explorer (IE) ---
//--- (document.layers) is a property identifying NS ---
NS4 = (document.layers)?true:false;

//--- resetExtrema: function to reset the value of the variables minimum and maximum ---
function resetExtrema()
{
	minimum=yReference-(fileListLength-clipLength);
	maximum=(fileListLength-clipLength);
}

//--- fixClip: function to fix the clip of a layer (the visible part of it) ---
function fixClip(divName,xLeft,xRight,yTop,yBottom)
{
	//--- The clip property is different for the two browsers ---
	if (NS4)
	{
		with (document.layers[divName].clip)
		{
			top = yTop;
			right = xRight;
			bottom = yBottom;
			left = xLeft;
		}
	}
	else
	{
		with (document.all[divName].style)
		{
	  	clip = "rect("+yTop+" "+xRight+" "+yBottom+" "+xLeft+")";
		}
	}
}

//--- fixVPosition: function, fix the vertical position of a layer ---
function fixVPosition(divName,yTop)
{
	if (NS4)
		document.layers[divName].top=yTop;
	else
		document.all[divName].style.pixelTop=yTop;
}

//--- scrollStop: function which stop the scrolling by clearing the timeout ID ---
function scrollStop()
{
  clearTimeout(timeoutId);
}

//--- scrollUp: function, make the text going up ---
function scrollUp()
{
	//--- Reset the timeout ---
	clearTimeout(timeoutId);
	//--- Decrement the vertical position of the layer ---
	yDiv-=increment;
	if (yDiv<minimum)
	{
		//--- If the layer has reached the limit, stop the scrolling and cancel the last operation ---
		yDiv+=increment;
	}
	else
	{
		//--- Increment the vertical position of the clip ---
	  topClip+=increment;
	  bottomClip+=increment;
		//--- Fix the position and the clip of the layer ---
		fixVPosition(layerName,yDiv);
		fixClip(layerName,0,layerWidth,topClip,bottomClip)
		//--- Make the loop with the given tempo ---
		timeoutId=setTimeout("scrollUp()",tempo);
	}
}

//--- scrollDown: function, make the text going down
function scrollDown()
{
	//--- Reset the timeout ---
	clearTimeout(timeoutId);		
	//--- Increment the vertical position of the layer ---
	yDiv+=increment;
	if (yDiv>yReference)
	{
		//--- If the layer has reached the limit, stop the scrolling and cancel the last operation ---
		yDiv-=increment;
	}
	else
	{
	  topClip-=increment;
	  bottomClip-=increment;
		//--- Fix the position and the clip of the layer ---
		fixVPosition(layerName,yDiv);
		fixClip(layerName,0,layerWidth,topClip,bottomClip)
		//--- Make the loop with the given tempo ---
		timeoutId=setTimeout("scrollDown()",tempo);
	}
}
