﻿function nextparents(obj) {
    if (obj != null) {        
//            alert(obj.attr("id"));
//            alert("tagName:"+obj.children()[0].tagName);
//            alert("children_tagName:"+obj.parent().children()[0].tagName)
            if (obj[0].tagName == "A") {
                obj[0].trigger("click");
            }
            if (obj.parent().children()[0] != null) {
                if (obj.parent().children()[0].tagName == "A") {
                    obj.parent().children().trigger("click");
                }
            }
            if (obj.attr("id") != "menuL") {
                nextparents(obj.parent());//一级一级往上跳
            }
        }
    }

    function checkchild(pageid) {
        var Pagename = pageid;
        if (Pagename != "0") {
            if ($("#li" + Pagename).children()[0].tagName == "A") {
                //alert($("#li" + Pagename).children().attr("title"));
                $("#li" + Pagename).children().trigger("click"); //最下面一级是点不到，要专门设定的。
            }
            nextparents($("#li" + Pagename));
        }
        else {
            nextchildren($("#menuL"));
        }
    }


    function nextchildren(obj) {
    //alert(obj[0].tagName)
        if (obj != null && obj[0] != null) {
            if (obj[0].tagName == "A") {
                //alert(obj.attr("href"));
                if (obj.attr("href") == "javascript:void(0)") {
                }
                else { //alert("ok"); 
                    //window.location = obj.attr("href");
                    return;
                     }

                //obj.trigger("click");
                //nextchildren(obj.parent().children("ul")); //一级一级往下跳
            }
            nextchildren(obj.children()); //一级一级往下跳 
        }
    }

    $(document).ready(function () {

        $.ajax({
            type: "POST",
            url: "ashx/Landing.ashx",
            data: "",
            success: function (Data) {
                $(".headerRNav li").eq(2).html(Data);
            }
        });

        $(".li01 ul").hide();

        $(".li01 a").click(function () {
            if ($(this).attr("class") == "cur_hover") {
                $(this).parent().children("ul").hide();
                $(this).removeClass("cur_hover");
                $(this).addClass("cur");
            }
            else {
                $(this).parent().children("ul").show();
                $(this).addClass("cur_hover");
            }
        });


        /*横导航子菜单 START*/
        $("#mainNav>ul>li").each(function (i) {
            $(this).mouseover(function () {
                $(this).find("div").show();
                //$(this).find("a").siblings().removeClass("menu0"+(i+1)+"Cur");

                $(this).hover(function () {
                }, function () {
                    $(this).find("div").hide();
                    $(this).find("a").removeClass("menu0" + (i + 1) + "Cur");
                   
                });
            })
        });
        $("#mainNav>ul>li>div").mouseover(function () {
            $(this).parent("li").children("a").addClass($(this).parent("li").children("a").attr("class").replace("Cur", "") + "Cur");
            // alert( $(this).parent("li").children("a").attr("class"));
        });
        /*横导航子菜单 END*/



    });


