﻿
function SaveTinyMCEEditors() {
    tinyMCE.triggerSave();

}    


    //Ids de los elementos separados por comas
    //maximos separados por comas
function InitEditorInIds(idsStr, maxStr, readonly) {

    var idsArray = idsStr.split(',');
    var maxArray = maxStr.split(',');
        for(var i = 0; i < idsArray.length; i++){
            tinyMCE.init({
                // General options
                mode: "exact",
                elements: idsArray[i],
                theme: "advanced",
                plugins: "autolink,lists,advlink,inlinepopups,preview,print,contextmenu,paste,fullscreen,advlist,maxchars",
                language: "en",
                dialog_type: "modal",
                readonly: readonly,

                // Theme options
                theme_advanced_buttons1: "cut,copy,paste,pastetext,pasteword,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,code,print,fullscreen",
                theme_advanced_buttons2: "bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,|,forecolor,backcolor,|,sub,sup,charmap",
                theme_advanced_buttons3: "",
                theme_advanced_toolbar_location: "top",
                theme_advanced_toolbar_align: "left",
                theme_advanced_resizing: true,
                max_chars: maxArray[i],
                max_chars_indicator: idsArray[i] + "Counter"
        });
    }
}


function validateTinyMCEText(source, args) 
{   
    var txt = document.getElementById(source.controltovalidate);
    tinyMCE.triggerSave();
    args.Value = (txt.value.replace(/^W+/,'')).replace(/W+$/,'');
    args.IsValid = (args.Value != '');
}
