function layerObj(id,parent) {
	this.id = id;
	if (!parent) {
		this.parent = document.body;
	} else {
		if (typeof(parent) == 'string') {
			this.parent = (getLayer(parent)) ? getLayer(parent) : createLayer(this.id,document.body);
		} else {
			this.parent = (parent.layer) ? parent.layer : parent;
		}
	}
	this.layer = (getLayer(this.id,this.parent)) ? getLayer(this.id,this.parent) : createLayer(this.id,this.parent);
	this.style = this.layer.style;
	this.getMouseOverColor = layerObjGetMouseOverColor;
	this.getMouseOutColor = layerObjGetMouseOutColor;
	this.getSubMouseOverColor = layerObjGetSubMouseOverColor;
	this.getSubMouseOutColor = layerObjGetSubMouseOutColor;
	this.setMouseOverColor = layerObjSetMouseOverColor;
	this.setMouseOutColor = layerObjSetMouseOutColor;
	this.setSubMouseOverColor = layerObjSetSubMouseOverColor;
	this.setSubMouseOutColor = layerObjSetSubMouseOutColor;
	
	// Position
	this.getLeft = layerObjGetLeft;
	this.getTop = layerObjGetTop;
	this.moveTo = layerObjMoveTo;
	this.moveBy = layerObjMoveBy;
	this.getZindex = layerObjGetZindex;
	this.setZindex = layerObjSetZindex;
	
	// Size
	this.getWidth = layerObjGetWidth;
	this.getHeight = layerObjGetHeight;
	this.setWidth = layerObjSetWidth;
	this.setHeight = layerObjSetHeight;
	this.setClipping = layerObjSetClipping;
	
	// Visibility
	this.getVisibility = layerObjGetVisibility;
	this.show = layerObjShow;
	this.hide = layerObjHide;
	this.inherit = layerObjInherit;
	
	// Content
	this.write = layerObjWrite;
}

function getLayer(id,parent) {
	if (document.all && !document.getElementById) {
		return document.all[id];
	} else {
		if (document.getElementById(id)) {
			return document.getElementById(id);
		} else if (document.getElementsByTagName('IFRAME')[id]) {
			return document.getElementsByTagName('IFRAME')[id];
		} else {
			return false;
		}
	}
}

function createLayer(id,parent) {
	if (document.all && !document.getElementById) {
		parent.insertAdjacentHTML('BeforeEnd','<DIV ID=\"' + id + '\">');
		id = document.all[id];
	} else {
		id = document.createElement('DIV');
		parent.appendChild(id);
	}
	
	with (id.style) {
		position = 'absolute';
		left = '0px';
		top = '0px';
		border = menuOuterBorderWidth+"px";
		visibility = 'hidden';
	}
	
	return eval(id);
}

function layerObjGetMouseOverColor()
{
	return(this.mouseOverColor);
}

function layerObjGetMouseOutColor()
{
	return(this.mouseOutColor);
}

function layerObjGetSubMouseOverColor()
{
	return(this.subMouseOverColor);
}

function layerObjGetSubMouseOutColor()
{
	return(this.subMouseOutColor);
}

function layerObjSetMouseOverColor(color)
{
	this.mouseOverColor = color;
}

function layerObjSetMouseOutColor(color)
{
	this.mouseOutColor = color;
}

function layerObjSetSubMouseOverColor(color)
{
	this.subMouseOverColor = color;
}

function layerObjSetSubMouseOutColor(color)
{
	this.subMouseOutColor = color;
}


function layerObjGetLeft() {
	return parseInt(this.style.left);
}

function layerObjGetTop() {
	return parseInt(this.style.top);
}

function layerObjMoveTo(x,y) {
	this.style.left = x + 'px';
	this.style.top = y + 'px';
}

function layerObjMoveBy(x,y) {
	this.style.left = parseInt(this.style.left) + x + 'px';
	this.style.top = parseInt(this.style.top) + y + 'px';
}

function layerObjGetZindex() {
	return this.style.zIndex;
}

function layerObjSetZindex(z) {
	this.style.zIndex = z;
}

function layerObjGetWidth() {
	return this.layer.offsetWidth;
}

function layerObjGetHeight() {
	return this.layer.offsetHeight;
}

function layerObjSetWidth(width) {
	this.style.width = width;
}

function layerObjSetHeight(height) {
	this.style.height = height;
}

function layerObjSetClipping(t,r,b,l) {
	this.style.clip = 'rect(' + t + 'px ' + r + 'px ' + b + 'px ' + l + 'px)';
}

function layerObjGetVisibility() {
	return this.style.visibility;
}

function layerObjShow() {
	this.style.visibility = 'visible';
}

function layerObjHide() {
	this.style.visibility = 'hidden';
}

function layerObjInherit() {
	this.style.visibility = 'inherit';
}

function layerObjWrite(htmlStr) {
	this.layer.innerHTML = '';
	this.layer.innerHTML = htmlStr;
}
