function SelectKT()
{
    var info="您确实要选择此课题吗？请注意，选择后您将无法更换！";
    if(UsConfirm(info))
    {
        return true;
    }
    else
    {
        return false;
    }
}


//################################################
//代码功能：打开模式窗口
//编写时间：2013-03-12
//################################################
function UsOpenDialogTree(para, src) {
    var url = "/admin/exam/exambasetree.aspx" + para;
    var res;
    res = showModalDialog(url, 'sky2013', 'dialogWidth: 300px; dialogHeight: 500px; center: yes; resizable: no; scroll: no; status: no;');
    if (res == undefined) {
        window.alert("系统提示您：您没有选择相关需要的信息！");
    }
    else {
        try {
            //alert(res);
            var strs = res.split("#")
            var m = $id(src)
            m.title = strs[0];
            m.value = strs[1];

            var m1 = $id("txtSIDList")
            m1.value = strs[0];
            jsShowCount(strs[0]);
        }
        catch (e) {
            alert(e);
        }
    }
}

//################################################
//代码功能：打开模式窗口
//编写时间：2013-03-12
//################################################
function UsOpenDialogTree(paraurl, src, txtValue) {
    var url = paraurl;
    var res;
    res = showModalDialog(url, 'careff2013', 'dialogWidth: 300px; dialogHeight: 500px; center: yes; resizable: no; scroll: no; status: no;');
    if (res == undefined) {
        window.alert("系统提示您：您没有选择相关需要的信息！");
    }
    else {
        try {
            //alert(res);
            var strs = res.split("#")
            var m = $id(src)
            //m.title = strs[0];
            m.value = strs[1];
            var m1 = $id(txtValue)
            m1.value = strs[0];
        }
        catch (e) {
            alert(e);
        }
    }
}


//################################################
//代码功能：打开模式窗口,选择试卷
//编写时间：2013-03-19
//################################################
function UsOpenDialogexampaper(para, src,srcname) {
    var url = "/admin/exam/exampaperlistselect.aspx" + para;
    var res;
    res = showModalDialog(url, 'sky2013', 'dialogWidth: 1120px; dialogHeight: 600px; center: yes; resizable: no; scroll: no; status: no;');
    if (res == undefined) {
        window.alert("系统提示您：您没有选择相关需要的信息！");
    }
    else {
        try {
            //alert(res);
            var strs = res.split("#")
            var m = $id(src)
            m.value = strs[0];

            var m1 = $id(srcname)
            m1.value = strs[1];
        }
        catch (e) {
            alert(e);
        }
    }
}


//################################################
//代码功能：防止非法打开
//编写时间：2013-08-28
//################################################
function UsURLNoSrc() {
    try {
        var srcURL = window.opener.location;
        var doURL = document.domain.toString();

        var strObj = new String(srcURL);
        if (strObj.indexOf(doURL) < 0) {
            //window.location.href = "/";
        }
    }
    catch (err) {
        //在此处理错误
        //window.close();
        //alert(err);
        //window.location.href = "/";
    }


}

//document.writeln("<script language='javascript' src='/editor/xheditor_lang/zh-cn.js'></script>");

//careff.com
//2014-10-25  我的文档功能完善
function SkyOpen2014(txt) {
    SkyOpen2014(txt, "");
}

function SkyOpen2014(txt) {
    if ($("#careff_mdiv").length <= 0) {
        $(document.body).append("<div id='careff_main'><iframe src='' id='selectfile' frameborder='0' width='100%' height='100%'></iframe></div><div id='careff_mdiv'></div>");
    }
    $('#careff_mdiv').show();
    $('#careff_main').show();
    $('#selectfile').attr("src", "../document/uploadone.aspx?id=" + txt);

    var left = ($(window).width() - $('#careff_main').outerWidth()) / 2;
    var top = ($(window).height() - $('#careff_main').outerHeight()) / 2 + $(document).scrollTop();

    if (left < 0) {
        left = 0;
    }
    if (top < 0) {
        top = 0;
    }
    $('#careff_main').css({
        position: 'absolute',
        left: left,
        top: top
    });

    $('#careff_mdiv').css({
        position: 'absolute',
        left: 0,
        top: 0,
        width: $(window).width(),
        height: $(window).height()
    });
}

