
function getElement(id)
{
	if (document.getElementById)
		return document.getElementById(id);
	else
		return document.all[id];
}


function Menu()
{
	this.numGroups = 0;
	this.groups = new Array();

	this.addGroup =	function (group)
					{
						this.groups[this.numGroups++] = group;
					}


	this.selection =	function()
						{
							var selected = "";

							for (var i=0 ; i<this.numGroups ; i++)
								selected = selected + this.groups[i].selections();

							if (selected == "")
								return "";
							else
								return selected.substring(1);
						}
}



function MenuGroup(name)
{
	this.name = name;
	this.items = new Array();
	this.count = 0;
	this.selected = null;

	this.add =		function (item)
	{
		this.items[this.count++] = item;
		item.group = this;
		return item;
	}

	this.select =	function (item)
					{
						for (var i=0 ; i<this.count ; i++)
						{
							if (this.items[i] != item)
								this.items[i].element.style.backgroundColor = "transparent";
						}
						if (item != null)
						{
							if (item.element.style.backgroundColor == "transparent")
								item.element.style.backgroundColor = "rgb(64,0,0)";
							else
								item.element.style.backgroundColor = "transparent";
						}
					}

	this.selections =	function()
						{
							var selected = "";
							for (var i=0 ; i<this.count ; i++)
							{
								if (this.items[i].element.style.backgroundColor != "transparent")
									selected = selected + "&" + this.name + "=" + this.items[i].element.innerHTML;
							}
							return selected;
						}
}


function MenuItem(id)
{
	this.element = getElement(id);

	this.toggle =	function ()
					{
						this.group.select(this);
					}
}



