//########################################################
//##							##
//##	Ticker Class v1.0 by Uhu			##
//##							##
//##	Created: Apr 6 2000				##
//##	Last Modified: Apr 6 2000			##
//##							##
//########################################################

//=== Definition ======================================

function Ticker (iFieldRef) {

//--- Properties ---
	this.tickerStatus="TICKER_OFF";			// TICKER_OFF, TICKER_ON, TICKER_ACTIVE
	this.tickerInterval;				// internal;
	this.index=0;					// internal; character index
	this.tickerString="";				// internal;
	this.iFieldRef=eval(iFieldRef);			// inputfield object reference
	this.iFieldRef.value="";			// clear inputfield
	this.tickerSpan=10;				// number of digits
	this.tickerDelay=200;				// ticker speed

//--- to be modified by ticker.cgi --- BEGIN ---
	this.textChangeEnabled=false;
	this.tickerText="Herzlich Willkommen beim Internetauftritt von Vetter-Industrieausrüstung";
//--- to be modified by ticker.cgi --- END ---

//--- Methods ---
	this.setIFieldRef=setIFieldRef;			// change inputfield object reference; ticker must be in state TICKER_OFF
	this.setText=setText;				// set/change ticker text; ticker must be in state TICKER_OFF
	this.setSpan=setSpan;				// set/change number of digits; ticker must be in state TICKER_OFF
	this.setDelay=setDelay;				// set/change ticker speed; ticker must be in state TICKER_OFF
	this.on=tickerOn;				// ticker on; ticker must be in state TICKER_OFF (--> TICKER_ON)
	this.off=tickerOff;				// ticker off; ticker must be in state TICKER_ON (--> TICKER_OFF)
	this.start=tickerStart;				// ticker runs; ticker must be in state TICKER_ON (--> TICKER_ACTIVE)
	this.stop=tickerStop;				// ticker stops; ticker must be in state TICKER_ACTIVE (--> TICKER_ON)
	this.getStatus=getStatus;			// returns ticker status
	this.getIFieldRef=getIFieldRef;			// returns inputfield object reference
	this.getText=getText;				// returns ticker text
	this.getSpan=getSpan;				// returns number of digits
	this.getDelay=getDelay;				// returns ticker speed
	}

//=== Implementation ===================================

function setIFieldRef(iFieldRef) {
	if (this.tickerStatus=="TICKER_OFF") {
		this.iFieldRef=iFieldRef;
		return true;
		}
	else return false;
	}

function setText(text) {
	if (this.tickerStatus=="TICKER_OFF" && this.textChangeEnabled) {
		this.tickerText=text;
		return true;
		}
	else return false;
	}

function setSpan(span) {
	if (this.tickerStatus=="TICKER_OFF") {
		this.tickerSpan=span;
		return true;
		}
	else return false;
	}

function setDelay(delay) {
	if (this.tickerStatus=="TICKER_OFF") {
		this.tickerDelay=delay;
		return true;
		}
	else return false;
	}

function tickerOn() {
	if (this.tickerStatus=="TICKER_OFF") {
		this.index=this.tickerSpan-1;
		this.tickerString="";
		for (i=0; i<this.tickerSpan; i++) {
			this.tickerString+=" ";
			}
		this.iFieldRef.value=this.tickerString;
		this.tickerString+=this.tickerText;
		this.tickerStatus="TICKER_ON";
		return true;
		}
	else return false;
	}

var tickerSelf;
function tickerStart() {
	if (this.tickerStatus=="TICKER_ON") {
		tickerSelf=this;
		this.tickerStatus="TICKER_ACTIVE";
		this.tickerInterval=window.setInterval("tickerAnimation(tickerSelf)", tickerSelf.tickerDelay);
		return true;
		}
	else return false;
	}

function tickerStop() {
	if (this.tickerStatus=="TICKER_ACTIVE") {
		clearInterval(this.tickerInterval);
		this.tickerStatus="TICKER_ON";
		return true;
		}
	else return false;
	}

function tickerOff() {
	if (this.tickerStatus=="TICKER_ON") {
		this.iFieldRef.value="";
		this.tickerStatus="TICKER_OFF"
		return true;
		}
	else return false;
	}

function getStatus() {
	return this.tickerStatus;
	}

function getIFieldRef() {
	return this.iFieldRef;
	}

function getText() {
	return this.tickerText;
	}

function getSpan() {
	return this.tickerSpan;
	}

function getDelay() {
	return this.tickerDelay;
	}

function tickerAnimation(tickerObject) {
	if (tickerObject.tickerStatus=="TICKER_ACTIVE") {
		outString=tickerObject.iFieldRef.value.slice(1);
		outString+=tickerObject.tickerString.charAt(tickerObject.index);
		if (tickerObject.index<tickerObject.tickerString.length-1) {
			tickerObject.index++;
			}
		else tickerObject.index=0;
		tickerObject.iFieldRef.value=outString;
		return true;
		}
	else return false;
	}
