var userID = "";
var srvID = "";
var mPage = 1;
var firstLoad = 0;
var mPage1 = 1;
var firstLoad1 = 0;
var selectID;
var selectNode;
var mousex = "";
var mousey = "";
var ifrm;
var employData;
var clickUser = 0;
var TorF = false;
$(function() {
    $(document).bind("contextmenu",
    function() {
        return false;
    });
    $('#dAddTop').hide();
    $(document).mousemove(function(e) {
        mousex = e.pageX;
        mousey = e.pageY;
    });
    $("#txtName").keydown(function(event) {
        e = event ? event: (window.event ? window.event: null);
        if (e.keyCode == 13) {
            //执行的方法
            return false;
        }
    });
    $(window).resize(function() {
        $("#tree1").height($(window).height() - 130);
        $("#right").height($(window).height() - 105);
    });

    $('#jstree').on("changed.jstree",
    function(e, data) {
        var ss = data;
        selectID = data.node.id;
        selectNode = data.node;
        $('#dAddTop').toggle();
        $('#dAddTop').css({
            position: "absolute",
            "left": mousex + 10,
            "top": mousey
        });
        showMenu(data.node);
    });
    $('#jstree').on('ready.jstree',
    function() {
        $('.usercontainerclass li').bind('click',
        function(e) {
            employData = eval('[' + $(this).attr('empdata').replace(/'/g, '"') + ']');
            showUserMenu();
        });

        resize_r();
    });
    $('#jstree').on('after_open.jstree',
    function() {
        $('.usercontainerclass li').bind('click',
        function(e) {
            employData = eval('[' + $(this).attr('empdata').replace(/'/g, '"') + ']');
            showUserMenu();
        });
        resize_r();
    });

    $("#userPg").change(function() {
        firstLoad1 = 0;
        mPage1 = 1;
        loadUser($("#userPg").val(), 1);
    });
});
function setManger(usertype) {
    var msg = '';
    switch (usertype) {
    case 1:
        {
            msg = '确实要设成主管吗?';
            break;
        }
    case 0:
        {
            msg = '确实要设成员工吗?';
            break;
        }
    case 2:
        {
            msg = '确实要设成Boss吗?';
            break;
        }
    default:
        break;
    }
    $('#xwbdy').text(msg);
    $('#Button2').unbind('click');
    $('#Button2').bind('click',
    function(e) {
        setSave(usertype);
    });
    $('#Div1').modal('show');
}
function setSave(usertype) {
    $('#Div1').modal('hide');
    var msg = '';
    switch (usertype) {
    case 1:
        {
            msg = '已经是主管！';
            break;
        }
    case 0:
        {
            msg = '已经是员工！';
            break;
        }
    case 2:
        {
            msg = '已经是Boss！';
            break;
        }
    default:
        break;
    }
    if (employData[0].header == usertype.toString()) {
        layer.msg(msg, 1, 3);
        return;
    }
    $.ajax({
        url: '../Handlers/system/Unit.aspx?Method=setPosition&id=' + employData[0].id + "&userType=" + usertype + "&svrid=" + srvID,
        type: 'post',
        cache: false,
        success: function(data) {
            if (data == "success") {
                layer.msg('设置成功！', 1, 1);
                $("#AddDialog").modal("hide");
                //loadUnit();
                refreshbdy();
            } else {
                layer.msg('设置失败！', 1, 3);
            }
        },
        error: function() {
            layer.msg('设置失败！', 1, 3);
        }
    });
}

//生成表格数据
function creatTable(op, data) {

    if (op == 1) { //主页面的用户信息
        $("#tdata tbody").empty();
        for (var i = 0; i < data.rows.length; i++) {
            var row = $("<tr></tr>");
            var td0 = $('<td class="center"> <label class="position-relative"><input type="checkbox" class="ace" /><span class="lbl"></span></label></td>');
            row.append(td0);
            var td1 = $('<td></td>');
            td1.text(data.rows[i].userXM);
            row.append(td1);
            var td2 = $('<td></td>');
            td2.text(data.rows[i].unitName);
            row.append(td2);
            var td3 = $('<td></td>');
            td3.text(data.rows[i].state);
            row.append(td3);
            var td4 = $('<td></td>');
            td4.text(data.rows[i].frees);
            row.append(td4);
            var td5 = $('<td></td>');
            td5.text(data.rows[i].userName);
            row.append(td5);
            var td6 = $('<td style="display:none;"></td>');
            td6.text(data.rows[i].ID);
            row.append(td6);
            $("#tdata tbody").append(row);
        }
    } else {
        $("#tUser tbody").empty();
        for (var i = 0; i < data.rows.length; i++) {
            var row = $("<tr></tr>");
            var td0 = $('<td class="center"> <label class="position-relative"><input type="checkbox" class="ace" /><span class="lbl"></span></label></td>');
            row.append(td0);
            var td1 = $('<td></td>');
            td1.text(data.rows[i].userXM);
            row.append(td1);
            var td2 = $('<td></td>');
            td2.text(data.rows[i].unitName);
            row.append(td2);
            var td6 = $('<td style="display:none;"></td>');
            td6.text(data.rows[i].ID);
            row.append(td6);
            $("#tUser tbody").append(row);
        }
    }
}
function breakdep() {
    $('#Div1').modal('hide');
    $.ajax({
        url: '../Handlers/system/Unit.aspx?Method=brk&id=' + employData[0].id,
        type: 'post',
        cache: false,
        success: function(data) {
            if (data == "success") {
                layer.msg('脱离成功！', 1, 1);
                refreshbdy();
            } else {
                layer.msg('脱离失败！', 1, 3);
            }
        },
        error: function() {
            layer.msg('脱离失败！', 1, 3);
        }
    });
}
function showUserMenu() {
    $("#dAddTop div").hide();
    $("#dAddTop div").unbind('click');
    $('#dAddTop legend').text(employData[0].name);
    $("#dAddTop div[methodname='setManager']").show();
    $("#dAddTop div[methodname='setManager']").bind('click',
    function(e) {
        setManger(1);
    });
    $("#dAddTop div[methodname='setcommon']").show();
    $("#dAddTop div[methodname='setcommon']").bind('click',
    function(e) {
        setManger(0);
    });
    $("#dAddTop div[methodname='movedep']").show();
    $("#dAddTop div[methodname='upboss']").show();
    $("#dAddTop div[methodname='upboss']").bind('click',
    function(e) {
        setManger(2);
    });
    $("#dAddTop div[methodname='movedep']").show();
    $("#dAddTop div[methodname='movedep']").bind('click',
    function(e) {
        brkConfirm();
    });
}
function showMenu(node) {
    if (node.a_attr.header != "-1") {
        return;
    }
    $("#dAddTop div").hide();
    $("#dAddTop div").unbind('click');

    if (node.a_attr.pid == '0') {

        $('#dAddTop legend').text(node.text);
        $('#dAddTop').attr('nesteddata', "{'pid':'" + node.a_attr.pid + "','depid':'" + node.id + "'}");
        $("#txtID").val(node.id);
        $("#dAddTop div[methodname='createboss']").show();
        $("#dAddTop div[methodname='createboss']").unbind('click');
        $("#dAddTop div[methodname='createboss']").bind('click',
        function(e) {
            open_userWindow(this);
        });
        $("#dAddTop div[methodname='createuser']").show();
        $("#dAddTop div[methodname='createuser']").unbind('click');
        $("#dAddTop div[methodname='createuser']").bind('click',
        function(e) {
            open_userWindow(this);
        });
        $("#dAddTop div[methodname='renamedep']").show();
        $("#dAddTop div[methodname='renamedep']").unbind('click');
        $("#dAddTop div[methodname='renamedep']").bind('click',
        function(e) {
            open_editWindow();
        });
        $("#dAddTop div[methodname='createdep']").show();
        $("#dAddTop div[methodname='createdep']").unbind('click');
        $("#dAddTop div[methodname='createdep']").bind('click',
        function(e) {

            open_AddWindow();
        });

    } else {
        if (node.a_attr.dep == "yes") {
            $('#dAddTop').attr('nesteddata', "{'pid':'" + node.a_attr.pid + "','depid':'" + node.id + "'}");
            $("#txtID").val(node.id);
            $('#dAddTop legend').text(node.text);
            $("#txtID").val(node.id);
            $("#dAddTop div[methodname='createuser']").show();
            $("#dAddTop div[methodname='createuser']").bind('click',
            function(e) {
                open_userWindow(this);
            });
            $("#dAddTop div[methodname='renamedep']").show();
            $("#dAddTop div[methodname='renamedep']").bind('click',
            function(e) {
                open_editWindow();
            });
            $("#dAddTop div[methodname='deldep']").show();
            $("#dAddTop div[methodname='deldep']").bind('click',
            function(e) {
                open_Confirm();
            });
            $("#dAddTop div[methodname='createdep']").show();
            $("#dAddTop div[methodname='createdep']").bind('click',
            function(e) {
                open_AddWindow();
            });
        } else {}
    }
}

function resize_r() {
    var s = 0;
    var l = $(window.parent).height();
    var t = $(document).height();
    if ($(window.parent).height() - 100 > $(document).height()) {
        s = $(window.parent).height() - 90;
    } else {
        s = $(document).height() + 10;
    }
    var ss = $(window.parent.document).find('iframe[id=' + ifrm + ']');
    $($(window.parent.document).find('iframe[id=' + ifrm + ']')).height(s);
}

function open_AddWindow() {
    $("#txtName").val('');
    $(".popover ").remove();
    $("#spnTxt").text('添加');
    $("#Delete_sc").remove();
    $("#myModalLabel").text('添加部门信息');
    $("#dlgSave").unbind("click");
    $("#dlgSave").bind("click",
    function(e) {
        add();
    });
    $("#AddDialog").modal("show");
}
function add() {
    $('#frmAdd').validation();
    var alm = $(".popover");
    if (alm.length > 0) {
        return;
    }
    if ($("#txtName").val().length > 30) {
        layer.msg('部门名称过长,不可超过30字！', 1, 3);
        $("#txtName").focus();
        return;
    }
    $.post('../Handlers/system/Unit.aspx?Method=Add&srvid=' + srvID, encodeJson_News(decodeURIComponent($('#frmAdd').serialize())),
    function(data, stus) {
        if (data == "success") {
            $("#AddDialog").modal("hide");
            layer.msg('添加成功！', 1, 1);
            $("#txtName").val('');
            $("#txtName").focus();
            //loadUnit();
            refreshbdy();
        } else {
            layer.msg('添加失败！', 1, 3);
        }
    });
}
function open_editWindow() {
    $(".popover ").remove();
    $("#txtName").val(selectNode.text);
    $("#spnTxt").text('修改');
    $("#Delete_sc").remove();
    $("#Update").append('<button id="Delete_sc" onclick="open_Confirm();" style="float:left;" type="button" class="btn btn-white btn-info btn-bold" ><i class="ace-icon fa fa-trash-o bigger-110 ren"></i><span id="spnTxt">删除</span></button>');       $("#myModalLabel").text('修改部门信息');
    $("#dlgSave").unbind("click");
    $("#dlgSave").bind("click",
    function(e) {
        editDep();
    });
    $("#AddDialog").modal("show");
}

function editDep() {
    var l = layer.load('正在生成编号...');
    $('#frmAdd').validation();
    var alm = $(".popover");
    if (alm.length > 0) {
        layer.close(l);
        return;
    }
    if ($("#txtName").val().length > 30) {
        layer.msg('部门名称过长,不可超过30字！', 1, 3);
        return;
    }
    $.post('../Handlers/system/Unit.aspx?Method=edit&srvid=' + srvID, encodeJson_News(decodeURIComponent($('#frmAdd').serialize())),
    function(data, stus) {
        if (data == "success") {
            $("#AddDialog").modal("hide");
            layer.msg('修改成功！', 1, 1);
            $("#txtName").val('');
            $("#txtName").focus();
            refreshbdy();

        } else {
            layer.msg('修改失败！', 1, 3);
        }
    });
    layer.close(l);
}

function open_Confirm() {
    if (!selectNode) {
        layer.msg('请选择部门!', 1, 3);
        return;
    }
    var ssss = selectNode;
    if (selectNode.a_attr.pid == "0") {
        layer.msg('不能删除该节点!', 1, 3);
        return;
    }
    $("#myModual").modal("show");
}

function del() {
    var l = layer.load('正在删除...');
    $("#myModual").modal("hide");
    $.ajax({
        url: '../Handlers/system/Unit.aspx?Method=del&id=' + selectNode.id,
        type: 'post',
        cache: false,
        success: function(data) {
            if (data == "success") {
                layer.msg('删除成功！', 1, 1);
                $("#AddDialog").modal("hide");
                //loadUnit();
                refreshbdy();
            } else {
                layer.msg('删除失败！', 1, 3);
            }
        },
        error: function() {
            layer.msg('删除失败！', 1, 3);
        }
    });
    layer.close(l);
}

function createPage(pageSize, buttons, total) {
    $("#kk").jBootstrapPage({
        pageSize: pageSize,
        total: total,
        maxPageButton: buttons,
        onPageClicked: function(obj, pageIndex) {
            mPage = pageIndex + 1;
            loadCurDepUsers($("#PSize").val(), mPage);
        }
    });
}

function createPageUser(pageSize, buttons, total) {
    $("#userPage").jBootstrapPage({
        pageSize: pageSize,
        total: total,
        maxPageButton: buttons,
        onPageClicked: function(obj, pageIndex) {
            mPage = pageIndex + 1;
            loadUser($("#userPg").val(), mPage);
        }
    });
}

function loadUser(pagesize, page) {
    var l = layer.load('正在加载数据......');
    $.ajax({
        url: "../Handlers/system/Unit.aspx?Method=loadallperson&page=" + page + "&rows=" + $("#userPg").val() + "&name=userXM" + "&value=" + encodeJson($("#txtSearcher").val()) + "&srvid=" + srvID,
        type: "post",
        cache: false,
        dataType: "json",
        success: function(data) {
            creatTable(2, data);
            if (firstLoad1 == 0) {
                createPageUser(pagesize, 5, data.total);
                firstLoad1 = 1;
            }

            layer.close(l);
            resize_r();

        },
        error: function() {

}
    });
}

function searcher() {
    mPage1 = 1;
    firstLoad1 = 0;
    loadUser($("#userPg").val(), 1);
}

function open_userWindow(_menu) {
    if (!selectNode) {
        layer.msg('请选择部门', 1, 3);
        return;
    }
    $("#txtName").val('');
    $(".popover ").remove();
    $("#userPg").trigger('change');
    $("#Button1").unbind("click");
    var usertype = 0;
    if ($(_menu).attr("methodname") == "createboss") {
        usertype = 2;
    }
    if ($(_menu).attr("methodname") == "createuser") {
        usertype = 0;
    }
    $("#Button1").bind("click",
    function(e) {
        addUserToUnit(usertype);
    });
    $("#userModal").modal("show");
}

function selectall(_this) {
    if ($(_this).is(':checked')) {
        $(".ace:checkbox").attr("checked", true);

    } else {
        $(".ace:checkbox").attr("checked", false);
    }
}
function selectall1(_this) {
    if ($(_this).is(':checked')) {
        $("#userModal .ace:checkbox").attr("checked", true);

    } else {
        $("#userModal .ace:checkbox").attr("checked", false);
    }
}

function refreshbdy() {
    window.location.reload(true);
}

function addUserToUnit(userType) {
    var l = layer.load('正在添加用户...');
    var sel = $("#userModal .ace:checkbox:checked");
    if (sel.length < 1) {
        layer.msg('请选择用户！', 1, 3);
        layer.close(l);
        return;
    }
    var s = "";
    for (var i = 0; i < sel.length; i++) {
        var id = $(sel[i]).parent().parent().parent().find('td').eq(3).text();
        s += "'" + id + "',";
    }
    s = s.substring(0, s.length - 1);
    $.ajax({
        url: '../Handlers/system/Unit.aspx?Method=adduser&srvid=' + srvID + "&userid=" + s + "&depid=" + selectNode.id + "&userType=" + userType,
        cache: false,
        type: 'post',
        success: function(data) {
            if (data == "success") {

                refreshbdy();
                $('#userModal').modal('hide');
                layer.msg('添加成功！', 1, 1);
            } else {
                layer.msg('添加失败！', 1, 3);
            }
        },
        error: function() {
            layer.msg('添加失败！', 1, 3);
        }
    });
    layer.close(l);
}

function loadUnit() {
    $.ajax({
        dataType: 'json',
        type: "post",
        url: "../Handlers/Process/Process.aspx?Method=ldunit",
        data: {
            srvid: srvID
        },
        success: function(jsons) {

            $('#jstree').jstree({
                "plugins": ['types'],
                'core': {
                    'data': jsons,
                    "themes": {
                        "icons": false
                    },
                    'dblclick_toggle': false
                }
            });
            //resize_r(); 
        },
        error: function() {
            layer.msg("网络错误！", 1, 8);
        }
    });
}

function loadRole() {
    $.ajax({
        url: '../Handlers/system/control.aspx?Method=loadRole&srvid=' + srvID,
        cache: false,
        type: 'post',
        dataType: 'json',
        success: function(data) {
            $("#belongRole").empty();
            $("#belongRole").append("<option value='0'>" + "" + "</option>");
            for (var i = 0; i < data.length; i++) {
                $("#belongRole").append("<option value='" + data[i].ID + "'>" + data[i].roleName + "</option>");
            }
            // resize_r();
        },
        error: function() {
            layer.msg('加载职位信息错误！', 1, 3);
        }
    });
}

function loadPos() {
    $.ajax({
        url: '../Handlers/system/DataDic.aspx?Method=Load&srvid=' + srvID + "&tbname=TCWL_All_Dic_ComPosition&userid=''",
        cache: false,
        type: 'post',
        dataType: 'json',
        success: function(data) {
            $("#SPos").empty();
            for (var i = 0; i < data.rows.length; i++) {
                $("#SPos").append("<option value='" + data.rows[i].id + "'>" + data.rows[i].text + "</option>");
            }
            //resize_r();
        },
        error: function() {
            layer.msg('加载职位信息错误！', 1, 3);;
        }
    });
}

var editElement;
function openEdit(_this) {
    editElement = _this;
    $(".popover ").remove();
    var id = $(_this).parent().parent().parent().find('td').eq(14).text();
    $("#txtUsersID").val(id);
    $("#txtName").val($(_this).parent().parent().parent().find('td').eq(1).text().trim());
    $("#txtphone").val($(_this).parent().parent().parent().find('td').eq(2).text());
    $("#txtaddress").val($(_this).parent().parent().parent().find('td').eq(3).text());
    $("#SPos").val($(_this).parent().parent().parent().find('td').eq(15).text());
    $("#belongRole").val($(_this).parent().parent().parent().find('td').eq(16).text());
    $("#states").val($(_this).parent().parent().parent().find('td').eq(17).text());
    $("#actives").val($(_this).parent().parent().parent().find('td').eq(18).text());
    $("#sex").val($(_this).parent().parent().parent().find('td').eq(8).text());
    $("#txtemail").val($(_this).parent().parent().parent().find('td').eq(20).text());
    $("#head").val($(_this).parent().parent().parent().find('td').eq(21).text());
    $("#user_admin").val(userID);
    $("#user_srv").val(srvID);
    $("#user_user").val($(_this).parent().parent().parent().find('td').eq(7).text());
    var dep = $(_this).parent().parent().parent().find('td').eq(19).text();
    var pubRoot1 = $("#cc").combotree('tree').tree('getRoots'); //获取行业
    for (var i = 0; i < pubRoot1.length; i++) {
        var child = $("#cc").combotree('tree').tree('getChildren', pubRoot1[i].target);
        var ee = 0;
        $("#cc").combotree('tree').tree('uncheck', pubRoot1[i].target);
        for (var j = 0; j < child.length; j++) {
            if (dep.indexOf(child[j].id) >= 0) {
                $("#cc").combotree('tree').tree('select', child[j].target);
                $("#cc").combotree('setValue', child[j].id);
                ee = 1;
            }
        }
        if (ee == 0) {
            $("#cc").combotree('clear');
        }
    }
    if (TorF == "true") {
        $("#torf").attr("checked", false);
        $("#torf_div").show();
    } else {
        $("#torf").remove("checked");
        $("#torf_div").hide();
    }

    $("#editUser").modal('show');
    ClickEvent();
    resize_r();

}

function ClickEvent() {
    $('[data-rel=tooltip]').tooltip();
    $('[data-rel=popover]').popover({
        html: true
    });
}

function saveEdit() {
    var l = layer.load('正在保存...');
    $('#frmUser').validation();
    var alm = $(".popover");
    if (alm.length > 0) {
        layer.close(l);
        return;
    }
    if ($("#txtName").val() == "") {
        $("#txtName").focus();
        layer.msg('姓名不为空！', 1, 3);
        layer.close(l);
        return;
    }
    if (TorF == "true") {
        if ($("#torf").attr("checked")) {
            var phone = $("#txtphone").val();
            if (phone == "") {
                $("#txtphone").focus();
                layer.msg('请输入手机号！', 1, 3);
                layer.close(l);
                return;
            }
        }
    }
    if ($("#txtphone").val().length > 0) {
        var regu = /^1[3,4,5,8]\d{9}$/;
        var re = new RegExp(regu);
        if (!re.test($("#txtphone").val())) {
            $("#txtphone").focus();
            layer.msg('手机格式不正确！', 1, 3);
            layer.close(l);
            return;
        }
    }

    if ($("#txtemail").val().length > 0) {
        var regu = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
        var re = new RegExp(regu);
        if (!re.test($("#txtemail").val())) {
            $("#txtemail").focus();
            layer.msg('邮箱格式不正确！', 1, 3);
            layer.close(l);
            return;
        }
    }
    var ss = "";
    var selectNode = $("#cc").combotree('tree').tree('getSelected');
    if (selectNode) {
        ss = selectNode.id;
    }

    $.post('../Handlers/system/user.aspx?Method=updateUser&srvid=' + srvID + "&dep=" + ss, encodeJson_News(decodeURIComponent($('#frmUser').serialize())),
    function(data, stus) {
        if (data == "success") {
            $("#editUser").modal('hide');
            layer.msg('修改成功！', 1, 1);
            $(editElement).parent().parent().parent().find('td').eq(1).text($("#txtName").val());
            $(editElement).parent().parent().parent().find('td').eq(2).text($("#txtphone").val());
            $(editElement).parent().parent().parent().find('td').eq(3).text($("#txtaddress").val());
            $(editElement).parent().parent().parent().find('td').eq(15).text($("#SPos").val());
            $(editElement).parent().parent().parent().find('td').eq(16).text($("#belongRole").val());
            $(editElement).parent().parent().parent().find('td').eq(17).text($("#states").val());
            $(editElement).parent().parent().parent().find('td').eq(18).text($("#actives").val());
            $(editElement).parent().parent().parent().find('td').eq(11).text($("#states").find("option:selected").text());
            $(editElement).parent().parent().parent().find('td').eq(12).text($("#actives").find("option:selected").text());
            $(editElement).parent().parent().parent().find('td').eq(4).text($("#SPos").find("option:selected").text());
            $(editElement).parent().parent().parent().find('td').eq(5).text($("#belongRole").find("option:selected").text());
            $(editElement).parent().parent().parent().find('td').eq(8).text($("#sex").val());
            $(editElement).parent().parent().parent().find('td').eq(20).text($("#txtemail").val());
            $(editElement).parent().parent().parent().find('td').eq(19).text(selectNode.id);
            $(editElement).parent().parent().parent().find('td').eq(6).text(selectNode.text);
            //alert(selectNode.text);
        }
        if (data == "exist") {
            layer.msg('绑定失败，该手机已绑定别的手机号！', 2, 3);
        }
        if (data == "have") {
            layer.msg('绑定失败，当前账号已绑定手机，不可二次绑定！', 2, 3);
        }
        if (data == "nobindinf") {
            layer.msg('绑定失败，输入信息有误！', 2, 3);
        }
        if (data == "noyzm") {
            layer.msg('验证码输入有误，请重新绑定！', 2, 3);
        }
        if (data == "error") {
            layer.msg('修改失败，请稍后再试！', 1, 3);
        }
    });
    layer.close(l);
}

function iniParms() {
    var coks = document.cookie.substring(document.cookie.indexOf('userinf_tcwl'));
    var ary = coks.split(';');
    var ary1 = ary[0].split('=');
    userID = ary1[2].split('&')[0];
    srvID = ary1[3];
    if (!ary1[2]) {
        $('html').empty();
        return;
    }
    var s = window.location.href.split('=');
    if (s.length == 4) {
        ifrm = s[3];
    }
    resize_r();
    loadUnit();
    $("#cc").combotree({
        url: "../Handlers/system/Unit.aspx?Method=loadunit&srvid=" + srvID + "&ID=" + Math.random(),
        multiple: false,
        lines: true,
        checkbox: true,
        panelWidth: '200',
        width: 100
    });
}