<!--
mceTagWrap = function(element_id, html, body) {
    html = trim(html);
    if (html.length > 0) {
        /* check that text starts and ends with tags if not wrap it in <p>s.
         * This only happens for single line text messages */
        if(html.charAt(0) != "<" || (html.charAt(html.length - 1) != ">" || html.charAt(html.length -2) == "/")) {
            html = "<p>"+html+"</p>";
            /*html = html;*/	
            	
        }
    }
    return html;
}

trim = function(inString) {
    inString = inString.replace(/^\s+/g, "");// strip leading
    return inString.replace(/\s+$/g, "");// strip trailing
}

initTinyMCE = function() {
    tinyMCE.init({
	    mode : "specific_textareas",
	    editor_selector : "formTextfieldEditor",
        theme : "advanced",
        height : "300px",
        width : "500px",
        force_p_newlines : true,
        plugins : "paste",
        forced_root_block : '', // Needed for 3.x*/
        save_callback : "mceTagWrap",
        theme_advanced_buttons1 : "justifyleft,separator,justifycenter,separator,justifyright,separator,justifyfull,separator,bold,separator,italic,separator,underline,separator,bullist,separator,numlist,separator,link,separator,unlink,separator,undo,separator,redo,separator,code,separator,pastetext,separator,pasteword,separator,selectall",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_buttons4 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        valid_elements : "#p[id|style|dir|class|align],-strong/-b,-em/-i,-strike,-u,-ol,-ul,-li,-a[href|target|name],br,-img,-font[color|id|size],upload,advimage,media,paste",
        paste_strip_class_attributes : "mso",
        paste_create_paragraphs : true,
        fix_content_duplication : false,
        paste_remove_styles : false,
        paste_convert_headers_to_strong : true

    });
}
// -->