tinyMCE.init({
    document_base_url: mdlHome,
	editor_selector: "form-textarea",
	mode: "textareas",
	theme: "advanced",
	skin: "o2k7",
	skin_variant: "silver",
	
	plugins: "inlinepopups,contextmenu,table,style,searchreplace,emotions,media,insertdatetime,paste,safari,advimage,advlink,moodlelink",
	
	theme_advanced_toolbar_location: "top",
	theme_advanced_toolbar_align: "left",
	
	theme_advanced_buttons1: "formatselect,fontselect,fontsizeselect,|,bold,italic,underline,|,forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull",
	theme_advanced_buttons2: "cut,copy,paste,pasteword,|,emotions,charmap,|,search,replace,|,bullist,numlist,|,image,media,styleprops,hr,link,|,insertdate,inserttime,|,code",
	theme_advanced_buttons3: "",
	theme_advanced_buttons4: "",
	
	moodleimage_course_id: mdlId,
	file_browser_callback: "moodlefilemanager",
	
	relative_urls: false,
    remove_script_host: true,
	theme_advanced_resize_horizontal: false,
	theme_advanced_resize_vertical: true,
	theme_advanced_resizing: true,
	
	force_br_newlines: false,
	convert_newlines_to_brs: false,
	forced_root_block: '',
	cleanup: true,
	
	apply_source_formatting: true,
	extended_valid_elements: "input[name|size|type|value|onclick|id],img[id|class|style|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],iframe[height|width|src],form[method|action|name|id]"
});

function moodlefilemanager(field_name, url, type, win)
{
	   tinyMCE.activeEditor.windowManager.open(
	   {
           file: mdlHome + "/lib/editor/tinymce_whs/plugins/moodlelink/link.php?id=" + mdlId,
           width: 480,
           height: 380,
           resizable: "yes",
           inline: "yes",  
           close_previous: "no"
       },
	   {
           window : win,
           input : field_name
       });
       return false;
}
