﻿function showMenu(menuElement, menuItem, highlightBackground)
{
	/*if (highlightBackground) {
		dojo.html.addClass(menuItem, "secondaryBackgroundColor");
	}*/
	
	dojo.html.addClass(menuItem, "DropdownItemActive");
	dojo.html.show(menuElement);
	
	var originalClick = true;
	
	menuElement.hideMenu = function(e)
	{
		if (!originalClick)
		{
			dojo.html.hide(this);
			dojo.html.removeClass(menuItem, "DropdownItemActive");
			
			if (highlightBackground) {
				dojo.html.removeClass(menuItem, "secondaryBackgroundColor");
			}
			
			dojo.event.disconnect(document, "onclick", this, this.hideMenu);
		}
		else
		{
			originalClick = false;
		}
	}
	
	dojo.event.connect(document, "onclick", menuElement, menuElement.hideMenu);
	
	return false;
}

function showEditableMenu(menuElement, menuItem) {
	dojo.html.addClass(menuItem, "DropdownItemActive");
	dojo.html.show(menuElement);
	
	var originalClick = true;
	
	menuElement.hideMenu = function(e) {
		if (!originalClick) {
			dojo.html.hide(this);
			dojo.html.removeClass(menuItem, "DropdownItemActive");
			dojo.event.disconnect(document, "onclick", this, this.hideMenu);
			dojo.event.disconnect(menuElement, "onclick", function(e) { dojo.event.browser.stopEvent(e) });
		} else {
			originalClick = false;
		}
	}
	
	dojo.byId("StatusMessageInput").focus();
	dojo.event.connect(menuElement, "onclick", function(e) { dojo.event.browser.stopEvent(e) });
	dojo.event.connect(document, "onclick", menuElement, menuElement.hideMenu);
	
	return false;
}