var IsPostionValue = $("#IsPostionValue").val();


//设置页面大小
function ChangePageSize(obj) {
    $(".main_papermain").width(obj.value);
}

//设定全卷遮挡区域
function SetHideArea() {
    var html = "";
    html += "<div class=\"main_tabletop hidearea\" style='top:100px;width:400px;'>";
    html += "            <div class=\"hidetext\">屏蔽显示区</div>";
    html += "            <div class=\"hideareaclose\" onclick=\"CloseHideArea(this)\">X</div>";
    html += "</div>";
    $(".main_papermain").append(html);
    $(".hidearea").draggable({ containment: ".main_papermain" });
    $(".hidearea").resizable({ containment: ".main_papermain", handles: 'all' });//设置缩放
}
//删除全屏遮挡区域
function CloseHideArea(obj) {
    $(obj).parent().remove();
}

///设置锚点
function SetMao(obj, index) {
    if (IsPostionValue == "False") {
        alert("无法设置定位点，请修改主模板数据.");
        return;
    }
    if ($(obj).attr("class") == "maodian_hover") {
        $("#draggable_" + index).remove();
        $(obj).attr("class", "maodian");
        return;
    }
    var style = "";
    var pright = parseInt($(".main_papermain").width()) - 120;
    var pheight = parseInt($(".main_papermain").height()) - 100;
    if (index == 0) {
        style = "left:60px; top:40px;"
    }

    if (index == 1) {
        style = "left:" + pright + "px; top:30px;"
    }
    if (index == 2) {
        style = "left:60px; top:" + pheight + "px;"
    }
    if (index == 3) {
        style = "left:" + pright + "px; top:" + pheight + "px;"
    }
    $(obj).attr("class", "maodian_hover");

    $(".main_papermain").append("<div class='main_tabletop' style='cursor: move;width:75px;height:75px;" + style + "' id='draggable_" + index + "'>" + $(obj).html() + "</div>");


    $("#draggable_" + index).draggable({ containment: ".main_papermain" });
    $("#draggable_" + index).resizable({ containment: ".main_papermain", handles: 'all' });//设置缩放
}
///设置锚点
///设置学号
function SetXuehao(obj) {
    if ($(obj).attr("class") == "main_select_set_hover") {
        $("#xuehaoTable").remove();
        $(obj).attr("class", "main_select_set");
        return;
    }
    $(obj).attr("class", "main_select_set_hover");
    var num = $("#xuehaonum").val();
    var html = "<table class='xuehaotable_list' listNum='" + num + "' cellpadding=\"0\" cellspacing=\"0\">";
    for (var i = 0; i < 10; i++) {
        html += "<tr>";
        for (var j = 0; j < num; j++) {
            html += "<td></td>";
        }
        html += "</tr>";
    }
    html += "</table>";

    $(".main_papermain").append("<div id=\"xuehaoTable\"  listNum='" + num + "' class='main_tabletop' style='width:300px; height:200px;cursor: move;'>" + html + "</div>");
    $("#xuehaoTable").draggable({ containment: ".main_papermain" });
    $("#xuehaoTable").resizable({ containment: ".main_papermain", handles: 'all' });//设置缩放
}
//设置学号


/////////设置客观题//////////////////
function SetKeguanTi() {
    var tihao = $("#tihao").val().toUpperCase().replace(".", "·").replace("(", "（").replace(")", "）").replace(")", "）").replace("=", "＝").replace("@", "＠");//题号
    var tihao_end = $("#tihao_end").val().toUpperCase().replace(".", "·").replace("(", "（").replace(")", "）").replace(")", "）").replace("=", "＝").replace("@", "＠");
    var tihaoM = tihao + "-" + tihao_end;

    var score = $("#questionscroe").val();
    var tihaoList = tihaoM.toString().split('-');

    if (tihaoList.length != 2) {
        alert("题号规则错误，请重新输入");
        return;
    }



    if (document.getElementById("keguan_" + tihaoM) != undefined) {
        alert("题目配置重复:" + tihaoM);
        return;
    }

    var rd_listtype = document.getElementsByName("listtype");//题目横竖向
    var listtype = 0;
    var selectNum = $("#selectNum").val();

    for (var i = 0; i < rd_listtype.length; i++) {
        if (rd_listtype[i].checked) {
            listtype = rd_listtype[i].value;
        }
    }

    var questiontype = $("#questiontype").val();

    var startnum = parseInt(tihaoList[0]);
    var endnum = parseInt(tihaoList[1]);
    if (endnum == undefined) {
        endnum = startnum;
    }
    var html = "<table class='keguan_list' cellpadding=\"0\"  style='background:#ff3300;' cellspacing=\"0\">";

    var BigTihao = "";
    if (tihao.indexOf('M') > -1) {
        BigTihao = tihaoList[0].split('M')[0] + "M";
        startnum = tihaoList[0].split('M')[1];
        endnum = tihaoList[1].split('M')[1];
    }

    if (listtype == 0)//横向
    {
        for (var i = parseInt(startnum); i <= parseInt(endnum); i++) {

            html += "<tr>";
            for (var j = 0; j < selectNum; j++) {
                html += "<td></td>";
            }
            html += "</tr>";
        }
    }
    else {//竖向
        for (var i = 0; i < selectNum; i++) {
            html += "<tr>";
            for (var j = startnum; j <= endnum; j++) {
                html += "<td></td>";
            }
            html += "</tr>";
        }
    }
    html += "</table>";
    var selectMore = 0;

    var questionHtml = "单选题";
    if (questiontype == 1) {
        questionHtml = "多选题";
    }
    if (questiontype == 2) {
        questionHtml = "判断";
    }

    $(".main_papermain").append("<div id=\"keguan_" + tihao + "\" class='main_tabletop keguanti' questiontype='" + questiontype + "' tihaovalue='" + tihao + "' startnum='" + BigTihao + "" + startnum + "' endNum='" + BigTihao + "" + endnum + "'  selectNum='" + selectNum + "' listtype='" + listtype + "' score='" + score + "' style='cursor: move;width:200px;background:none; left:100px; top:" + (100 + $(document).scrollTop()) + "px; height:140px'><div style=\" float:left; width:auto; text-align:center; height:30px;  position:absolute; margin-top:-30px;z-index:22; color:#fff; line-height:30px; background:#666;\">" + tihaoM + "</div>" + html + "</div>");
    $("#keguan_" + tihao).draggable({ containment: ".main_papermain" });
    $("#keguan_" + tihao).resizable({ containment: ".main_papermain", handles: 'all' });//设置缩放
    var listtypeText = listtype == 0 ? "横向" : "竖向";
    $("#NowSelect").append("<li style='background:#fff;' id='selectNow_" + tihao + "' ><div class='sp'><div class='go'>" + questionHtml + "</div></div><div class='sf'>" + tihaoM + "</div> <div class='sm'>" + selectNum + "</div><div class='sx'>" + listtypeText + "</div><div class='ss' idAtt='keguan_" + tihao + "' onclick=\"UpdateBaseData(1,'" + score + "','" + tihao + "','客观题')\">" + score + "</div><div class='sd' onclick=\"DeleteKeguanti('" + tihao + "')\">x</div></li>");

}
function DeleteKeguanti(tihao) {
    $("#keguan_" + tihao).remove();
    $("#selectNow_" + tihao).remove();
    $("#pyti_" + tihao).remove();
    if (tihao.indexOf('X') > -1) {
        $("#pyti_" + tihao.split('X')[0]).remove();
    }
    GetZhuguantiScoreList();
}
/////////设置客观题/////////////

