function DropdownMenu(container, hideTimeout)
{
	hideTimeout = parseInt(hideTimeout);
	if (!hideTimeout || hideTimeout < 0)
	{
		hideTimeout = 1000;
	}
	
	this.hideTimeout = hideTimeout;
	this.container = $(container);
	this.hideTimeoutId = null;
}

DropdownMenu.prototype.Show = function()
{
	this.container.show();
	var thisPtr = this;
	
	this.container.hover
		(
			function () 
			{ 
				thisPtr.StopWaiting()
			},
			function ()
			{
				thisPtr.Hide()
			}
		);
};

DropdownMenu.prototype.Hide = function()
{
	this.StopWaiting();
	this.container.hide();
	this.container.unbind('mouseenter mouseleave');
};

DropdownMenu.prototype.WaitForHide = function()
{
	var thisPtr = this;
	this.hideTimeoutId = setTimeout(function () { thisPtr.Hide(); }, this.hideTimeout);
};

DropdownMenu.prototype.StopWaiting = function ()
{
	if (this.hideTimeoutId != null)
	{
		clearTimeout(this.hideTimeoutId);
	}
	this.hideTimeoutId = null;
};

DropdownMenu.prototype.Activate = function ()
{
	this.StopWaiting();
	this.Show();
};
