﻿Ext.onReady(function() {
    var main_form = new Ext.Viewport({
        renderTo: Ext.getBody(),
        layout: 'border',
        items: [{
            layout: 'border',
            region: 'west',
            border: false,
            split: true,
            margins: '2 0 5 5',
            width: 170,
            minSize: 100,
            maxSize: 300,
            animCollapse: false,
            title: 'Navigation',
            collapsible: true,
            items: [{
                xtype: 'treepanel',
                region: 'center',
                autoScroll: true,
                split: true,
                rootVisible: false,
                loader: new Ext.tree.TreeLoader(),
                root: new Ext.tree.AsyncTreeNode({
                    expanded: true,
                    children: [{
                        text: 'Error Log',
                        href: 'ErrorLog.aspx',
                        leaf: true
                    }, {
                        text: 'Global Login',
                        href: 'GlobalLogin.aspx',
                        leaf: true
                    }, {
                        text: 'Matches',
                        href: 'Matches.aspx',
                        leaf: true
                    }, {
                        text: 'Map League',
                        href: 'MapLeague.aspx',
                        leaf: true
                    }, {
                        text: 'Map Team',
                        href: 'MapTeam.aspx',
                        leaf: true
                    }, {
                        text: 'View Capture Odds',
                        href: 'ViewCaptureOdds.aspx',
                        leaf: true
                    }, {
                        text: 'Job List',
                        href: 'JobList.aspx',
                        leaf: true
                    }, {
                        text: 'Restart Services',
                        href: 'RestartServices.aspx',
                        leaf: true
                    }]
                }),
                listeners: {
                    click: function(n, e) {
                        e.stopEvent(); 
                        getCmp('iframe').setTitle(n.attributes.text);
                        getCmp('iframe').setSrc(n.attributes.href, false);
                    }
                }
            }, {
                layout: 'border',
                title: 'Others',
                region: 'south',
                height: 300,
                items: [{
                     region: 'center',
                     xtype: 'iframepanel',
                     defaultSrc: 'CompanyStatus.aspx'
                }]
            }]
        }, {
            id: 'iframe',
            xtype: 'iframepanel',
            region: 'center',
            title:'&nbsp'
        }]
    });
});

function getCmp(obj){
    return Ext.getCmp(obj);
}