/////////////////设置主观题//////////////////////

function SetZhuguanTi() {

    var zhuguan_tihao = $("#zhuguan_tihao").val().toUpperCase().replace(".", "·").replace("(", "（").replace(")", "）").replace(")", "）").replace("=", "＝").replace("@", "＠");

    if (zhuguan_tihao == "") {
        alert("主观题 题号不能为空");
        return;
    }
    var score = $("#zgquestionscroe").val();
    var scoretype = $("#questionscroetype").val();
    var questiontype_zg = $("#questiontype_zg").val();
    //var scoretypeText = scoretype == "1" ? "全分" : "半分";
    var scoretypeText = scoretype;

    if (document.getElementById("keguan_" + zhuguan_tihao) != undefined) {
        alert("0题目配置重复:" + zhuguan_tihao);
        return;
    }
    var zhuguan_xiaoti = $("#zhuguan_xiaoti").val();
    if (zhuguan_xiaoti == "") {
        zhuguan_xiaoti = "0";
    }
    var lineWh = "width:450px;height:250px;";
    var lineWhTx = "大题";
    if (questiontype_zg == "2") {
        var lineWh = "width:200px;height:90px;";
        lineWhTx = "填空"
    }
    $(".main_papermain").append("<div id=\"keguan_" + zhuguan_tihao + "\"  class='main_tabletop zhuguanti' questiontype_zg='" + questiontype_zg + "'  tihaovalue='" + zhuguan_tihao + "' zhuguan_xiaoti='" + zhuguan_xiaoti + "' score='" + score + "' scoretype='" + scoretype + "'  style='" + lineWh + ";cursor: move;background:none; left:100px; top:" + (100 + $(document).scrollTop()) + "px;'><div style=\" float:left;  width:auto;text-align:center; height:30px;  position:absolute; margin-top:-30px;z-index:22; color:#fff; line-height:30px; background:#666;\">" + lineWhTx + "：" + zhuguan_tihao + "</div><div  style='width:100%;height:100%;background:#fff;border:1px solid red;'></div></div>");
    $("#keguan_" + zhuguan_tihao).draggable({ containment: ".main_papermain" });
    $("#keguan_" + zhuguan_tihao).resizable({ containment: ".main_papermain", handles: 'all' });

    $("#NowSelect").append("<li style='background:#fff;' id='selectNow_" + zhuguan_tihao + "'><div class='sp'><div class='go'>主观题</div></div><div class='sf'>" + zhuguan_tihao + "</div><div class='sm'>" + zhuguan_xiaoti + "</div><div class='ss' idAtt='keguan_" + zhuguan_tihao + "' id='ss_" + zhuguan_tihao + "'  onclick=\"UpdateBaseData(1,'" + score + "','" + zhuguan_tihao + "','主观题')\">" + score + "</div><div class='ssd' id='ssd_" + zhuguan_tihao + "' onclick=\"UpdateBaseData(2,'" + scoretype + "','" + zhuguan_tihao + "','主观题')\">" + scoretypeText + "</div><div class='sd' onclick=\"DeleteKeguanti('" + zhuguan_tihao + "')\">x</div></li>");
    //如果是手阅
    GetZhuguantiScoreList();
}
////////////////设置主观题//////////////////////


/////////////////设置条码识别区//////////////////////

function SetTiaoMa(obj) {
    if ($(obj).attr("class") == "tiaomasz_hover") {
        $(obj).attr("class", "tiaomasz");
        DeleteKeguanti('tiaomashibie');
        return;
    }
    else {
        $(obj).attr("class", "tiaomasz_hover");
    }
    $(".main_papermain").append("<div id=\"keguan_tiaomashibie\"  class='main_tabletop'  style='cursor: move;width:200px;background:none; left:100px; top:200px; height:80px'><div style=\" float:left;  width:auto; text-align:center; height:30px;  position:absolute; margin-top:-30px;z-index:22; color:#fff; line-height:30px; background:#666;\">条码</div><div  style='width:100%;height:100%;background:#fff;border:1px solid red;'></div></div>");
    setTimeout(function () {
        $("#keguan_tiaomashibie").draggable({ containment: ".main_papermain" });
        $("#keguan_tiaomashibie").resizable({ containment: ".main_papermain", handles: 'all' });
    }, 500);

}

////////////////设置条码识别区//////////////////////


/////////////////准考证号识别区//////////////////////

function SetZunkaoZheng() {
    if (document.getElementById("zhunkaozhenghaoshibie") != undefined) {
        alert("准考证号配置重复");
        return;
    }
    $(".main_papermain").append("<div id=\"keguan_zhunkaozhenghaoshibie\"  class='main_tabletop'  style='width:300px;background:none; left:100px; top:200px; height:200px'><div style=\" float:left; width:auto; text-align:center; height:30px;  position:absolute; margin-top:-30px;z-index:22; color:#fff; line-height:30px; background:#666;\">准考证号</div><div  style='width:100%;height:100%;background:#fff;border:1px solid red;'></div></div>");
    $("#keguan_zhunkaozhenghaoshibie").draggable({ containment: ".main_papermain" });
    $("#keguan_zhunkaozhenghaoshibie").resizable({ containment: ".main_papermain", handles: 'all' });
    $("#NowSelect").append("<li  id='selectNow_zhunkaozhenghaoshibie'  >准考证号<span onclick=\"DeleteKeguanti('zhunkaozhenghaoshibie')\">删除</span></li>");
}

////////////////准考证号识别区//////////////////////





/////////////////设置缺考标记//////////////////////

