// Textual Content Scroller v 1.01
// Directions;
// The IFRAME Id and name to be "textualContentDiv" unless replaced here as well.
// The "scroll_" to be called when it is to scroll the text (not the "do_scroll_").
// Body (holding IFRAME) onload="[variable=]scroller_initialise(Initial values);" Where the value returned from the initialiser defines if scrolls are needed and so to place the buttons or whatever or turn them on.
// You will need to provide the "theiframeheight" when callin' initialiser function if you do not explicitly specify the "height" in the style attribute of the IFRAME.
// Dont forget to place height in the style attribute of "thecopy", the Div tag in the iframe src html holding the text
// Note : When unable to define the "copy" page's height [as in dynamic generated pages], turn off 'no-boundry exccess' feature of the scrolls, assigning a 'true' value to corresponding BEON index.
<!--
var scrollspeed = new Array(),
	scrollstep = new Array(),
	dataobj = new Array(),
	_scroll_is_on = new Array(),
	scroll_iid = new Array(),
	_prev_dir = new Array(),
	_approachends = new Array(),
	iframeheight = new Array(),
	BEON = new Array();

function scroller_initialise (containerName, speed, theiframeheight, copyholder, codeindex) {
	// initialise constants	
	if(!(codeindex)) var codeindex = dataobj.length;
	scrollspeed[codeindex] = 10;
	scrollstep [codeindex] = /* old browser, leg. sys. bug fix */ (ie4 && iswin98)?5:1 /* -- */;
	_scroll_is_on[codeindex] = false;
	_approachends[codeindex] = false;
	iframeheight [codeindex] = false;
	// initialise references
	dataobj[codeindex]=( containerName==-1 ? document.getElementById((copyholder?copyholder:"thecopy")) : eval(containerName?containerName:"textualContentDiv").document.getElementById((copyholder?copyholder:"thecopy")) );
	if(speed) scrollspeed[codeindex]=speed;
	iframeheight[codeindex]=(theiframeheight)?theiframeheight:parseInt(window.document.getElementById((containerName?containerName:"textualContentDiv")).style.height);
	return (parseInt(dataobj[codeindex].style.top)+parseInt(dataobj[codeindex].style.height)>iframeheight[codeindex]) || BEON[codeindex]; /* scrolls needed; */ }

function do_scroll_ (dir, id, pos, tscrollstep) {
	if (!(id)) var id = 0;
	// Caution: Height of the div must be specified (at the Style of the "copy" div) not to be left "auto"
	_approachends[id] = parseInt(dataobj[id].style.top)>=0 && dir || parseInt(dataobj[id].style.top)+parseInt(dataobj[id].style.height)<=iframeheight[id] && !(dir) && !(BEON[id]) || parseInt(dataobj[id].style.top)+pos<=0 && (pos) && !(dir) && !(BEON[id]) || parseInt(dataobj[id].style.top)+pos>0 && (pos) && (dir);
	// old browser, leg. sys. bug fix
	if (ie4 && iswin98 && tscrollstep) tscrollstep += 5;
	// --
	if(!(_approachends[id])) dataobj[id].style.top = parseInt(dataobj[id].style.top)-((dir?(-1):1)*(tscrollstep?tscrollstep:scrollstep[id])); else _approachends[id] = turn_off_scroll_(id);
	return true; }

function scroll_ (dir, id, pos, tscrollspeed) {
	if(!(id)) var id = 0;
	if(dir==_prev_dir[id] && _scroll_is_on[id]) return false; else _prev_dir[id] = dir;
	if(_scroll_is_on[id]) turn_off_scroll_(id);
	scroll_iid[id] = window.setInterval("do_scroll_("+dir+","+id+(pos?", "+pos:"")+(tscrollspeed?", " + (pos?"":"'', ") + tscrollspeed:"")+");", scrollspeed[id]);
	return (_scroll_is_on[id] = true); }

function turn_off_scroll_ (id) {
	if (!(id)) var id = 0;
	if(_scroll_is_on[id]) window.clearInterval(scroll_iid[id]);
	_scroll_is_on[id] = false;
	return true; }
//-->
/*]
Farid Atighehtchi. January 2005
[*/