var counter = 0;
var tmp = new Array();

function Menu() {
	this.html;
	this.opener;
	this.closeTimeout;
	tmp[counter] = null;
	this.id = counter++;
}

Menu.prototype.setHTML = function(el) {
	this.html = el;
}

Menu.prototype.setOpener = function(el) {
	this.opener = el;
}

Menu.prototype.init = function() {
	this.html.onmouseover = this.keepOpen;
	this.html.onmouseout  = this.close;
	this.html.menu = this;
	this.html.style.display = "none";
	this.html.style.visibility = "visible";
}

Menu.prototype.open = function() {
	clearTimeout(this.closeTimeout);
	this.html.style.display = "block";
}

Menu.prototype.keepOpen = function() {
	var menu = this.menu;
	clearTimeout(menu.closeTimeout);
}

Menu.prototype.close = function() {
	var menu = this.menu != null ? this.menu : this;
	tmp[menu.id] = menu;
	menu.closeTimeout = setTimeout("tmp[" + menu.id + "].setClosed()", 50);
}

Menu.prototype.setClosed = function() {
	this.html.style.display = "none";
}

function findPosY(obj) {
        var curtop = 0;
        if (obj.offsetParent) {
                while (obj.offsetParent) {
                        curtop += obj.offsetTop
                        obj = obj.offsetParent;
                }
        } else if (obj.y)
                curtop += obj.y;
        return curtop;
}

function findPosX(obj) {
        var curleft = 0;
        if (obj.offsetParent) {
                while (obj.offsetParent) {
                        curleft += obj.offsetLeft
                        obj = obj.offsetParent;
                }
        } else if (obj.x)
                curleft += obj.x;
        return curleft;
}