
/*---------------------------------------------------------------------
  Timer: An object that performs actions at various intervals
---------------------------------------------------------------------*/

function Timer(action,timeout) {
	this.id = ++Timer.id;
	if (action) this.set(action,timeout);
}
Timer.prototype.active = function() { return this.tid }
Timer.prototype.cancel = function() {
	if (this.tid) {
		clearTimeout(this.tid);
		this.tid = 0;
	}
	delete Timer.map[this.id];
}
Timer.prototype.set = function(action,timeout) {
	if (this.tid) clearTimeout(this.tid);
	this.action = action;
	Timer.map[this.id] = this;
	if (timeout) this.tid = setTimeout("Timer.trigger("+this.id+")",timeout);
	else Timer.trigger(this.id);
}
Timer.trigger = function(id) {
	var t = Timer.map[id];
	t.action();
	if (t.timeout) {
		t.tid = setTimeout("Timer.trigger("+id+")",t.timeout);
		t.timeout = 0;
	}
	else {
		t.tid = 0;
		t.cancel();
	}
}
Timer.shutdown = function() {
	var k,t;
	for (k in Timer.map) {
		t = Timer.map[k];
		if (t.tid) clearTimeout(t.tid);
	}
}
Timer.map={};
Timer.id=0;


/*---------------------------------------------------------------------
  Pane: A simple cross-browser object that provides visibility and
  placement of "layers"
---------------------------------------------------------------------*/

function Pane(id,win) {
	this.setElement(id,win);
}
Pane.prototype.setElement = function(id,win) {
	this.win = win || this.win || window;
	if (typeof(id)=='string') this.obj = this.getElement(id);
	else this.obj = id;
}
Pane.prototype.moveTo = function(x,y) {
	this.setX(x);
	this.setY(y);
}
if (document.images) {
	Pane.prototype.images = function() {
		return document.images;
	}
}
else {
	Pane.prototype.images = function() {
		return {};
	}
}
if (document.layers) {
	function FindLayer(doc,id) {
		var obj = doc.layers[id];
		if (obj) return obj;
		for (var i=0; i<doc.layers.length; i++) {
			obj = FindLayer(doc.layers[i].document,id);
			if (obj) return obj;
		}
		return null;
	}
	Pane.prototype.getElement = function(id) {
		return FindLayer(this.win.document,id);
	}
	Pane.prototype.show = function() {
		this.obj.visibility = "visible";
	}
	Pane.prototype.hide = function() {
		this.obj.visibility = "hidden";
	}
	Pane.prototype.getScrollX = function() {
		return this.win.pageXOffset;
	}
	Pane.prototype.getScrollY = function() {
		return this.win.pageYOffset;
	}
	Pane.prototype.getX = function() {
		return this.obj.pageX;
	}
	Pane.prototype.getY = function() {
		return this.obj.pageY;
	}
	Pane.prototype.getZ = function() {
		return this.obj.zIndex;
	}
	Pane.prototype.setX = function(n) {
		this.obj.pageX = n;
	}
	Pane.prototype.setY = function(n) {
		this.obj.pageY = n;
	}
	Pane.prototype.setZ = function(n) {
		this.obj.zIndex = n;
	}
	Pane.prototype.images = function() {
		return this.obj.document.images;
	}
}
else if (document.all || document.getElementById) {
	if (document.all) {
		Pane.prototype.getElement = function(id) {
			return this.win.document.all[id];
		}
	}
	else {
		Pane.prototype.getElement = function(id) {
			return this.win.document.getElementById(id);
		}
	}
	Pane.prototype.show = function() {
		this.obj.style.visibility = "visible";
	}
	Pane.prototype.hide = function() {
		this.obj.style.visibility = "hidden";
	}
	Pane.prototype.getScrollX = function() {
		return this.win.document.body.scrollLeft;
	}
	Pane.prototype.getScrollY = function() {
		return this.win.document.body.scrollTop;
	}
	Pane.prototype.getX = function() {
		var n = 0;
		var p = this.obj;
		while (p) {
			n += p.offsetLeft;
			p = p.offsetParent;
		}
		return n;
	}
	Pane.prototype.getY = function() {
		var n = 0;
		var p = this.obj;
		while (p) {
			n += p.offsetTop;
			p = p.offsetParent;
		}
		return n;
	}
	Pane.prototype.getZ = function() {
		return this.obj.style.zIndex;
	}
	Pane.prototype.setX = function(n) {
		var p = this.obj.offsetParent;
		while (p) {
			n -= p.offsetLeft;
			p = p.offsetParent;
		}
		this.obj.style.left = n+'px';
	}
	Pane.prototype.setY = function(n) {
		var p = this.obj.offsetParent;
		while (p) {
			n -= p.offsetTop;
			p = p.offsetParent;
		}
		this.obj.style.top = n+'px';
	}
	Pane.prototype.setZ = function(n) {
		this.obj.style.zIndex = n;
	}
}
else {
	Pane.protocol.getElement = function(id) { return null; }
	Pane.prototype.show = 
	Pane.prototype.hide = function() {;}
	Pane.prototype.getScrollX =
	Pane.prototype.getScrollY =
	Pane.prototype.getX =
	Pane.prototype.getY =
	Pane.prototype.getZ = function() { return 0; }
	Pane.prototype.setX =
	Pane.prototype.setY =
	Pane.prototype.setZ = function(n) {;} 
}

/*---------------------------------------------------------------------
  clientWidth, clientHeight: Return visible document dimensions
---------------------------------------------------------------------*/

function clientWidth() {
	if (typeof(window.innerWidth)=='number') {
		return window.innerWidth-17;
	}
	if (document.body && typeof(document.body.clientWidth)=='number') {
		return document.body.clientWidth;
	}
	return 0;
}
function clientHeight() {
	if (typeof(window.innerHeight)=='number') {
		return window.innerHeight;
	}
	if (document.body && typeof(document.body.clientHeight)=='number') {
		return document.body.clientHeight;
	}
	return 0;
}

function base_exit()
{
	Timer.shutdown();
	document.cookie = 'width='+clientWidth();
	document.cookie = 'height='+clientHeight();
}
