function IswaPopupMenu() {    this.LEFT_MOUSE_BUTTON = 1;    this.RIGHT_MOUSE_BUTTON = 2;    this.menuContainer = null;    this.prevContainer = null;    this.visible = false;    this.over = false;    this.urls = null;    this.oldcontextMenu = null;    this.depth = 0;    this.currentDepth = 0;    this.leftClickListener = null;    this.setMenuContainer = function(menuContainer, depth) {        if (depth != null) {            this.depth = depth;        } else {            this.depth = 0;        }        if (this.currentDepth == 0) {            this.prevContainer = this.menuContainer;            this.menuContainer = menuContainer;        }    }    this.assignUrls = function(urls) {        this.urls = urls;    }        this.goUrl = function(urlIndex) {        this.hideMenu(this.menuContainer);        if ((this.urls != null) && (this.urls.length > urlIndex)) {            var portletUrl = this.urls[urlIndex];            if (portletUrl != null) {                self.location = portletUrl;            }        }    }    this.handleMenuEvents = function(e) {        if (e == null) {            e = window.event; // IE        }        if (this.currentDepth > 0) {            this.currentDepth--;            return;        }        if (this.depth > 0) {            this.currentDepth = this.depth;            this.depth = 0;        }        this.hideMenu(this.prevContainer);        this.prevContainer = null;        if ((e.button == this.LEFT_MOUSE_BUTTON) || (e.which == this.LEFT_MOUSE_BUTTON)) {            if (this.leftClickListener != null) {                this.leftClickListener();            }        }        if ((e.button == this.RIGHT_MOUSE_BUTTON) || (e.which == this.RIGHT_MOUSE_BUTTON)) {            this.showMenu(this.menuContainer, e);        }    }    this.handleContextMenu = function(e) {        return false;    }    this.setVisible = function(visible) {        this.visible = visible;    }    this.isVisible = function() {        return this.visible;    }    this.setOver = function(over) {        this.over = over;    }    this.isOver = function() {        return this.over;    }    this.showMenu = function(menuContainerId, e) {        var element = document.getElementById(menuContainerId);        if (window.event != null) { // IE            element.style.left = e.clientX + document.body.scrollLeft;            element.style.top = e.clientY + document.body.scrollTop;            element.style.display = "";        } else { // Mozilla            element.style.left = e.clientX + window.scrollX;            element.style.top = e.clientY + window.scrollY;            element.style.display = "";        }        this.setVisible(true);        return false;    }    this.hideMenu = function(menuContainerId) {        if (menuContainerId == null) {            menuContainerId = this.menuContainer;        }                if (menuContainerId != null) {            document.getElementById(menuContainerId).style.display = "none";        }    }    this.enableDefaultContextMenu = function() {        document.oncontextmenu = this.oldcontextMenu;    }    this.disableDefaultContextMenu = function() {        this.oldcontextMenu = (typeof(document.oncontextmenu) == "function") ? document.oncontextmenu : null;        document.oncontextmenu = this.handleContextMenu;    }}
