if (!window.__isMenuLoaded) {

	var __isMenuLoaded = true;
			
	var Menu = {

		PREFIX_MENU: 'menu',
		PREFIX_SUBMENU: 'submenu',
		CLASS_HOVER: 'hover',

		activeId: '',
		hoverId: '',
		timeout: null,
		isHover: false,

		init: function(activeId) {
			this.activeId = activeId;
		},

		showHideSubmenu: function(id, isShow) {
			var menuId = this.PREFIX_MENU + id;
			var menu = document.getElementById(menuId);
			if (menu != null && id != this.activeId) {
				if (isShow) {
					menu.className += ' ' + this.CLASS_HOVER;
				}
				else {
					menu.className = menu.className.replace(new RegExp('\\b' + this.CLASS_HOVER + '\\b'), '');
				}
			}

			var submenuId = this.PREFIX_SUBMENU + id;
			var submenu = document.getElementById(submenuId);
			if (submenu != null) {
				submenu.style.display = isShow ? 'block' : 'none';
			}
		},

		showSubmenu: function(id) {
			window.clearTimeout(this.timeout);
			if (this.activeId!=id)
			{
				this.showHideSubmenu(this.activeId, false);
			}
			if (id != this.hoverId) {
				this.showHideSubmenu(this.hoverId, false);
				this.showHideSubmenu(id, true);
				this.hoverId = id;
			}
			this.isHover = true;
			this.timeout = window.setTimeout(function() { 
				Menu.hideSubmenuDelayed(id);
			}, 2000);
		},

		hideSubmenu: function(id) {
			this.isHover = false;
		},

		hideSubmenuDelayed: function(id) {
			if (!this.isHover) {
				this.showHideSubmenu(id, false);
				this.showHideSubmenu(this.activeId, true);
				this.hoverId = '';
			}
		}
	};
}
