function doActionAddGroup(pObj) {
  var S = getSelectSelValue(pObj);
  if (S == '')
    pObj.selectedIndex = 0;
  else
    submitAndAction('details', 'addgroup');
}

function doActionSetFlag(pIndex, pFlag) {
  doHttpRequest('plain.php?umi=crm_campaigns&page=setflag.dyn&flag=' + pFlag + '&index=' + pIndex, 'retActionSetFlag', pIndex, '');
}

function doConfirmAction(pAction, pMsg, pIndex) {
  loadPageConfirm(pMsg, '&action=' + pAction + '&index=' + pIndex);
}

function doConfirmActionDeleteJournal(pMsg, pIndex, pSubIndex) {
  loadPageConfirm(pMsg, '&page=details&action=deletejournal&index=' + pIndex + '&subindex=' + pSubIndex + '&tab=3');
}

function doConfirmActionRemoveAddressee(pMsg, pIndex, pSubIndex) {
  loadPageConfirm(pMsg, '&page=details&action=removeaddressee&index=' + pIndex + '&subindex=' + pSubIndex + '&tab=2');
}

function doConfirmActionRemoveFile(pMsg, pIndex, pSubIndex) {
  loadPageConfirm(pMsg, '&page=details&action=removefile&index=' + pIndex + '&subindex=' + pSubIndex + '&tab=4');
}

function doConfirmActionRemoveTask(pMsg, pIndex, pSubIndex) {
  loadPageConfirm(pMsg, '&page=details&action=removetask&index=' + pIndex + '&subindex=' + pSubIndex + '&tab=1');
}

function doIndexConfirmAction(pAction, pMsg) {
  doConfirmAction(pAction, pMsg, getOptSelValue(formByName('index').elements['index']));
}

function doPopupActionAddFile(pIndex, pSubIndex) {
  goOpener('index.php?umi=crm_campaigns&page=details&action=addfile&index=' + pIndex + '&subindex=' + pSubIndex + '&tab=4');
  window.close();
}

function doPopupActionAddTask(pIndex, pSubIndex) {
  goOpener('index.php?umi=crm_campaigns&page=details&action=addtask&index=' + pIndex + '&subindex=' + pSubIndex + '&tab=1');
  window.close();
}

function doPopupActionSelAddressees(pIndex) {
  var List = getAllOptSelValues(formByIndex(1).elements['addressees']);
  if (List.length > 0) {
    if (!opener.closed)
      with (formByNameOpener('details')) {
        elements['seladdressees'].value = List.join('|');
        elements['action'].value = 'addaddressees';
        submit();
      }
    window.close();
  }
}

function getDynPreview(pIndex) {
  if (elementById('index_preview').style.display != 'none')
    doHttpRequest('plain.php?umi=crm_campaigns&page=preview.dyn&index=' + pIndex, 'setHTML', 'index_preview', '');
}

function goAssignedUser() {
  var S = getSelectSelValue(formByName('details').elements['assigneduser']);
  if (S != '')
    go('index.php?umi=admin_users&page=details&id=' + S);
}

function popupAddFile(pIndex) {
  popupWindow('plain.php?umi=crm_campaigns&page=addfile.pop&index=' + pIndex, 300, 420);
}

function popupAddTask(pIndex) {
  popupWindow('plain.php?umi=crm_campaigns&page=addtask.pop&index=' + pIndex, 300, 260);
}

function popupHistory(pIndex) {
  popupWindow('plain.php?page=history.pop&entity=crm_campaigns_campaigns&index=' + pIndex, 240, 500);
}

function popupSelAddressees(pIndex) {
  popupWindow('plain.php?umi=crm_campaigns&page=seladdressees.pop&index=' + pIndex, 300, 420);
}

function retActionSetFlag(pValue, pParam) {
  var SrcConfirm = 'global/img/basics/confirm_g.png';
  var SrcReject = 'global/img/basics/reject_g.png';
  if (pValue == '1')
    SrcConfirm = 'global/img/basics/confirm.png';
  else if (pValue == '2')
    SrcReject = 'global/img/basics/reject.png';
  imageByName('confirm' + pParam).src = SrcConfirm;
  imageByName('reject' + pParam).src = SrcReject;
}

function updateReplyRate(pObj) {
  if (pObj.value > 100)
    pObj.value = 100;
}

function viewInfoBoxUser(pId) {
  if (pId != '')
    viewInfoBox('user' + pId, 'plain.php?umi=admin_users&page=user.info&id=' + pId);
}

function viewInfoBoxUser2() {
  viewInfoBoxUser(getSelectSelValue(formByName('details').elements['assigneduser']));
}