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()
    $('#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", "../document/uploadmulti.aspx?path=" + path);

    var left = ($(window).width() - $('#careff_mainmul').outerWidth()) / 2;
    var top = ($(window).height() - $('#careff_mainmul').outerHeight()) / 2 + $(document).scrollTop()
    $('#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()
    $('#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;
}
function HSCardRead() {

    if ($.browser.msie) { } 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);
        HSCardSelect("drpSSex", CVR_IDCard.Sex);
        HSCardSelect("drpSNational", CVR_IDCard.Nation);
       
        var age = CVR_IDCard.Born;
        age = age.replace("年", "-").replace("月", "-").replace("日", "");
        $("#txtSAge").val(age);

         


        $("#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 ($.browser.msie) { } else {
        alert("对不起，身份证扫描功能必须使用IE内核的浏览器才能正常使用，请使用IE浏览器，或者其他浏览器切换到兼容模式！");
        return;
    }

    HSCardCheck();


    var CVR_IDCard = document.getElementById("CVR_IDCard");
    var strReadResult = CVR_IDCard.ReadCard();
    if (strReadResult == "0") {
        //alert(CVR_IDCard.CardNo);
        $("#txtInd").val(CVR_IDCard.CardNo);
        $("#txtSInd").val(CVR_IDCard.CardNo);
        $("#txtsInd").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; }   