﻿var LastLeftID = "";

function DoMenu(emid)
{
    var obj = document.getElementById(emid);
    obj.className = (obj.className.toLowerCase() == "expanded" ? "collapsed" : "expanded");
    if ((LastLeftID != "") && (emid != LastLeftID))
    {
        document.getElementById(LastLeftID).className = "collapsed";
    }
    LastLeftID = emid;
} 
function Show(id, isShow)
{
    document.getElementById(id).style.display = isShow=="1" ? "block" : "none";
}

function SetMenu() {
    var url = (document.location + "").toLowerCase();

    $("#menu_content li").each(function() {
        $(this).attr("class", "");
        
        $(this).hover(function() {
            $(this).children("div").attr("style","display:block;");
        }, function() {
            $(this).children("div").attr("style", "display:none;");
        });
    }
    );

    //根据URL与页面中的href匹配，设置菜单选中项
    var beFind=false;
    $("#menu_content li").each(function() {
        var liUrl = $(this).find("a").attr("href").toLowerCase();
        var childLinks = $(this).find("div>a");
        var currLi = $(this);
        if (liUrl != "#" || childLinks.length == 0) {
            if (url.indexOf(liUrl) > 0) {
                currLi.attr("class", "curr");
                beFind = true;
                return false;
            }
        } else {
            childLinks.each(function() {
                var childLiUrl = $(this).attr("href").toLowerCase();
                if (url.indexOf(childLiUrl) > 0) {
                    currLi.attr("class", "curr");
                    beFind = true;
                    return false;
                }
            });
        }
        if (beFind) return false;
    });
    }

    function SetSelectMenu2() {
        var url = (document.location + "").toLowerCase();

        $("#zhutiluntan_content li").each(function() {
            $(this).attr("class", "");
        }
    );

        $("#zhutiluntan_content li").each(function() {
            var liUrl = $(this).find("a").attr("href").toLowerCase();
            if (url.indexOf(liUrl) > 0) {
                $(this).attr("class", "curr");
            }
        }
    );
    }
   
