function popUp (url, title) {
        mywindow = window.open(url, title, "width=640,height=480,left=20,top=20,resizable=yes");
        if (mywindow) {
                mywindow.focus();
        }
}
function resizeInner (pictureWidth, pictureHeight) {
        var win = window;
        if (typeof win.innerWidth != 'undefined') {
                my_inner_width = win.innerWidth;
                my_inner_height = win.innerHeight;
        } else {
                var obj = getBody(win);
                my_inner_width = parseInt(obj.clientWidth);
                my_inner_height = parseInt(obj.clientHeight);
        }
        completeWidth = pictureWidth - my_inner_width;
        completeHeight = pictureHeight - my_inner_height;
        window.resizeBy (completeWidth, completeHeight);
}
function getBody(w) {
        return (w.document.compatMode && w.document.compatMode == "CSS1Compat") ? w.document.documentElement : w.document.body || null;
}

function xinha_init() {

        xinha_plugins = ["CharCounter","ExtendedFileManager","FindReplace","GetHtml","HtmlEntities","InsertAnchor","Linker","SmartReplace","SuperClean"];
        
        if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;
        
        xinha_config = new Xinha.Config();
        xinha_config.showLoading = true;
        xinha_config.toolbar = [
                ["formatblock"],
                ["separator","bold","italic","underline","strikethrough"],
                ["separator","forecolor","hilitecolor"],
                ["separator","subscript","superscript"],
                ["separator","insertorderedlist","insertunorderedlist","outdent","indent"],
                ["separator","inserthorizontalrule","createlink","insertimage","inserttable"],
                ["linebreak","popupeditor","separator","FR-findreplace"],
                ["separator","undo","redo","selectall"],
                ["separator","cut","copy","paste"],
                ["separator","killword","clearfonts","removeformat","htmlmode"],
                ["separator","showhelp","about"]
        ];
        
        xinha_config.SmartReplace.quotes = [String.fromCharCode(8222),String.fromCharCode(8221),String.fromCharCode(8222),String.fromCharCode(8221)];

        xinha_config.pageStyleSheets = [RTEstylesheet];      
        xinha_config.hideSomeButtons(" fontname fontsize textindicator print overwrite saveas toggleborders splitblock lefttoright righttoleft ");
        xinha_config.flowToolbars = false;
        xinha_config.formatblock = RTEformatBlock;         
        xinha_editors = Xinha.makeEditors(RTEtextAreas, xinha_config, xinha_plugins);
        Xinha.startEditors(xinha_editors); 
}

         

function initRTE (_textAreas, _stylesheet, _formatBlock) {
        RTEtextAreas = _textAreas;
        RTEstylesheet = _stylesheet;
        RTEformatBlock = _formatBlock; 
        Xinha.addOnloadHandler(xinha_init);
}
