

	tinyMCE.init({
		height: '200px',
		width: '300px',
		mode : "textareas",
		theme : "advanced",
		plugins : "safari,pagebreak,style,layer,save,advhr,advlink,emotions,iespell,insertdatetime,preview,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,template,inlinepopups",

		// Theme options
		theme_advanced_buttons1 : "fontsizeselect,|,forecolor,backcolor,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,cleanup",
		theme_advanced_buttons2 : ",cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,removeformat,|,charmap,iespell,|,fullscreen",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,


		// Example word content CSS (should be your site CSS) this one removes paragraph margins
		content_css : "css/word.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		editor_selector : "text_editor",
		relative_urls : false,
		setup: function(ed) {
			var text = '';
			var span = document.getElementById('word-count-' + ed.id);
			if(span) {
				var wordlimit = span.innerHTML;
				ed.onKeyDown.add(function(ed, e) {
					text = ed.getContent().replace(/(< ([^>]+)<)/g, '').replace(/\s+/g, ' ');
					text = text.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
					wordcount = wordlimit - (text.split(' ').length);
					span.innerHTML = wordcount;
					if(wordcount <= 0 && e.keyCode != 8) {
						return tinymce.dom.Event.cancel(e);
					}
				});
			}
		}
	});

function ezfilemanager (field_name, url, type, win) {
//Change the var pluginPath to reflect your installation path
var PluginPath = "tiny_mce/plugins/ezfilemanager/ezfilemanager.php"; 
       if (PluginPath.indexOf("?") < 0) 
	   		{
            PluginPath = PluginPath + "?type=" + type;
       		}
       else {
            PluginPath = PluginPath + "&type=" + type;
       		}

       tinyMCE.activeEditor.windowManager.open({
           file : PluginPath,
           title : '',
           width : 650, 
           height : 440,
           resizable : "yes",
           scrollbars : "yes",
           inline : "yes", 
           close_previous : "no"
       		}, {
           window : win,
           input : field_name
       		});
       return false;
     }
