/******************************************************************************/
// lib_sheds - 07/2003
// written by Pascal Carles (p.carles@aprim-t.com)
// You can use, modify or distribute freely this code as far as you mention
// my tribute to it somewhere in the sources...
/******************************************************************************/

var Sheds = new Array();

function Shed(aAction, aLastAction, stepTime, steps) {
	this.num = Sheds.length;
	Sheds[this.num] = this;
	
	this.Action = aAction;
	this.LastAction = aLastAction;
	this.stepTime = stepTime;
	this.steps = steps;
	this.curStep = steps;
	this.idTimer = null;
	this.on = false;
	this.AutoRun = false;
	this.pause = false;
	
	this.start = startShed;
	this.run = runShed;
	this.stop = stopShed;
}

function startShed() {
	if(this.on) {
		this.stop();
	}
	this.on = true;
	eval(this.Action);
	this.idTimer = setInterval("Sheds["+this.num+"].run()", this.stepTime);
}

function runShed() {
	if(this.on) {
		if(!this.pause) {
			if(this.curStep > 0) {
				eval(this.Action);
				this.curStep = this.curStep - 1;
			}
			else {
				this.curStep = this.steps;
				if(!this.AutoRun) {
					this.stop();
					eval(this.LastAction);
				}
			}
		}
	}
}

function stopShed() {
	clearInterval(this.idTimer);
	this.on = false;
}
