<script type="text/javascript">
function inserttags(open, close)
{

    msgfield = document.form.message

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

    // Moz support
    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;
        msgfield.focus();
    }

    // Other browsers
    else {
        msgfield.value += open + close;
        msgfield.focus();
    }

    return;
}
</script>