var idlist = new Array();

function toggleMessage(check, id) {
  var ids = '';
  var inlist = false;

  for (i=0;i<this.idlist.length;i++) {
    if (this.idlist[i][0] == id) { 
      inlist = true; 
      this.idlist[i][1] = check;
    }
  }

  if (!inlist) { 
    this.idlist[this.idlist.length] = new Array();
    this.idlist[this.idlist.length - 1][0] = id; 
    this.idlist[this.idlist.length - 1][1] = check;
  }

  for (i=0;i<this.idlist.length;i++) {
    if (this.idlist[i][1]) {
      if (ids!='') { ids = ids + ','; }
      ids = ids + this.idlist[i][0];
    }
  }
  document.getElementById('messageids').value=ids;
}

function setChecked(id) {
  document.getElementById(id).checked=true;
}