﻿/*
导航
*/
var i_timeout = 0;
var v_pageSize = 4;
function showMenu(id) {
    clearMenuTimeout();
    //hiddenMenuEnd();
    //alert(id);
    $("#cont div").css("visibility", "hidden");
    $(".dropdown").slideDown("slow");
    $("#" + id).css("visibility", "visible");
}
function hiddenMenuEnd() {
    $(".dropdown").slideUp("slow");
    $("#cont div").css("visibility", "hidden");
}
function hiddenMenu() {
    clearMenuTimeout();
    i_timeout = setTimeout("hiddenMenuEnd()", 500);
}

function clearMenuTimeout() {
    clearTimeout(i_timeout);
}
/***********************************************/
/*
作品展示动画
*/
var _c = _h = 0;
function initBox() {
    $('#play > li').click(function () {
        var i = $(this).attr('alt') - 1;
        clearInterval(_h);
        _c = i;
        change(i);
        play();
    });
    $("#pic img").hover(function () { clearInterval(_h) }, function () { play() });
    play();
}
function play() {
    _h = setInterval("auto()", 2000);
}
function change(i) {
    $('#play > li').addClass("pic-guage-02").removeClass("pic-guage-01");
    $('#play > li').eq(i).removeClass("pic-guage-02").addClass("pic-guage-01");
    $("#pic img").fadeOut('slow').eq(i).fadeIn('slow');
}
function auto() {
    var size = $('#play > li').size();
    if (size > 1) {
        _c = _c > (size - 2) ? 0 : _c + 1;
        change(_c);
    }
}
/* 
读取xml
*/
function init(id) {
    $("#client,#discipline,#team").hover(function () {
        $(this).removeClass("type-label").addClass("type-label-mouseon");
    }, function () { $(this).removeClass("type-label-mouseon").addClass("type-label"); });
    initAjax(1, v_pageSize, true, id, "");
}
//设置浮动div位置
function getPosition(id, wId) {
    var p = $("#" + wId).offset();
    var h = $("#" + id).height();
    $("#" + id).css("left", p.left);
    $("#" + id).css("top", (p.top - h - 15));
}
//当前类型
var type = "";
/*
加载xml
pageIndex 表示第几页
pageSize 表示每页的个数
isDefault true表示初始化 
*/
function initAjax(pageIndex, pageSize, isDefault, Id, isclient) {
    $.ajax({
        type: "GET",
        url: "/images-data/cases-data.xml",
        dataType: "xml",
        cache: false,
        success: function (xml) {
            clearHtml("box_Right");
            clearHtml("pageDiv");
            var where = "";
            if (type == "client") {
                where = "[ClientId='" + Id + "']";
            } else if (type == "industry") {
                where = "[IndustryId='" + Id + "']";
            }
            if (isDefault) {
                where += "[IsDefault='True']";
            }
            $(xml).find("Cases").children().filter(where).each(function (i) {
                if (i >= (pageIndex - 1) * pageSize && i < (pageIndex * pageSize)) {
                    var str = "<div style=\"width: 93px; height:106px; text-align: center\"><div style='margin-left:80px;'><img onclick=\"imgOnClick('" + $(this).attr("Id") + "',this)\" src='" + $(this).attr("CoverUrl") + " ' width=\"93\" height=\"56\" /></div>";
                    var obj = $(xml).find("Disciplines").children().filter("[Id=" + $(this).attr("DisciplineId") + "]");
                    str += "<div style='margin-left:80px; width:100%'><div class=\"float-left icon-print\"></div><div class=\"property float-left\">" + $(this).attr("Name") + "</div></div></div>";
                    $("#box_Right").append(str);
                    //if (type != "client" && i == 0) {
                    if (i == 0) {
                        //默认动画
                        imgOnClick($(this).attr("Id"));
                    }
                }
            })
            var size = $(xml).find("Cases").children().filter(where).size();
            if (size != 0) {
                if (size / pageSize > Math.round((size / pageSize) * 1) / 1) {
                    pageShow(pageIndex, (Math.round((size / pageSize) * 1) / 1) + 1, isDefault, Id);
                } else {
                    pageShow(pageIndex, Math.round((size / pageSize) * 1) / 1, isDefault, Id);
                }
            } else {
                clearHtml("next");
                clearHtml("prev");
            }

            if (Id > 0 && isclient === "") {
                imgOnClick(Id, null);
            }
        },
        error: function (xml) {
            alert('Error loading XML document' + xml);
        }
    });
}

