/**
 *	DnaObject BASE v1.0 (23|04|03)
 *	paul.crabtree@dna.co.uk
 */

// browser Object, example is.ns4 returns true if the browser is Netscape 4.
var is = new function()
{
	this.ns4 = document.layers ? 1 : 0;
	this.ie4 = document.all && !document.getElementById ? 1 : 0;
}

////PRIVATE.

// gives ns4 and ie4 some DOM methods so it can try to cope.
if (is.ie4) document.getElementById = new Function("id","return document.all[id]");
if (is.ns4) document.getElementById = new Function("id","return document.layers[id]");
if (is.ns4) Layer.prototype.onload = function()
{
	document.layers[this.id] = this;
	with (this.document)
	{
		for (var i=0; i<images.length; i++)
			if (images[i].name) document.images[images[i].name] = images[i];
	}	
}

// DnaObject class.
DnaObject = function(id)
{
	this.id = id;
	this.constructor.all[id] = this;
	var r = this.ref = document.getElementById(id);
	var c = this.css = r.style||r;
	this.x = !is.ns4 ? r.offsetLeft : r.left;
	this.y = !is.ns4 ? r.offsetTop : r.top;
	this.w = !is.ns4 ? !is.ie4 ? r.offsetWidth : c.pixelWidth : r.clip.width;
	this.h = !is.ns4 ? !is.ie4 ? r.offsetHeight : c.pixelHeight : r.clip.height;
}
// static all object to hold references to all DnaObjects.
DnaObject.all = {};
// overriden toString method to give a String representation of the Object reference.
DnaObject.prototype.toString = function()
{
	return "DnaObject.all." + this.id;
}

////PUBLIC.

// use this to get any DnaObject on the page.
function getDnaObject(id)
{
	return DnaObject.all[id]||(DnaObject.all[id] = new DnaObject(id));
}
// use this on the DnaObject to show it.
DnaObject.prototype.show = function()
{
	this.css.visibility = is.ns4 ? "show" : "visible";
}
// use this on the DnaObject to hide it.
DnaObject.prototype.hide = function()
{
	this.css.visibility = is.ns4 ? "hide" : "hidden";
}
// use this on the DnaObject to write html into it.
DnaObject.prototype.write = function(html)
{
	if (ns4) this.doc.write(html), this.doc.close();
	this.ref.innerHTML = html;
}
// use this to move a DnaObject by x and y pixels.
DnaObject.prototype.moveTo = function(x, y)
{
	if (x!=null) this.css.left = (this.x = parseInt(x)) + (!is.ns4 ? "px" : "");
	if (y!=null) this.css.top = (this.y = parseInt(y)) + (!is.ns4 ? "px" : "");
}

function gifPreload(strFldr)
{
	for (var i=1; i<(a = arguments).length; i++)
		(window[a[i]+"on"] = new Image()).src = strFldr + "/" + a[i] + "_on.gif",
		(window[a[i]+"off"] = new Image()).src = strFldr + "/" + a[i] + "_off.gif";
}
/*
function roll(strName, strState)
{
	if (document.images)
		document.images[strName].src = window[strName + strState].src;
}
*/
function roll(strName, strPath)
{
	if (document.images)
		document.images[strName].src = strPath;
}

