function bbcode_insert(open, close) {
        textarea = (document.all) ? document.all.contents : document.forms[0]['contents'];
        if (document.selection && document.selection.createRange) {
                textarea.focus();
                sel = document.selection.createRange();
                sel.text = open + sel.text + close;
                textarea.focus();
        } else if (textarea.selectionStart || textarea.selectionStart == '0') {
                var startPos = textarea.selectionStart;
                var endPos = textarea.selectionEnd;
                textarea.value = textarea.value.substring(0, startPos) + open + textarea.value.substring(startPos, endPos) + close + textarea.value.substring(endPos, textarea.value.length);
                textarea.selectionStart = textarea.selectionEnd = endPos + open.length + close.length;
                textarea.focus();
        } else {
                textarea.value += open + close;
                textarea.focus();
        }
        return false;
}
function bbcode_url() {
        var FoundErrors = '';
        var URL = prompt(enterURL, "http://");
        var TITLE = prompt(enterTitle, "Click me");
        if (!URL) FoundErrors += " " + PleaseURL+"!";
        if (!TITLE) FoundErrors += " " + PleaseTitle+"!";
        if (FoundErrors)
        {
                alert(Error+FoundErrors);
                return false;
        }
        bbcode_insert("[url="+URL+"]"+TITLE+"[/url]", "", false);
        return false;
}
function bbcode_img() {
        var FoundErrors = '';
        var URL = prompt(enteriURL, "http://");
        if (!URL) FoundErrors += " " + PleaseiURL+"!";
        if (FoundErrors)
        {
                alert(Error+FoundErrors);
                return false;
        }
        bbcode_insert("[img]"+URL+"[/img]", "", false);
        return false;
}