function clearHtml(id) {
    $("#" + id).html("");
}
//计算页数
function pageShow(pageIndex, size, isDefault, clientId) {
    var pageStart = Math.round((pageIndex / v_pageSize - 0.1) * 1) / 1;
    var count = pageStart + v_pageSize;
    if (size < count) {
        count = size;
    }
    //alert("size=" + size + ";pageStart=" + pageStart + ";count=" + count);
    for (var j = pageStart + 1; j <= count; j++) {
        //alert("j=" + j + ";pageIndex=" + pageIndex + ";pageStart=" + pageStart);
        if (j == pageStart + 1) {
            if (j == pageIndex) {
                $("#pageDiv").append(" <span class=\"current\">" + j + "</span>");
            } else {
                $("#pageDiv").append("<a onclick='initAjax(" + j + "," + v_pageSize + "," + isDefault + "," + clientId + ");' href=\"#\">" + j + "</a>");
            }
        } else {
            if (j == pageIndex) {
                $("#pageDiv").append(" <span style='border-left:1px #ccc solid;padding-left:4px;margin-left:4px;' class=\"current\">" + j + "</span>");
            } else {
                $("#pageDiv").append("<a style='border-left:1px #ccc solid;padding-left:4px;margin-left:4px;'  onclick='initAjax(" + j + "," + v_pageSize + "," + isDefault + "," + clientId + ");' href=\"#\">" + j + "</a>");
            }
        }
    }
    clearHtml("next");
    clearHtml("prev");
    if (pageIndex - 1 >= pageStart + 1) {
        $("#prev").html(" <input onclick='initAjax(" + (pageIndex - 1) + "," + v_pageSize + "," + isDefault + "," + clientId + ");' type=\"button\" class=\"left\"  value=\" \" />");
    } else {
        $("#prev").html(" <input onclick='initAjax(" + pageIndex + "," + v_pageSize + "," + isDefault + "," + clientId + ");' type=\"button\" class=\"left\"  value=\" \" />");
    }
    if ((pageIndex + 1) <= count) {
        $("#next").html("<input onclick='initAjax(" + (pageIndex + 1) + "," + v_pageSize + "," + isDefault + "," + clientId + ");' type=\"button\" class=\"right\"  value=\" \" />");
    } else {
        $("#next").html("<input onclick='initAjax(" + pageIndex + "," + v_pageSize + "," + isDefault + "," + clientId + ");' type=\"button\" class=\"right\" value=\" \" />");
    }

}

