
function pop_users() {
    url = "pop_users.aspx";
    popWin.showWin("320", "500", "", url);
}


function openRule() {
    var v = $("#hf_rpt").val();
    if (v == "1") {
        url = "AddBookOccur.aspx";
        popWin.showWin("320", "500", "", url);
    }
    else {
        layer.msg("请联系管理员获取循环预订权限");
    }
}


function setPopAttend(result) {
    var oldValue = $("#sel_attend").select2("data");
    var newValue = processArray(oldValue, result);
    $("#sel_attend").select2("data", newValue);
}


function processArray(arrSource, strResult) {
    strResults = strResult.split('!');
    var users = "";
    var loginname = "";
    var displayname = "";
    var text = "";

    for (var i = 0; i < strResults.length; i++) {
        if (strResults[i] != "") {
            users = strResults[i].split('$');
            loginname = users["1"];
            displayname = users["2"];
            text = displayname + "(" + loginname + ")";
            arrSource.push({ id: loginname, text: text });
        }
    }

    return arrSource;

}


function getSelect(arrSource) {
    var result = "";
    for (var i = 0; i < arrSource.length; i++) {
        if (arrSource[i] != "") {
            result += arrSource[i].id + ";";
        }
    }
    return result;
}


function getSelectText(arrSource) {
    var result = "";
    for (var i = 0; i < arrSource.length; i++) {
        if (arrSource[i] != "") {
            result += arrSource[i].text + ";";
        }
    }
    return result;
}


function setRule(_rec, _txt) {
    $("#hf_rec").val(_rec);
    $("#txt_rule").val(_txt);

}