tinyMCE.init({
                    theme : "advanced",
                    //mode : "textareas",
                    //elements : "content",
                    mode : "exact",
                    plugins : "paste",
                    paste_auto_cleanup_on_paste : true,
                    paste_remove_styles: true,
                    elements : "textarea_id,message,r_message",
                    theme_advanced_buttons3_add : "pastetext,pasteword,selectall",
                    theme_advanced_buttons1 : "bold,italic,underline,bullist,numlist,sub,sup,charmap",
                    theme_advanced_buttons2 : "",
                    theme_advanced_buttons3 : "",
                    theme_advanced_buttons4 : "",
                    theme_advanced_toolbar_location : "top",
                    theme_advanced_toolbar_align : "left",
                    paste_preprocess : function(pl, o) {
                        // Content string containing the HTML from the clipboard
                        //alert('pasteprocess startet');
                        o.content = strip_tags(o.content, '<br/>');
                        //alert('pasteprocess ended - function strip_tags found and used');
                    },
                    handle_event_callback : function(e){
                        if(e.type == 'blur'){
                            tinyMCE.triggerSave();
                            if(tinyMCE.photonic_textarea){
                                validateIt(tinyMCE.photonic_textarea);  
                            }
                        }
                    }
                });
                
   function strip_tags (str, allowed_tags) {
        var key = '', allowed = false;
        var matches = [];    var allowed_array = [];
        var allowed_tag = '';
        var i = 0;
        var k = '';
        var html = '';
        var replacer = function (search, replace, str) {
            return str.split(search).join(replace);
        };
         // Build allowes tags associative array
        if (allowed_tags) {
            allowed_array = allowed_tags.match(/([a-zA-Z0-9]+)/gi);
        }
         str += '';

        // Match tags
        matches = str.match(/(<\/?[\S][^>]*>)/gi);
         // Go through all HTML tags
        for (key in matches) {
            if (isNaN(key)) {
                // IE7 Hack
                continue;        }

            // Save HTML tag
            html = matches[key].toString();
             // Is tag not in allowed list? Remove from str!
            allowed = false;

            // Go through all allowed tags
            for (k in allowed_array) {            // Init
                allowed_tag = allowed_array[k];
                i = -1;

                if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+'>');}            if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+' ');}
                if (i != 0) { i = html.toLowerCase().indexOf('</'+allowed_tag)   ;}

                // Determine
                if (i == 0) {                allowed = true;
                    break;
                }
            }
             if (!allowed) {
                str = replacer(html, "", str); // Custom replace. No regexing
            }
        }
         return str;
}

//console.log(tinymce);
