Timers = new Array();

function timerDef(period, mult, name, href, frame, autostart, repeat, index, onTimer) {
	this.name = name;
	this.period = period;
	this.mult = mult;
	this.href = href;
	this.frame = frame;
	this.onTimer = onTimer;
	this.active = false;
	this.index = index;
	this.repeat = repeat;
	this.id = 0;
	this.count = 0;
	this.restart = "";
	this.stop = tmrStop;
	this.start = tmrStart;
	this.getHref = tmrGH;
	this.setHref = tmrSH;
	this.getCount = tmrGC;
	this.isActive = tmrIA;
	this.getPeriod = tmrGP;
	this.setPeriod = tmrSP;
	this.setRepeat = tmrSR;
	this.getRepeat = tmrGR;
	this.IsTimeUnitMillisecond = tmrITUMS;
	this.SetTimeUnitMillisecond = tmrSTUMS;
	this.IsTimeUnitSecond = tmrITUS;
	this.SetTimeUnitSecond = tmrSTUS;
	this.IsTimeUnitMinute = tmrITUM;
	this.SetTimeUnitMinute = tmrSTUM;
	this.IsTimeUnitHour = tmrITUH;
	this.SetTimeUnitHour = tmrSTUH;
	this.IsTimeUnitDay = tmrITUD;
	this.SetTimeUnitDay = tmrSTUD;
	if (autostart) this.start();
}

function _xx_onTimer(ID,Count) {
	with(Timers[ID]) {
		if (count == Count) {
			if (href != '' || onTimer != nullFunc) {
				if (repeat)
					id = setTimeout(restart, period * mult);
				else
					stop();

				onTimer();			// onTimer before HRef

				if (href != '') {
					if(frame == '')
						window.location.href = href;
					else if (window.parent == window)
						window.open(href,frame);
					else
						window.parent.frames.open(href,frame);
				}
			}
		}
	}
}

function tmrStart() {
	with(this) {
		if (!active) {
			this.active = true;
			restart = "_xx_onTimer(" + index + "," + count + ")";
			id = setTimeout(restart, period * mult);
		}
	}
}

function tmrStop() {
	this.count++;
	this.active = false;
}

function tmrGC() { return this.count; }
function tmrGP() { return this.period; }
function tmrGR() { return this.repeat; }
function tmrGH() { return this.href; }
function tmrIA() { return this.active; }
function tmrSP(sec) { if (sec > 0) this.period = sec; }
function tmrSR(state) { this.repeat = state; }
function tmrSH(theRef) { this.href = theRef; }
function tmrITUMS() { return (this.mult == 1); }
function tmrITUS() { return (this.mult == 1000); }
function tmrITUM() { return (this.mult == 60000); }
function tmrITUH() { return (this.mult == 3600000); }
function tmrITUD() { return (this.mult == 86400000); }
function tmrSTUMS() { this.mult = 1; }
function tmrSTUS() { this.mult = 1000; }
function tmrSTUM() { this.mult = 60000; }
function tmrSTUH() { this.mult = 3600000; }
function tmrSTUD() { this.mult = 86400000; }


