var selectedNames = new Array();

if (typeof String.prototype.trim !== 'function') {
    String.prototype.trim = function () {
        return this.replace(/^\s+|\s+$/g, '');
    };
}

function addSelectedStatuses(id) {

    var selectedIds = new Array();

    $('.rids:checked').each(function (i, id) { selectedIds.push($(this).val()); });

    var result = new Array();
    result["selectedIds"] = selectedIds;
    result["selectedNames"] = selectedNames;

    if (self.callback == null) {
        if (getURLParameter('cbmode') != null && getURLParameter('cbmode') != '') {
            eval('opener.' + getURLParameter('cbmode') + '.workflowsCallback(result)');
        } else {
            self.callback = opener.workflowsCallback;
            self.callback(result);
        }
    } else {
        self.callback(result);
    }

    self.close();
    return false;
}

function addSRole(chb, type) {
    if (chb.is(':checked')) {
        var id = chb.val();
        switch (type) {
            case "status":
                selectedNames["id" + id] = $.trim(chb.parent().find('#name').text());
                break;
        }

    }
}