var selectedIds = new Array();
var selectedNames = new Array();
//var taskTypeNames = new Array();

$(function () {
    $('.rowid').click(function () { selectRow(this.value, this.checked); });
});

function rowChecked(id, check) {
    if ($('#id' + id).length > 0) {
        selectedNames['id' + id.toString()] = $('#id' + id).attr('fullname');
        //taskTypeNames['id' + id.toString()] = $('#id' + id).attr('fullname');
    }
}

function selectRow(val, check) {    
    if (check) {
        selectedIds.push(val);        
    }
    else {
        selectedIds = $.grep(selectedIds, function (i) { return i != val; });        
    }
    try { if (rowChecked) rowChecked(val, check); } catch (e) { }
}

function addSelectedTypes() {    
    if (selectedIds.length == 0) { alert(AssetResources.NoAssetSelected); return false; }
    selectedIds = $.unique(selectedIds);       

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

    if (getURLParameter('msName') != null && getURLParameter('msName') != '') {
        result["msName"] = getURLParameter('msName');
    }

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

    self.close();
    return false;
}