﻿function quoteThis(author, comment) {
    var commentInputText = document.getElementById(commentInputTextID);
    if (commentInputText != null) {
        commentInputText.value += '[quote] Сообщение от [b]' + author + '[/b]:[paragraph]' + comment + '[/paragraph][/quote]';
        setSelRange(commentInputText, commentInputText.value.length, commentInputText.value.length);
    }
}

function askTo(author) {
    var commentInputText = document.getElementById(commentInputTextID);
    if (commentInputText != null) {
        commentInputText.value += '[b]' + author + '[/b],';
        commentInputText.focus();
        setSelRange(commentInputText, commentInputText.value.length, commentInputText.value.length);
    }
}

function appendSmile(smile) {
    var commentInputText = document.getElementById(commentInputTextID);
    if (commentInputText != null) {
        commentInputText.value += smile;
        commentInputText.focus();
        setSelRange(commentInputText, commentInputText.value.length, commentInputText.value.length);
    }
}

function setSelRange(inputEl, selStart, selEnd) {
    if (inputEl.setSelectionRange) {
        inputEl.focus();
        inputEl.setSelectionRange(selStart, selEnd);
    } else if (inputEl.createTextRange) {
        var range = inputEl.createTextRange();
        range.collapse(true);
        range.moveEnd('character', selEnd);
        range.moveStart('character', selStart);
        range.select();
    }
}

