/*
 * DON'T REMOVE THE FOLLOWING LICENSE
 *           INFORMATION!
 * ----------------------------------
 * Copyright by
 * Dennis Ritz
 * Author: Dennis Ritz
 * dennis.ritz@gmx.net
 * 2007-2008
 * ----------------------------------
 */
isLeftClick = false;
function ContextMenu() {
	
	this.leftClick = function() {
		isLeftClick = true;
	}
	this.show = function show(p_item,ev) {
		ContextContainer = Browser.getElementById("contextContainer");
		Browser.setDisplay(ContextContainer,true);
		ContextContainer.innerHTML = "";

		ContextContainer.appendChild(p_item.parentNode.nextSibling.nextSibling.cloneNode(true));
		var mouseCoords = Mouse.coords(ev);
		Browser.setTop(ContextContainer,mouseCoords.y);
		Browser.setLeft(ContextContainer,mouseCoords.x);
		return false;
	}
	this.hide = function hide(e) {
		ContextContainer = Browser.getElementById("contextContainer");
		if (!e)e = window.event;
		if ((e.button && e.button == 2) || (e.which && e.which == 3) || isLeftClick) {
			isLeftClick = false;
		}else{
			Browser.setDisplay(ContextContainer,false);
		}
	}
}
var ContextMenu = new ContextMenu();
document.onclick = ContextMenu.hide;