function SetWenziQuyu(obj) {
    var zhuguan_tihao = "缺考";
    if ($(obj).attr("class") == "quelapsz_hover") {
        $(obj).attr("class", "quelapsz");
        DeleteKeguanti(zhuguan_tihao);
        return;
    }
    else {
        $(obj).attr("class", "quelapsz_hover");
    }

    if (document.getElementById("keguan_" + zhuguan_tihao) != undefined) {
        alert("缺考已标记");
        return;
    }
    $(".main_papermain").append("<div id=\"keguan_" + zhuguan_tihao + "\" class='main_tabletop wenzimiaoshu'  wenzimiaoshu='" + zhuguan_tihao + "' style='width:80px;background:none; left:100px; top:200px; height:60px'><div style=\" float:left; width:auto; text-align:center; height:30px;  position:absolute; margin-top:-30px;z-index:22; color:#fff; line-height:30px; background:#666;\">" + zhuguan_tihao + "</div><div  style='width:100%;height:100%;background:#fff;border:1px solid red;'></div></div>");
    $("#keguan_" + zhuguan_tihao).draggable({ containment: ".main_papermain" });
    $("#keguan_" + zhuguan_tihao).resizable({ containment: ".main_papermain", handles: 'all' });
}


////////////////设置文字区域//////////////////////

/////////////////设置标准店//////////////////////

function SetBiaoZhunDian(obj) {
    var zhuguan_tihao = "标准点";

    if ($(obj).attr("class") == "biaozhundian_hover") {
        $(obj).attr("class", "biaozhundian");
        DeleteKeguanti(zhuguan_tihao);
        return;
    }
    else {
        $(obj).attr("class", "biaozhundian_hover");
    }
    if (document.getElementById("keguan_" + zhuguan_tihao) != undefined) {
        alert("标准点已标记");
        return;
    }
    $(".main_papermain").append("<div id=\"keguan_" + zhuguan_tihao + "\" class='main_tabletop biaozhundian_select'  wenzimiaoshu='" + zhuguan_tihao + "' style='width:80px;background:none; left:100px; top:200px; height:30px'><div style=\" float:left; width:auto; text-align:center; height:30px;  position:absolute; margin-top:-30px;z-index:22; color:#fff; line-height:30px; background:#666;\">" + zhuguan_tihao + "</div><div  style='width:100%;height:100%;background:#fff;border:1px solid red;'></div></div>");
    $("#keguan_" + zhuguan_tihao).draggable({ containment: ".main_papermain" });
    $("#keguan_" + zhuguan_tihao).resizable({ containment: ".main_papermain", handles: 'all' });
}






////设置先批后阅//////
function SetPYPostion(type) {

    var py_tihao = $("#py_tihao").val();
    var isHaveX = false;
    if (document.getElementById("pyti_" + py_tihao) != null) {
        alert("已有先批后阅该主观题");
        return;
    }
    if (document.getElementById("keguan_" + py_tihao) == null) {
        if (document.getElementById("keguan_" + py_tihao + "X1") == null) {
            alert("找不到该主观题题号");
            return;
        }
        else {
            isHaveX = true;
        }
    }
    var lineWhTx = "填空题打分";
    var score = 0;

    if (isHaveX) {
        score = $("#keguan_" + py_tihao + "X1").attr("score");
        type = $("#keguan_" + py_tihao + "X1").attr("questiontype_zg");
    }
    else {
        score = $("#keguan_" + py_tihao).attr("score");
        type = $("#keguan_" + py_tihao).attr("questiontype_zg");
    }
    ///如果是填空题，批阅类型为0
    if (type == "2") {
        type = "0";
    }

    var lineWh = "width:35px;height:35px;";




    if (type == "") {
        type == "1";
    }


    if (type == 1) {
        lineWhTx = "主观题打分";
        lineWh = "width:736px;height:30px;";
    }

    if (score.indexOf(".") > -1) {
        alert("题目分数不能有小数点");
        return;
    }

    var html = "";

    html += "<div id=\"pyti_" + py_tihao + "\"  class='main_tabletop pyti' piyueType='" + type + "' tihaovalue='" + py_tihao + "'   score='" + score + "'  style='" + lineWh + ";background:none;font-size:11px; background:#ff3300; left:100px; top:" + (100 + $(document).scrollTop()) + "px;'>";
    html += "<div style =\" float:left;  width:auto;text-align:center;font-size:12px; min-width:150px; height:30px;  position:absolute; margin-top:-30px;z-index:22; color:#fff; line-height:30px; background:#666;\">" + lineWhTx + "：" + py_tihao + "<span style='float:right; margin-left:5px; background:#000;color:fff; padding-left:5px; padding-right:5px;' onclick=\"closepy_hi(this)\">x</span></div>";
    html += "<div  style = 'width:100%;height:100%;background:#fff;border:1px solid red;' >";
    html += "</div >";
    html += "</div > ";
    $(".main_papermain").append(html);
    $("#pyti_" + py_tihao).draggable({ containment: ".main_papermain" });
    $("#pyti_" + py_tihao).resizable({ containment: ".main_papermain", handles: 'all' });
    GetZhuguantiScoreList();
}

function closepy_hi(obj) {
    $(obj).parent().parent().remove();
    GetZhuguantiScoreList();
}
////设置先批后阅//////


///////////////////统计数据//////////////////////////
//获取锚点位置
function GetMaoPostion() {
    if ($(".maodian_hover").length == 0) {
        return "";
    }
    var xy = "";
    if ($(".maodian_hover").length == 4) {
        for (var i = 0; i < 4; i++) {
            xy += parseFloat($("#draggable_" + i).position().left) + "," + parseFloat($("#draggable_" + i).position().top) + "," + parseFloat($("#draggable_" + i).width()) + "," + parseFloat($("#draggable_" + i).height()) + "^";
        }
    }
    else {
        //alert("锚点未设置完成");
        return "";
    }
    if ($("#select_ishaspostion").val() == "0") {
        return "^";
    }
    return xy.trim('^');;
}

//获取学号数据
function GetXuehaoPostion() {
    if (document.getElementById("xuehaoTable") == undefined) {
        return "";
    }
    var xy = "";
    xy = parseFloat($("#xuehaoTable").position().left) + "," + parseFloat($("#xuehaoTable").position().top) + "," + parseFloat($("#xuehaoTable").width()) + "," + parseFloat($("#xuehaoTable").height()) + "," + $("#xuehaoTable").attr("listNum");
    return xy;
}
//获取客观题
function GetKeguanPostion() {
    if ($(".keguanti").length == 0) {
        return "";
    }
    var xy = "";
    $(".keguanti").each(function () {
        xy += parseFloat($(this).position().left) + "," + parseFloat($(this).position().top) + "," + parseFloat($(this).width()) + "," + parseFloat($(this).height()) + "," + $(this).attr("startnum") + "," + $(this).attr("endNum") + "," + $(this).attr("selectNum") + "," + $(this).attr("listtype") + "," + $(this).attr("questiontype") + "," + $(this).attr("score") + "^";
    })
    return xy.trim('^');
}

