docs: function createNewDialog() {
    var usersIds = [];
    var usersNames = [];
  
    $('#users_list .users_form.active').each(function(index) {
      usersIds[index] = $(this).attr('id');
      usersNames[index] = $(this).text();
    });
  
    $("#add_new_dialog").modal("hide");
    $('#add_new_dialog .progress').show();
  
    var dialogName;
    var dialogOccupants;
    var dialogType;
  
    if (usersIds.length > 1) {
      if (usersNames.indexOf(currentUser.login) > -1) {
        dialogName = usersNames.join(', ');
      }else{
        dialogName = currentUser.login + ', ' + usersNames.join(', ');
      }
      dialogOccupants = usersIds;
      dialogType = 2;
    } else {
      dialogOccupants = usersIds;
      dialogType = 3;
    }
  
    var params = {
      type: dialogType,
      occupants_ids: dialogOccupants,
      name: dialogName
    };
  
    // create a dialog
    //
    console.log("Creating a dialog with params: " + JSON.stringify(params));
  
    QB.chat.dialog.create(params, function(err, createdDialog) {
      if (err) {
        console.log(err);
      } else {
        console.log("Dialog " + createdDialog._id + " created with users: " + dialogOccupants);
  
        // save dialog to local storage
        var dialogId = createdDialog._id;
        dialogs[dialogId] = createdDialog;
  
        currentDialog = createdDialog;
  
        joinToNewDialogAndShow(createdDialog);
  
        notifyOccupants(createdDialog.occupants_ids, createdDialog._id, 1);
  
        triggerDialog(createdDialog._id);
  
        $('a.users_form').removeClass('active');
      }
    });
  }