//copyright 2000; Gravity Media Group.
//this code may be used only for the purposes for which
//it was purchased. Unauthorized duplication or usage is
//prohibited.
//contact woody@gravitymedia.com with any questions.


//------------dynamic element stuff----del.js
function dEl(id, width,nestref) {
	if(is.dom > 2) {
		if (typeof(id) != "object") {
			myEl = document.createElement("DIV");
			if (is.dom >= 3) {
				myEl.setAttribute("id", id);
				myEl.setAttribute("style", "position:absolute;visibility:hidden;");
			} else {
				myEl.style.position='absolute';
				myEl.id = id;
				myEl.style.visibility = 'hidden';
			}
			if (typeof(nestref) == "object") nestref.appendChild(myEl);
			else if (nestref && document.getElementById(nestref) != null) document.getElementById(nestref).appendChild(myEl);
			else document.body.appendChild(myEl);
			this.id = id;
		} else {
			myEl = id;
			this.id = myEl.id;
		}
		this.el = myEl;
		this.el.label = "el_" + id;
		this.css = this.el.style;
		if (width) {
			if (typeof(this.css.pixelWidth) == "number") this.css.pixelWidth = width;
			else this.css.width = width;
		}
		this.doc = this.el;
		this.x = this.css.left;
		this.y = this.css.top;
		this.w = this.css.width;
		this.h = this.css.height;
	} else if (is.dom == 1) {
		if (typeof(id) != "object") {
			if (nestref) {
				eval(id + " = new Layer(" + width + ", nestref);");
				this.el = eval(id);
			} else {
				eval(id + " = new Layer(" + width + ")");
			}
		}
		this.el = eval(id);
		this.el.label = "el_" + id;
		this.event = this.css = this.el;
		this.doc = this.el.document;
		this.x = this.el.left;
		this.y = this.el.top;
		this.w = this.el.clip.right;
		this.h = this.el.clip.height;
		this.hide();
	} else if (is.dom == 2) {
		if (typeof(id) != "object") {
			myEl = document.createElement("DIV");
			myEl.style.position='absolute';
			myEl.id = id;
			myEl.style.visibility = 'hidden';
			this.id = id;
			if (typeof(nestref) == "object") nestref.appendChild(myEl);
			else if (nestref && document.getElementById(nestref) != null) document.getElementById(nestref).appendChild(myEl);
			else document.body.appendChild(myEl);
		} else {
			myEl = id;
			this.id = myEl.id;
		}
		this.el = myEl;
		this.el.label = "el_" + id;

		this.event = this.el;
		this.css = this.el.style;
		this.doc = this.el;
		this.x = this.el.offsetLeft;
		this.y = this.el.offsetTop;
		if (width) this.css.pixelWidth = width;
		this.w = (is.ie4)? this.css.pixelWidth : this.el.offsetWidth;
		this.h = (is.ie4)? this.css.pixelHeight : this.el.offsetHeight;
		this.hide();
	}
}

dElTest = new Function('return true');

function dElShow() { this.css.visibility = (is.dom == 1) ? "show" : "visible"; }
dEl.prototype.show = dElShow;

function dElHide() { this.css.visibility = (is.dom == 1) ? "hide" : "hidden"; }
dEl.prototype.hide = dElHide;

function dElMoveTo(x, y) {
	if (x != null) {
		this.x = x
		if (is.dom >= 3 || is.dom == 1) this.css.left = this.x;
		else this.css.pixelLeft = this.x;
	}
	if (y != null) {
		this.y = y;
		if (is.dom >= 3 || is.dom == 1) this.css.top = this.y;
		else this.css.pixelTop = this.y;
	}
}
dEl.prototype.moveTo = dElMoveTo;

function dElMoveToImage(imname, mx, my) {
	var myx = 0;
	var myy = 0;
	if (!mx) mx = 0;
	if (!my) my = 0;
	if (is.dom >= 2) {
		var el = document.getElementById(imname);
		while (typeof(el.offsetParent) != "undefined" && el.offsetParent != null) {
			myx += el.offsetLeft;
			myy += el.offsetTop;
			el = el.offsetParent;
		}
	} else if (is.dom == 1) {
		myx = eval("document.images['" + imname + "'].x");
		myy = eval("document.images['" + imname + "'].y");
	} else if (is.ie) {
		myx = eval("document.all." + imname + ".offsetLeft");
		myy = eval("document.all." + imname + ".offsetTop");
	}
	this.moveTo((myx + mx), (myy + my));
}
dEl.prototype.moveToImage = dElMoveToImage;

