function ReadOfferDialogue($po_id, $prj_id = 0, $fldr = '')
{
    global $session;
    session_start();
    $objResponse = new xajaxResponse();
    $prj_offer = new projects_offers();
    $po_id = intval($po_id);
    $prj_id = intval($prj_id);
    $user_id = get_uid(false);
    $pod = new projects_offers_dialogue();
    if (hasPermissions('projects')) {
        $pod->markReadMod(array($po_id), $user_id);
        $objResponse->script('if($("new_msgs_' . $po_id . '").get("need_change")==1) { $("po_comments_' . $po_id . '").setStyle("background-color","#fff"); }');
    }
    if (is_emp()) {
        $pod->markReadEmp(array($po_id), $user_id);
        $script = 'if($chk($("po_comments_' . $po_id . '"))) { ' . "if (\$('new_msgs_{$po_id}').get('need_change') == 1) {" . "\$('po_comments_{$po_id}').removeClass('po_comments_new_hide');" . "\$('po_comments_{$po_id}').addClass('po_comments'); } }";
        $objResponse->script($script);
        switch ($fldr) {
            case 'o':
                list($po_offers_count, $msg_offers_count) = $prj_offer->CountPrjOffers($prj_id, 'offers');
                if ($msg_offers_count > 0) {
                    $objResponse->assign('op_count_offers_new_msgs', 'innerHTML', '<img src="/images/ico_envelop.gif" alt="" width="10" height="8" border="0"> ' . $msg_offers_count . ending($msg_offers_count, 'новое сообщение', 'новых сообщения', 'новых сообщений'));
                } else {
                    //              $objResponse->script($script);
                    $objResponse->assign('op_count_offers_new_msgs', 'innerHTML', '');
                }
                break;
            case 'i':
                list($po_executor_count, $msg_executor_count) = $prj_offer->CountPrjOffers($prj_id, 'executor');
                if ($msg_executor_count > 0) {
                    $objResponse->assign('op_count_executor_new_msgs', 'innerHTML', '<img src="/images/ico_envelop.gif" alt="" width="10" height="8" border="0"> ' . $msg_executor_count . ending($msg_executor_count, 'новое сообщение', 'новых сообщения', 'новых сообщений'));
                } else {
                    //              $objResponse->script($script);
                    $objResponse->assign('op_count_executor_new_msgs', 'innerHTML', '');
                }
                break;
            case 'c':
                list($po_candidate_count, $msg_candidate_count) = $prj_offer->CountPrjOffers($prj_id, 'candidate');
                if ($msg_candidate_count > 0) {
                    $objResponse->assign('op_count_candidate_new_msgs', 'innerHTML', '<img src="/images/ico_envelop.gif" alt="" width="10" height="8" border="0"> ' . $msg_candidate_count . ending($msg_candidate_count, 'новое сообщение', 'новых сообщения', 'новых сообщений'));
                } else {
                    //                 $objResponse->script($script);
                    $objResponse->assign('op_count_candidate_new_msgs', 'innerHTML', '');
                }
                break;
            case 'r':
                list($po_refuse_count, $msg_refuse_count) = $prj_offer->CountPrjOffers($prj_id, 'refuse');
                if ($msg_refuse_count > 0) {
                    $objResponse->assign('op_count_refuse_new_msgs', 'innerHTML', '<img src="/images/ico_envelop.gif" alt="" width="10" height="8" border="0"> ' . $msg_refuse_count . ending($msg_refuse_count, 'новое сообщение', 'новых сообщения', 'новых сообщений'));
                } else {
                    //              $objResponse->script($script);
                    $objResponse->assign('op_count_refuse_new_msgs', 'innerHTML', '');
                }
                break;
            case 'fr':
                list($po_refuse_count, $msg_refuse_count) = $prj_offer->CountPrjOffers($prj_id, 'frl_refuse');
                if ($msg_refuse_count > 0) {
                    $objResponse->assign('op_count_frl_refuse_new_msgs', 'innerHTML', '<img src="/images/ico_envelop.gif" alt="" width="10" height="8" border="0"> ' . $msg_refuse_count . ending($msg_refuse_count, 'новое сообщение', 'новых сообщения', 'новых сообщений'));
                } else {
                    $objResponse->assign('op_count_frl_refuse_new_msgs', 'innerHTML', '');
                }
                break;
        }
        // Обновляем количество новых сообщений в заголовке.
        $cnt_emp_new_messages = projects_offers_dialogue::CountMessagesForEmp($_SESSION['uid'], true);
        if ($cnt_emp_new_messages > 0) {
            $last_emp_new_messages_pid = projects_offers_dialogue::FindLastMessageProjectForEmp($_SESSION['uid']);
        } else {
            $last_emp_new_messages_pid = false;
        }
        $ndm_html = '';
        $sScript = "\$\$('.b-userbar__prjic').addClass('b-userbar__prjic_hide');\$\$('.b-userbar__icprj').removeClass('b-userbar__icprj_hide');";
        if ($last_emp_new_messages_pid) {
            $ndm_html = '(<a class="b-userbar__toplink" href="/projects/?pid=' . $last_emp_new_messages_pid . '" title="Есть новые сообщения">' . $cnt_emp_new_messages . '</a>)';
            $sScript = "\$\$('.b-userbar__prjic').removeClass('b-userbar__prjic_hide');\$\$('.b-userbar__icprj').addClass('b-userbar__icprj_hide');";
        }
        $objResponse->assign('new_dialogue_messages', 'innerHTML', $ndm_html);
        $objResponse->script($sScript);
    } else {
        $pod->markReadFrl($po_id, $user_id);
        // обновляем мигающий значек проекта
        if (!projects_offers::CheckNewFrlEvents($user_id, false) && !projects_offers_dialogue::CountMessagesForFrl($user_id, true, false)) {
            $objResponse->script("\$('new_offers_messages').getElement('img').addClass('b-userbar__prjic_hide'); \n                                      \$('new_offers_messages').getElement('i').removeClass('b-userbar__icprj_hide'); ");
        }
        if (hasPermissions('projects')) {
            $script = '$("po_comments_' . $po_id . '").setStyle("background-color","#fff"); if($chk($("po_comments_' . $po_id . '"))) { ' . "if (\$('new_msgs_{$po_id}').get('need_change') == 1) {" . "\$('new_msgs_{$po_id}').set('need_change', 0); dialogue_toggle({$po_id}); } }";
            $objResponse->script($script);
        }
    }
    if (defined('NEO')) {
        $objResponse->script('Page.checkNotifications(true)');
    } else {
        $objResponse->script('Notification()');
    }
    return $objResponse;
}