﻿
function setRegion(regionid) {
    $('#__RegionID').val(regionid);
    $("#SearchForm").submit();
}
function setQuestionClass(code) {
    $('#__ClassCode').val(code);
    $("#SearchForm").submit();
}
function loadA(id, obj) {
    $.ajax({
        type: "GET",
        cache: false,
        url: "GIM_C_Know_QA.axml?IsSimpleRequest=true",
        data: "__KnowledgeBaseID=" + id,
        beforeSend: function() {
            $(obj).append($("#loadImg")); $("#loadImg").show();
        },
        success: function(msg) {
            //折叠其他答案
            $(".ListGrid td[colspan=4]").parent().remove();
            $(obj).parent().parent().append("<tr><td colspan=4><div class='roundModule RBlue'><div class=MMbg ><h2 class='h2b pL10'>问："
            + $(obj).attr("basetext")
            + "</h2><div class=MMBox >"
            + msg
            + "</div></div><DIV class=BTL><SPAN></SPAN></DIV><DIV class=BBL><SPAN></SPAN></DIV></div><td></tr>");
            $(".html").each(function() { $(this).html($(this).text()).show(); });
            $(".ListGrid img").each(function() {
                if ($(this).width() > 600)
                    $(this).width("600px");
            });
            $("#loadImg").hide();
        },
        error: function() {
            alert("网络繁忙，请稍候重试!");
        }
    });
    return false;
}
function redirectPage(style) {
    location.href = replaceUrlParam(location.href, "__Style", style);
    return false;
}
$(function() {
    $("#knowlist a").click(
                    function() {
                        loadA($(this).attr("baseid"), this);
                    }
                  );
    $(".html").each(function() {
        $(this).html($(this).text()).show();
    });
    $(".kb_a img").each(function() {
        if ($(this).width() > 600)
            $(this).width("600px");
    });
    var ws = new Array("440px", "140px", "60px", "80px");
    $(".kb_info").each(function() {
        $("span", this).each(function(i) {
            $(this).width(ws[i]);
        });
    });

    if ($(".sortBox").children().length == 0) {
        //加载树数据
        $(".sortBox").load("/html/classtree/knowclass.htm", "", function() {
            $(".sortBox h2 img.openIco").removeClass("openIco");
			if ($("#__ClassCode").length > 0) {
                //当前分类加样式
                $(".sortBox a[code=" + $("#__ClassCode").val() + "]").addClass("onA").parent().parent().addClass("show").prev().find('img').toggleClass("openIco");
            }
            $(".sortBox ul img").click(function() {
                $(this).toggleClass("openIco").next("ul").toggleClass("show");
            });
            $(".sortBox h2 img").click(function() {
                $(this).toggleClass("openIco").parent().next("ul").toggleClass("show");
            });
        });
    }
});     
