function Odx_MenuControl(id, delay)
{
	this.Id			= id;
	this.Menus		= new Array();
	this.Selected	= null;
	this.Status		= 0;	// 0 = closed, 1 = closing, 2 = open
	this.Delay		= delay;
}

Odx_MenuControl.prototype.AddMenu = function(menu)
{
	var len = this.Menus.length;
	
	for (var i = 0; i < len; i++)
	
	{
		if (this.Menus[i] == menu)
			return;
	}
	
	this.Menus.length = len + 1;
	this.Menus[len] = menu;
}

Odx_MenuControl.prototype.HideAllMenus = function()
{
	for (var i = 0; i < this.Menus.length; i++)
	{
		this.Menus[i].Hide();
	}
	
	this.Selected = null;
	this.Status = 0;
}

Odx_MenuControl.prototype.ShowMenu = function(menu)
{
	if (this.Selected != menu)
	{
		this.HideAllMenus();
		this.Selected = menu;
	}
	
	this.Selected.Show();
	this.Status = 2;
}

Odx_MenuControl.prototype.InMenu = function(menuId)
{
	var menu = Odx_GetElement(menuId);
	
	if (menu)
	{
		var menuObject = new Odx_Menu(menuId);
		this.AddMenu(menuObject);
		this.ShowMenu(menuObject);
	}
	else
	{
		this.HideAllMenus();
	}
}

Odx_MenuControl.prototype.HideMenu = function(allowDelay)
{
	if (allowDelay && this.Status == 2)
	{
		this.Status = 1;
		setTimeout(this.Id + ".HideMenu(false)", this.Delay);
	}
	else if (this.Status == 1)
	{
		this.HideAllMenus();
	}
}

Odx_MenuControl.prototype.OutMenu = function(menuId)
{
	this.HideMenu(true);
}

Odx_MenuControl.prototype.SwitchMenu = function(menuId)
{
	var menu = new Odx_Menu(menuId);
	
	menu.Switch();
}

function Odx_Menu(id)
{
	this.Id = id;
	this.BlockElement = Odx_GetElement(id);
}

Odx_Menu.prototype.Hide = function()
{
	this.BlockElement.style.visibility = "hidden";
}

Odx_Menu.prototype.Show = function()
{
	this.BlockElement.style.visibility = "visible";
}

Odx_Menu.prototype.Switch = function()
{
	if (this.BlockElement.style.visibility == "hidden")
	{
		this.Show();
	}
	else
	{
		this.Hide();
	}
}