<!--
/*
	Word Scroll
	Copyright 1997 by Chris Baron	All Rights Reserved

	
*/

	var HINTING = false; // a flag variable set true if we are displaying a hint
	var spacer = "                                                                                                                                                                                                             "; // space between words/chars
//	var spacer = "........................................................................................................................"; // if you like dots
	var SCROLL = false; // scroll the message if true
	var speed = 100; // scrolling speed smaller numbers are faster 
	var words = new Array;  // create an empty array to hold the words of the message 
	msg = ""; // the string holding the text to display each loop through the scroller
	field = ""; // the textfield object to scroll text in.

	if (navigator.appName == "Netscape" ) {
		btype = 'netscape';  
		if (parseInt(navigator.appVersion) >= 3)  ns3 = 1; else ns3=0;
	}
	else { btype = 'other'; ns3=0; }

	function spaceTrim(InString) {
		var LoopCtrl=true;
		while (LoopCtrl) {
			if (InString.indexOf("  ") != -1) {
				Temp = InString.substring(0, InString.indexOf("  "))
				InString = Temp + InString.substring(InString.indexOf("  ")+1, 
					InString.length)
			} else
				LoopCtrl = false;
		}
		if (InString.substring(0, 1) == " ")
			InString = InString.substring(1, InString.length)
		if (InString.substring (InString.length-1) == " ")
			InString = InString.substring(0, InString.length-1)
		return (InString)
	}

	function splitword(line) {
		var pos = last = num = 0;
		while (true) {
			pos++;
			pos = line.indexOf(" ", pos);
			if (pos == -1 || pos == null) {
				words[num] = line.substring(last, line.length);
				break;
			}
			else {
				words[num] =  line.substring(last, pos);
			}
			num++;
			if (! ns3) words.length = num;
			last = pos;
		}
	} // end of splitword

	function scroller(m, mode, fld) { 
		// m contains the message string to scroll 
		// mode is either "word", "char", or "all" 
		// fld contains the text field object to scroll in.

		if (mode == "") mode = 'word';

		if (SCROLL) return; // ignore if we are already scrolling
		SCROLL = true;

		m = spaceTrim(m);
		field = fld;
		left = "";
		space = spacer.length;
		cur_word = 0;
		words.length= 0;

		if (mode == "word") { 			
			splitword(m);
			words[words.length] = " "; // blank for end to give time delay
			speed /= 5;;
			scroll_by_word();
			return;
		 }

		if (mode == "char") { 
			i = 0;
			num = 0;
			while  (i < m.length) {
				if (m.charAt(i) == " ") 
					words[num-1] += " ";
				else {
					words[num] = m.charAt(i);
					num++;
					if (! ns3) words.length = num;
				}
				i++;
			}
			words[words.length] = " "; // blank for end to give time delay
			speed = 1;
			scroll_by_word(); 
			return; 
		}

		if (mode == "all") {
			if (m.length > spacer.length - 5) 
				spacer = spacer.substring(0,6);
			else
				spacer = spacer.substring(0, spacer.length - m.length);
			msg = m + spacer;
			pos = 0;			
			scroll_all();
			return; 
		}
	} // end of scroller()

	function scroll_all() {
		if (! SCROLL) return;
		if (! HINTING) {
			if (field) 
				field.value = msg.substring(pos, msg.length) + msg.substring(0, pos);
			else
				window.status = msg.substring(pos, msg.length) + msg.substring(0, pos);
			pos++;
			if (pos > msg.length) pos = 0;
		}
		window.setTimeout("scroll_all()", speed);
	} // end of scroll_all

	function scroll_by_word() {
		if (! SCROLL) return;
		if (! HINTING) {  // wait if we are displaying a hint
			right = words[cur_word];
			if (field) 
				field.value = left  + spacer.substring(0,space) + right;
			else
				window.status = left  + spacer.substring(0,space) + right;
		//	space--;
			space -= 3;
			if (space <= 0) {
				left = left  + words[cur_word];
				space = spacer.length - left.length;
				cur_word++;
			}
		}
		if (cur_word == words.length) {
			cur_word = 0;
			left = "";
			space = spacer.length;
		}
		window.setTimeout("scroll_by_word()", speed); 

	} // end of scroll_by_word

	function scrolloff() {
		SCROLL = false;
		words.length = 0;
		while (HINTING) {} // hold here until HINTING is done
		window.status = ""; // just to be sure
	} 
		
//-->
