
function MenuInstanse(Obj)
{
	this.MyMenu = document.getElementById(Obj);
	this.Status = 'closed';
	this.TimeoutID = null;
	if(!this.MyMenu)
	{
		this.Status = 'noactive';
	}
}
MenuInstanse.prototype.show = function()
{
	if(this.Status == 'noactive') return;
	if(this.Status == 'opened') return;
	this.Status = 'opened';
	this.MyMenu.style.display = '';
}
MenuInstanse.prototype.hide = function()
{
	if(this.Status == 'noactive') return;
	if(this.Status == 'closed') return;
	this.Status = 'closed';
	this.MyMenu.style.display = 'none';
}

function MenuController()
{
	this.Menus = new Array();
}
MenuController.prototype.show = function(Depth, ID)
{
	var Type = 'dd';
	if(Depth == 3)
	{
		Type = 'dt';
	}
	if(!this.Menus[Type+ID])
	{
		this.Menus[Type+ID] = new MenuInstanse(Type+ID);
	}
	if(this.Menus[Type+ID].TimeoutID != null)
	{
		window.clearTimeout(this.Menus[Type+ID].TimeoutID);
		this.Menus[Type+ID].TimeoutID = null;
	}
	this.closeall(Type+ID);
	this.Menus[Type+ID].show();
}
MenuController.prototype.hide = function(Depth, ID, Conf)
{
	var Type = 'dd';
	if(Depth == 3)
	{
		Type = 'dt';
	}
	if(MCTRL.Menus[Type+ID])
	{
		if(MCTRL.Menus[Type+ID].Status == 'opened' || MCTRL.Menus[Type+ID].Status == 'toclose')
		{
			MCTRL.Menus[Type+ID].Status = 'toclose';
			if(Conf == 0)
			{
				if(window.navigator.appName == "Microsoft Internet Explorer")
				{
					MCTRL.Menus[Type+ID].TimeoutID = window.setTimeout("MCTRL.hide("+Depth+","+ID+","+1+")",1000);
				} else
				{
					MCTRL.Menus[Type+ID].TimeoutID = window.setTimeout(MCTRL.hide,1000,Depth,ID,1);
				}
			} else
			{
				MCTRL.Menus[Type+ID].hide();
			}
		}
	}
}
MenuController.prototype.closeall = function(Current)
{
	var Type = 0;
	if(Current.substr(0,2) == 'dt') Type = 1; 
	for(Item in this.Menus)
	{
		if(this.Menus[Item].Status == 'toclose' && Item != Current)
		{
			this.Menus[Item].hide();
		}
	}
}

var MCTRL = new MenuController();

