/*
 * Ext JS Library 2.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */


// Sample desktop configuration
MyDesktop = new Ext.app.App({
	init :function(){
		Ext.QuickTips.init();
	},
    
	getModules : function(){
		return [
			new MyDesktop.SQLWindow(),
			new MyDesktop.PHPWindow(),
			new MyDesktop.JavaWindow(),
            new MyDesktop.TabWindow(),
			new MyDesktop.CssAccordionWindow(),
            new MyDesktop.AccordionWindow(),
            new MyDesktop.BogusMenuModule(),
            new MyDesktop.BogusModule()
		];
	},

    // config for the start menu
    getStartConfig : function(){
        return {
            title: 'theOpenSourcery List',
            iconCls: 'user',

            toolItems: [{
                text:'Reports',
                iconCls:'settings',
                scope:this
            },'-',{
                text:'Logout',
                iconCls:'logout',
                scope:this,
				id: 'close',
                handler: function(){
                  MyDesktop.destroy();
                }
            }]
        };
    }
});



/*
 * Example windows
 */
MyDesktop.CssAccordionWindow = Ext.extend(Ext.app.Module, {
    id:'accss-win',
    init : function(){
        this.launcher = {
            text: 'CSS Accordion Window',
            iconCls:'accordion',
            handler : this.createWindow,
            scope: this
        }
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('accss-win');
        if(!win){
            win = desktop.createWindow({
                id: 'accss-win',
                title: 'CSS Window',
                width:700,
                height:500,
                iconCls: 'accordion',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
                layout:'accordion',
                border:false,
                layoutConfig: {
                    animate:false
                },

                items: [
                     {
                        title: 'CSS Links',
                        autoLoad: {url: '_linkscss.html'},
						autoScroll:true
                    },{
                        title: 'CSS Most Popular',
                        autoLoad: {url: '_cssbest.html'},
                        autoScroll:true
                    },{
                        title: 'CSS Tips & Tutorials',
                        autoLoad: {url: '_csstips.html'},
                        autoScroll:true
                    }
                ]
            });
        }
        win.show();
    }
});


MyDesktop.TabWindow = Ext.extend(Ext.app.Module, {
    id:'tab-win',
    init : function(){
        this.launcher = {
            text: 'JavaScript Window',
            iconCls:'tabs',
            handler : this.createWindow,
            scope: this
        }
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('tab-win');
        if(!win){
            win = desktop.createWindow({
                id: 'tab-win',
                title:'JavaScript Resources at theOpenSourcery.com',
                width:740,
                height:500,
                iconCls: 'tabs',
                shim:false,
                animCollapse:false,
                border:false,
                constrainHeader:true,

                layout: 'fit',
                items:
                    new Ext.TabPanel({
                        activeTab:0,

                        items: [{
                            title: 'JavaScript Most Popular',
                            autoLoad: {url: '_jsbest.html'},
							autoScroll:true
                        },{
                            title: 'JavaScript Tips & Tutorials',
                            autoLoad: {url: '_jstips.html'},
							autoScroll:true
                        },{
                            title: 'JavaScript Links',
                            autoLoad: {url: '_linksjs.html'},
							autoScroll:true
                        }]
                    })
            });
        }
        win.show();
    }
});