function SkyOpenUploadMuti(txt) {
    //alert(txt);
    var path = document.getElementById(txt).value;
    if ($("#careff_mdiv").length <= 0) {
        $(document.body).append("<div id='careff_mainmul'><iframe src='' id='selectfile' frameborder='0' width='100%' height='100%'></iframe></div><div id='careff_mdiv'></div>");
    }
    $('#careff_mdiv').show();
    $('#careff_mainmul').show();
    $('#selectfile').attr("src", "/admin/document/uploadmulti.aspx?path=" + path);

    var left = ($(window).width() - $('#careff_mainmul').outerWidth()) / 2;
    var top = ($(window).height() - $('#careff_mainmul').outerHeight()) / 2 ;

    if (left < 0)
    {
        left = 0;
    }
    if (top < 0)
    {
        top = 0;
    }

    //alert($(window).width() + "," + $(window).height());

    //alert($('#careff_mainmul').outerWidth() + "," + $('#careff_mainmul').outerHeight());
    //top = 20;

    //alert(left + "," + top);
    $('#careff_mainmul').css({
        position: 'absolute',
        left: left,
        top: top
    });

    $('#careff_mdiv').css({
        position: 'absolute',
        left: 0,
        top: 0,
        width: $(window).width(),
        height: $(window).height()
    });
    return false;
}

function SkyOpenUploadMuticourseware(txt) {
    //alert(txt);
    var path = document.getElementById(txt).value;
    var pID = $('#' + txt).attr("title");
    if ($("#careff_mdiv").length <= 0) {
        $(document.body).append("<div id='careff_mainmul'><iframe src='' id='selectfile' frameborder='0' width='100%' height='100%'></iframe></div><div id='careff_mdiv'></div>");
    }
    $('#careff_mdiv').show();
    $('#careff_mainmul').show();
    $('#selectfile').attr("src", "../document/uploadmulticourseware.aspx?path=" + path + "&pid=" + pID);

    var left = ($(window).width() - $('#careff_mainmul').outerWidth()) / 2;
    var top = ($(window).height() - $('#careff_mainmul').outerHeight()) / 2 + $(document).scrollTop();
    if (left < 0) {
        left = 0;
    }
    if (top < 0) {
        top = 0;
    }

    
    $('#careff_mainmul').css({
        position: 'absolute',
        left: left,
        top: top
    });

    $('#careff_mdiv').css({
        position: 'absolute',
        left: 0,
        top: 0,
        width: $(window).width(),
        height: $(window).height()
    });
    return false;
}

function SkyOpenUploadMutiPic(txt) {
    //alert(txt);
    var path = document.getElementById(txt).value;
    var pID = $('#' + txt).attr("title");
    if ($("#careff_mdiv").length <= 0) {
        $(document.body).append("<div id='careff_mainmul'><iframe src='' id='selectfile' frameborder='0' width='100%' height='100%'></iframe></div><div id='careff_mdiv'></div>");
    }
    $('#careff_mdiv').show();
    $('#careff_mainmul').show();
    $('#selectfile').attr("src", "/admin/document/uploadmultipic.aspx?path=" + path + "&pid=" + pID);

    var left = ($(window).width() - $('#careff_mainmul').outerWidth()) / 2;
    var top = ($(window).height() - $('#careff_mainmul').outerHeight()) / 2 + $(document).scrollTop();
    if (left < 0) {
        left = 0;
    }
    if (top < 0) {
        top = 0;
    }


    $('#careff_mainmul').css({
        position: 'absolute',
        left: left,
        top: top
    });

    $('#careff_mdiv').css({
        position: 'absolute',
        left: 0,
        top: 0,
        width: $(window).width(),
        height: $(window).height()
    });
    return false;
}

function HSCardUploadImage(Card, img, txt) {
    var data = "";
    data = "Picture=" + encodeURIComponent(Card.Picture);
    data += "&Name=" + Card.Name;
    data += "&Sex=" + Card.Sex;
    data += "&Nation=" + Card.Nation;
    data += "&Born=" + Card.Born;
    data += "&Address=" + Card.Address;
    data += "&CardNo=" + Card.CardNo;
    data += "&IssuedAt=" + Card.IssuedAt;
    data += "&EffectedDate=" + Card.EffectedDate;
    data += "&ExpiredDate=" + Card.ExpiredDate;
    data += "&SAMID=" + Card.SAMID;
    $.ajax({
        type: "POST",
        url: "/admin/card/cardajax.aspx?type=add",
        data: data,
        success: function (msg) {
            $("#" + txt).val(msg);
            $("#" + img).attr("src", msg);
        }
    });
}



