// ----------------------------------------------------------------------------
// показать форму для добавления голосовалки
//
function attachVoting()
{
    if (JS_IS_VOTING) return false; // у этой ветки уже есть голосование

    $.ajax({
        type: "POST",
        url: '/topic/getAttachVotingForm',
        data: {
            TOPIC_ID:   JS_TOPIC_ID
        },
        success: function(response) {
            var jsonResponse = JSON.parse(response);
            if (jsonResponse.success == "1") {
                $headMessageTD = $("#m0");
                $headMessageTD.html(jsonResponse.data + '<br><br>' + $headMessageTD.html());
            } else {
                console.log('Error: ' + response);
            }
        }
   });
   return false;
}

// ----------------------------------------------------------------------------
// добавить голосование
//
function attachVotingSubmit(e, topic_id)
{
    e.preventDefault();

    $.ajax({
        type: "POST",
        url: '/topic/attachVoting',
        data: $("#attachVotingForm").serialize(),
        success: function(response) {
            var jsonResponse = JSON.parse(response);
            if (jsonResponse.success == "1") {
                refreshMessage(topic_id, 0);
                clickHammer(topic_id);
            } else {
                console.log('Error: ' + response);
            }
        }
   });
   return false;
}

// --------------------------------------------------------------------------------------
// очистить сделанный выбор варианта голосования
//
function clearVotingVariant()
{
    $('#votingVariants :radio').prop("checked", false);
}