var LF = String.fromCharCode(10);

function rate_publication(id, score)
{
    if (score == "")
    {
        return;
    }

    document.location.href = ROOT+'/publication.php?action=rate&id='+id+'&score='+score;
}

function login_form(theform)
{
    if(theform.username.value == 'Логин')
    {
        alert('Вы не ввели информацию для входа!');
        return false;
    }

    return true;
}

function insert_user(user_id)
{
    content = document.getElementById('comment').content;
    content.value += '[USER]'+user_id+'[/USER] ';
}

function quote(user_id, text)
{
    if (text == '')
    {
        return;
    }
    
    document.getElementById('comment').content.value += '[QUOTE][USER]' + user_id + '[/USER]:' + LF + text + '[/QUOTE]' + LF;
}

function get_selection()
{
    if (document.getSelection)
    {
        selection = document.getSelection();
        selection = selection.replace(/\r/gi, '');
        while (selection.indexOf('  ') != -1)
        {
            selection = selection.replace(/  /gi, '');
        }
    }
    else
    {
        selection = document.selection.createRange().text;
    }
}