﻿/*
The code in this file or document and its designs, methods, data, know-how and all other related elements are the property of LUXSON ltd © Copyright 2009-2010 and/or may contain code operated under third party licence(s); unauthorised use is therefore prohibited, including (without limitation) copying, editing, adapting, reverse engineering or any other similar or related action, in part or in full. Separate rights may also exist for LUXSON and/or client and/or third party content and/or services. For licensing information please contact LUXSON ltd.
*/

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;

    };

}
