YAHOO.util.Event.onDOMReady(function() {
    if ($('SubmitReply')) {
        var SubmitReply = new YAHOO.widget.Button('SubmitReply');

        SubmitReply.addListener('click', function() {
            SimpleEditor.saveHTML();
            sendRequest('forums', 'submitReply', 'replyForm');
        });
    }

    if ($('SubmitThread')) {
        var SubmitThread = new YAHOO.widget.Button('SubmitThread');

        SubmitThread.addListener('click', function() {
            SimpleEditor.saveHTML();
            sendRequest('forums', 'SubmitThread', 'threadForm');
        });
    }

    var SimpleEditor = new YAHOO.widget.SimpleEditor('editor', {
        'height'        : '250px',
        'width'         : '100%',
        'animate'       : true,
        'dompath'       : false,
        'focusAtStart'  : true,
        'autoHeight'    : true,
        'markup'        : 'xhtml',
        'toolbar'       : {
            'buttons'   : [{
                'group' : 'textstyle',
                'buttons'   : [{
                    'type'  : 'push',
                    'label' : 'Bold',
                    'value' : 'bold'
                }, {
                    'type'  : 'push',
                    'label' : 'Italic',
                    'value' : 'italic'
                }, {
                    'type': 'push',
                    'label': 'Underline',
                    'value': 'underline'
                }, {
                    'type'  : 'separator'
                }, {
                    'type'      : 'color',
                    'label'     : 'Font Color',
                    'value'     : 'forecolor',
                    'disabled'  : true
                }, {
                    'type'      : 'color',
                    'label'     : 'Background Color',
                    'value'     : 'backcolor',
                    'disabled'  : true
                }]
            }
        ]}
    });

    SimpleEditor.render();
});