//获取主观题
function GetZhuguanPostion() {
    var xy = "";
    if ($(".zhuguanti").length == 0) {
        return "";
    }
    $(".zhuguanti").each(function () {
        xy += parseFloat($(this).position().left) + "," + parseFloat($(this).position().top) + "," + parseFloat($(this).width()) + "," + parseFloat($(this).height()) + "," + $(this).attr("tihaovalue") + "," + $(this).attr("zhuguan_xiaoti") + "," + $(this).attr("score") + "," + $(this).attr("scoretype") + "," + $(this).attr("questiontype_zg") + "^";
    })
    return xy.trim('^');
}
//获取条码
function GettiaomaPostion() {
    var xy = "";
    if (document.getElementById("keguan_tiaomashibie") == undefined) {
        return "";
    }
    xy += parseFloat($("#keguan_tiaomashibie").position().left) + "," + parseFloat($("#keguan_tiaomashibie").position().top) + "," + parseFloat($("#keguan_tiaomashibie").width()) + "," + parseFloat($("#keguan_tiaomashibie").height());
    return xy.trim('^');
}
//获取准考证号
function GetZKZHPostion() {
    var xy = "";
    if (document.getElementById("keguan_zhunkaozhenghaoshibie") == undefined) {
        return "";
    }
    xy += parseFloat($("#keguan_zhunkaozhenghaoshibie").position().left) + "," + parseFloat($("#keguan_zhunkaozhenghaoshibie").position().top) + "," + parseFloat($("#keguan_zhunkaozhenghaoshibie").width()) + "," + parseFloat($("#keguan_zhunkaozhenghaoshibie").height());
    return xy.trim('^');
}

//获取文字截获
function GetWenziPostion() {
    var xy = "";
    if ($(".wenzimiaoshu").length == 0) {
        return "";
    }
    $(".wenzimiaoshu").each(function () {
        xy += parseFloat($(this).position().left) + "," + parseFloat($(this).position().top) + "," + parseFloat($(this).width()) + "," + parseFloat($(this).height()) + "," + $(this).attr("wenzimiaoshu") + "^";
    })
    return xy.trim('^');
}

//获取标准点
function GetBiaoZhunDianPostion() {
    var xy = "";
    if ($(".biaozhundian_select").length == 0) {
        return "";
    }
    $(".biaozhundian_select").each(function () {
        xy += parseFloat($(this).position().left) + "," + parseFloat($(this).position().top) + "," + parseFloat($(this).width()) + "," + parseFloat($(this).height()) + "," + $(this).attr("wenzimiaoshu") + "^";
    })
    return xy.trim('^');
}


//获取屏蔽区数据
function GetHideAreaPostion() {
    var xy = "";
    if ($(".hidearea").length == 0) {
        return "";
    }
    var jsonstr = [];
    $(".hidearea").each(function () {
        xy += parseFloat($(this).position().left) + "," + parseFloat($(this).position().top) + "," + parseFloat($(this).width()) + "," + parseFloat($(this).height()) + "^";
        var json = {};
        json.width = parseFloat($(this).width());
        json.height = parseFloat($(this).height());
        json.left = parseFloat($(this).position().left);
        json.top = parseFloat($(this).position().top);
        jsonstr.push(json);
    })
    return JSON.stringify(jsonstr);
}
//获取先批后阅数学
function GetPyAreaPostion() {
    var xy = "";
    if ($(".pyti").length == 0) {
        return "";
    }
    $(".pyti").each(function () {
        xy += parseFloat($(this).position().left) + "," + parseFloat($(this).position().top) + "," + parseFloat($(this).width()) + "," + parseFloat($(this).height()) + "," + $(this).attr("tihaovalue") + "," + $(this).attr("score") + "," + $(this).attr("piyueType") + "^";
    })

    return xy.trim('^');
}



///////////////////统计数据//////////////////////////
function GetDataTotal(objvalue, tenant) {
    if ($("#hd_isHand").val() == "1") {
        if ($("#py_tihao").val() != "all") {
            alert("主观题有未批阅分数,请先配置好主观题分数选择框！");
            return;
        }
    }
   
    var maodian = GetMaoPostion();//左边距,右边距,长,高
    var xuehao = GetXuehaoPostion();//左边距,右边距,长,高,学号数量
    var keguanti = GetKeguanPostion(); //左边距,右边距,长,高,题号开始,题号结束,选择几项,横排还是竖排,单选多选或者判断
    var zhuguanti = GetZhuguanPostion();//左边距,右边距,长,高,题号,小题数量
    var wenzimiaoshu = GetWenziPostion();//左边距,右边距,长,高,文字描述
    var tiaoma = GettiaomaPostion();////左边距,右边距,长,高
    var zhunkaozhenghao = GetZKZHPostion();///获取准考证号识别区域
    var hideArea = GetHideAreaPostion();//获取屏蔽区数据
    var pytiArea = GetPyAreaPostion();//获取批阅条件
    var biaoZhunDian = GetBiaoZhunDianPostion();//设置标准点
    var UserID = $("#UserID").val();
    var roteX = rote;
    var BatchID = $("#BatchID").val();
    var GroupNo = $("#GroupNo").val();
    var selectPageSize = $("#selectPageSize").val();
    if (selectPageSize == null) {
        $("#selectPageSize").focus();
        alert("请选择版面");
        return;
    }

    if (document.getElementById("keguan_标准点") == undefined && $("#PageIndex").val() == "1") {
        alert("您尚未设置标准点,无法保存数据");
        return;
    }

    //if (document.getElementById("keguan_缺考") == undefined && $("#PageIndex").val() == "1") {
    //    if (confirm("您尚未设置缺考标记,无需设置点击取消按钮")) {
    //        return;
    //    }
    //}


    var PageIndex = $("#PageIndex").val();
    var MainTempId = $("#MainTempId").val();
    var WandH = parseFloat($("#SelectImg").width()) + "," + parseFloat($("#SelectImg").height());
    var totalHtml = maodian + "$" + xuehao + "$" + keguanti + "$" + zhuguanti + "$" + wenzimiaoshu + "$" + tiaoma + "$" + WandH + "$" + zhunkaozhenghao + "$" + pytiArea + "$" + biaoZhunDian;
    if (maodian == "") {
        //alert("必须设置4个锚点");
        //return;
    }
    if (objvalue == "1") {
        if (confirm("锁定模板后,仅可修改识别区域,无法增删主客观题！")) {
            $("#ansyButton").attr("disabled", "disabled");
            $("#ansyButton").attr("value", "正在更新数据");
            $.post("UserNoPostionTemp.aspx", { action: "2", rd: Math.round(), MainTempId: MainTempId, PageIndex: PageIndex, totalHtml: encodeURIComponent(totalHtml), TempID: $("#TempID").val(), HideAreaPostionList: encodeURIComponent(hideArea), tenant: tenant }, function (res) {
                if (res == "ok") {
                    $("#ansyButton").attr("disabled", "disabled");
                    $("#ansyButton").attr("value", "模板已锁定");
                    alert("数据更新成功");
                    LockFunction(1);
                }

                else {
                    $("#ansyButton").removeAttr("disabled");
                    $("#ansyButton").attr("value", "锁定模板");
                    alert(res + "更新失败");
                }
            })
        }
    }
    else {
        $("#noButtonK").attr("disabled", "disabled");
        $("#noButtonK").attr("value", "正在更新数据");
        $.post("UserNoPostionTemp.aspx", { action: "1", rd: Math.round(), GroupNo: GroupNo, BatchID: BatchID, UserID: UserID, MainTempId: MainTempId, PageIndex: PageIndex, totalHtml: encodeURIComponent(totalHtml), TempID: $("#TempID").val(), HideAreaPostionList: encodeURIComponent(hideArea), tenant: tenant, roteX: roteX.toFixed(2) }, function (res) {
            $("#noButtonK").removeAttr("disabled");
            $("#noButtonK").attr("value", "保存数据");
            if (res == "ok") {
                alert("数据更新成功");
            }
            else {

                alert(res + "或更新失败,定位点错误");
            }
        })
    }
}


