////////// TINYMCE CONFIGURATION //////////

tinyMCE.init({
    mode : "none",
    theme : "advanced",
    //plugins : "safari,inlinepopups,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen",
    plugins : "safari,inlinepopups,table,advhr,advimage,advlink,emotions,insertdatetime,preview,media,searchreplace,contextmenu,paste,directionality,fullscreen",
    theme_advanced_buttons1_add : "fontselect,fontsizeselect,separator",
    theme_advanced_buttons2_add : "insertdate,inserttime,preview,separator,forecolor,backcolor,separator",
    theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
    //theme_advanced_buttons3_add : "emotions,iespell,media,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",
    theme_advanced_buttons3_add : "emotions,media,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",
    theme_advanced_buttons3_add_before : "tablecontrols,separator",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    //content_css : "/styles/general.css",
    content_css : radical.objh['mceStylesheet'],  //radical.objh['mceStylesheet'] is declared in loadhtml_dev.inc to provide a config bridge
  plugi2n_insertdate_dateFormat : "%Y-%m-%d",
  plugi2n_insertdate_timeFormat : "%H:%M:%S",
    //external_link_list_url : "example_link_list.js",
    //external_image_list_url : "example_image_list.js",
    //media_external_list_url : "example_media_list.js",
    file_browser_callback : "mFileBrowserCallBack",
    paste_use_dialog : false,
    theme_advanced_resizing : true,
    theme_advanced_resize_horizontal : false,
    //theme_advanced_link_targets : "_something=My somthing;_something2=My somthing2;_something3=My somthing3;",
    theme_advanced_link_targets : "",
    paste_auto_cleanup_on_paste : true,
    paste_convert_headers_to_strong : false,
    paste_strip_class_attributes : "all",
    paste_remove_spans : true,
    paste_remove_styles : true
});

function mFileBrowserCallBack(field_name, url, type, win) {
    // block multiple file browser windows
    //if (!tinyMCE.selectedInstance.fileBrowserAlreadyOpen) {
        // toggle file browser state to open (true)
        //tinyMCE.selectedInstance.fileBrowserAlreadyOpen = true;

        // configure mMediaManager variables
        var mmm = [];
        mmm.push(radical.objh['filebrowser_' + tinyMCE.selectedInstance.editorId]);
        mmm.push('action=makeui');
        mmm.push('type=' + type);

        // open the media manager popup
        tinyMCE.activeEditor.windowManager.open({
            file : mmm.join('&'),
            title : "mMediaManager",
            width : 800,
            height : 500,
            inline : true
        }, {
            input : field_name,
            window : win,
            tinymceselectedinstance : tinyMCE.selectedInstance
        });
    //} else {
        //alert('Only one file browser window can be opened at a time!');
    //}
    return false;
}
