YAHOO.util.Event.onDOMReady(function() {
    var buttons = $$('button.deleteComment');

    if (buttons) {
        for (x in buttons) {
            button = new YAHOO.widget.Button(buttons[x]);

            button.addListener('click', function(e) {
                sendRequestObject('global', 'deleteComment', {'comment_id': YAHOO.util.Event.getTarget(e).id});
            });
        }
    }

    var commentButton = new YAHOO.widget.Button('commentButton');

    commentButton.addListener('click', function() {
        SimpleEditor.saveHTML();
        sendRequest('global', 'addComment', 'commentForm');
    });

    var SimpleEditor = new YAHOO.widget.SimpleEditor('editor', {
        'height'        : '250px',
        'width'         : '100%',
        'animate'       : true,
        'dompath'       : false,
        'focusAtStart'  : false,
        'autoHeight'    : true,
        '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();
});
