/* //:::::::::::      MENU    :::::::::::\\
                  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/Javascripts/dynobj

	//:::::::::::   copyright 1999   :::::::::::\\	*/

function Menu()
{	var arg = arguments

	this.ID = "Menu" + (Menu.count++)
	this.ref = this.ID + "RefObj"
	eval(this.ref + " = this")

	this.x = arg[0]
	this.y = arg[1]
	this.w = arg[2]
	this.h = 0

	this.str = ""
	this.visibility = "visible"

	this.items = []
	this.itemHeight = arg[3]

	this.style = new Object()

	this.style.itemSpacing = style.itemSpacing
	this.style.hiTech = style.hiTech

	this.style.useAltText = style.useAltText
	this.style.altText = style.altText
	
	this.style.borderColor = style.borderColor
	this.style.borderWidth = style.borderWidth

	this.style.useTextOver = style.useTextOver

	this.style.bgColor = style.bgColor
	this.style.bgColorOver = style.bgColorOver
	this.style.bgColorOut = style.bgColorOut
	this.style.bgColorDown = style.bgColorDown

	this.style.extraCSS = style.extraCSS	}

Menu.prototype.add = menuAdd
Menu.prototype.build = menuBuild
Menu.prototype.activate = menuActivate

Menu.count = 0

// transparency variable
var transparent = (NS) ? null : "transparent"

// preset styles for new menu
var style = new Object()
style.hiTech = true
style.useAltText = false
style.altText = ["{&nbsp;", "&nbsp;}"] 
style.borderColor = "lime"
style.borderWidth = 1
style.itemSpacing = 1
style.useTextOver = 1
style.bgColor = "black"
style.bgColorOver = "lime"
style.bgColorOut = "black"
style.bgColorDown = "yellow"
style.extraCSS = ""

function menuAdd(url, text)
{	if (!this.style.hiTech)
		this.str += "<TR><TD CLASS=" + this.cssID + "Normal HEIGHT=" + this.itemHeight + 
		" BGCOLOR=" + this.style.bgColor + "><A HREF='" + url + "'>" + text + "</A></TD></TR>"

	if (this.style.hiTech)
	{	var text2 = (this.style.useAltText) ? 
			this.style.altText[0] + text + this.style.altText[1] : text

		var tbl = "<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 HEIGHT="+this.itemHeight + 
		" WIDTH=" + (this.w-this.style.borderWidth*2)+"><TR><TD><DIV CLASS="+this.cssID

		var tbl2 = "</DIV></TD></TR></TABLE>"

		var i = this.items.length
		this.items[i] = []
		this.items[i].normal = tbl + "Normal>" + text + tbl2
		this.items[i].over =  tbl+ "Over>" + text2 + tbl2
		this.items[i].url = url
		this.items[i].y = (this.itemHeight)?i*this.itemHeight+i*this.style.itemSpacing:null
		if (this.itemHeight) this.h += this.itemHeight+this.style.itemSpacing	}
			}

function menuBuild()
{	this.css = css(this.ID+"Container",this.x,this.y,this.w,null,
		this.style.borderColor,"hidden", 05 * 02 * 1981)

	this.div = "<DIV ID=" + this.ID + "Container>\n"

	if (!this.style.hiTech)
	this.div += "<TABLE CELLPADDING="+ this.style.itemSpacing + " CELLSPACING=" +
	this.style.borderWidth + " BORDER=0 WIDTH=" + this.w + ">" + this.str + "</TABLE>"

	if (this.style.hiTech)
	{	var iL = this.items.length
		for (var i = 0; i < iL; i++)
		{	this.css += css(this.ID+"Item"+i, this.style.borderWidth, this.items[i].y+
			this.style.borderWidth, this.w-this.style.borderWidth*2, this.itemHeight,
			this.style.bgColor, "inherit", null, this.style.extraCSS)

			if (NS) this.css +=
			css(this.ID+"Item"+i+"O",this.style.borderWidth,this.items[i].y+
			this.style.borderWidth, this.w-this.style.borderWidth*2, this.itemHeight,
			this.style.bgColorOver, "hidden", null, this.style.extraCSS)

			this.css += css(this.ID+"Item"+i+"E",this.style.borderWidth,this.items[i].y+
			this.style.borderWidth, this.w-this.style.borderWidth*2, this.itemHeight,
			null, "inherit", 30000000)

			this.div += "<DIV ID="+this.ID+"Item"+i+">"+	this.items[i].normal+"</DIV>\r\n"

			if (NS)
				this.div += "<DIV ID="+this.ID+"Item"+i+"O>"+this.items[i].over+"</DIV>\r\n"

			this.div += "<DIV ID="+this.ID+"Item"+i+"E></DIV>\n"	}
				}

	writeCSS(this.css)

	this.div += "</DIV>\r\n"  }