///////////////////统计数据//////////////////////////


//初始化绑定数据
function BaseDataBind() {
    var Bindlist = $("#Bindlist").val()
    var list = Bindlist.split('$');
    var maodian = "";//左边距,右边距,长,高
    var xuehao = "";//左边距,右边距,长,高,学号数量
    var keguanti = ""; //左边距,右边距,长,高,题号开始,题号结束,横排还是竖排
    var zhuguanti = "";//左边距,右边距,长,高,题号,小题数量
    var wenzimiaoshu = "";//左边距,右边距,长,高,文字描述
    var tiaoma = "";//左边距,右边距,长,高,文字描述
    var pageWidth = "";
    var HideAreaText = $("#HideAreaText").val();
    var piyueList = "";
    var zhunkaozhenghao = "";
    var biaozhundian = "";
    if (Bindlist != "") {
        maodian = list[0].trim('^');//左边距,右边距,长,高
        xuehao = list[1].trim('^');//左边距,右边距,长,高,学号数量
        keguanti = list[2].trim('^'); //左边距,右边距,长,高,题号开始,题号结束,横排还是竖排
        zhuguanti = list[3].trim('^');//左边距,右边距,长,高,题号,小题数量
        wenzimiaoshu = list[4].trim('^');//左边距,右边距,长,高,文字描述
        tiaoma = list[5].toString().trim('^');//左边距,右边距,长,高,文字描述
        pageWidth = list[6].toString().trim('^').split(',')[0];
        if (list[7] != undefined) {
            zhunkaozhenghao = list[7].toString().trim('^');
        }
        if (list[8] != undefined) {
            piyueList = list[8].toString().trim('^');
        }
        if (list[9] != undefined) {
            biaozhundian = list[9].toString().trim('^');
        }
    }

    if (pageWidth == 1200 || pageWidth == 1199 || pageWidth == 1198 || pageWidth == 1201) {
        pageWidth = 1200;
    }
    if (pageWidth == 1570 || pageWidth == 1569 || pageWidth == 1571 || pageWidth == 1572 || pageWidth == 1573) {
        pageWidth = 1570;
    }

    //if(pageWidth==""){
    var pageType = $("#pager_A").val();
    if (pageType == "a3") {
        pageWidth = 1570;
    }
    else {
        pageWidth = 1200;
    }
    //}


    $(".main_papermain").width(pageWidth + "px");
    if ($("#pager_A").val() == "a3") {

        $("#selectPageSize").val("1570");
    }
    if ($("#pager_A").val() == "a4") {
        $("#selectPageSize").val("1200");
    }

   

    $("#selectPageSize").val(pageWidth);
    $("#selectPageSize").change();

    SetMaoPostion(maodian);
    SetXuehaoPostion(xuehao);
    SetKeguanTiPostion(keguanti);
    SetZhuguanTiPostion(zhuguanti);
    SetWenziQuyuPostion(wenzimiaoshu);
    SetTiaomaPostion(tiaoma);
    SetZhunkaozhengPostion(zhunkaozhenghao);
    SetHideAreaBind(HideAreaText);
    SetPyPostion(piyueList);
    GetZhuguantiScoreList();
    SetBiaoZhunDianPostion(biaozhundian);
}


/////////////////批阅//////////////////////
function SetPyPostion(PostionData) {
    //alert(PostionData);
    //  $(this).attr("tihaovalue") + "," + $(this).attr("score") + "," + $(this).attr("piyueType")+"^";

    if (PostionData == "" || PostionData == undefined) {
        return;
    }
    //左边距,右边距,长,高,题号,小题数量
    var listdata = PostionData.split('^');

    for (var i = 0; i < listdata.length; i++) {
        var zhuguanList = listdata[i].split(',');
        var py_tihao = zhuguanList[4];
        var score = zhuguanList[5] == undefined ? "" : zhuguanList[5];
        var type = zhuguanList[6] == undefined ? "1" : zhuguanList[6];





        var lineWhTx = "大题批阅";
        if (type == "0") {
            lineWhTx = "填空批阅"
        }
        var style = "";
        style = "left:" + zhuguanList[0] + "px; top: " + zhuguanList[1] + "px; width:" + zhuguanList[2] + "px;height:" + zhuguanList[3] + "px;";
        var html = "";
        html += "<div id=\"pyti_" + py_tihao + "\"  class='main_tabletop pyti' piyueType='" + type + "' tihaovalue='" + py_tihao + "'  score='" + score + "'  style='" + style + ";background:none;font-size:11px; background:yellow;'>";
        html += "<div style =\" float:left;  width:auto;text-align:center;font-size:12px; min-width:150px; height:30px;  position:absolute; margin-top:-30px;z-index:22; color:#fff; line-height:30px; background:#666;\">" + lineWhTx + "：" + py_tihao + "<span style='float:right; margin-left:5px; background:#000;color:fff; padding-left:5px; padding-right:5px;' onclick=\"closepy_hi(this)\">x</span></div>";
        html += "<div  style = 'width:100%;height:100%;background:yellow;border:1px solid red;' >";
        html += "</div >";
        html += "</div > ";
        $(".main_papermain").append(html);
        $("#pyti_" + py_tihao).draggable({ containment: ".main_papermain" });
        $("#pyti_" + py_tihao).resizable({ containment: ".main_papermain", handles: 'all' });



    }
}
////////////////设置主观题//////////////////////


//设置屏蔽区
function SetHideAreaBind(data) {
    if (data == "") {
        return;
    }
    var json = JSON.parse(data);
    var html = "";
    for (var i = 0; i < json.length; i++) {
        var style = "left:" + json[i].left + "px; top: " + json[i].top + "px; width:" + json[i].width + "px;height:" + json[i].height + "px;";
        html += "<div class=\"main_tabletop hidearea\" style='" + style + "'>";
        html += "            <div class=\"hidetext\">屏蔽显示区</div>";
        html += "            <div class=\"hideareaclose\" onclick=\"CloseHideArea(this)\">x</div>";
        html += "</div>";
    }
    $(".main_papermain").append(html);
    $(".hidearea").draggable({ containment: ".main_papermain" });
    $(".hidearea").resizable({ containment: ".main_papermain", handles: 'all' });//设置缩放
}

