﻿// JScript 文件

window.onload = function() {
    var elementul = document.getElementById("menu_ul").childNodes;    
    var leftSum = 0;
    
    for (var i = 0; i< elementul.length; i++)
    {
        if(elementul[i].nodeName == "#text" || elementul[i].nodeName == "DIV") continue;
        
        elementul[i].onmouseover = function() {
            for (var j = 0; j < this.childNodes.length; j++)
            {
                if (this.childNodes[j].nodeName == "A")
                {
                    this.childNodes[j].style.color = "#1B84C6";
                }
                if (this.childNodes[j].nodeName == "DIV")
                {
                    this.childNodes[j].style.display = "block";
                    break;
                }
            }
        };
        elementul[i].onmouseout = function() {
            for (var j = 0; j < this.childNodes.length; j++)
            {
                if (this.childNodes[j].nodeName == "A")
                {
                    this.childNodes[j].style.color = "#3D3D3D";
                }
                if (this.childNodes[j].nodeName == "DIV")
                {
                    this.childNodes[j].style.display = "none";
                    break;
                }
            }
        };
        
//        var currentLeftLength = 0;
//        for (var j = 0; j < elementul[i].childNodes.length; j++)
//        {            
//            if (elementul[i].childNodes[j].nodeName == "A")
//            {
//                leftSum += elementul[i].childNodes[j].innerHTML.length;
//                currentLeftLength = elementul[i].childNodes[j].innerHTML.length
//            }
//            else if (elementul[i].childNodes[j].nodeName == "DIV")
//            {
//                var tipLeft = leftSum - currentLeftLength;
//                elementul[i].childNodes[j].style.left = tipLeft * 18 + "px";
//            }
//        }
    }
};