MyDesktop.SQLWindow = Ext.extend(Ext.app.Module, {
    id:'sql-win',
    init : function(){
        this.launcher = {
            text: 'SQL Window',
            iconCls:'tabs',
            handler : this.createWindow,
            scope: this
        }
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('sql-win');
        if(!win){
            win = desktop.createWindow({
                id: 'sql-win',
                title:'SQL Resources at theOpenSourcery.com ',
                width:900,
                height:350,
                iconCls: 'tabs',
                shim:false,
                animCollapse:false,
                border:false,
                constrainHeader:true,

                layout: 'fit',
                items:
                    new Ext.TabPanel({
                        activeTab:0,

                        items: [{
                            title: 'SQL Popular Stories',
                            header:false,
                            autoLoad: {url: '_sqlbest.html'},
                            autoScroll:true
                        },{
                            title: 'Links to SQL Websites',
                            header:false,
                            autoLoad: {url: '_linkssql.html'},
                            autoScroll:true
                        },{
                            title: 'SQL Tips & Tutorials',
                            autoLoad: {url: '_sqltips.html'},
                            autoScroll:true
                        }]
                    })
            });
        }
        win.show();
    }
});
MyDesktop.PHPWindow = Ext.extend(Ext.app.Module, {
    id:'php-win',
    init : function(){
        this.launcher = {
            text: 'PHP Window',
            iconCls:'tabs',
            handler : this.createWindow,
            scope: this
        }
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('php-win');
        if(!win){
            win = desktop.createWindow({
                id: 'php-win',
                title:'PHP Resources at theOpenSourcery.com ',
                width:810,
                height:240,
                iconCls: 'tabs',
                shim:false,
                animCollapse:false,
                border:false,
                constrainHeader:true,

                layout: 'fit',
                items:
                    new Ext.TabPanel({
                        activeTab:0,

                        items: [{
                            title: 'PHP Popular Stories',
                            header:false,
                            autoLoad: { url: '_phpbest.html'},
                            autoScroll:true
                        },{
                            title: 'PHP Tips & Tutorials',
                            header:false,
                            autoLoad: {url: '_phptips.html'},
                            autoScroll:true
                        },{
                            title: 'PHP Links',
                            autoLoad: {url: '_linksphp.html'},
                            autoScroll:true
                        }]
                    })
            });
        }
        win.show();
    }
});
MyDesktop.JavaWindow = Ext.extend(Ext.app.Module, {
    id:'java-win',
    init : function(){
        this.launcher = {
            text: 'Java Window',
            iconCls:'tabs',
            handler : this.createWindow,
            scope: this
        }
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('java-win');
        if(!win){
            win = desktop.createWindow({
                id: 'java-win',
                title:'Java Resources at theOpenSourcery.com',
                width:800,
                height:240,
                iconCls: 'tabs',
                shim:false,
                animCollapse:false,
                border:false,
                constrainHeader:true,
                layout: 'fit',
                items:
                    new Ext.TabPanel({
                        activeTab:1,
                        items: [{
                            title: 'Java Most Popular',
                            autoLoad: {url: '_javabestf.html'},
                            autoScroll:true
                        },{
                            title: 'Java Tips and Tutorials',
                            header:false,
                            autoLoad: {url: '_javatips.html'},
                            autoScroll:true
                        },{
                            title: 'Java OpenSource Programs',
                            header:false,
                            autoLoad: {url: '_javafree.html'},
                            autoScroll:true
                        },{
                            title: 'Java Links',
                            autoLoad: {url: '_linksjava.html'},
                            autoScroll:true
                        }]
                    })
            });
        }
        win.show();
    }
});



MyDesktop.AccordionWindow = Ext.extend(Ext.app.Module, {
    id:'acc-win',
    init : function(){
        this.launcher = {
            text: 'Flash Accordion Window',
            iconCls:'accordion',
            handler : this.createWindow,
            scope: this
        }
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('acc-win');
        if(!win){
            win = desktop.createWindow({
                id: 'acc-win',
                title: 'Flash Accordion Window',
                width:750,
                height:400,
                iconCls: 'accordion',
                shim:true,
                animCollapse:false,
                constrainHeader:true,
                layout:'accordion',
                border:false,
                layoutConfig: {
                    animate:false
                },

                items: [
                     {
                        title: 'Flash Links',
                        autoLoad: {url: '_linksflash.html'},
                        autoScroll:true
                    },{
                        title: 'Flash Most Popular',
						autoLoad: {url: '_flashbest.html'},
                        autoScroll:true
                    },{
                        title: 'Flash Demos',
                        autoLoad: {url: '_flashings.html'},
						autoScroll:true
                    },{
                        title: 'Flash Tips & Tutorials',
                        autoLoad: {url: '_flashtips.html'},
                        autoScroll:true
                    }
                ]
            });
        }
        win.show();
    }
});

// for example purposes
var windowIndex = 0;

MyDesktop.BogusModule = Ext.extend(Ext.app.Module, {
    init : function(){
        this.launcher = {
            text: 'Notes on this Desktop',
            iconCls:'bogus',
            handler : this.createWindow,
            scope: this,
            windowId:windowIndex
        }
    },

    createWindow : function(src){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('bogus'+src.windowId);
        if(!win){
            win = desktop.createWindow({
                id: 'bogus'+src.windowId,
                title:src.text,
                width:400,
                height:400,
                autoLoad: {url: '_basewin.html'},
				autoScroll:true,
                iconCls: 'bogus',
                shim:false,
                animCollapse:false,
                constrainHeader:true
            });
        }
        win.show();
    }
});


MyDesktop.BogusMenuModule = Ext.extend(MyDesktop.BogusModule, {
    init : function(){
        this.launcher = {
            text: 'Bogus Submenu',
            iconCls: 'bogus',
            handler: function() {
				return false;
			},
            menu: {
                items:[{
                    text: 'Note to Users',
                    iconCls:'bogus',
                    handler : this.createWindow,
                    scope: this,
                    windowId: "htmlwindow"
                    },{
                    text: 'Bogus Window '+(++windowIndex),
                    iconCls:'bogus',
                    handler : this.createWindow,
                    scope: this,
                    windowId: windowIndex
                }]
            }
        }
    }
});