///设置锚点
function SetMaoPostion(postiondata) {
    //alert(postiondata);
    //alert(IsPostionValue);

    if ($("#select_ishaspostion").val() == "0") {
        IsPostionValue = "False";
    }
    if (postiondata == "") {
        if (IsPostionValue == "1" || IsPostionValue == "True") {
            SetMao(document.getElementById("point_0"), 0);
            SetMao(document.getElementById("point_1"), 1);
            SetMao(document.getElementById("point_2"), 2);
            SetMao(document.getElementById("point_3"), 3);
        }
        return;
    }
  


    if (IsPostionValue == "0" || IsPostionValue == "False") {
        $("#draggable_0").remove();
        $("#draggable_1").remove();
        $("#draggable_2").remove();
        $("#draggable_3").remove();
        return;
    }


    var list = postiondata.split('^');
    for (var i = 0; i < list.length; i++) {
        var obj = document.getElementById("point_" + i);
        //左边距,右边距,长,高
        if ($(obj).attr("class") == "maodian_hover") {
            $("#draggable_" + i).remove();
            $(obj).attr("class", "maodian");
            return;
        }
        var postionList = list[i].split(',');
        var style = "";
        style = "left:" + postionList[0] + "px; top: " + postionList[1] + "px; width:" + postionList[2] + "px;height:" + postionList[3] + "px;";
        $(obj).attr("class", "maodian_hover");
        $(".main_papermain").append("<div class='main_tabletop' style='" + style + "' id='draggable_" + i + "'>" + $(obj).html() + "</div>");
        $("#draggable_" + i).draggable({ containment: ".main_papermain" });
        $("#draggable_" + i).resizable({ containment: ".main_papermain", handles: 'all' });
    }
}

///设置学号
function SetXuehaoPostion(postionData) {
    if (postionData == "") {
        return;
    }
    var obj = document.getElementById("main_select_set");
    var postionList = postionData.split(',');
    if ($(obj).attr("class") == "main_select_set_hover") {
        $("#xuehaoTable").remove();
        $(obj).attr("class", "main_select_set");
        return;
    }
    //左边距,右边距,长,高,学号数量
    $(obj).attr("class", "main_select_set_hover");
    var num = postionList[4];
    $("#xuehaonum").val(num);
    var html = "<table class='xuehaotable_list' listNum='" + postionList[4] + "' cellpadding=\"0\" cellspacing=\"0\">";
    for (var i = 0; i < 10; i++) {
        html += "<tr>";
        for (var j = 0; j < num; j++) {
            html += "<td></td>";
        }
        html += "</tr>";
    }
    html += "</table>";
    $(".main_papermain").append("<div id=\"xuehaoTable\" listNum='" + num + "' class='main_tabletop' style='top:" + postionList[1] + "px; left:" + postionList[0] + "px;width:" + postionList[2] + "px; height:" + postionList[3] + "px'>" + html + "</div>");
    $("#xuehaoTable").draggable({ containment: ".main_papermain" });
    $("#xuehaoTable").resizable({ containment: ".main_papermain", handles: 'all' });//设置缩放
}
//设置学号

/////////设置客观题//////////////////
function SetKeguanTiPostion(PostionData) {
    if (PostionData == "") {
        return;
    }
    //左边距,右边距,长,高,题号开始,题号结束,横排还是竖排

    var listOption = PostionData.split('^')
    for (var jt = 0; jt < listOption.length; jt++) {
        var listpostion = listOption[jt].split(',');
        var tihao = listpostion[4].replace(".", "·").replace("(", "（").replace(")", "）").replace(")", "）").replace("=", "＝").replace("@", "＠") + "-" + listpostion[5].replace(".", "·").replace("(", "（").replace(")", "）").replace(")", "）").replace("=", "＝").replace("@", "＠");//题号

        if (document.getElementById("keguan_" + tihao) != undefined) {
            alert("题目配置重复:" + tihao);
            return;
        }
        var rd_listtype = document.getElementsByName("listtype");//题目横竖向
        var listtype = listpostion[7];
        var selectNum = listpostion[6];
        var questiontype = listpostion[8];
        var score = listpostion[9] == undefined ? "" : listpostion[9];
        for (var i = 0; i < rd_listtype.length; i++) {
            if (rd_listtype[i].value == listtype) {
                rd_listtype[i].checked
            }
        }


        var tihaolist = tihao.split('-');


        var startnum = tihaolist[0];
        var endnum = tihaolist[1];
        if (endnum == undefined) {
            endnum = startnum;
        }
        var BigTihao = "";
        if (tihao.indexOf('M') > -1) {
            BigTihao = tihaolist[0].split('M')[0] + "M";
            startnum = tihaolist[0].split('M')[1];
            endnum = tihaolist[1].split('M')[1];
        }
        var html = "<table class='keguan_list' cellpadding=\"0\"  style='background:#ff3300;' cellspacing=\"0\">";
        if (listtype == 0)//横向
        {

            for (var i = parseInt(startnum); i <= parseInt(endnum); i++) {

                html += "<tr>";
                for (var j = 0; j < selectNum; j++) {
                    html += "<td></td>";
                }
                html += "</tr>";
            }
        }
        else {//竖向
            for (var i = 0; i < selectNum; i++) {
                html += "<tr>";
                for (var j = parseInt(startnum); j <= parseInt(endnum); j++) {
                    html += "<td></td>";
                }
                html += "</tr>";
            }
        }
        html += "</table>";
        var questionHtml = "单选题";
        if (questiontype == 1) {
            questionHtml = "多选题";
        }
        if (questiontype == 2) {
            questionHtml = "判断";
        }

        $(".main_papermain").append("<div id=\"keguan_" + tihao + "\" questiontype=\"" + questiontype + "\" class='main_tabletop keguanti'  tihaovalue='" + tihao + "' startnum='" + BigTihao + "" + startnum + "' endNum='" + BigTihao + "" + endnum + "' score='" + score + "'  selectNum='" + selectNum + "' listtype='" + listtype + "' style='background:none; left:" + listpostion[0] + "px; top:" + listpostion[1] + "px;width:" + listpostion[2] + "px; height:" + listpostion[3] + "px'><div style=\" float:left; width:auto; text-align:center; height:30px;  position:absolute; margin-top:-30px;z-index:22; color:#fff; line-height:30px; background:#666;\">" + tihao + "</div>" + html + "</div>");
        $("#keguan_" + tihao).draggable({ containment: ".main_papermain" });
        $("#keguan_" + tihao).resizable({ containment: ".main_papermain", handles: 'all' });//设置缩放
        var listtypeText = listtype == 0 ? "横向" : "竖向";
        $("#NowSelect").append("<li style='background:#fff;' id='selectNow_" + tihao + "' ><div class='sp'><div class='go'>" + questionHtml + "</div></div><div class='sf'>" + tihao + "</div> <div class='sm'>" + selectNum + "</div><div class='sx'>" + listtypeText + "</div><div class='ss' id='ss_" + tihao + "' idAtt='keguan_" + tihao + "'  onclick=\"UpdateBaseData(1,'" + score + "','" + tihao + "','客观题')\">" + score + "</div><div class='sd' onclick=\"DeleteKeguanti('" + tihao + "')\">x</div></li>");
    }

}

