var HelpManager = function() {

    var helpDialog;
    var helpText;
    return {
        init: function () {
            
            helpDialog = new Ext.Window({                
                id: 'focalpowerHelpWindow',
                title: 'Online Help',
                height: 300,
                width: 500,
                autoScroll: true,
                modal: true,
                closable: true,
                closeAction:'hide',
                collapsible: false,
                draggable: true,
                resizable: true,
                fixedcenter: true,
                shadow: true,
                border: false,
                bodyStyle: 'background-color: white;',
                items: new Ext.Panel({
                    id: 'focalpowerHelpPanel',
                    border: false,
                    style: 'padding: 5px'
                }),
                buttons: [
                    {
                        text: 'Done',
                        handler: function() { helpDialog.hide() }
                    }
                ]
            });
        },
        showHelp: function (id, helpKey) {
            if (!helpDialog.rendered) {
                helpDialog.show();
            }            
                    
            Ext.getCmp('focalpowerHelpPanel').load({
                url: '/app/help/' + helpKey + '/',
                indicatorText: "Loading Help...",
                disableCaching: true
            }); 
            helpDialog.center();
            helpDialog.show();
            
        }

    };

}();

Ext.EventManager.onDocumentReady(function(){
    HelpManager.init();
},
HelpManager, true);