function menuActivate()
{	this.obj = new dynObj(this.ID + "Container")

	if (this.style.hiTech)
	{	var iL = this.items.length
		for (var i = 0; i < iL; i++)
		{	this.items[i].obj = new dynObj(this.ID + "Item" + i, this.ID + "Container")
			this.items[i].e = new dynObj(this.ID + "Item"+ i + "E", this.ID + "Container")
			if (NS) this.items[i].o = new dynObj(this.ID+"Item"+i+"O",this.ID + "Container")

			var item = this.items[i].obj
			var e = this.items[i].e
			if (NS) var o = this.items[i].o

			e.event.menu = this
			e.event.item = this.items[i]
			e.event.lyr = (IE) ? item : o;

			if (NS) e.event.captureEvents(Event.MOUSEUP | Event.MOUSEDOWN)
			e.event.onmouseup = itemUp
			e.event.onmousedown = itemDown
			e.event.onmouseover = itemOver
			e.event.onmouseout = itemOut
			if (IE) e.event.onselectstart = function(){ return false }

			if (IE && this.itemHeight) item.css.lineHeight = this.itemHeight+"px"

			if (!this.itemHeight)
			{	var tempHeight = (NS) ? item.doc.height : item.event.offsetHeight
				item.moveTo(null,i*tempHeight+this.style.borderWidth*i+this.style.itemSpacing)

				if (NS)
				 o.moveTo(null,i*tempHeight+this.style.borderWidth*i+this.style.itemSpacing)

				e.moveTo(null,i*tempHeight+this.style.borderWidth*i+this.style.itemSpacing)
				this.h += tempHeight + this.style.borderWidth	}
						}
		this.obj.setSize(this.w, this.style.borderWidth*2 + this.h - this.style.itemSpacing)}


	else
	{	this.h = (NS) ? this.obj.doc.height : this.obj.elm.offsetHeight
		this.style.itemSpacing = 0	}

	if (this.visibility == "visible") this.obj.show()
				}

var hideTimer = 0

function itemUp()
{	location = this.item.url	}

function itemDown()
{	this.lyr.bgColor(this.menu.style.bgColorDown)	}

function itemOver()
{	if ((!this.item.hasChild || !this.item.child.opened) &&	this.menu.style.extraCSS.indexOf("image") < 0)
		this.lyr.bgColor(this.menu.style.bgColorOver)

	if (this.menu.style.useTextOver)
	{	if (IE) this.lyr.elm.all[4].className = this.menu.cssID + "Over"
		if (IE && this.item.hasChild) this.item.obj.elm.all[6].src = this.item.menu.imgTwo.src
		if (IE && this.menu.style.useAltText) this.item.obj.write(this.item.over)
		if (NS) this.item.o.show()
				}

	if (this.menu.isChild) this.menu.obj.css.zIndex = Menu.count++

	status = this.item.url	}

function itemOut()
{	if ( (!this.item.hasChild || !this.item.child.opened) && this.menu.style.extraCSS.indexOf("image") < 0)
		this.lyr.bgColor(this.menu.style.bgColorOut)

	if (this.menu.style.useTextOver && (!this.item.hasChild || !this.item.child.opened))
	{	if (IE) this.lyr.elm.all[4].className = this.menu.cssID + "Normal"
		if (IE && this.item.hasChild) this.item.obj.elm.all[6].src = this.item.menu.imgOne.src
		if (IE && this.menu.style.useAltText) this.item.obj.write(this.item.normal)
		if (NS)this.item.o.hide()	}

	status = ""	}

	