tinyMCE.init({
	mode : "textareas",
	editor_selector : "mceEditor",
	save_callback : "mceSave",
	urlconverter_callback : "mceURLConverter",
	theme : "advanced",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	language : "zh",
	dialog_type : "modal",
	relative_urls : false,
	remove_linebreaks : false,
	forced_root_block : "",
	force_br_newlines : true,
	event_elements : "a,img,span,div",
	extended_valid_elements : "iframe[src|frameborder=0|width|height|align|scrolling|name|id|style|marginheight|marginwidth|border],"+
							"script[src|type|language],"+
							"form[action|method|name|style],"+
							"center,"+
							"input[type|name|value|checked|src|alt|size|maxlength|onfocus|onclick|onblur],"+
							"button[name|value|type],"+
							"select[name|size|multiple|onchange],"+
							"textarea[name|rows|cols|onfocus|onclick|onblur]",
	height : 150,
	width : 550,
	
	add_form_submit_trigger : true,
	submit_patch : true,
	add_unload_trigger : false,
	
	plugins : "preview,media,inlinepopups",
	
	theme_advanced_buttons2 : "",
	theme_advanced_buttons3 : "",
	theme_advanced_buttons1_add_before : "undo,redo,separator",
	theme_advanced_buttons1_add : "forecolor,backcolor,fontsizeselect,removeformat,separator,link,unlink,image,media,preview,code,help",
	theme_advanced_disable : "styleselect,formatselect,justifyfull,strikethrough",
	theme_advanced_resizing : true,
	theme_advanced_resizing_use_cookie : false,
	invalid_elements : ""
});

// 保存数据前处理
function mceSave(eleId, html, body){
	var re=/^\s*<p>(.*)<\/p>\s*$/ig;
	if(html.search(re)>-1 && html.match(/<p>/ig).length==1){
		html = html.replace(re, "$1");
	}
	return html;
}

// tinyMCE地址转换有点问题
function mceURLConverter(url, node, on_save) {
	var du=tinyMCE.activeEditor.documentBaseURI.getURI();
	if(url.length>du.length && url.toLowerCase().indexOf(du.toLowerCase())==0){
		url=url.substring(du.length);
	}
	return url;
}


