function brstonewline(element_id, html, body) {
	//html = html.replace(/<br\s*\/>/gi, "\n");
	return html;
}


function initAjaxMCE() {

 if (!document.getElementById('mp_pinkeltje_postearea_ajax'))
  return false;
 
 $(document).ready(function () {
	tinyMCE.init({
				 elements:  "mp_pinkeltje_postearea_ajax",
				 mode : "exact",
				 theme : "advanced",
				 theme_advanced_buttons1 : "bold,italic,underline,|,strikethrough,|,bullist,numlist,|,undo,redo,|,link,unlink,|,removeformat",
				 theme_advanced_buttons2 : "",
				 theme_advanced_buttons3 : "",
				 width : "553",
				 theme_advanced_toolbar_location : "top",
				 theme_advanced_toolbar_align: "left",
				 theme_advanced_statusbar_location : "none",
				 theme_advanced_resizing : false, 
				 content_css : "http://www.matepress.com/wp-content/mu-plugins/mp-pinkeltje/css/tinymce.css",
				 theme_advanced_resize_horizontal: false,
				 theme_advanced_disable : "code",
				 force_p_newlines : false,
				 force_br_newlines : true,
				 forced_root_block: "",
				 gecko_spellcheck : true,
				 directionality : "ltr",
				 save_callback : "brstonewline",
				 entity_encoding : "raw",
				 extended_valid_elements : "a[name|href|title],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],blockquote[cite]",
				 language : "en"
	}); 
	
	var postform = document.getElementById('mp_pinkeltje_new_post_form_ajax');
	
	if (postform) {
		postform.onsubmit = function()
		{
			 var sTitleBox = document.getElementById('mp_pinkeltje_posttitle_js_ajax');
	
			 if (sTitleBox) {
				 if (sTitleBox.value.length == 0)
				 {
					var mErrorBox = document.getElementById('mp_pinkeltje_title_error_ajax');
					mErrorBox.innerHTML = 'Please fill in the title'; 
				 }	else {
					
	
					 
					return true;
				 }
			 }
			return false;	
		}
	}
	
 });
}


window.onload = function() {

	
	 if (!document.getElementById('post_text'))
		  return false;

	tinyMCE.init({
		 elements:"post_text",
		 mode : "exact",
		 theme: "advanced",
		 theme_advanced_buttons1 : "bold,italic,underline,|,strikethrough,|,bullist,numlist,|,undo,redo,|,link,unlink,|,removeformat,|,image",
		 theme_advanced_buttons2 : "",
		 theme_advanced_buttons3 : "",
		 width : "548",
		 content_css : "http://www.matepress.com/wp-content/mu-plugins/mp-pinkeltje/css/tinymce.css",
		 theme_advanced_toolbar_location : "top",
		 theme_advanced_toolbar_align: "left",
		 theme_advanced_statusbar_location : "none",
		 theme_advanced_resizing : false, 
		 theme_advanced_resize_horizontal: false,
		 theme_advanced_disable : "code",
		 force_p_newlines : false,
		 force_br_newlines : true,
		 forced_root_block: "",
		 gecko_spellcheck : false,
		 directionality : "ltr",
		 save_callback : "brstonewline",
		 entity_encoding : "raw",
		 plugins: "",
		 media_strict: true,
		 extended_valid_elements : "a[name|href|title],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],blockquote[cite]"
		
	}); 	
	var postform = document.getElementById('express');
	
	if (postform) {
		postform.onsubmit = function()
		{
			 var sTitleBox = document.getElementById('post_title');
	
			 if (sTitleBox) {
				 if (sTitleBox.value.length == 0)
				 {
					var mErrorBox = document.getElementById('mp_pinkeltje_title_error');
					mErrorBox.innerHTML = 'Please fill in the title'; 
				 }	else {
					
	
					 
					return true;
				 }
			 }
			return false;	
		}
	}
	


}