function SelectType(obj) {
    var TypeCount = document.getElementsByName(obj.id);
    var s;
    if (navigator.appName == "Microsoft Internet Explorer") {
        s = TypeCount[1].checked;
    }
    else {
        s = TypeCount[0].checked;
    }

    if (s) {
        DianCMS_$("Type_1").style.display = "none";
    }
    else {
        DianCMS_$("Type_1").style.display = "";
    }
}
function Exists() {
    var v = DianCMS_$("txtNumber").value;
    D.Exam.BLL.B_ExamPaper.ExistsNumber(v, CallBack);
}

function CallBack(v) {
    $.dialog.alert(v.value, function() {
    }); 
}

function ThemeType(obj) {
    var TypeCount = document.getElementsByName(obj.id);
    var p = 0;
    if (navigator.appName == "Microsoft Internet Explorer") {
        p = 1;
    }
    for (var i = p; i < TypeCount.length; i++) {
        if (TypeCount[i].checked) {
            switch (TypeCount[i].value) {
                case "3":
                    DianCMS_$("DivLess").style.display = "";
                    DianCMS_$("ValueName").innerHTML = "每题分值";
                    DianCMS_$("DivKongNum").style.display = "none";
                    break;
                case "4":
                    DianCMS_$("ValueName").innerHTML = "每空分值";
                    DianCMS_$("DivLess").style.display = "none";
                    DianCMS_$("DivKongNum").style.display = "";
                    break;
                default:
                    DianCMS_$("DivLess").style.display = "none";
                    DianCMS_$("ValueName").innerHTML = "每题分值";
                    DianCMS_$("DivKongNum").style.display = "none";
                    break;
            }
        }
    }
}

function ThemeSource(obj) {
    var TypeCount = document.getElementsByName(obj.id);
    var p = 0;
    if (navigator.appName == "Microsoft Internet Explorer") {
        p = 1;
    }
    for (var i = p; i < TypeCount.length; i++) {
        if (TypeCount[i].checked) {
            switch (TypeCount[i].value) {
                case "1":
                    DianCMS_$("Tab1").style.display = "";
                    DianCMS_$("Tab2").style.display = "none";
                    break;
                case "2":
                case "3":
                    DianCMS_$("Tab1").style.display = "none";
                    DianCMS_$("Tab2").style.display = "";
                    break;
            }
        }
    }
}

function UseTitle(v) {
    switch (v) {
        case "1":
            DianCMS_$("txtTitle").value = "单项选择题(下列各题的备选答案中，请从中选出一个最符合题意的答案。本类题共10个，每小题1分，共10分。错选、不选均不得分。)";
            break;
        case "2":
            DianCMS_$("txtTitle").value = "多项选择题(下列各题中，分别有两个或两个以上符合题意的正确答案。本类题共10小题，每小题1分，共10分。多选、少选或错选均不得分。)";
            break;
        case "3":
            DianCMS_$("txtTitle").value = "判断题(判断以下各题的对错，认为正确的选“√”，认为错误的选“×”。判断结果错误、不判断的均不得分。)";
            break;
        case "4":
            DianCMS_$("txtTitle").value = "不定项选择题(每题给出四个选项，选项中有一个或一个以上的正确答案。多选、少选或不选均不得分。)";
            break;
        case "5":
            DianCMS_$("txtTitle").value = "填空题(在下列各题的空格中填入正确的答案。本类题共10小题，每小题1分，共10分。不填、填错均不得分。)";
            break;
        case "6":
            DianCMS_$("txtTitle").value = "名词解释题(本大题共5小题，每小题3分，共15分)";
            break;
        case "7":
            DianCMS_$("txtTitle").value = "简答题(本大题共5小题，每小题6分，共30分)";
            break;
        case "8":
            DianCMS_$("txtTitle").value = "论述题(本大题共2小题，每小题10分，共20分)";
            break;
    }
}

function SelectTheme(adminFolder, CssName) {
    var TypeCount = document.getElementsByName("RadThemeType");
    var p = 0;
    if (navigator.appName == "Microsoft Internet Explorer") {
        p = 1;
    }
    var t;
    for (var i = p; i < TypeCount.length; i++) {
        if (TypeCount[i].checked) {
            t = TypeCount[i].value;
            break;
        }
    }

    WinOpenLhgDialog('选择试题', '../../' + adminFolder + '/exam/selecttheme.aspx?t=' + t + '&ControlId=txtThemeId', 800, 400, '' + CssName + '');
}

/*添加试题*/
function SelFieldType() {
    var TypeCount = document.getElementsByName("RadQuestionType");
    var p = 0;
    if (navigator.appName == "Microsoft Internet Explorer") {
        p = 1;
    }

    for (var i = p; i < TypeCount.length; i++) {
        var DivType = eval("Div" + TypeCount[i].value);

        if (TypeCount[i].checked) {
            DivType.style.display = "";
        }
        else {
            DivType.style.display = "none";
        }
    }
}
function CheckQuestion() {
    var q = DianCMS_$("txtQuestion").value;
    if (q.length == 0) {
        $.dialog.alert('题目名称不能够为空', function() {
            DianCMS_$("txtQuestion").focus();
        });
        return false;
    }
    else {
        D.Exam.BLL.B_Theme.CheckExists(q, ThemeCallBack);
    }
}

function ThemeCallBack(res) {
    $.dialog.alert(res.value, function() {
    }); 
}