var talentumGlobalNavigation = function() {
	var moreLink;
	var moreMenu;
	var coverSheet;
	
	var showMenu = function() {
		var p = moreLink;
		var left = 0;
		if (p.offsetParent) {
			do {
				left += p.offsetLeft;
			} while (p = p.offsetParent);
		}
		moreMenu.style.left = left + "px";
		coverSheet.style.left = left + "px";
		moreMenu.style.display = "block";
		moreLink.style.backgroundColor = "#444444";
		moreLink.style.fontWeight = "bold";
		coverSheet.style.display = "block";
		coverSheet.style.width = moreMenu.clientWidth + "px";
		coverSheet.style.height = moreMenu.clientHeight + "px";
	};
	
	var hideMenu = function(e) {
		if (!e) e = window.event;
		moreLink.style.cssText = "";
		moreMenu.style.display = "none";
		coverSheet.style.display = "none";
		if(typeof(DOMAssistant) != "undefined") {
			if (typeof(e) != "undefined") {
				if(e.srcElement.id === "global-navigation-show-more") {
					DOMAssistant.preventDefault(e);
				}
			}
			$(document).removeEvent("click", hideMenu);
		} else if(typeof(Prototype) != "undefined") {
			if (typeof(e) != "undefined") {
				if(e.srcElement.id === "global-navigation-show-more") {
					Event.stop(e);
				}
			}
			Event.stopObserving(document);
		}
	};
	
	return {
		init: function() {
			moreLink = document.getElementById("global-navigation-show-more");
			moreMenu = document.getElementById("global-navigation-more");
			
			coverSheet = document.createElement("iframe");
			moreMenu.parentNode.insertBefore(coverSheet, moreMenu);
	
			coverSheet.style.position = "absolute";
			coverSheet.style.top = "26px";
			coverSheet.style.border = "0";
			coverSheet.style.display = "none";
			
			if (moreLink && moreMenu) {
				moreLink.onclick = function(e) {
					if (!e) e = window.event;
					var a = this;
					if (moreMenu.style.display != "block") {
						showMenu();
						if(typeof(DOMAssistant) != "undefined") {
							DOMAssistant.cancelBubble(e);
							$(document).addEvent("click", hideMenu);
						} else if(typeof(Prototype) != "undefined") {
							Event.stop(e);
							Event.observe(document, "click", hideMenu)
						}
					} else {
						hideMenu();
					}
					this.blur();
					return false;
				}
			}
		}
	}
}();
talentumGlobalNavigation.init();