/* //:::::::::::     HIERMENU   :::::::::::\\
                  by Micah Goulart

	This script can be used as long as this
	disclaimer is left untouched.
	For bug reports or custom scripts, email me at:
	micahgoulart@mailbr.com.br
	
	IMPORTANT!!
		This script requires the dynObj.js source file.
		Download it at members.xoom.com/micahgoulart/dynObj.js

   //:::::::::::   copyright 1999   :::::::::::\\	*/

function hierMenu()
{	var arg = arguments
	
	if (arg.length == 4)
	{	this.isChild = false
		this.x = arg[0]
		this.y = arg[1]
		this.w = arg[2]

		this.itemHeight = arg[3]
		this.offsetX = -10
		this.offsetY = 4
		this.imgURL = ["arrow1.gif", "arrow2.gif"]
		this.imgSize = [5, 9]	}
	
	else
	{	this.isChild = true
		this.parent = arg[0]
		var index = arg[1]
	
		this.offsetX = this.parent.offsetX
		this.offsetY = this.parent.offsetY
	
		this.x = this.parent.w + this.parent.x + this.offsetX
		this.y = this.parent.menu.items[index].y + this.parent.y + this.offsetY
		this.w = (arg.length == 3) ? arg[2] : this.parent.w
		
		this.itemHeight = this.parent.itemHeight
		this.imgURL = this.parent.imgURL
		this.imgSize = this.parent.imgSize
		var item = this.parent.menu.items[index]		

		item.hasChild = true
		item.child = this
		item.menu = this.parent		}

	this.menu = new Menu(this.x, this.y, this.w, this.itemHeight)

	if (this.isChild)
	{	this.menu.ID = this.parent.menu.ID + "child" + index
		hierMenu.count2++
		this.menu.cssID = this.parent.menu.cssID
		this.menu.style = (arg.length == 5) ? arg[4] : this.parent.menu.style
		this.menu.opened = false
		this.menu.isChild = this.isChild
		this.menu.container = this }
	else this.menu.ID = "hierMenu" + (hierMenu.count++)

	this.ref = this.menu.ID + "RefObj"
	eval(this.ref + " = this")

	this.childShown = null
	this.visible = false

	this.menu.visibility = "hidden"

	this.style = this.menu.style	}
	
hierMenu.prototype.build = hierMenuBuild
hierMenu.prototype.activate = hierMenuActivate
hierMenu.prototype.open = hierMenuOpen
hierMenu.prototype.close = hierMenuClose
hierMenu.prototype.toggle = hierMenuToggle

hierMenu.count = 0
hierMenu.count2 = -1
self.defaultStatus = ""

function hierMenuBuild()
{	status = "Building hierMenu " + hierMenu.count
	this.menu.build()	
	this.div = this.menu.div
	var m_iL = this.menu.items.length
	for (var i = 0; i < m_iL; i++)
		if (this.menu.items[i].hasChild)
		{	var item = this.menu.items[i]
			 writeCSS(css(this.ref+"image"+i,this.w-this.style.borderWidth-this.imgSize[0]-7,
			(this.itemHeight-this.imgSize[1])/2, this.imgSize[1],null,null,null,4000000000))
			
			item.normal += 
				"<DIV ID="+this.ref+"image"+i+"><IMG SRC='"+this.imgURL[0]+"'></DIV>\n"
			item.over += 
				"<DIV ID="+ this.ref+ "image"+i+"><IMG SRC='"+this.imgURL[1]+"'></DIV>\n"
				
			item.child.build()
			this.div += item.child.div	}
	
	status = "Preloading Arrow Images"
	this.imgOne = new Image()
	this.imgOne.src = this.imgURL[0]
	
	this.imgTwo = new Image()
	this.imgTwo.src = this.imgURL[1]		}

function hierMenuActivate()
{	status = "Activating hierMenu " + (cnt++) + " of " + (hierMenu.count + hierMenu.count2)
	this.menu.activate()
	var m_iL = this.menu.items.length
	for (var i = 0; i < m_iL; i++)
		if (this.menu.items[i].hasChild)
		{	var item = this.menu.items[i]
			item.obj.write(item.normal)
			if (NS) item.o.write(item.over)
			item.e.css.cursor = "hand"
			item.child.activate()
			item.url = "javascript:" + this.ref + ".toggle(" + i + ")"	}
				}
var cnt = 0
	
function hierMenuOpen(i)
{	if (i != this.childShown && this.childShown != null) this.toggle(this.childShown)
	var item = this.menu.items[i]
	item.child.menu.obj.show()
	item.child.menu.obj.css.zIndex = Menu.count++
	item.child.opened = true
	this.childShown = i
	item.obj.bgColor(item.child.menu.style.bgColorDown)	}

function hierMenuClose()
{	var i = this.childShown
	if (i != null && this.menu.items[i] != null)
	{	var item = this.menu.items[i]
		this.childShown = null
		item.child.menu.obj.hide()
		item.child.opened = false
		item.obj.bgColor(this.menu.style.bgColorOut)
		if (IE) item.obj.elm.all[4].className = this.menu.cssID + "Normal"
		if (IE && item.hasChild) item.obj.elm.all[6].src = this.imgOne.src
		if (IE && this.menu.style.useAltText) item.obj.write(item.over)
		if (NS) item.o.hide()
		this.menu.items[i].child.close()	}
			}

function hierMenuToggle(i)
{	if (i == null)
		if (!this.visible)
		{	this.menu.obj.show()
			this.visible = true	}
		else
		{	if (this.childShown != null) this.close()
			this.menu.obj.hide()
			this.visible = false	}
	else
	{	if (!this.menu.items[i].child.opened) this.open(i)
		else this.close()	}
			}