//点击右边图片时响应的方法
function imgOnClick(id, obj) {
    apHidden('apDiv');
    //点击小图时 设置透明背景
    $("#box_Right img").parent().removeClass("imgHover").css("margin-left", "80px");
    $("#box_Right img").parent().css("clear", "both");
    if (obj != null) {
        $(obj).parent().addClass("imgHover").css("margin-left", "69px");
    }
    $.ajax({
        type: "GET",
        url: "/images-data/cases-data.xml",
        dataType: "xml",
        cache: false,
        success: function (xml) {
            clearHtml("pic");
            //clearHtml("play");
            clearHtml("descript");
            clearHtml("img_text");
            $("#img_text").html("<ul id=\"play\" class=\" float-right\"></ul>");
            var obj = $(xml).find("CaseFiles").children().filter("[CaseId='" + id + "']");
            if (obj.size() == 0) {
                $(".case-large-picture").attr("style", "border:1px #ccc solid;");
                $("#pic").html("<p align='center' style='margin-top:200px;color:#666;font-size:14px'>您选择的类型没有数据,请重新选择！</p>");
            }
            obj.each(function (i) {
                if ($(this).attr("Type") == 0) {
                    var str = " <a href=\"#\"><img alt=\"\" src=\"" + $(this).attr("FileUrl") + "\" width=\"736\" height=\"443\" /></a>";
                    $(".case-large-picture").attr("style", "border:0px");
                    $("#pic").append(str);
                    if (obj.size() != 1) {
                        var str1 = "";
                        if (i == 0) {
                            str1 = "<li alt=\"" + (i + 1) + "\" class=\"pic-guage-01\"></li>";
                        } else {
                            str1 = "<li alt=\"" + (i + 1) + "\" class=\"pic-guage-02\"></li>";
                        }
                        $("#play").append(str1);
                    }
                } else {
                    clearHtml("img_text");
                    var str = "<a href=\"" + $(this).attr("FileUrl") + "\" style=\"width:736px;height:443px\"  id=\"player\"> </a>";
                    $(".case-large-picture").attr("style", "border:0px");
                    $("#pic").append(str);
                    flowplayer("player", "/scripts/flowplayer-3.2.7.swf", {
                        clip: {
                            autoPlay: true,
                            autoBuffering: true
                        }
                    });
                    var str1 = "<input class='playbtn float-right' style='margin-top:12px;' type='button'>";
                    $("#img_text").append(str1);
                }
            });
            $(xml).find("Cases").children().filter("[Id='" + id + "']").each(function (i) {
                $("#descript").append("<p><span style=\"font-weight:bold;font-size:14px;margin:0 5px 10px 0;\" >" + $(this).attr("Name") + "</span></p>");
                $("#descript").append("<p style=\"margin-bottom:30px;line-height:200%;\">" + $(this).children().text().replace(/\n/g, "<br/>") + "</p>");
                var shareStr = "<div style='float:left;font-family:微软雅黑;line-height:200%;margin:20px 0 0 0;font-size:11pt;'>分享到&nbsp;&nbsp;&nbsp;　</div>";
                var urlStr = "http://www.shunyagroup.com";
                shareStr += "<a title=\"新浪\" style=\"cursor:pointer\" href=\"http://v.t.sina.com.cn/share/share.php?title=" + encodeURI($(this).attr("Name")) + "&url=" + urlStr + "/Cases/Index.html?id=" + id + "&source=" + urlStr + "\" target=\"blank\"><div class='share-sina' style='float:left;'></div></a>";
                shareStr += "<a title=\"人人\" style=\"cursor:pointer\" href=\"http://share.renren.com/share/buttonshare/post/1004?title=" + encodeURI($(this).attr("Name")) + "&url=" + urlStr + "/Cases/Index.html?id=" + id + "\" target=\"blank\"><div class='share-renren' style='float:left;'></div></a>";
                shareStr += "<a title=\"豆瓣\" style=\"cursor:pointer\" href=\"http://www.douban.com/recommend/?title=" + encodeURI($(this).attr("Name")) + "&url=" + urlStr + "/Cases/Index.html?id=" + id + "\" target=\"blank\"><div class='share-douban' style='float:left;'></div></a>";
                shareStr += "<a title=\"开心\" style=\"cursor:pointer\" href=\"http://www.kaixin001.com/repaste/share.php?rtitle=" + encodeURI($(this).attr("Name")) + "&rurl=" + urlStr + "/Cases/Index.html?id=" + id + "\" target=\"blank\"><div class='share-kaixin001' style='float:left;'></div></a>";
                $("#descript").append(shareStr);
            });

            _c = 0;
            clearInterval(_h);
            initBox();
        },
        error: function (xml) {
            alert('Error loading XML document' + xml);
        }
    });
}
/*
获取客户详情
*/
function getDetailData(id, type) {
    apHidden('apDiv');
    $.ajax({
        type: "GET",
        url: "/images-data/cases-data.xml",
        dataType: "xml",
        cache: false,
        success: function (xml) {
            if (type == "client") {
                initAjax(1, v_pageSize, false, id);
            } else {
                initAjax(1, v_pageSize, false, id);
            }
        }
    });
}
/*
显示浮动的div
*/
var j_timeout = 0;
function apShow(id, bool, wId) {
    if (bool == "child") {
        clearTimeout(j_timeout);
        //getPosition(id, wId);
    } else if (bool) {
        //getPosition(id, wId);
        var client = $("#" + id);
        var p = $("#" + wId).offset();
        var h = client.height();
        client.css("left", p.left);
        client.css("overflow", "hidden");
        client.css("margin-top", 443);
        client.css("height", "2px");
        clearTimeout(j_timeout);
        client.css("display", "block");
        client.animate({ fake_style: 0.9 }, {
            duration: 800,
            easing: "swing",
            queue: false,
            step: function (now, fx) {
                $(this).css("margin-top", 443 - fx.pos * h + 1);
                $(this).css("height", fx.pos * h);
            },
            complete: function () {
                $(this).css("margin-top", 443 - h);
                $(this).css("height", h);
            }
        });
    } else {
        clearTimeout(j_timeout);
        j_timeout = setTimeout("apHidden('" + id + "', '" + wId + "')", 1000);
    }
}
function apHidden(id, wId) {
    $("#" + id).css("display", "none");
    $("#" + id).stop();
    if (wId) {
        var owId = $("#" + id).data("__wId");
        if (owId == wId)
            $("#" + id).data("__wId", null);
    }
    else {
        $("#" + id).data("__wId", null);
    }
}
function apMouseOver(id, wId, xml) {
    var owId = $("#" + id).data("__wId");
    if (owId == wId)
        return;

    clearHtml(id);
    var obj;
    if (wId == "client") {
        type = "client";
        obj = $(xml).find("Clients").children();
        $("#" + id).attr("style", "width:100px;height:auto");
        var floatstr = " <div style=\"margin-top: 5px;\">";
        obj.each(function (i) {
            floatstr += "<p style=\"line-height: 13px;\" align=\"center\"><a onclick=\"getDetailData('" + $(this).attr("Id") + "','" + wId + "')\" href=\"#\">" + $(this).attr("Name") + "</a></p>";
        });
        floatstr += "</div>";

    } else if (wId == "industry") {
        type = "industry";
        obj = $(xml).find("Industrys").children();
        $("#" + id).attr("style", "width:100px;height:auto");
        var floatstr = " <div style=\"margin-top: 5px;\">";
        obj.each(function (i) {
            floatstr += "<p style=\"line-height: 13px;\" align=\"center\"><a onclick=\"getDetailData('" + $(this).attr("Id") + "','" + wId + "')\" href=\"#\">" + $(this).attr("Name") + "</a></p>";
        });
        floatstr += "</div>";
    }

    $("#" + id).append(floatstr);
    apShow(id, true, wId);
    $("#" + id).mouseover(function () { apShow(id, "child", wId) });
    $("#" + id).mouseout(function () { apShow(id, false, wId) });
    $("#" + id).data("__wId", wId);

}
function selectInitial(str, wId) {
    $.ajax({
        type: "GET",
        url: "/images-data/cases-data.xml",
        dataType: "xml",
        cache: false,
        success: function (xml) {
            clearHtml('apDiv');
            obj = $(xml).find("Clients").children();
            var floatstr = "<div style='margin:20px 20px 0 20px;height:390px;width:100%' >";
            var index = 0;
            obj.each(function (i) {
                if ($(this).attr("Initial").match("^[" + str + "]+$") != null) {
                    var start = Math.round((index + 1) % 16 * 1) / 1;
                    if (start == 1) {
                        floatstr += "<table style='vertical-align:top;' class='float-left' width=\"25%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
                    }
                    floatstr += "<tr><td width=\"25%\" height=\"24\"><img src=\"/images/ico-corner.gif\" width=\"6\" height=\"6\" / style=\"margin:0 10px 1px 20px;\" ><a onclick=\"getDetailData('" + $(this).attr("Id") + "','" + wId + "')\" href=\"#\">" + $(this).attr("Name") + "</a></td></tr>";
                    if (start == 0) {
                        floatstr += "</table>";
                    }
                    index++;
                }
            });
            floatstr += "</div>";
            $("#apDiv").html(floatstr);
            floatstr = "";
            floatstr += "<div class='clear-both'><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin:0 0 0 20px;\" class=\"point\"><tr>";
            floatstr += "<td height=\"30\" align=\"center\"><span onclick=\"selectInitial('A-Za-z','" + wId + "')\" >ALL</span>　　<span onclick=\"selectInitial('A-Da-d','" + wId + "')\">A-D</span>　　<span onclick=\"selectInitial('E-He-h','" + wId + "')\">E-H</span>　　<span onclick=\"selectInitial('I-Li-l','" + wId + "')\">I-L</span>　　<span onclick=\"selectInitial('M-Pm-p','" + wId + "')\">M-P</span>　　<span onclick=\"selectInitial('Q-Tq-t','" + wId + "')\">Q-T</span>　　<span onclick=\"selectInitial('U-Wu-w','" + wId + "')\">U-W</span>　　<span onclick=\"selectInitial('X-Zx-z','" + wId + "')\">X-Z</span></td></tr></table></div>";
            $("#apDiv").append(floatstr);
        }
    });
    return;
}

