/*
 * Cross-browser API for manipulating positional html elements (divs).
 * Recently updated to support Netscape 6.
 * Author: Scott Martin, razorfish (scott.martin@razorfish.com)
 */
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.setVisible = function(bool)
{	this.styleObject.visibility = (document.layers) ? ((bool) ? "show" : "hide") : ((bool) ? "visible" : "hidden");
}

