 



function setpopuser(result, uid, username, displayname, tel, email, staffcode, dept) {
    result = result.split("!")[0];
    var _result = result.split("$");
    if (uid != "") {
        $('#' + uid).val(_result[0]);
    }
    if (username != "") {
        $('#' + username).val(_result[1]);
    }

    if (displayname != "") {
        $('#' + displayname).val(_result[2]);
    }

    if (tel != "") {
        $('#' + tel).val(_result[3]);
    }


    if (email != "") {
        $('#' + email).val(_result[4]);
    }


    if (staffcode != "") {
        $('#' + staffcode).val(_result[5]);
    }

    if (dept != "") {
        $('#' + dept).val(_result[6]);
    }
     

} 




function isselect() {

    var checked = 0;
    var allvalue = '';

    var _c = 0;
    $(".ck_item").each(

     function () {
         if ($(this).is(':checked')) {
             checked++;

             if (checked > 1) {
                 allvalue += ',' + $(this).val();
             }
             else {
                 allvalue = $(this).val();
             }
         }

     });

    $("#hf_ids").val(allvalue);

    if (checked > 0) {
        return true;
    }
    else {
        layer.alert('请至少选择一条记录', 12);
        return false;
    }

}



function selectall() {
    var checkFlag = $("#cb_selectall").is(':checked');

    $(".ck_item").each(
        function () {
            if ($(this).prop('disabled') == false) {
                $(this).prop("checked", checkFlag);
            }
        }
        );

}






function op(action, url, popTitle, returnUrl, showIFrame) {


    allvalue = $("#hf_ids").val();

    if (action == "get") {
        return;
    }

    if (action == "delete") {
        return;
    }



    if (showIFrame) {
        ShowIframeNoScroll(url + "&ids=" + allvalue + "&returnUrl=" + returnUrl, "500", "350", popTitle);
    }
    else {
        location.href = url + "&ids=" + allvalue;
    }


}

function ShowIframeNoScroll(_src, _width, _height, _title) {

    layer.open({
        type: 2,
        title: _title,
        shadeClose: true,
        shade: 0.8,
        area: [_width + 'px', _height + 'px'],
        content: _src
    });

}


function popusers()
{
 Pop('Pop_Users.aspx',950,580,'选择人员');
}

function Pop(_src, _width, _height, _title) {
    if (!_width)
    {
        _width = 500;
    }

    if (!_height)
    {
        _height = 380;
    }

    if (!_title)
    {
        _title = "信息说明";
    }
 

    layer.open({
        type: 2,
        title: _title,
        shadeClose: true,
        shade: 0.8,
        area: [_width + 'px', _height + 'px'],
        content: _src
    });
 
}


function ept(url) { 
    Pop(url, 450, 350, ""); 
}



function closedept(cont) {
    $(".department").val($(cont).html());
    layer.closeAll();
}
 


function ftd(r) {
    if (r == "--" || r == "" || r == "&nbsp;")
        return 0;
    return parseFloat(r);

}


function sumRow(tabid) {
    var col = "<td class=sumhead>行合计</td>";
    $("#" + tabid + " tr").append(col);


    $('#' + tabid + ' tr:not(:first)').each(function () {

        var rowsum = 0;
        tds = $(this).find('td');
        var index = 0;
        var len = tds.length - 1;
        for (var index = 0; index < len - 1; index++) {
            rowsum += ftd($(tds[index + 1]).html());
        }

        $(tds[len]).html(rowsum);

    });
}



function sumCol(tabid) {
    var result = "<tr style='border-bottom:solid 1px #ddd' > <td class='sumhead'>列合计</td> ";
    var colLen = $("#" + tabid + " th").length;
    var colArray = new Array(30);
    for (var k = 0; k < 30; k++) {
        colArray[k] = 0;
    }

    $.each($('#' + tabid + ' tr'), function (idx, _tr) {
        if (idx != 0) {

            for (var j = 0; j < colLen ; j++) {
                var _v = ($(_tr).find('td')[j + 1].innerHTML);

                colArray[j + 1] += ftd(_v);

            }

        }
    });

    for (var r = 1; r < colLen + 1; r++) {
        result += "<td class=sumhead>" + colArray[r] + "</td>"
    }

    $('#' + tabid + '').append(result);
}