/////////////////设置主观题//////////////////////
function SetZhuguanTiPostion(PostionData) {

    if (PostionData == "" || PostionData == undefined) {
        return;
    }
    //左边距,右边距,长,高,题号,小题数量
    var listdata = PostionData.split('^');

    for (var i = 0; i < listdata.length; i++) {
        var zhuguanList = listdata[i].split(',');
        var zhuguan_tihao = zhuguanList[4].toUpperCase().replace(".", "·").replace("(", "（").replace(")", "）").replace(")", "）").replace("=", "＝").replace("@", "＠");
        var score = zhuguanList[6] == undefined ? "" : zhuguanList[6];

        var scoretype = zhuguanList[7] == undefined ? "1" : zhuguanList[7];

        //var scoretypetext = scoretype;
        var scoretypetext = scoretype;
        var questiontype_zg = zhuguanList[8] == undefined ? "1" : zhuguanList[8];


        if (document.getElementById("keguan_" + zhuguan_tihao) != undefined && document.getElementById("keguan_" + zhuguan_tihao) != null) {
            alert("2题目配置重复:" + zhuguan_tihao);
            return;
        }
        var lineWhTx = "大题";
        if (questiontype_zg == "2") {
            lineWhTx = "填空"
        }
        var zhuguan_xiaoti = zhuguanList[5];
        $(".main_papermain").append("<div id=\"keguan_" + zhuguan_tihao + "\" class='main_tabletop zhuguanti' questiontype_zg='" + questiontype_zg + "' tihaovalue='" + zhuguan_tihao + "' zhuguan_xiaoti='" + zhuguan_xiaoti + "' score='" + score + "' scoretype='" + scoretype + "'  style='left:" + zhuguanList[0] + "px; top:" + zhuguanList[1] + "px;width:" + zhuguanList[2] + "px;height:" + zhuguanList[3] + "px; background:none; '><div style=\" float:left; width:auto; text-align:center; height:30px;  position:absolute; margin-top:-30px;z-index:22; color:#fff; line-height:30px; background:#666;\">" + lineWhTx + ":" + zhuguan_tihao + "</div><div  style='width:100%;height:100%;background:#fff;border:1px solid red;'></div></div>");
        $("#keguan_" + zhuguan_tihao).draggable({ containment: ".main_papermain" });
        $("#keguan_" + zhuguan_tihao).resizable({ containment: ".main_papermain", handles: 'all' });
        $("#NowSelect").append("<li style='background:#fff;' id='selectNow_" + zhuguan_tihao + "'><div class='sp'><div class='go'>主观题</div></div><div class='sf'>" + zhuguan_tihao + "</div><div class='sm'>" + zhuguan_xiaoti + "</div><div class='ss' id='ss_" + zhuguan_tihao + "' idAtt='keguan_" + zhuguan_tihao + "'  onclick=\"UpdateBaseData(1,'" + score + "','" + zhuguan_tihao + "','主观题')\">" + score + "</div><div class='ssd' id='ssd_" + zhuguan_tihao + "'  onclick=\"UpdateBaseData(2,'" + scoretype + "','" + zhuguan_tihao + "','主观题')\">" + scoretypetext + "</div><div class='sd' onclick=\"DeleteKeguanti('" + zhuguan_tihao + "')\">x</div></li>");
    }
}
////////////////设置主观题//////////////////////

/////////////////设置文字区域//////////////////////

function SetWenziQuyuPostion(PostionData) {
    if (PostionData == "" || PostionData == undefined) {
        return;
    }
    //左边距,右边距,长,高,题号,小题数量
    var listdata = PostionData.split('^');
    for (var i = 0; i < listdata.length; i++) {
        var zhuguanList = listdata[i].split(',');
        var zhuguan_tihao = zhuguanList[4];
        if (document.getElementById("keguan_缺考") != undefined) {
            alert("缺考配置重复");
            return;
        }
        $(".main_papermain").append("<div id=\"keguan_缺考\" class='main_tabletop wenzimiaoshu'   wenzimiaoshu='" + zhuguan_tihao + "'  style='left:" + zhuguanList[0] + "px; top:" + zhuguanList[1] + "px;width:" + zhuguanList[2] + "px;height:" + zhuguanList[3] + "px; background:none; '><div style=\" float:left; width:auto; text-align:center; height:30px;  position:absolute; margin-top:-30px;z-index:22; color:#fff; line-height:30px; background:#666;\">" + zhuguan_tihao + "</div><div  style='width:100%;height:100%;background:#fff;border:1px solid red;'></div></div>");
        $("#keguan_" + zhuguan_tihao).draggable({ containment: ".main_papermain" });
        $("#keguan_" + zhuguan_tihao).resizable({ containment: ".main_papermain", handles: 'all' });
        $(".quelapsz").attr("class", "quelapsz_hover");
    }
}


////////////////设置文字区域//////////////////////


/////////////////设置标准点//////////////////////

function SetBiaoZhunDianPostion(PostionData) {
    if (PostionData == "" || PostionData == undefined) {
        return;
    }
    //左边距,右边距,长,高,题号,小题数量
    var listdata = PostionData.split('^');
    for (var i = 0; i < listdata.length; i++) {
        var zhuguanList = listdata[i].split(',');
        var zhuguan_tihao = zhuguanList[4];
        if (document.getElementById("keguan_标准点") != undefined) {
            alert("标准点配置重复");
            return;
        }
        $(".main_papermain").append("<div id=\"keguan_标准点\" class='main_tabletop biaozhundian_select'   wenzimiaoshu='" + zhuguan_tihao + "'  style='left:" + zhuguanList[0] + "px; top:" + zhuguanList[1] + "px;width:" + zhuguanList[2] + "px;height:" + zhuguanList[3] + "px; background:none; '><div style=\" float:left; width:auto; text-align:center; height:30px;  position:absolute; margin-top:-30px;z-index:22; color:#fff; line-height:30px; background:#666;\">" + zhuguan_tihao + "</div><div  style='width:100%;height:100%;background:#fff;border:1px solid red;'></div></div>");
        $("#keguan_" + zhuguan_tihao).draggable({ containment: ".main_papermain" });
        $("#keguan_" + zhuguan_tihao).resizable({ containment: ".main_papermain", handles: 'all' });
        $(".biaozhundian").attr("class", "biaozhundian_hover");
    }
}

