// original code chunks by dan steinman
// modified and improved by damon goosh

var dummyNode = null

// --- BEGIN: METHODS
function NavLayerShow() { this.css.visibility = (is.ns) ? "show" : "visible" }
function NavLayerHide() { this.css.visibility = (is.ns) ? "hide" : "hidden" }

function NavLayerMoveOnScreen()		{
	this.show()
	this.moveTo(null,this.orgYPos)
	}
function NavLayerMoveOffScreen()	{	this.moveTo(null,-2000)	}

function NavLayerWrite(html) {
	if (is.ns) 		{	this.doc.open();	this.doc.write(html);	this.doc.close()	}
	else if (is.ie) {	this.elm.innerHTML = html		}
}

function NavLayerSetBgColor(color) {
	if (is.ns)	{this.doc.bgColor = color} else if (is.ie)	{this.css.backgroundColor = color}
}

function NavLayerMoveBy(x,y)	{ this.moveTo(this.x+x,this.y+y) }
function NavLayerMoveTo(x,y) {
	if (x!=null)
		{	this.x = x
			if (is.ns) this.css.left =	this.x
			else this.css.pixelLeft = this.x
		}
	if (y!=null)
		{	this.y = y
			if (is.ns) this.css.top = this.y
			else this.css.pixelTop = this.y
		}
}
function NavLayerResizeTo(w,h) {
	if (w!=null) this.w = w
	if (h!=null) this.h = h
	if (is.ie)
		{	if (is.ie4)
				{	this.css.pixelWidth = this.w
					this.css.pixelHeight = this.h	}
			else{	this.css.setAttribute("width",this.w,"false")
					this.css.setAttribute("height",this.h,"false")		}
		}
	if (is.ns) this.css.resizeTo(this.w,this.h)
}

function NavSetZIndex(z) {	this.z = z;	this.css.zIndex = z	}

function NavLayerClipTo(top,right,bottom,left)	{
	if (is.ns)
		{	this.css.clip.top = top;			this.css.clip.right = right
			this.css.clip.bottom = bottom;		this.css.clip.left = left
		}
	else if (is.ie) this.css.clip = "rect("+top+" "+right+" "+bottom+" "+left+")"
}
// --- END: METHODS

function LayerObject(nodeName,eventCapture,parentLayer,dontResizeMeAtInit)	{
	id	=	nodeName+"DIV"

	if (is.ns)
		{	if (is.ns4)
				{	if (parentLayer)	this.css	=	document.layers[parentLayer].document.layers[id]	
					else	this.css = document.layers[id]
					
					this.elm	=	this.css
					this.doc	=	this.css.document
				}
			if (is.ns5)
				{	this.elm	=	document.getElementById(id)
					this.css	=	this.elm.style
					this.doc	=	document
				}
			this.x			=	this.css.left
			this.y			=	this.css.top
			this.w			=	this.css.clip.width
			this.h			=	this.css.clip.height
			this.bgColor	=	this.css.bgColor
		}
	else if (is.ie)
		{	this.elm	=	document.all[id]
			this.css	=	document.all[id].style
			this.doc	=	document
			this.x		=	this.elm.offsetLeft
			this.y		=	this.elm.offsetTop
			this.w		=	(is.ie4)	?	this.elm.scrollWidth : this.elm.offsetWidth
			this.h		=	(is.ie4)	?	this.elm.scrollHeight : this.elm.offsetHeight

			this.bgColor	=	this.css.backgroundColor
		}
	this.z	=	this.css.zIndex

	this.node	=	dummyNode

	this.write		=	NavLayerWrite
	this.clipTo		=	NavLayerClipTo
	this.hide		=	NavLayerHide
	this.show		=	NavLayerShow
	this.moveOnScreen=	NavLayerMoveOnScreen
	this.moveOffScreen=	NavLayerMoveOffScreen
	this.setBgColor =	NavLayerSetBgColor
	this.moveTo 	=	NavLayerMoveTo
	this.moveBy		=	NavLayerMoveBy
	this.resizeTo	=	NavLayerResizeTo
	this.setZIndex	=	NavSetZIndex
	this.orgYPos	=	this.y
	this.firstItem	=	0
	
	if (eventCapture)
		{	if (is.ns)	this.elm.captureEvents(Event.MOUSEOVER|Event.MOUSEOUT|Event.MOUSEUP)
			this.elm.onmouseover	=	NavItemOver
			this.elm.onmouseout		=	NavItemOut
			this.elm.onmouseup		=	NavItemClicked
		}

	if (is.ie4)
		{
			if (!dontResizeMeAtInit)	{	this.resizeTo(this.w,this.h)		}
		}
}