/***********************************************/
/*
新闻xml加载
*/
function initNews(id, index, newsid) {
    $.ajax({
        type: "GET",
        url: "/images-data/cases-data.xml",
        dataType: "xml",
        cache: false,
        success: function (xml) {
            clearHtml(id);
            clearHtml("NewsList");
            var str = "";
            $(xml).find("NewsCategorys").children().each(function (i) {
                str += "<div onclick='getNewsList(" + $(this).attr("Id") + "," + 0 + "," + index + ")' style='  cursor:pointer;' class=\"typebtn-mouseover\">" + $(this).attr("Name") + "\</div>"
                //初始化
                if (i == index) {
                    getNewsList($(this).attr("Id"), newsid);
                }
            })
            $("#" + id).html(str);
            $("#" + id + " > div").eq(index).removeClass("typebtn-mouseover").addClass("typebtn-mouseon");
            $("#" + id + " div").click(function () {
                $("#" + id + " div").removeClass("typebtn-mouseon").addClass("typebtn-mouseover");
                $(this).removeClass("typebtn-mouseover").addClass("typebtn-mouseon");
            });

            if (newsid > 0) {
                getNewsContent(newsid);
            }
        }
    });
}

function getNewsList(id, newsid, index) {
    $.ajax({
        type: "GET",
        url: "/images-data/cases-data.xml",
        dataType: "xml",
        cache: false,
        success: function (xml) {
            clearHtml("NewsList");
            var cont = "";
            var obj = $(xml).find("NewsData").children().filter("[CategoryId='" + id + "']");
            if (obj.size() == 0) {
                cont = " <div class=\"weibo\" style='text-align:center;font-size:14px;margin-top:100px;'><span >暂无数据，请选择其它类别！</span></div>";
            }
            obj.each(function (i) {
                cont += "<div class=\"weibo\"><div style=\"padding: 0 10px 10px 10px\" class=\"float-left\"><a onclick='getNewsContent(" + $(this).attr("Id") + "," + index + ")' href=\"#\"><img src=\"" + $(this).attr("CoverUrl") + "\" width=\"93\" height=\"56\" /></a></div><div><a  onclick='getNewsContent(" + $(this).attr("Id") + "," + index + ")' href=\"#\">" + $(this).find("Title").text() + "<br /> </a>" + $(this).attr("NewsDatetime") + "</div><div class=\"clear-both\"></div></div>";
            });
            $("#NewsList").html(cont);
        }
    });
}
function getNewsContent(id, index) {
    $.ajax({
        type: "GET",
        url: "/images-data/cases-data.xml",
        dataType: "xml",
        cache: false,
        success: function (xml) {
            clearHtml("NewsList");
            var obj = $(xml).find("NewsData").children().filter("[Id='" + id + "']");
            if (obj.size() == 0) {
                return;
            }
            var cont = "<div class=\"weibo\"><div><span style='font-family:微软雅黑;font-weight:bold;font-size:14pt;color:#E77612'>" + obj.find("Title").text() + "</span><br />" + obj.attr("NewsDatetime") + "</div><div class=\"clear-both\"></div></div>";
            cont += "<div class=\"weibo\"><div style=\"padding:10px 10px 10px 0px;width:473px;word-break: break-all; \" class=\" lineheight-24px\">";

            if ($.trim(obj.attr("ImageUrl")) != null && $.trim(obj.attr("ImageUrl")) != "") {
                cont += "<img width='473' src=\"" + obj.attr("ImageUrl") + " \" ><br/>";
            }
            cont += obj.find("Content").text().replace(/\n/g, "<br/>") + "</div><div class=\"clear-both\"></div>";
            $("#NewsList").html(cont);
            var shareStr = "<div style='float:left;font-family:微软雅黑;line-height:200%;margin:20px 0 0 0;font-size:11pt;'>分享到&nbsp;&nbsp;&nbsp;　</div>";
            var urlStr = "http://www.shunyagroup.com";
            shareStr += "<a title=\"新浪\" style=\"cursor:pointer\" href=\"http://v.t.sina.com.cn/share/share.php?title=" + encodeURI(obj.find("Title").text()) + "&url=" + urlStr + "/Microblog/Index.html?id=" + id + "&index=" + index + "&source=" + urlStr + "\" target=\"blank\"><div class='share-sina' style='float:left;'></div></a>";
            shareStr += "<a title=\"人人\" style=\"cursor:pointer\" href=\"http://share.renren.com/share/buttonshare/post/1004?title=" + encodeURI(obj.find("Title").text()) + "&url=" + urlStr + "/Microblog/Index.html?id=" + id + "&index=" + index + "\" target=\"blank\"><div class='share-renren' style='float:left;'></div></a>";
            shareStr += "<a title=\"豆瓣\" style=\"cursor:pointer\" href=\"http://www.douban.com/recommend/?title=" + encodeURI(obj.find("Title").text()) + "&url=" + urlStr + "/Microblog/Index.html?id=" + id + "&index=" + index + "\" target=\"blank\"><div class='share-douban' style='float:left;'></div></a>";
            shareStr += "<a title=\"开心\" style=\"cursor:pointer\" href=\"http://www.kaixin001.com/repaste/share.php?rtitle=" + encodeURI(obj.find("Title").text()) + "&rurl=" + urlStr + "/Microblog/Index.html?id=" + id + "&index=" + index + "\" target=\"blank\"><div class='share-kaixin001' style='float:left;'></div></a>";
            $("#NewsList").append(shareStr);
        }
    });
}
function getMenuData(id) {
    $.ajax({
        type: "GET",
        url: "/images-data/cases-data.xml",
        dataType: "xml",
        cache: false,
        success: function (xml) {
            clearHtml(id);
            clearHtml("NewsList");
            var str = "";
            $(xml).find("NewsCategorys").children().each(function (i) {
                if (i < 5) {
                    str += "  <a style='padding-left:2px;' href=\"javascript:MenuClick(" + i + ")\">" + $(this).attr("Name") + "</a><br />";
                }
            })
            $("#" + id).html(str);

        }
    });
}
function MenuClick(id) {
    location.href = "/Microblog/Index.html?id=0&year=" + id;
}

