// created 2005-1-12 by Martin Sadera (
[email protected])
// ported to Xoops CMS by ralf57
// updated to TinyMCE v3.0.1 / 2008-02-29 / by luciorota
tinyMCEPopup.requireLangPack();
var XoopscodeDialog = {
    init : function()
    {
        var formObj = document.forms[0];
        // Get the selected contents as text and place it in the input
        formObj.ctext.value = tinyMCEPopup.editor.selection.getContent({format : 'text'});
    },
    insert : function()
    {
        // Insert the contents from the input into the document
        var formObj = document.forms[0];
        //if (window.opener) {
            var ctext = formObj.ctext.value;
            ctext.replace(new RegExp("<",'g'), "<");
            ctext.replace(new RegExp(">",'g'), ">");
            var html = '<div class="xoopsCode">';
            html += ctext+'</div><br />';
            tinyMCEPopup.editor.execCommand('mceInsertContent', true, html);
        //}
        tinyMCEPopup.close();
    }
};
tinyMCEPopup.onInit.add(XoopscodeDialog.init, XoopscodeDialog);