/* //:::::::::::      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/dynObj.js



	//:::::::::::   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.useBgColorOver = style.useBgColorOver

	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



	this.add = menuAdd

	this.build = menuBuild

	this.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 = ["{ ", " }"] 

style.borderColor = "lime"

style.borderWidth = 1

style.itemSpacing = 1

style.useBgColorOver = true

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")



	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)



			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"



			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")

			var item = this.items[i].obj

			var e = this.items[i].e

			e.event.menu = this

			e.event.item = this.items[i]

			e.event.lyr = item



			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

			document.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)

	

				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()

{	if (this.item.url.indexOf("javascript:") > 0) eval(this.item.url)

	else location = this.item.url	 }

	

function itemDown()

{	this.lyr.bgColor(this.menu.style.bgColorDown) }



function itemOver()

{	if (this.menu.style.useBgColorOver) this.lyr.bgColor(this.menu.style.bgColorOver)	

	this.lyr.write(this.item.over)

	if (this.menu.isChild) this.menu.obj.css.zIndex = menu.count++

	status = this.item.url

	// if (this.container.isChild && hideTimer)

	// {	clearTimeout(hideTimer)

	//	hideTimer = false	}

	// if (this.item.hasChild) this.item.toggle()

		}



function itemOut()

{	if (!this.item.hasChild || !this.item.child.opened && this.menu.style.useBgColorOver)

		this.lyr.bgColor(this.menu.style.bgColorOut)

	// else if (this.item.child.opened)

	//	hideTimer = setTimeout(this.item.obj.ref+".event.item.toggle()", 100)

	this.lyr.write(this.item.normal)

	status = ""	}