//分页查询
function onBlurPage(obj, url, count) {
    if ($(obj).val() != null && $(obj).val() != "") {
        var i = parseInt($(obj).val());
        if (i >= 1 && i <= count) {
            location.href = url + $(obj).val();
        } else {
            alert("你输入的数值大于总页数，请重新输入！");
        }
    }
}
/***********************************************/
/*
关于宣亚xml加载
*/
function initTreeInfo(id, dataName, sid) {
    $.ajax({
        type: "GET",
        url: "/images-data/about-data.xml",
        dataType: "xml",
        cache: false,
        success: function (xml) {
            var itemId = $.query.get("id") - 1;
            clearHtml(id);
            clearHtml("NewsList");
            var str = "";
            $(xml).find(id).children().each(function (i) {
                if (typeof ($(this).attr("Href")) == "undefined") {
                    var divId = $(this).attr("Id");
                    var isPorwerOfOne = "";
                    var isPorwerOfOne2 = "";
                    if (id === "PowerOfOneCategorys" && ($(this).attr("Id") === "3" || $(this).attr("Id") === "5")) {
                        isPorwerOfOne = "letter-spacing:4px;";
                    }
                    if (id === "PowerOfOneCategorys" && $(this).attr("Id") === "4") {
                        isPorwerOfOne = "letter-spacing:36px;";
                    }
                    //---------------------------------
                    if ($(this).attr("Name") == "虚位以待") {
                        str += "<div style=\"display:block;color:#bdbebe\" id=\"slient\" class=\"typebtn-mouseover\">" + $(this).attr("Name") + "\</div>"
                        return;
                    }
                    //---------------------------------
                    if (id == "ContactUsCategorys") {
                        str += "<div  id='div" + divId + "'></div>"
                    }
                    else {
                        
                        str += "<div  id='div" + divId + "' style='cursor:pointer;" + isPorwerOfOne + "' class=\"typebtn-mouseover\">" + $(this).attr("Name") + "\</div>"
                    }

                    $(this).children().each(function (j) {
                        str += "<label id='sub-" + divId + "-" + j + "' class='typebtn-se-mouseover' style='cursor:pointer;margin-bottom:10px; margin-top:10px;'>&gt; " + $(this).attr("Name") + "</label>";
                        $(this).children().each(function (k) {
                            str += "<label id='sub-" + divId + "-" + j + "-" + k + "' class='typebtn-se-mouseover_sub' style='cursor:pointer;margin-bottom:10px; margin-top:10px;'>&gt; " + $(this).attr("Name") + "</label>";
                        })
                    })
                } else {
                    str += "<div class='typebtn-mouseover'><a href='" + $(this).attr("Href") + "'>" + $(this).attr("Name") + "</a></div>";
                }
            })

            $("#" + id).html(str);
            $("#" + id + " div[id!=slient]").click(function () {
                $("#" + id + " div").removeClass("typebtn-mouseon").addClass("typebtn-mouseover");
                $("#" + id + " label").removeClass("typebtn-se-mouseon").addClass("typebtn-se-mouseover"); ;
                $("#" + id + " label").css("display", "none");
                if (id != "ContactUsCategorys") {
                    $(this).removeClass("typebtn-mouseover").addClass("typebtn-mouseon");
                }
                var sub1Id = "sub-" + $(this).attr("id").replace("div", "") + "-0";
                var strId = "sub-" + $(this).attr("id").replace("div", "") + "-";
                var subId = sub1Id;
                if (dataName == "JoinData") {
                    sub1Id += "-0";
                }

                //显示二级菜单
                var i = 0;
                while ($("#" + strId + i).attr("Id")) {
                    $("#" + strId + i).css("display", "block");
                    i++;
                }
                if ($("#" + sub1Id).size() != 0) {
                    $("#" + sub1Id).removeClass("typebtn-se-mouseover").addClass("typebtn-se-mouseon");
                    $("#" + subId).removeClass("typebtn-se-mouseover").addClass("typebtn-se-mouseon");
                    if (sid != "0" && sid != "" && sid !== undefined) {
                        $("#sub-2-0").removeClass("typebtn-se-mouseon").addClass("typebtn-se-mouseover");
                        $("#sub-" + sid).removeClass("typebtn-se-mouseover").addClass("typebtn-se-mouseon");
                        getContent(sid, dataName);
                    } else {
                        getContent(sub1Id.replace("sub-", ""), dataName);
                    }
                } else {
                    getContent($(this).attr("id").replace("div", ""), dataName);
                }
            });
            $("#" + id + " label").click(function () {
                $("#" + id + " label").removeClass("typebtn-se-mouseon").addClass("typebtn-se-mouseover");
                $("#" + id + " div").removeClass("typebtn-mouseon").addClass("typebtn-mouseover");
                $("#" + id + " label").css("display", "none");
                $(this).removeClass("typebtn-se-mouseover").addClass("typebtn-se-mouseon");
                var divId = "div" + $(this).attr("id").toString().split('-')[1];
                $("#" + divId).removeClass("typebtn-mouseover").addClass("typebtn-mouseon");
                var subId = $(this).attr("id").replace("sub-", "");
                var strId = "sub-" + divId.replace("div", "") + "-";
                //显示二级菜单
                var i = 0;
                while ($("#" + strId + i).attr("Id")) {
                    $("#" + strId + i).css("display", "block");
                    i++;
                }
                if (dataName == "JoinData") {
                    if ($(this).attr("id").toString().split('-').length == 3) {
                        $("#" + "sub-" + subId + "-0").removeClass("typebtn-se-mouseover").addClass("typebtn-se-mouseon");
                        //显示三级菜单
                        var i = 0;
                        while ($("#" + "sub-" + subId + "-" + i).attr("Id")) {
                            $("#" + "sub-" + subId + "-" + i).css("display", "block");
                            i++;
                        }
                        subId += "-0";
                    } else {
                        var parentSubId = subId.substring(0, subId.length - 2);
                        $("#" + "sub-" + parentSubId).removeClass("typebtn-se-mouseover").addClass("typebtn-se-mouseon");
                        //显示三级菜单
                        var i = 0;
                        while ($("#" + "sub-" + parentSubId + "-" + i).attr("Id")) {
                            $("#" + "sub-" + parentSubId + "-" + i).css("display", "block");
                            i++;
                        }
                    }
                }
                getContent(subId, dataName);
            });
            $("#" + id + " > div").eq(itemId).click();
        }
    });
}

