  tinyMCE.init({
    mode : "textareas",
    theme : "advanced",
    relative_urls : false,
    plugins : 'emotions,spellchecker',
    spellchecker_languages : "+English=en",
    spellchecker_rpc_url:"/TinyMCESpellCheck.do",
    setup : function(ed) {
        // Add a custom button
        ed.addButton('insertImage', {
        title : 'Upload Image',
        image : '/images/insertimage.gif',
        onclick : function() {
            tinyMCE_onBlurCallback(ed);
            var timestamp = Number(new Date());
            jQuery.get('/photos/InsertPhotos.do?'+timestamp, function(data) { jQuery.facebox(data) })
        }
        }); },    
    
    theme_advanced_buttons1 : "bold,italic,underline,image,link,unlink,|,bullist,numlist,|,fontsizeselect,forecolor,|,emotions,insertImage,spellchecker,|,code",
	theme_advanced_buttons2 : "",
	theme_advanced_buttons3 : "",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : 'none',
	tab_focus : ':prev,:next',
	handle_event_callback : "myHandleEvent",
	extended_valid_elements :"a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[align|style],p[align],h2[title|align|width|height]]",
	invalid_elements :"div,table,td,tr,textarea[cols|rows|disabled|name|readonly],xml,form,input,noscript,optgroup,option,script"
});  
 
	function myHandleEvent(e) {
  		if(typeof handleEvent == 'function') {
  			handleEvent(e);
  		}
	}
    // A global variable for storing cursor-position
    // If you have multiple instances of MCE on the same page,
    // You need to do something smarter :-)
    var editorCursorPosition = 0;
    var editorObj = null;

    // The function called by MCE on "blur"
    function tinyMCE_onBlurCallback(ed) {
        ua=navigator.userAgent.toLowerCase();
        editorObj = ed;

        // Aparently this is only needed for IE, and seems to give bugs when used if FF
        if (editorCursorPosition == 0 && ua.indexOf('msie 6.0') >= 0) {
            editorCursorPosition = tinyMCE.selectedInstance.selection.getBookmark(false);
        }
    }	
