function OpenClose() {
    Loading(true);
    window.location.href = "AppendProductList.aspx";
}
//添加考试
//增加新数据
var qarowindex = 1;
function ExamaddNew(id, name, Type) {
    $("#table6 tbody").append("<tr><td><input type='checkbox' checked='checked' name='checkbox_qa' value='" + qarowindex + "|" + id + "'></td><td><input  value='" + name + "' name='checkbox_name_qa_" + qarowindex + "' style='width: 300px;' /></td></tr>");
    qarowindex++;
}
var ExamorCw = 0;
//选择课程
$(".iframe_left").attr("src", "/Training/plan/Plan_Courseware_CourType.aspx");
function CowtabShow(value) {
    ExamorCw = value;
    if (value == 0) {
        $("#Cowtab").show();
        $.get("/Training/plan/GetCourseware.ashx", "",
                          function (data) {
                              $("#cwtbody").html(data);
                          });
    } else {
        $("#ExamTab").show();
        $.get("/Training/ExamPlan/GetExamTable.ashx", { orderfile: 'Examination_CreateDate' },
                          function (data) {
                              $("#Exambody").html(data);
                          });
    }
}
//分页
function CowTabPage(index, typeid) {
    if (ExamorCw == 0) {
        $.get("/Training/plan/GetCourseware.ashx", { page: index, key: typeid },
                          function (data) {
                              $("#cwtbody").html(data);
                          });

    } else {
        $.get("/Training/ExamPlan/GetExamTable.ashx", { page: index, orderfile: 'Examination_CreateDate', key: typeid },
                          function (data) {
                              $("#Exambody").html(data);
                          });
    }

}

//选择
function setcs(obj, csid, csname, csType) {
    if (ExamorCw == 0) {
        if ($(obj).attr("checked")) {
            $("#cslist").show();
            //alert("a ");
            addNew(csid, csname, "1", "1", "1", csType);
        }
    } else {
        if ($(obj).attr("checked")) {
            $("#qalist").show();
            //alert("a ");
            ExamaddNew(csid, csname, csType);
        }
    }
}
function CowtabHide() {
    $("#TypeDiv").hide();
    $("#Cowtab").hide();
    $("#ExamTab").hide();

}
//增加新数据
var rowindex = 1;
function addNew(csid, csname, csxue, type, csshi, csType) {
    var xuanxiang = "";
    var titleObj = $("#PlanName");
    if (jQuery.trim(titleObj.val()) == "") {
        var userGoupName = $('.userGroupInfo').eq(0);
        var userGoupTxt = "";
        if (userGoupName.length > 0)
            userGoupTxt = userGoupName.text();
        titleObj.val(userGoupTxt + " " + csType + " - " + csname);
    }
    $("#table5 tbody").append("<tr><td><input type='checkbox' checked='checked' name='checkbox_cs' value='" + rowindex + "|" + csid + "'></td><td><input  value='" + csname + "' name='checkbox_name_" + rowindex + "' style='width: 250px;' /></td></tr>");
    rowindex++;
}
/*添加试卷*/
function GetQA() {
    $("#qatishi").show();
    var inputvalue = $.trim($("#QuesNaire").val());
    $.get("/Training/plan/GetExamPlan.ashx", { key: inputvalue },
                          function (data) {
                              $("#qatishi").html(data);
                          });
}

function SelectedExam(ExamId, ExamPlan_Name) {
    $("#qalist").show();
    $("#table6 tbody").append("<tr><td><input type='checkbox' checked='checked' name='checkbox_qa' value='" + qarowindex + "|" + ExamId + "'></td><td><input  value='" + ExamPlan_Name + "' name='checkbox_name_qa_" + qarowindex + "' style='width: 300px;' /></td></tr>");
    qarowindex++;
    $("#qatishi").hide();
}

/*添加自定义商品*/
function GetShop() {
    $("#shoptishi").show();
    var inputvalue = $.trim($("#ShopTxt").val());
    $.get("GetAppendShop.ashx", { key: inputvalue },
                          function (data) {
                              $("#shoptishi").html(data);

                          });
}
var shoprowindex = 1;
function SelectShop(ShopId, ShopName) {
    $("#qatishi").show();

    $("#table7 tbody").append("<tr><td><input type='checkbox' checked='checked' name='checkbox_shop' value='" + shoprowindex + "|" + ShopId + "'></td><td><input  value='" + ShopName + "' name='checkbox_name_shop_" + shoprowindex + "' style='width: 300px;' /></td></tr>");
    shoprowindex++;
    $("#shoptishi").hide();
}
/*添加章节练习*/
function GetChapShow() {
    $("#TypeDiv").show();
}
var Menu_Id = '';
function GetClickTableValue() {
    $('table tr').not('#td').click(function () {
        $(this).find('td').each(function (i) {
            if (i == 1) {
                Menu_Id = $(this).text();
            }
        });
    });
    $("#dnd-example").treeTable({
        initialState: "collapsed" //collapsed 收缩 expanded展开的
    });
}
var Chaprowindex = 1;
function OnChapSelect(obj) {
    var arrayObj = new Array();
    //arrayObj[0] = obj;
    var i = 0;
    ///循环所有 获取tr
    $("#chapList").find("tr").each(
    function () {
        if ($(this).attr("id").indexOf($(obj).attr("id") + "-") >= 0 || $(this).attr("id") == $(obj).attr("id")) {
            ///获取所有id
            arrayObj[i] = $(this);
            i++;
        }
    });
    for (var i = 0; i < arrayObj.length; i++) {
        addChapList(arrayObj[i].children('td').eq(1).html(), arrayObj[i].children('td').eq(0).children(".folder").html());
    }
}
function addChapList(chapid, chapnane) {
    $("#chapshowlist").show();
    $("#table8 tbody").append("<tr><td><input type='checkbox' checked='checked' name='checkbox_chap' value='" + Chaprowindex + "|" + chapid + "'></td><td><input  value='" + chapnane + "' name='checkbox_name_chap_" + Chaprowindex + "' style='width: 300px;' /></td></tr>");
    Chaprowindex++;
}