////////////////设置文字区域//////////////////////



/////////////////设置条码//////////////////////

function SetTiaomaPostion(PostionData) {

    if (PostionData == "") {
        return;
    }
    var zhuguanList = PostionData.split(',');
    $(".main_papermain").append("<div id=\"keguan_tiaomashibie\" class='main_tabletop'   style='left:" + zhuguanList[0] + "px; top:" + zhuguanList[1] + "px;width:" + zhuguanList[2] + "px;height:" + zhuguanList[3] + "px; background:none; '><div style=\" float:left; width:auto; text-align:center; height:30px;  position:absolute; margin-top:-30px;z-index:22; color:#fff; line-height:30px; background:#666;\">条码</div><div  style='width:100%;height:100%;background:#fff;border:1px solid red;'></div></div>");
    $(".tiaomasz").attr("class", "tiaomasz_hover");
    $("#keguan_tiaomashibie").resizable({ containment: ".main_papermain", handles: 'all' });
    $("#keguan_tiaomashibie").draggable({ containment: ".main_papermain" });
}


/////////////////设置准考证号//////////////////////

function SetZhunkaozhengPostion(PostionData) {
    if (PostionData == "") {
        return;
    }
    var zhuguanList = PostionData.split(',');
    $(".main_papermain").append("<div id=\"keguan_zhunkaozhenghaoshibie\" class='main_tabletop'   style='left:" + zhuguanList[0] + "px; top:" + zhuguanList[1] + "px;width:" + zhuguanList[2] + "px;height:" + zhuguanList[3] + "px; background:none; '><div style=\" float:left; width:auto; text-align:center; height:30px;  position:absolute; margin-top:-30px;z-index:22; color:#fff; line-height:30px; background:#666;\">准考证号</div><div  style='width:100%;height:100%;background:#fff;border:1px solid red;'></div></div>");
    $("#keguan_zhunkaozhenghaoshibie").draggable({ containment: ".main_papermain" });
    $("#keguan_zhunkaozhenghaoshibie").resizable({ containment: ".main_papermain", handles: 'all' });
    $("#NowSelect").append("<li id='selectNow_zhunkaozhenghaoshibie'>准考证号<span onclick=\"DeleteKeguanti('zhunkaozhenghaoshibie')\">删除</span></li>");
}


////////////////设置文字区域//////////////////////
//初始化绑定数据
BaseDataBind();

function LockFunction(flag) {
    var islocked = $("#isLocked").val();
    if (islocked == true || islocked == "True" || flag == 1) {
        $("#ansyButton").attr("disabled", "disabled");
        $("#ansyButton").attr("value", "模板已锁定");
        $(".sd").hide();
        $(".lockHide").hide();
    }

}
LockFunction();

var hd_isHand = $("#hd_isHand").val();
if (hd_isHand == 0) {
    $("#isHand_Py").hide();
}
//批阅判定
function GetZhuguantiScoreList() {
    if ($("#hd_isHand").val() == "1") {
        var py_tihao = "";
        var git = document.getElementById("py_tihao");
        var i = 0;
        var isallPY = true;
        var html = "";
        $(".zhuguanti").each(function () {
            var tihaovalue = $(this).attr("tihaovalue").toUpperCase();
            //如果有分割

            if (tihaovalue.indexOf("X") > -1) {
                var mx = tihaovalue.split('X');
                if (mx[1] != 1) {
                    return true;
                }
            }
            var isok = true;

            if ($(".pyti").each(function () {
                if ($(this).attr("tihaovalue") == tihaovalue) {
                    isok = false;
                }
            }))
                if (isok) {
                    if (tihaovalue.indexOf("X") > -1) {
                        html += "<option value='" + tihaovalue.split('X')[0] + "'>" + "主观题" + tihaovalue.split('X')[0] + "</option>";
                    }
                    else {
                        html += "<option value='" + tihaovalue + "'>" + "主观题" + tihaovalue + "</option>";
                    }

                    // git.options[i] = new Option("主观题" + tihaovalue, tihaovalue);
                    isallPY = false;
                }
            i++;
        })
        if (isallPY) {
            $("#py_tihao").html("<option value='all'>全部配置完成</option>");
            $("#pytimups").attr("disabled", "disabled");
        }
        else {
            $("#py_tihao").html(html);
            $("#pytimups").removeAttr("disabled");
        }

    }
}



function UpdateBaseData(type, score, selectID, title) {
    $("#scoreShow").hide();
    $("#dfxShow").hide();
    $("#git_fix").val(score);
    $("#TiMU_num").val(selectID);
    $("#TiMU_Type").val(type);
    //客观题
    if (type == 1) {
        $("#git_fix").val(score);
        $("#scoreShow").show();
    }
    if (type == 2) {
        $("#git_sd_fix").val(score);
        $("#dfxShow").show();
    }
    $("#divbig_title").html(title + ":" + selectID)
    $(".backgroundGo").show(500);
}

function GoChange() {
    var selectID = $("#TiMU_num").val();
    var type = $("#TiMU_Type").val();
    var score = $("#git_fix").val();
    var sdscore = $("#git_sd_fix").val();
    if (type == "1") {
        $("#ss_" + selectID).html(score);
        $("#keguan_" + selectID).attr("score", score);
    }

    if (type == "2") {
        if (sdscore == "0") {
            //$("#ssd_" + selectID).html("半分");
        }
        else {
            //$("#ssd_" + selectID).html("全分");
        }
        $("#ssd_" + selectID).html(sdscore);
        $("#keguan_" + selectID).attr("scoretype", sdscore);
    }


    DeleteUpdateBaseData();
}

function DeleteUpdateBaseData() {
    $(".backgroundGo").hide(500);
}

//扩展方法
String.prototype.trim = function (char, type) {
    if (char) {
        if (type == 'left') {
            return this.replace(new RegExp('^\\' + char + '+', 'g'), '');
        } else if (type == 'right') {
            return this.replace(new RegExp('\\' + char + '+$', 'g'), '');
        }
        return this.replace(new RegExp('^\\' + char + '+|\\' + char + '+$', 'g'), '');
    }
    return this.replace(/^\s+|\s+$/g, '');
};

//////////// 切换页数 ////////////////
function ChangePageNum(anotherTempID) {
    //if (confirm("当前页未保存，是否继续切换？")){
        var currentURL = window.location.href;
        var newUrl = currentURL.replace(/(TempID=)\d+/, "$1" + anotherTempID);
        window.location.href = newUrl;
    //}

}