//################################################
//代码功能：身份证读卡器相关功能   开始
//编写时间：2015-10-27
//################################################

function HSCardSelect(selectId, checkValue) {
    var select = document.getElementById(selectId);
    for (var i = 0; i < select.options.length; i++) {
        var txt = select.options[i].text;
        txt = txt.replace("族", "");
        if (txt == checkValue) {
            select.options[i].selected = true;
            break;
        }
    }
};

function HSCardClear() {
    $("#txtUserName").val("");
    $("#txtSAge").val("");
    $("#txtSFAddr").val("");
    $("#txtsInd").val("");
    $("#txtIssuedAt").val("");
    $("#txtEffectedDate").val("");

    $("#imaSpic").attr("src", "/upload/no.jpg");
    $("#txtSpic").val("/upload/no.jpg");

    return true;
}

//################################################
//代码功能：解决Jquery1.9.1版本不支持$.browser 的问题
//编写时间：2016-07-24
//################################################

function HSGetMSIE() {
    return (/msie/.test(navigator.userAgent.toLowerCase()));
}

function HSCardRead() {

    if (HSGetMSIE()) { } else {
        alert("对不起，身份证扫描功能必须使用IE内核的浏览器才能正常使用，请使用IE浏览器，或者其他浏览器切换到兼容模式！");
        return;
    }
    HSCardCheck();

    var CVR_IDCard = document.getElementById("CVR_IDCard");
    var strReadResult = CVR_IDCard.ReadCard();
    if (strReadResult == "0") {
        $("#txtUserName").val(CVR_IDCard.Name);
        var age = CVR_IDCard.Born;
        age = age.replace("年", "-").replace("月", "-").replace("日", "");

        if ($("#txtUserDate").length > 0) {
            //报名相关
            alert(age);
            $("#txtUserDate").val(age);
            $("#txtUserInd").val(CVR_IDCard.CardNo);
            HSCardSelect("drpUserSex", CVR_IDCard.Sex);
            $("#txtUserJTDZ").val(CVR_IDCard.Address);
            HSCardSelect("drpUserMZ", CVR_IDCard.Nation);
            HSCardUploadImage(CVR_IDCard, "txtUserPic", "txtUserPic");
            //结束
        }
        else {

            $("#txtSAge").val(age);
            HSCardSelect("drpSSex", CVR_IDCard.Sex);
            HSCardSelect("drpSNational", CVR_IDCard.Nation);

            $("#txtSFAddr").val(CVR_IDCard.Address);
            $("#txtsInd").val(CVR_IDCard.CardNo);
            $("#txtIssuedAt").val(CVR_IDCard.IssuedAt);
            $("#txtEffectedDate").val(CVR_IDCard.EffectedDate + "-" + CVR_IDCard.ExpiredDate);
            HSCardUploadImage(CVR_IDCard, "imaSpic", "txtSpic");

            HSCardSelect("drpSBJ2", "身份证");
            HSCardSelect("drpFZJType", "身份证");
        }
    }
    else {
        HSCardClear();
        alert("读取身份证失败：" + strReadResult);
    }
}

function HSCardReadSearch(btn) {
    if (HSGetMSIE()) { } else {
        alert("对不起，身份证扫描功能必须使用IE内核的浏览器才能正常使用，请使用IE浏览器，或者其他浏览器切换到兼容模式！");
        return;
    }

    HSCardCheck();


    var CVR_IDCard = document.getElementById("CVR_IDCard");
    var strReadResult = CVR_IDCard.ReadCard();
    //alert(strReadResult);
    if (strReadResult == "0") {
        //alert(CVR_IDCard.CardNo);
        $("#txtInd").val(CVR_IDCard.CardNo);
        $("#txtSInd").val(CVR_IDCard.CardNo);
        $("#txtsInd").val(CVR_IDCard.CardNo);
        $("#txtUserInd").val(CVR_IDCard.CardNo);

        document.getElementById("btnSearch").click();
    }
    else {
        alert("读取身份证失败：" + strReadResult);
    }
}

