function Div(divId)
{	this.id = divId;
	this.alias = (document.getElementById) ? document.getElementById(this.id).id 
		: (document.layers) ? findLayerAlias(this.id) : new String("document.all." + this.id);
	this.styleAlias = (document.getElementById || document.all) ? this.alias + ".style" : this.alias;
	this.documentObject = (document.getElementById) ? document.getElementById(this.id) : eval(this.alias);
	this.styleObject = (document.getElementById) ? this.documentObject.style : eval(this.styleAlias);

	function findLayerAlias(name, docAlias) 
	{	var i, layer, docLayers, layerAlias;
		if(!docAlias) docAlias = "document";
		docLayers = eval(docAlias + ".layers");
		for(i = 0; i < docLayers.length; i++) 
		{	layerAlias = docAlias + ".layers." + docLayers[i].name;
			layer = eval(layerAlias);
			if(layer.name == name) return layerAlias;
			if(layer.document.layers.length > 0) 
			{	layerAlias = findLayerAlias(name, layerAlias + ".document");
				if(layerAlias != null) return layerAlias;
			}
		}
		return null;
	}
	
	return this;
}

Div.prototype.getId = function()
{	return this.id;
}


Div.prototype.getAlias = function()
{	return this.alias;
}


Div.prototype.getStyleAlias = function()
{	return this.styleAlias;
}


Div.prototype.getDocumentObject = function()
{	return this.documentObject;
}


Div.prototype.getStyleObject = function()
{	return this.styleObject;
}


Div.prototype.getParentDiv = function()
{	pid = (document.getElementById) ? this.documentObject.parentNode.id 
		: (document.all) ? eval("document.all." + this.id + ".parentElement.id")
			: (document.layers) ? eval(this.alias + ".parentLayer.id")
				: null;
				
	return (pid && pid != null) ? new Div(pid) : null;
}


Div.prototype.isVisible = function()
{	if(this.styleObject.visibility)
	{	
		if(this.styleObject.visibility == "inherit" || this.styleObject.visibility.length == 0)
		{	pd = this.getParentDiv();
			return (pd != null) ? pd.isVisible() : true;
		}
		else return (this.styleObject.visibility == "visible" || this.styleObject.visibility == "show");
	}
	
	return true;
}

Div.prototype.setVisible = function(bool)
{	this.styleObject.visibility = (document.layers) ? ((bool) ? "show" : "hide") : ((bool) ? "visible" : "hidden");
}

Div.prototype.getLeft = function()
{	return (document.getElementById) ? (document.all || !this.documentObject.parentNode)
		? this.documentObject.offsetLeft : (this.documentObject.offsetLeft - this.documentObject.parentNode.offsetLeft) 
			: (document.all) ? this.styleObject.pixelLeft : this.styleObject.left;
}

Div.prototype.setLeft = function(x)
{	if(!isNaN(x)) 
	{	if(document.getElementById)
			this.styleObject.left = new String(x + "px");
		else this.styleObject.left = x;
	}
}

Div.prototype.getTop = function()
{	return (document.getElementById) ? (document.all || !this.documentObject.parentNode)
		? this.documentObject.offsetTop : (this.documentObject.offsetTop - this.documentObject.parentNode.offsetTop) 
			: (document.all) ? this.styleObject.pixelTop : this.styleObject.top;
}

Div.prototype.setTop = function(y)
{	if(!isNaN(y)) 
	{	if(document.getElementById)
			this.styleObject.top = new String(y + "px");
		else this.styleObject.top = y;
	}
}

Div.prototype.getHeight = function()
{	return (document.getElementById) ? this.documentObject.offsetHeight
		: (document.all) ? (this.styleObject.pixelHeight) ? this.styleObject.pixelHeight
			: eval("document.all." + this.id + ".clientHeight") : this.styleObject.clip 
				? (this.styleObject.clip.bottom - this.styleObject.clip.top)
					: (this.documentObject.height) ? this.documentObject.height : -1;
}

Div.prototype.setHeight = function(newHeight)
{	if(!isNaN(newHeight))
	{	if(document.getElementById) this.styleObject.height = new String(newHeight + "px");
		else if(document.all) this.styleObject.pixelHeight = newHeight;
		else this.styleObject.clip.bottom += (newHeight - this.getHeight());
	}
}

Div.prototype.getWidth = function()
{	return (document.getElementById) ? this.documentObject.offsetWidth
		: (document.all) ? (this.styleObject.pixelWidth) ? this.styleObject.pixelWidth
			: eval("document.all." + this.id + ".clientWidth") : this.styleObject.clip 
				? (this.styleObject.clip.right - this.styleObject.clip.left)
					: (this.documentObject.width) ? this.documentObject.width : -1;
}

Div.prototype.setWidth = function(newWidth)
{	if(!isNaN(newWidth))
	{	if(document.getElementById) this.styleObject.width = new String(newWidth + "px");
		else if(document.all) this.styleObject.pixelWidth = newWidth;
		else this.styleObject.clip.right = newWidth;
	}
}

Div.prototype.moveTo = function(x, y)
{	this.setLeft(x);
	this.setTop(y);
}

Div.prototype.getZIndex = function()
{	zi = parseInt(this.styleObject.zIndex);
	return (!isNaN(zi)) ? zi : -1;
}

Div.prototype.setZIndex = function(z)
{	if(!isNaN(z)) this.styleObject.zIndex = z;
}

Div.prototype.getContent = function()
{	return (document.all) ? eval("document.all." + this.id + ".innerHTML") 
		: (this.documentObject.innerHTML) ? this.documentObject.innerHTML : new String("");
}

Div.prototype.setContent = function(str)
{	if(document.all)
		eval("document.all." + this.id + ".innerHTML = str;");
	else
	{
		this.documentObject.innerHTML = str;
			
		if(document.layers)
		{	thisDoc = this.documentObject.document;
			thisDoc.open();
			thisDoc.write(this.getContent());
			thisDoc.close();
		}
	}
}

Div.prototype.getForm = function(frmName)
{	frmArray = (document.getElementById || document.all) ? document.forms : this.documentObject.document.forms;
	return (frmArray != null && frmArray.length > 0) ? frmArray[frmName] : null;
}

Div.prototype.getImage = function(imgName)
{	imgArray = (document.getElementById || document.all) ? document.images : this.documentObject.document.images;
	return (imgArray != null && imgArray.length > 0) ? imgArray[imgName] : null;
}
