    function insertText(txtarea, tagOpen) {
    tagClose   = '';
    sampleText = '';
	// IE
	if (document.selection  && !is_gecko) {
		var theSelection = document.selection.createRange().text;
		if (!theSelection)
			theSelection=sampleText;
		txtarea.focus();
		if (theSelection.charAt(theSelection.length - 1) == " ") { // exclude ending space char, if any
			theSelection = theSelection.substring(0, theSelection.length - 1);
			document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
		} else {
			document.selection.createRange().text = tagOpen + theSelection + tagClose;
		}

	// Mozilla
	} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
		var replaced = false;
		var startPos = txtarea.selectionStart;
		var endPos = txtarea.selectionEnd;
		if (endPos-startPos)
			replaced = true;
		var scrollTop = txtarea.scrollTop;
		var myText = (txtarea.value).substring(startPos, endPos);
		if (!myText)
			myText=sampleText;
		if (myText.charAt(myText.length - 1) == " ") { // exclude ending space char, if any
			subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
		} else {
			subst = tagOpen + myText + tagClose;
		}
		txtarea.value = txtarea.value.substring(0, startPos) + subst +
			txtarea.value.substring(endPos, txtarea.value.length);
		txtarea.focus();
		//set new selection
		if (replaced) {
			var cPos = startPos+(tagOpen.length+myText.length+tagClose.length);
			txtarea.selectionStart = cPos;
			txtarea.selectionEnd = cPos;
		} else {
			txtarea.selectionStart = startPos+tagOpen.length;
			txtarea.selectionEnd = startPos+tagOpen.length+myText.length;
		}
		txtarea.scrollTop = scrollTop;

	// All other browsers get no toolbar.
	// There was previously support for a crippled "help"
	// bar, but that caused more problems than it solved.
	}
	// reposition cursor if possible
	if (txtarea.createTextRange)
		txtarea.caretPos = document.selection.createRange().duplicate();
    }

    
    function otk_html_smile(name, area)
    {
        var text = document.getElementById(area);
        insertText(text, ' :' + name + ': ');
    }
    function otk_html_strong(area)
    {
        var strong = prompt(otk_lang_buttons_b, '');
        if (strong == null) {
            exit;
        }
        var text = document.getElementById(area);
        insertText(text, '<strong>' + strong + '</strong>');
    }
    function otk_html_em(area)
    {
        var em = prompt(otk_lang_buttons_i, '');
        if (em == null) {
            exit;
        }
        var text = document.getElementById(area);
        insertText(text, '<em>' + em + '</em>');
    }
    function otk_html_samp(area)
    {
        var samp = prompt(otk_lang_buttons_samp, '');
        if (samp == null) {
            exit;
        }
        var text = document.getElementById(area);
        insertText(text, '<samp>' + samp + '</samp>');
    }
    function otk_html_kbd(area)
    {
        var kbd = prompt(otk_lang_buttons_kbd, '');
        if (kbd == null) {
            exit;
        }
        var text = document.getElementById(area);
        insertText(text, '<kbd>' + kbd + '</kbd>');
    }
    function otk_html_var(area)
    {
        var var_ = prompt(otk_lang_buttons_var, '');
        if (var_ == null) {
            exit;
        }
        var text = document.getElementById(area);
        insertText(text, '<var>' + var_ + '</var>');
    }

    function otk_html_ol(area)
    {
        var number = Number(prompt(otk_lang_buttons_ol, ''));
        if (number != 0) {
            t = '<ol>\n';
            for (i = 1; i <= number; i++) {
                element = prompt(otk_lang_buttons_li, '');
                if (element == null) {
                    exit;
                }
                t += '<li>' + element + '</li>\n';
            }
            t += '</ol>\n';
            var text = document.getElementById(area);
            insertText(text, t);
        }
    }
    function otk_html_ul(area)
    {
        var number = Number(prompt(otk_lang_buttons_ul, ''));
        if (number != 0) {
            t = '<ul>\n';
            for (i = 1; i <= number; i++) {
                element = prompt(otk_lang_buttons_li, '');
                if (element == null) {
                    exit;
                }
                t += '<li>' + element + '</li>\n';
            }
            t += '</ul>\n';
            var text = document.getElementById(area);
            insertText(text, t);
        }
    }
    function otk_html_dl(area)
    {
        var number = Number(prompt(otk_lang_buttons_dl, ''));
        if (number != 0) {
            t = '<dl>\n';
            for (i = 1; i <= number; i++) {
                term = prompt(otk_lang_buttons_dt, '');
                if (term == null) {
                    exit;
                }
                definition = prompt(otk_lang_buttons_dd, '');
                if (definition == null) {
                    exit;
                }
                t += '<dt>' + term + '</dt>\n';
                t += '<dd>' + definition + '</dd>\n';
            }
            t += '</dl>\n';
            var text = document.getElementById(area);
            insertText(text, t);
        }
    }
    function otk_html_abbr(area)
    {
        var abbr  = prompt(otk_lang_buttons_abbr, '');
        if (abbr == null) {
            exit;
        }
        var title = prompt(otk_lang_buttons_abbr_title, '');
        if (title == null) {
            exit;
        }
        var lang  = prompt(otk_lang_buttons_abbr_lang, otk_lang);
        if (lang == null) {
            exit;
        }
        var text = document.getElementById(area);
        insertText(text, '<abbr title="' + title + '" lang="' + lang + '">' + abbr + '</abbr>');
    }
    function otk_html_acronym(area)
    {
        var acr  = prompt(otk_lang_buttons_acronym, '');
        if (acr == null) {
            exit;
        }
        var title = prompt(otk_lang_buttons_acronym_title, '');
        if (title == null) {
            exit;
        }
        var lang  = prompt(otk_lang_buttons_acronym_lang, otk_lang);
        if (lang == null) {
            exit;
        }
        var text = document.getElementById(area);
        insertText(text, '<acronym title="' + title + '">' + acr + '</acronym>');
    }
    function otk_html_img(area)
    {
        var src = prompt(otk_lang_buttons_img_src, 'http://');
        if (src == null) {
            exit;
        }
        var alt = prompt(otk_lang_buttons_img_alt, '');
        if (alt == null) {
            exit;
        }
        var text = document.getElementById(area);
        insertText(text, '<img src="' + src + '" alt="' + alt + '" />');
    }
    function otk_html_a(area)
    {
        var href = prompt(otk_lang_buttons_a_href, 'http://');
        if (href == null) {
            exit;
        }
        var desc = prompt(otk_lang_buttons_a_description, '');
        if (desc == null) {
            exit;
        }
        var text = document.getElementById(area);
        insertText(text, '<a href="' + href + '">' + desc + '</a>');
    }
    function otk_html_link(area)
    {
        var href = prompt(otk_lang_buttons_link_href, 'http://');
        if (href == null) {
            exit;
        }
        var desc = prompt(otk_lang_buttons_link_description, '');
        if (desc == null) {
            exit;
        }
        var text = document.getElementById(area);
        insertText(text, '<a class="blank" href="' + href + '">' + desc + '</a>');
    }
    function otk_html_code(area)
    {
        var text = document.getElementById(area);
        t = '<strong>' + otk_lang_code + ':</strong><div class="code"><code>\n';
        t += '\n';
        t += '</code></div>';
        insertText(text, t);
    }
    function otk_html_quote(area)
    {
        var cite = prompt(otk_lang_buttons_quote_cite, '');
        if (cite == null) {
            exit;
        }
        var text = document.getElementById(area);
        t = '<blockquote cite="' + cite + '">\n';
        t += '\n';
        t += '</blockquote>';
        insertText(text, t);
    }
    function otk_html_q(area)
    {
        var q = prompt(otk_lang_buttons_q, '');
        if (q == null) {
            exit;
        }
        var text = document.getElementById(area);
        insertText(text, '<q>' + q + '</q>');
    }
    function otk_html_hr(area)
    {
        var text = document.getElementById(area);
        insertText(text, '<hr />\n');
    }
    function otk_html_color(c, area)
    {
        var t = prompt(otk_lang_buttons_color, '');
        if (t == null) {
            exit;
        }
        var text = document.getElementById(area);
        insertText(text, '<span style="color: ' + c + ';">' + t + '</span>');
    }
    function otk_redirect(location)
    {
        location.href = location;
    }
    function otk_show_hide(id)
    {
        var element = document.getElementById(id);
        if (element.style.display == 'block') {
            element.style.display = 'none';
        } else {
            element.style.display = 'block';
        }
    }
    function otk_intercept()
    {
        for (var count = 0; count < document.links.length; count++) {
            if (document.links[count].className == 'blank') {
                document.links[count].target = '_blank';
            }
            if (document.links[count].className == 'button_blank') {
                document.links[count].target = '_blank';
            }
            if (document.links[count].className == 'partner') {
                document.links[count].target = '_blank';
            }
        }
    }
    function otk_popup(url, w, h)
    {
        if (!w) {
            w = '300';
        }
        if (!h) {
            h = '250';
        }
        var style = 'top=0, left=0, width=' + w + ', height=' + h + ', status=no, menubar=no, toolbar=no scrollbar=no';
        window.open(url, '', style);
    }
    function otk_update(id, urls)
    {
        var url = otk_base + urls[urls.selectedIndex].value;
        document.getElementById(id).setAttribute('src', url);
    }
