var bName = navigator.appName;
var bVer = parseInt(navigator.appVersion);

var NS4 = (document.layers);
var IE4 = (document.all);

function Point(x,y) {
	this.x = x;
	this.y = y;

	return this;
}

function Rect(left, top, right, bottom) {
	this.left   = left;
	this.top    = top;
	this.right  = right;
	this.bottom = bottom;

	this.width  = right - left;
	this.height = bottom - top;

	return this;
}

function noop() {
}


function uniLayer_hide_NS4() {
	this.lay.visibility = "hidden";
}

function uniLayer_hide_IE4() {
	this.lay.style.visibility = "hidden";
}

function uniLayer_show_NS4() {
	this.lay.visibility = "visible";
}

function uniLayer_show_IE4() {
	this.lay.style.visibility = "visible";
}

function uniLayer_moveTo_NS4(x, y) {
	this.lay.left = x;
	this.lay.top  = y;
	
	this.left = x;
	this.top  = y;
}

function uniLayer_moveTo_IE4(x, y) {
	this.lay.style.pixelLeft = x;
	this.lay.style.pixelTop  = y;

	this.left = x;
	this.top  = y;
}

function uniLayer_moveBy_NS4(x, y) {
	this.lay.left += x;
	this.lay.top  += y;

	this.left += x;
	this.top  += y;
}

function uniLayer_moveBy_IE4(x, y) {
	this.lay.style.pixelLeft += x;
	this.lay.style.pixelTop  += y;

	this.left += x;
	this.top  += y;
}

function uniLayer_clipTo_NS4(x1, y1, x2, y2) {
	this.clip = null;
	this.clip = new Rect(x1, y1, x2, y2);

	this.lay.clip.left   = x1;
	this.lay.clip.top    = y1;
	this.lay.clip.right  = x2;
	this.lay.clip.bottom = y2;
}

function uniLayer_clipTo_IE4(x1, y1, x2, y2) {
	this.clip = null;
	this.clip = new Rect(x1, y1, x2, y2);

	this.lay.style.clip  = "rect("+this.clip.top+","+this.clip.right+","+this.clip.bottom+","+this.clip.left+")";
}

function uniLayer_clipBy_NS4(x1, y1, x2, y2) {
	clip2 = new Rect(this.clip.left+x1, this.clip.top+y1,this.clip.right+x2,this.clip.bottom+y2);
	this.clip = null;
	this.clip = clip2;

	this.lay.clip.left   += x1;
	this.lay.clip.top    += y1;
	this.lay.clip.right  += x2;
	this.lay.clip.bottom += y2;
}

function uniLayer_clipBy_IE4(x1, y1, x2, y2) {
	clip2 = new Rect(this.clip.left+x1, this.clip.top+y1,this.clip.right+x2,this.clip.bottom+y2);
	this.clip = null;
	this.clip = clip2;
	
	this.lay.style.clip  = "rect("+this.clip.top+","+this.clip.right+","+this.clip.bottom+","+this.clip.left+")";
}

function uniLayer(name) {
	if(NS4) {
		this.hide = uniLayer_hide_NS4;
		this.show = uniLayer_show_NS4;
		this.moveTo = uniLayer_moveTo_NS4;
		this.moveBy = uniLayer_moveBy_NS4;
		this.clipTo = uniLayer_clipTo_NS4;
		this.clipBy = uniLayer_clipBy_NS4;

		this.lay  = document.layers[name];
		
		this.clip = new Rect(
			this.lay.clip.left,
			this.lay.clip.top,
			this.lay.clip.right,
			this.lay.clip.bottom);

		this.left   = this.lay.left;
		this.top    = this.lay.top;
		this.width  = this.lay.clip.width;
		this.height = this.lay.clip.height;
	} else if(IE4) {
		this.hide = uniLayer_hide_IE4;
		this.show = uniLayer_show_IE4;
		this.moveTo = uniLayer_moveTo_IE4;
		this.moveBy = uniLayer_moveBy_IE4;
		this.clipTo = uniLayer_clipTo_IE4;
		this.clipBy = uniLayer_clipBy_IE4;

		this.lay  = document.all[name];

		this.clip = new Rect(
			this.lay.scrollLeft,
			this.lay.scrollTop,
			this.lay.scrollWidth + this.lay.scrollLeft,
			this.lay.scrollHeight + this.lay.scrollTop);

		this.left   = this.lay.style.pixelLeft;
		this.top    = this.lay.style.pixelTop;
		this.width  = this.lay.scrollWidth;
		this.height = this.lay.scrollHeight;
	} else {
		this.hide = uniLayer_hide_IE4;
		this.show = uniLayer_show_IE4;
		this.moveTo = uniLayer_moveTo_IE4;
		this.moveBy = uniLayer_moveBy_IE4;
		this.clipTo = uniLayer_clipTo_IE4;
		this.clipBy = uniLayer_clipBy_IE4;

		this.lay  = document.getElementsByName(name).item(0);

		this.clip = new Rect(
			this.lay.scrollLeft,
			this.lay.scrollTop,
			this.lay.scrollWidth + this.lay.scrollLeft,
			this.lay.scrollHeight + this.lay.scrollTop);

		this.left   = this.lay.style.pixelLeft;
		this.top    = this.lay.style.pixelTop;
		this.width  = this.lay.scrollWidth;
		this.height = this.lay.scrollHeight;
	}

	return this;
}

