var WOoo = {
	init_html_editors: function() {
		tinyMCE.init({
			mode : "none",
			theme : "advanced",
			plugins: "safari,advimage,contextmenu,table, save",
			width: "560px",
			height: "200px",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			editor_selector : "html_editor",
			editor_deselector : "text_editor",
			// class styles
			theme_advanced_styles : "Important=important",
			theme_advanced_buttons1: "bold,italic,underline,styleselect,formatselect,removeformat,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,outdent,indent",
			theme_advanced_buttons2: "link,unlink,|,image,code,|,tablecontrols",
			theme_advanced_buttons3: "",
			theme_advanced_blockformats : "p,div,h1,h2,h3,h4,h5,h6,blockquote,dt,dd,code,samp",
			cleanup_on_startup : true,
			cleanup: true,
			debug : true
		});
		tinyMCE.settings.keep_values = true;
	},
	
	init_html_textareas: function() {
		$$('.html_editor').each(function(field) {
			tinyMCE.execCommand("mceAddControl", true, field.id);
		});
	},
	
	remove_html_textareas: function() {
		$$('.html_editor').each(function(field) {
			tinyMCE.execCommand("mceRemoveControl", true, field.id);
		});
	},
	
	adjust_image_size: function(image, max_width, max_height) {
		var image_width = image.width;
		var image_height = image.height;
		
		if (image_width > image_height) {
			image.width = max_width;
			image.height = image_height * max_width / image_width;
		} else {
			image.height = max_height;
			image.width = image_width * max_height / image_height;
		}
	}
};

// Event.observe(window, 'load', WOoo.init_html_editors);
WOoo.init_html_editors();