﻿function HighlightEditableArea(strObjID, blnOver) {
   
    if (blnOver)
        document.getElementById(strObjID).setAttribute("class", "editableContentHighlight");
    else
        document.getElementById(strObjID).setAttribute("class", "editableContentNoHighlight");
}

function HTMLEditor() {

    this.InitCkeditor = function(strDivBrowserNotCompatibleID, strTxtEditorID, strTxtEditorUniqueID, strCkeditorConfigFile, strDivContentID, strDivTextEditorID, strBtnEditID, strBtnCloseID) {

        var objBrowserNotCompatible = document.getElementById(strDivBrowserNotCompatibleID);

        if (!CKEDITOR.env.isCompatible) {
            objBrowserNotCompatible.style.display = "block";
        } else {

            if (!this.editor) {

                this.editor = CKEDITOR.replace(strTxtEditorUniqueID,
                    {
                        customConfig: strCkeditorConfigFile
                    }
                );

                var html = document.getElementById(strDivContentID).innerHTML;
                this.editor.setData(html);

                document.getElementById(strDivTextEditorID).style.display = "block";
                document.getElementById(strDivContentID).style.display = "none";
                document.getElementById(strBtnEditID).style.display = "none";
                document.getElementById(strBtnCloseID).style.display = "block";

            } else {

                if (confirm('Close editor and lose all changes?')) {

                    this.editor.destroy();
                    this.editor = null;

                    document.getElementById(strDivTextEditorID).style.display = "none";
                    document.getElementById(strDivContentID).style.display = "block";
                    document.getElementById(strBtnEditID).style.display = "block";
                    document.getElementById(strBtnCloseID).style.display = "none";
                    document.getElementById(strTxtEditorID).value = "";

                }
            }

        }

        return false;

    };

}   