function getContent(id, dataName) {
    $.ajax({
        type: "GET",
        url: "/images-data/about-data.xml",
        dataType: "xml",
        cache: false,
        success: function (xml) {
            clearHtml("NewsList");
            if (v_timeout != 0) {
                clearTime();
            }
            var obj = $(xml).find(dataName).children().filter("[Id='" + id + "']");
            if (obj.size() == 0) {
                return;
            }
            var cont = "<div>" + obj.find("Content").text() + "</div>";
            $("#NewsList").html(cont);
        }
    });
}
var v_timeout = 0;
function news_onload() {
    $(".scrollable").scrollable({
        size: 10,
        vertical: false,
        loop: true,
        speed: 1500,
        interval: 2000,
        prevPage: '.prev',
        nextPage: '.next',
        onBeforeSeek: function () {
            this.getItems().fadeTo(300, 0.2);
        },
        onSeek: function () {
            this.getItems().fadeTo(300, 1);
        }
    });
    v_timeout = setInterval("news_show()", 3500);
    $(".next").hover(function () {
        clearTime();
    }, function () {
        clearTime();
        v_timeout = setInterval("news_show()", 3500);
    });
    $(".prev").hover(function () {
        clearTime();
    }, function () {
        clearTime();
        v_timeout = setInterval("news_show()", 3500);
    });
    $(".items img").hover(function () {
        clearTime();
    }, function () {
        clearTime();
        v_timeout = setInterval("news_show()", 3500);
    });
}
function news_show() {
    var scrollable = $(".scrollable").scrollable();
    var index = scrollable.getIndex();
    if (index == 9) {
        scrollable.begin();
    } else {
        scrollable.next();
    }
}
function clearTime() {
    clearInterval(v_timeout);
    v_timeout = 0;
}
/**
* jQuery.query - Query String Modification and Creation for jQuery
* Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
* Date: 2009/8/13
*
* @author Blair Mitchelmore
* @version 2.1.6
*
**/
new function (settings) {
    // Various Settings
    var $separator = settings.separator || '&';
    var $spaces = settings.spaces === false ? false : true;
    var $suffix = settings.suffix === false ? '' : '[]';
    var $prefix = settings.prefix === false ? false : true;
    var $hash = $prefix ? settings.hash === true ? "#" : "?" : "";
    var $numbers = settings.numbers === false ? false : true;

    jQuery.query = new function () {
        var is = function (o, t) {
            return o != undefined && o !== null && (!!t ? o.constructor == t : true);
        };
        var parse = function (path) {
            var m, rx = /\[([^[]*)\]/g, match = /^([^[]+?)(\[.*\])?$/.exec(path), base = match[1], tokens = [];
            while (m = rx.exec(match[2])) tokens.push(m[1]);
            return [base, tokens];
        };
        var set = function (target, tokens, value) {
            var o, token = tokens.shift();
            if (typeof target != 'object') target = null;
            if (token === "") {
                if (!target) target = [];
                if (is(target, Array)) {
                    target.push(tokens.length == 0 ? value : set(null, tokens.slice(0), value));
                } else if (is(target, Object)) {
                    var i = 0;
                    while (target[i++] != null);
                    target[--i] = tokens.length == 0 ? value : set(target[i], tokens.slice(0), value);
                } else {
                    target = [];
                    target.push(tokens.length == 0 ? value : set(null, tokens.slice(0), value));
                }
            } else if (token && token.match(/^\s*[0-9]+\s*$/)) {
                var index = parseInt(token, 10);
                if (!target) target = [];
                target[index] = tokens.length == 0 ? value : set(target[index], tokens.slice(0), value);
            } else if (token) {
                var index = token.replace(/^\s*|\s*$/g, "");
                if (!target) target = {};
                if (is(target, Array)) {
                    var temp = {};
                    for (var i = 0; i < target.length; ++i) {
                        temp[i] = target[i];
                    }
                    target = temp;
                }
                target[index] = tokens.length == 0 ? value : set(target[index], tokens.slice(0), value);
            } else {
                return value;
            }
            return target;
        };

        var queryObject = function (a) {
            var self = this;
            self.keys = {};

            if (a.queryObject) {
                jQuery.each(a.get(), function (key, val) {
                    self.SET(key, val);
                });
            } else {
                jQuery.each(arguments, function () {
                    var q = "" + this;
                    q = q.replace(/^[?#]/, ''); // remove any leading ? || #
                    q = q.replace(/[;&]$/, ''); // remove any trailing & || ;
                    if ($spaces) q = q.replace(/[+]/g, ' '); // replace +'s with spaces

                    jQuery.each(q.split(/[&;]/), function () {
                        var key = decodeURIComponent(this.split('=')[0] || "");
                        var val = decodeURIComponent(this.split('=')[1] || "");

                        if (!key) return;

                        if ($numbers) {
                            if (/^[+-]?[0-9]+\.[0-9]*$/.test(val)) // simple float regex
                                val = parseFloat(val);
                            else if (/^[+-]?[0-9]+$/.test(val)) // simple int regex
                                val = parseInt(val, 10);
                        }

                        val = (!val && val !== 0) ? true : val;

                        if (val !== false && val !== true && typeof val != 'number')
                            val = val;

                        self.SET(key, val);
                    });
                });
            }
            return self;
        };

        queryObject.prototype = {
            queryObject: true,
            has: function (key, type) {
                var value = this.get(key);
                return is(value, type);
            },
            GET: function (key) {
                if (!is(key)) return this.keys;
                var parsed = parse(key), base = parsed[0], tokens = parsed[1];
                var target = this.keys[base];
                while (target != null && tokens.length != 0) {
                    target = target[tokens.shift()];
                }
                return typeof target == 'number' ? target : target || "";
            },
            get: function (key) {
                var target = this.GET(key);
                if (is(target, Object))
                    return jQuery.extend(true, {}, target);
                else if (is(target, Array))
                    return target.slice(0);
                return target;
            },
            SET: function (key, val) {
                var value = !is(val) ? null : val;
                var parsed = parse(key), base = parsed[0], tokens = parsed[1];
                var target = this.keys[base];
                this.keys[base] = set(target, tokens.slice(0), value);
                return this;
            },
            set: function (key, val) {
                return this.copy().SET(key, val);
            },
            REMOVE: function (key) {
                return this.SET(key, null).COMPACT();
            },
            remove: function (key) {
                return this.copy().REMOVE(key);
            },
            EMPTY: function () {
                var self = this;
                jQuery.each(self.keys, function (key, value) {
                    delete self.keys[key];
                });
                return self;
            },
            load: function (url) {
                var hash = url.replace(/^.*?[#](.+?)(?:\?.+)?$/, "$1");
                var search = url.replace(/^.*?[?](.+?)(?:#.+)?$/, "$1");
                return new queryObject(url.length == search.length ? '' : search, url.length == hash.length ? '' : hash);
            },
            empty: function () {
                return this.copy().EMPTY();
            },
            copy: function () {
                return new queryObject(this);
            },
            COMPACT: function () {
                function build(orig) {
                    var obj = typeof orig == "object" ? is(orig, Array) ? [] : {} : orig;
                    if (typeof orig == 'object') {
                        function add(o, key, value) {
                            if (is(o, Array))
                                o.push(value);
                            else
                                o[key] = value;
                        }
                        jQuery.each(orig, function (key, value) {
                            if (!is(value)) return true;
                            add(obj, key, build(value));
                        });
                    }
                    return obj;
                }
                this.keys = build(this.keys);
                return this;
            },
            compact: function () {
                return this.copy().COMPACT();
            },
            toString: function () {
                var i = 0, queryString = [], chunks = [], self = this;
                var encode = function (str) {
                    str = str + "";
                    if ($spaces) str = str.replace(/ /g, "+");
                    return encodeURIComponent(str);
                };
                var addFields = function (arr, key, value) {
                    if (!is(value) || value === false) return;
                    var o = [encode(key)];
                    if (value !== true) {
                        o.push("=");
                        o.push(encode(value));
                    }
                    arr.push(o.join(""));
                };
                var build = function (obj, base) {
                    var newKey = function (key) {
                        return !base || base == "" ? [key].join("") : [base, "[", key, "]"].join("");
                    };
                    jQuery.each(obj, function (key, value) {
                        if (typeof value == 'object')
                            build(value, newKey(key));
                        else
                            addFields(chunks, newKey(key), value);
                    });
                };

                build(this.keys);

                if (chunks.length > 0) queryString.push($hash);
                queryString.push(chunks.join($separator));

                return queryString.join("");
            }
        };

        return new queryObject(location.search, location.hash);
    };
} (jQuery.query || {}); 

