function insert_in_textarea(open, close)
{
    if (open == 'ul')
    {
        open = '<ul><li>';
        close = '</li></ul>';
    }
    else if (open == 'acro')
    {
        open = '<acronym title="">';
        close = '</acronym>';
    }
    else if (open == 'link')
    {
        open = '<a href="">';
        close = '</a>';
    }
    else if (open == 'img')
    {
        open = '';
        close = '<img src="" alt="" />';
    }
    else if (open == 'sad')
    {
        open = '';
        close = " :'(";
    }

    var msgfield = document.getElementById('form').text;

    // IE
    if (document.selection && document.selection.createRange)
    {
        msgfield.focus();
        sel = document.selection.createRange();
        sel.text = open + sel.text + close;
    }

    // Mozilla
    else if (msgfield.selectionStart || msgfield.selectionStart == '0')
    {
        var startPos = msgfield.selectionStart;
        var endPos = msgfield.selectionEnd;

        msgfield.value = msgfield.value.substring(0, startPos) + open + msgfield.value.substring(startPos, endPos) + close + msgfield.value.substring(endPos, msgfield.value.length);
        msgfield.selectionStart = msgfield.selectionEnd = endPos + open.length + close.length;
    }

    // Fallback support for other browsers
    else
        msgfield.value += open + close;

    msgfield.focus();
}