function HSCardCheck()
{
    var b = false;
    try {
        var obj = new ActiveXObject("IDCARDREADER.IDCardReaderCtrl.1");
        //alert("已经注册");
        b = true;
    }
    catch (e) {
        alert("对不起，您没有安装相关的身份证读卡器驱动程序，因此无法使用本功能，使用IE内核的系统才能使用本功能；");
    }
    return false;
}


function GoKeySearch() {
    document.onkeydown = function () {
        var oEvent = window.event;
        //Ctrl+Alt进行快速读取；
        if (oEvent.ctrlKey && oEvent.keyCode == 18) {
            HSCardReadSearch();
            return false;
        }
    }
}

function GoKey()
{
    document.onkeydown = function () {
        var oEvent = window.event;
        //Ctrl+Alt进行快速读取；
        if (oEvent.ctrlKey && oEvent.keyCode == 18) {
            HSCardRead();
            return false;
        }
    }
}

//################################################
//代码功能：身份证读卡器相关功能   结束
//编写时间：2015-10-27
//################################################
window.onerror = function () { return true; }


function ustoolsJsSum1(table, column, il) {//合计，表格对象，对哪一列进行合计，第一列从0开始
    if (table == null) {
        return;
    }
    var trs = table.getElementsByTagName('tr');
    var start = 1,//忽略第一行的表头
        end = trs.length - 1;//忽略最后合计的一行
    var total = 0;
    for (var i = start; i < end; i++) {
        var td = trs[i].getElementsByTagName('td')[column];
        var t = parseFloat(td.innerHTML);
        if (t) total += t;
    }
    trs[end].getElementsByTagName('td')[column].innerHTML = total.toFixed(il);
}

function ustoolsJsSum2(table, column, il) {
    var sArr = column.split(",");
    for (var j = 0; j < sArr.length; j++) {
        var c1 = parseInt(sArr[j])
        ustoolsJsSum1(document.getElementById("" + table), c1, il);
    }
}
function ustoolsJsSum(table, column) {
    ustoolsJsSum2(table, column, 1);
}

function UsGetProcess(p) {
    var imgName = "1";
    if (p < 50) {
        imgName = "red";
    }
    else if (p < 70) {
        imgName = "blue";
    }
    else if (p < 99) {
        imgName = "green";
    }
    else {
        imgName = "finish";
    }
    var html = '<table background="/upload/bar/' + imgName + '.jpg" width="' + p + '%" title="' + p + '%" height="10" class="tablebar1"><tr><td>' + p + '</td></tr></table>';
    return html;
}

function toFloat(src) {
    var ret = parseFloat(src);
    if (isNaN(ret)) {
        return 0;
    }
    return ret;
}

//zTree搜索专用
function ztreeinitsearch(zid, inputid) {
    ztreeID = zid;
    ztreeInput = inputid;
    $("#" + ztreeInput).bind("keyup", clickRadio);
    $("#" + ztreeInput).bind("blur", clickRadio);
}
var ztreeID = "";
var ztreeInput = "";
var lastValue = "", nodeList = [], fontCss = {};
function clickRadio(e) {
    //console.debug(e);
    lastValue = "";
    searchNode(e);
}
function searchNode(e) {
    var zTree = $.fn.zTree.getZTreeObj(ztreeID);
    updateNodes(false);
    var value1 = $("#" + ztreeInput).val();
    if (value1 != "") {
        nodeList = zTree.getNodesByParamFuzzy("name", value1);
        updateNodes(true);
    } else {
        //nodeList = zTree.getNodes()
        //updateNodes(false);
    }
}
function updateNodes(highlight) {
    var zTree = $.fn.zTree.getZTreeObj(ztreeID);
    for (var i = 0, l = nodeList.length; i < l; i++) {
        nodeList[i].highlight = highlight;
        zTree.updateNode(nodeList[i]);
        //console.debug(i);
    }
}
function getFontCss(treeId, treeNode) {
    return (!!treeNode.highlight) ? { color: "#A60000", "font-weight": "bold" } : { color: "#333", "font-weight": "normal" };
}
//zTree搜索专用


document.writeln("<script language='javascript' src='/admin/js/uslib/us.system.js'></script>");



$(function () {
    //var d = $('select:not[multiple]').select2();
    var d = $('select').not("*[multiple]").select2();
});