function dElMoveBy(x, y) { this.moveTo(this.x + x, this.y + y); }
dEl.prototype.moveBy = dElMoveBy;


function dElWrite(html) {
	if ((is.ie) && (is.mac)) html += "<noop>";
	if (is.dom>=3) {
		this.el.innerHTML = html;
		this.h = this.css.height;
	} else if (is.dom ==2 || is.ie) {
		this.el.innerHTML = html;
		this.h = (is.ie4) ? this.css.pixelHeight : this.el.offsetHeight;
	} else if (is.dom == 1) {
		this.doc.open();
		this.doc.write(html);
		this.doc.close();
		this.h = this.el.clip.height;
	}
}
dEl.prototype.write = dElWrite;

function dElAppend(html) {
	if (is.dom >= 3) {
		rng = document.createRange();
		rng.setStartBefore(this.el);
		htmlFrag = rng.createContextualFragment(html);
		this.el.appendChild(htmlFrag);
	} else if (is.dom == 2 || is.ie) {
		this.el.insertHTML("End", html);
	} else if (is.ns) {
		//this.doc.open()
		//this.doc.write(html)
		//this.doc.close()
	}
}
dEl.prototype.append = dElAppend


// Clip Methods
function dElClipInit(clipTop,clipRight,clipBottom,clipLeft) {
	if (is.ie) {
		if (arguments.length == 4) this.clipTo(clipTop, clipRight, clipBottom, clipLeft)
		else if (is.ie4) this.g(0, this.css.pixelWidth, this.css.pixelHeight, 0)
	}
}
dEl.prototype.clipInit = dElClipInit;

function dElClipTo(t, r, b, l) {
	if (t==null) t = this.clipValues('t');
	if (r==null) r = this.clipValues('r');
	if (b==null) b = this.clipValues('b');
	if (l==null) l = this.clipValues('l');
	if (is.dom >= 2) {
		this.css.clip = "rect(" + t + "px " + r + "px " + b + "px " + l + "px)";
	} else if (is.dom==1) {
		this.css.clip.top = t;
		this.css.clip.right = r;
		this.css.clip.bottom = b;
		this.css.clip.left = l;
	}
}
dEl.prototype.clipTo = dElClipTo;

function dElClipBy(t, r, b, l) { this.clipTo(this.clipValues('t')+t,this.clipValues('r')+r,this.clipValues('b')+b,this.clipValues('l')+l); }
dEl.prototype.clipBy = dElClipBy;

function dElClipValues(which) {
	if (is.dom>=2) {
		var clipv = this.css.clip.split("rect(")[1].split(")")[0].split("px")
	}
	if (which=="t") return (is.dom==1)? this.css.clip.top : Number(clipv[0])
	if (which=="r") return (is.dom==1)? this.css.clip.right : Number(clipv[1])
	if (which=="b") return (is.dom==1)? this.css.clip.bottom : Number(clipv[2])
	if (which=="l") return (is.dom==1)? this.css.clip.left : Number(clipv[3])
}
dEl.prototype.clipValues = dElClipValues;

function dElChangeBackground(str) {
	if (is.dom==1) this.css.bgColor = str;
	else if (is.dom == 2) this.css.background = str;
	else if (is.dom > 2) this.css.backgroundColor = str;
}
dEl.prototype.setbg = dElChangeBackground;

function dElSetHeight(str) {
	if (is.dom > 2) this.css.height = str;
	else if (is.dom==2) this.css.pixelHeight = str;
	else if (is.dom==1) this.clipTo(null, null, str, null);	
}
dEl.prototype.setHeight = dElSetHeight;

function dElSetWidth(str) {
	if(is.dom>2) this.css.width = str;
	else if (is.dom==2) this.css.pixelWidth = str;
	else if (is.dom==1) this.clipTo(null,str, null, null);
}
dEl.prototype.setWidth = dElSetWidth;
