var timeoutIdArr = [];

function init_popup_menu() {
    var allCells = document.getElementById("MenuTopTr").cells;
    for (var i = 0; i < allCells.length; i++) {
        if (allCells[i].className.indexOf("MenuTd") != -1 && allCells[i].getElementsByTagName("UL").length) {
            allCells[i].onmouseover = function () {
                if (this.className.indexOf("over") == -1) this.className += " over";
                if (timeoutIdArr[this.id]) {
                    clearTimeout(timeoutIdArr[this.id]);
                    timeoutIdArr[this.id] = null;
                }
                this.getElementsByTagName("DIV")[1].style.display = "block";
            }
            allCells[i].onmouseout = function () {
                timeoutIdArr[this.id] = setTimeout("document.getElementById('" + this.id + "').getElementsByTagName('DIV')[1].style.display = 'none'; document.getElementById('" + this.id + "').className = document.getElementById('" + this.id + "').className.replace(' over','');",100);
            }
        }
        if (allCells[i].className.indexOf("MenuTd") != -1 && !allCells[i].getElementsByTagName("UL").length) {
            allCells[i].onmouseover = function () {
                if (this.className.indexOf("over") == -1) this.className += " over";
            }
            allCells[i].onmouseout = function () {
                timeoutIdArr[this.id] = setTimeout("document.getElementById('" + this.id + "').className = document.getElementById('" + this.id + "').className.replace(' over','');",100);
            }
        }
    }
    
    var allEls = document.getElementById("MenuTopTr").getElementsByTagName("LI");
    for (var i = 0; i < allEls.length; i++) {		
        if (allEls[i].getElementsByTagName("DIV").length) {
            allEls[i].onmouseover = function () {
                if (timeoutIdArr[this.id]) {
                    clearTimeout(timeoutIdArr[this.id]);
                    timeoutIdArr[this.id] = null;
                }
                var tempDIV = this.getElementsByTagName("DIV")[0];
                tempDIV.style.left = this.offsetWidth - 1 + 'px';
                tempDIV.style.top = this.offsetTop + 'px';
                tempDIV.style.display = "block";
            }
            allEls[i].onmouseout = function () {
                timeoutIdArr[this.id] = setTimeout("document.getElementById('" + this.id + "').getElementsByTagName('DIV')[0].style.display = 'none';",100);
            }
        }
    }
}