var _elementCache=new Array();

function getElmt(nl) {
	var elmt=_elementCache[nl];
	if (elmt && elmt.tagName!="")
		return elmt;
	if (UAisCSS)
		elmt=document.getElementById(nl);
	else if (UAisIE)
		elmt=document.all[nl];
	else if (UAisNS4) {
		elmt=document.layers[nl];
		elmt.style=elmt;
	}
	if (!elmt)
		return null;//alert("Element '"+nl+"' not found!");
	elmt.setPos=_setPos;
	elmt.setSize=_setSize;
	elmt.setClip=_setClip;
	elmt.getClip=_getClip;
	elmt.hide=_hide;
	elmt.show=_show;
	elmt.xhide=_xhide;
	elmt.xshow=_xshow;
	_elementCache[nl]=elmt;
	return elmt;
}

function clearElmtCache() {
	_elementCache=new Array();
}

function _setPos(x,y) {
	if (!isNaN(parseInt(x)))
		this.xpos=this.style.left=x;
	if (!isNaN(parseInt(y)))
		this.ypos=this.style.top=y;
	return this;
}

function _setSize(x,y) {
	if (!isNaN(parseInt(x)))
		this.xsize=this.style.width=x;
	if (!isNaN(parseInt(y)))
		this.ysize=this.style.height=y;
	return this;
}

function _setClip(l,t,r,b) {
	this.clipl=(l=parseInt(l));
	this.clipt=(t=parseInt(t));
	this.clipr=(r=parseInt(r));
	this.clipb=(b=parseInt(b));
	this.clipset=true;	
	if (UAisIE || UAisCSS) {
		this.style.clip="rect("+t+"px, "+r+"px, "+b+"px, "+l+"px)";
	} else {
		this.style.clip.top = t;
		this.style.clip.right = r;
		this.style.clip.bottom = b;
		this.style.clip.left = l;
	}
	return this;
}

function _getClip(l) {
	if (!this.clipset) {
		if (UAisIE)	{
			var clipv = this.style.clip.split("rect(")[1].split(")")[0].split("px");
			this.clipt=clipv[0];
			this.clipr=clipv[1];
			this.clipb=clipv[2];
			this.clipl=clipv[3];
		} else {
			this.clipl=this.style.clip.left;
			this.clipt=this.style.clip.top;
			this.clipr=this.style.clip.right;
			this.clipb=this.style.clip.bottom;
		}
	}
	switch (l) {
		case 't':
			return parseInt(this.clipt);
		case 'r':
			return parseInt(this.clipr);
		case 'b':
			return parseInt(this.clipb);
		case 'l':
			return parseInt(this.clipl);
	}
	return 0;
}

function _hide(z) {
	this.style.visibility="hidden";
	if (!isNaN(parseInt(z)))
		this.style.zIndex=z;
	return this;
}

function _show(z) {
	this.style.visibility="visible";
	if (!isNaN(parseInt(z)))
		this.style.zIndex=z;
	return this;
}

function _xhide(z) {
	this.style.display="none";
	if (!isNaN(parseInt(z)))
		this.style.zIndex=z;
	return this;
}

function _xshow(z) {
	this.style.display="block";
	if (!isNaN(parseInt(z)))
		this.style.zIndex=z;
	return this;
}

function hide(e,z) {
	var elmt=e.tagName?e:getElmt(e);
	if (elmt)
		elmt.style.visibility="hidden";
	if (!isNaN(parseInt(z)))
		elmt.style.zIndex=z;
	return elmt;
}

function show(e,z) {
	var elmt=e.tagName?e:getElmt(e);
	if (elmt)
		elmt.style.visibility="visible";
	if (!isNaN(parseInt(z)))
		elmt.style.zIndex=z;
	return elmt;
}

function xhide(e,z) {
	var elmt=e.tagName?e:getElmt(e);
	if (elmt)
		elmt.style.display="none";
	if (!isNaN(parseInt(z)))
		elmt.style.zIndex=z;
	return elmt;
}

function xshow(e,z) {
	var elmt=e.tagName?e:getElmt(e);
	if (elmt)
		elmt.style.display="block";
	if (!isNaN(parseInt(z)))
		elmt.style.zIndex=z;
	return elmt;
}
