// tiny MCE - 
//    jQuery plugin for accessible, unobtrusive WYSIWYG HTML editing
// v .1
// by Alton Crossley
// http://www.nogahidebootstrap.com/jtinymce/
// Free beer and free speech. Enjoy!

$.fn.tinymce = function(options){
	return this.each(function(){
		//preString = "<div class='jqHTML_frame' style='width:"+$(this).css("width")+"px;height:" + ($(this).css("height")+20) + "px;'><div>";
		//postString = "</div><div class='jqHTML_link' style='float:right' onclick="toogleEditorMode('" + this.id + "');">HTML</div></div>";
		preString = "<div class='jqHTML_frame' style='width:"+$(this).css("width")+"px;height:" + ($(this).css("height")+20) + "px;'>";
		postString = "</div>";
		$(this).wrap(preString + postString);
		tinyMCE.settings = tinyMCEconfigs[this.className];
		tinyMCE.execCommand('mceAddControl', true, this.id);
	});
};

	var tinyMCEconfigs = {
		'mce1': {
			mode : "none",
			theme : "advanced",
			language : "pl",
			//mode : "textareas",
			//editor_selector : "post_text",
			plugins : "bbcode",
			//theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,styleselect,removeformat,cleanup,code",
			theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,forecolor,styleselect,removeformat,cleanup,code",
			theme_advanced_buttons2 : "",
			theme_advanced_buttons3 : "",
			theme_advanced_toolbar_location : "bottom",
			theme_advanced_toolbar_align : "center",
			theme_advanced_styles : "Kod=codeStyle;Cytat=quoteStyle",
			content_css : "/css/tinymce.css",
			entity_encoding : "raw",
			add_unload_trigger : false,
			remove_linebreaks : false
		},
		'mce2': {
			mode : "none",
			theme : "advanced",
			language : "pl",
			//plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",
			plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
			theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
			theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
			theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
			theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
			//theme_advanced_toolbar_location : "top",
			//theme_advanced_toolbar_align : "left",
			theme_advanced_toolbar_location : "bottom",
			theme_advanced_toolbar_align : "center",
			//theme_advanced_statusbar_location : "bottom",
			theme_advanced_resizing : true,
			content_css : "/css/tinymce.css",
			template_external_list_url : "js/template_list.js",
			external_link_list_url : "js/link_list.js",
			external_image_list_url : "js/image_list.js",
			media_external_list_url : "js/media_list.js",
			// Replace values for the template plugin
			template_replace_values : {
				username : "Some User",
				staffid : "991234"
			}
		}};

$(document).ready(function() {
	//$('.textarea').tinymce();
	$('.mce1,.mce2').tinymce();
});

