/*
 * $Id: faba5.sectionRichText-1.0.js 2325 2011-08-19 07:10:42Z markus.tripp@fabasoft.com $
 * 
 * Copyright © Fabasoft R&D GmbH, A-4020 Linz, 1995-2011.
 * 
 * All rights reserved. All hardware and software names used are registered trade names and/or registered trademarks of  
 * the respective manufacturers.
 * 
 * The user of this computer program acknowledges that the above copyright notice, which constitutes the Universal 
 * Copyright Convention, will be attached at the position in the function of the computer program which the author has 
 * deemed to sufficiently express the reservation of copyright. It is prohibited for customers, users and/or third  
 * parties to remove, modify or move this copyright notice.
 * 
 * This computer program is protected by copyright law and international treaties. Unauthorized reproduction or 
 * redistribution of this program, or any portion of it, may result in severe civil and criminal penalties.
 * 
 * The use of this software requires a valid license agreement for this software. This license agreement specifies 
 * especially permitted use through the licensing model. A license agreement must already exist prior to installing the 
 * software as the installation process of this software does not include the conclusion of a license agreement.
 */

(function ($) {
    var editor = null;

    var sectionRichTextMethods = {
        type: function() {
            return 'text';
        },
        supports: function(type) {
            // add browser tests if this tool is supported
            if (type == null || type == 'text') {
                return true;
            }
            
            return false;
        },
        edit: function(content, edit) {
            if (content.length == 0) {
                edit.html('<p>Enter text here...</p>').css('min-height', '100px');
            } else {
                edit.html(content);
            }
            
            var container = $('#finspectorContainer');
            if (container.length == 0) {
                container = $('<div/>').attr('id', 'finspectorContainer');
                container.hide().appendTo('body');
            }
            
            container.richeditor();
            container.richeditor('open', edit);
        },
        
        val: function(edit) {
            return $('#finspectorContainer').richeditor('value');
        },
        
        close: function(edit) {
            $('#finspectorContainer').richeditor('close');
            
            return true;
        }
    };

    $.fn.sectionRichText = function(method) {
        if (sectionRichTextMethods[method]) {
            return sectionRichTextMethods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        }
    };
}) (jQuery);

