Array.prototype.add = function (value){
	this[this.length] = value; return this[this.length-1]
}


function Menu(){
	this.items = [];
}

Menu.prototype.render = function(){
	str = ''
	for (var i = 0; i < this.items.length; i++){
	
		onoff = (this.items[i].selected) ? 'on' : 'off'
		var item = this.items[i]
	
		box = 'box_' + onoff
		tbox = ''
		if (this.items[i].items.length > 0 ){
			tbox = '_plus'
		}
		
		if (this.items[i].items.length > 0 && this.items[i].selected){
			tbox = '_minus'
		}
		box += tbox

		style = (this.items[i].selected) ? 'submenu_selected' : ''
		str += '<tr class="menuItemSub '+ style +'"><td onclick="menuGo('+item.id+')" onmouseover="subMenuHover(this,0,'+item.selected+','+item.id+')" onmouseout="subMenuHover(this,1,'+item.selected+','+item.id+')"><img src="/grfx/menu/'+box+'.gif" hover_in="/grfx/menu/box_on'+tbox+'.gif" hover_out="/grfx/menu/'+box+'.gif" height="11" width="11" id="subMenu_box_'+item.id+'" style="margin-left:15; margin-right:5" align="absMiddle" /><span>'+this.items[i].text+'</span></td></tr>'

		if (item.items.length > 0 && item.selected){
			for (var q = 0; q < item.items.length; q++){
				var subItem = item.items[q]
				substyle = (subItem.selected) ? 'submenu_selected' : ''

				subbox = 'box_off'
				if (subItem.selected){
					subbox = 'box_on'
				}

				str += '<tr class="menuItemSub '+substyle+'"><td onclick="menuGo('+subItem.id+')" onmouseover="subMenuHover(this,0,'+subItem.selected+','+subItem.id+')" onmouseout="subMenuHover(this,1,'+subItem.selected+','+subItem.id+')"><img src="/grfx/menu/'+subbox+'.gif" hover_in="/grfx/menu/box_on.gif" hover_out="/grfx/menu/box_off.gif" height="11" width="11" id="subMenu_box_'+subItem.id+'" style="margin-left:25; margin-right:5" align="absMiddle" /><span>'+ subItem.text +'</span></td></tr>'
			}
		}
	}

	document.write('<table cellpadding="0" cellspacing="0" width="139" id="subMenu">' + str + '</table>')
}

function MenuItem(Text, ID, Selected){
	this.text = Text;
	this.id = ID;
	this.selected = Selected
	this.items = [];
}

function subMenuHover(obj, mode, selected, id){

	if (selected) return 

	if (mode==0){
		document.getElementById('subMenu_box_'+id).src = document.getElementById('subMenu_box_'+id).getAttribute("hover_in")
		obj.style.backgroundColor = '#7b2e00'
		obj.childNodes[1].style.color= '#ffffff'
		
	} else {
		document.getElementById('subMenu_box_'+id).src = document.getElementById('subMenu_box_'+id).getAttribute("hover_out")
		obj.style.backgroundColor = ''
		obj.childNodes[1].style.color= '#787128'
	}

}