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

// Sample desktop configuration
MyDesktop = new Ext.app.App({

	init :function(){
		Ext.QuickTips.init();
		this.on('ready', function(){
			this.getModules()[0].createWindow();
			});
	},
	myModules: null,
	getModules : function(){
		if(this.myModules == null){
			this.myModules =  [
				new MyDesktop.MetroleoWindow(),
				new MyDesktop.ActivityWindow(),
				new MyDesktop.MemberWindow(),
				new MyDesktop.PublicationWindow(),
				new MyDesktop.PhotoWindow(),
				new MyDesktop.FacebookWindow(),
				new MyDesktop.FundWindow(),
				new MyDesktop.RegistrationWindow()
			]
		}
		return this.myModules;
	},

    // config for the start menu
    getStartConfig : function(){
        return {
            title: 'WorldLearn Workspace',
            iconCls: 'user',
            toolItems: [{
                text:'Settings',
                iconCls:'settings',
                scope:this
            },'-',{
                text:'Logout',
                iconCls:'logout',
                scope:this
            }]
        };
    }
});



/*
 * Example windows
 */
MyDesktop.ActivityWindow = Ext.extend(Ext.app.Module, {
    id:'activity-win',
    init : function(){
        this.launcher = {
            text: 'Upcoming Activity',
            iconCls:'activity',
            handler : this.createWindow,
            scope: this
        }
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('activity-win');
	var box = Ext.get('x-desktop').getBox(true);

        if(!win){
            win = desktop.createWindow({
                id: 'activity-win',
                title:'Upcoming Activities',
                width:box.width - 300,
		height: box.height - 100,
                iconCls: 'activity',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
		x: 200,
		y: 50,
                layout: 'fit',
                layoutConfig: {
                    animate:false
                },
		items: [
			new Ext.TabPanel({
			  activeTab:0,
			  items: [
				new Ext.ux.ManagedIFrame.Component({
					defaultSrc: 'https://spreadsheets.google.com/a/metroleo.org.hk/viewform?hl=en&formkey=dGtPOWM2NEI5cGdMMEJhVlhnZ29Menc6MA..',
					title: 'Sign up'
				}),
				new Ext.ux.ManagedIFrame.Component({
					defaultSrc: 'https://www.google.com/calendar/hosted/metroleo.org.hk/embed?showTitle=0&src=j06u0dek6hht5t6ghger980cr0%40group.calendar.google.com&ctz=Asia/Hong_Kong',
					title: 'Calendar'
				})
			  ]
			})
                ]
            });
        }
        win.show();
    }
});



MyDesktop.RegistrationWindow = Ext.extend(Ext.app.Module, {
    id:'registration-win',
    init : function(){
        this.launcher = {
            text: 'Observer Registration',
            iconCls:'registration',
            handler : this.createWindow,
            scope: this
        }
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('registration-win');
	var box = Ext.get('x-desktop').getBox(true);
	
        if(!win){
            win = desktop.createWindow({
                id: 'registration-win',
                title: 'Observer Registration',
                width:650,
		height: box.height - 100,
                iconCls: 'registration',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
                layout:'fit',
                border:false,
                layoutConfig: {
                    animate:false
                },
                items: [
			new Ext.ux.ManagedIFrame.Component({
				defaultSrc: 'http://spreadsheets.google.com/viewform?key=pOFCKaQ9lQCDUg7D8NXgXIA&email=true',
				title: 'Observer Signup'
			})
                ]
            });
        }
        win.show();
    }
});

MyDesktop.MetroleoWindow = Ext.extend(Ext.app.Module, {
    id:'metroleo-win',
    init : function(){
        this.launcher = {
            text: 'Metroleo Introduction',
            iconCls:'metroleo',
            handler : this.createWindow,
            scope: this
        }
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('metroleo-win');
	
        if(!win){
            win = desktop.createWindow({
                id: 'metroleo-win',
                title: 'About Leo Club of Metropolitan Hong Kong',
                width:'85%',
                height:600,
                iconCls: 'metroleo',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
                border:false,
                layout: 'fit',
                layoutConfig: {
                    animate:false
                },

                items: [
			new Ext.TabPanel({
			  activeTab:0,
			  items: [
				new Ext.ux.ManagedIFrame.Component({
					defaultSrc: 'http://docs.google.com/View?id=d7vwwsv_19gmgtspt2',
					title: 'About Us'
				}),
				new Ext.ux.ManagedIFrame.Component({
					defaultSrc: 'http://docs.google.com/View?id=d7vwwsv_26dr5v8gdd',
					title: 'Structure'
				}),
				new Ext.ux.ManagedIFrame.Component({
					defaultSrc: 'http://docs.google.com/View?id=d7vwwsv_27c7kz92f8',
					title: 'Useful Links'
				})
			  ]
			})
                ]
            });
        }
        win.show();
    }
});

MyDesktop.PublicationWindow = Ext.extend(Ext.app.Module, {
    id:'publication-win',
    init : function(){
        this.launcher = {
            text: 'Publications',
            iconCls:'publication',
            handler : this.createWindow,
            scope: this
        }
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('publication-win');

	
        if(!win){
            win = desktop.createWindow({
                id: 'publication-win',
                title: 'Publications',
                width:'85%',
                height:600,
                iconCls: 'publication',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
                border:false,
                layout: 'fit',
                layoutConfig: {
                    animate:false
                },

                items: [
			new Ext.ux.ManagedIFrame.Component({
				defaultSrc: 'http://docs.google.com/View?id=d7vwwsv_32grqjdxfz',
				title: 'Publications'
			})
                ]
            });
        }
        win.show();
    }
});

MyDesktop.PhotoWindow = Ext.extend(Ext.app.Module, {
    id:'photo-win',
    init : function(){
        this.launcher = {
            text: 'Metroleo Photos',
            iconCls:'photo',
            handler : this.createWindow,
            scope: this
        }
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('photo-win');
	var box = Ext.get('x-desktop').getBox(true);
	
        if(!win){
            win = desktop.createWindow({
                id: 'photo-win',
                title: 'Metroleo Photos',
                width:'85%',
                height:box.height - 100,
                iconCls: 'photo',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
                border:false,
		tools: [{
		    id:'pin',
		    on:{
			click: function(){
				var win = MyDesktop.getDesktop().getWindow('photo-win');
				var box = Ext.get('x-desktop').getBox(true);
				win.restore();
				win.setPosition(0,0);
				win.setSize(box.width - 280, box.height);
			}
		    }
		}],
                layout: 'fit',
                layoutConfig: {
                    animate:false
                },

                items: [
			new Ext.TabPanel({
			  activeTab:0,
			  items: [
				new Ext.ux.ManagedIFrame.Component({
					defaultSrc: 'files/photos/Test.html',
					title: '2008-2009 Regular Meeting'
				}),
				new Ext.ux.ManagedIFrame.Component({
					defaultSrc: 'http://picasaweb.google.com/allmetroleo',
					title: 'Photo Album'
				})
			  ]
			})
                ]
            });
        }
        win.show();
    }
});

MyDesktop.FundWindow = Ext.extend(Ext.app.Module, {
    id:'fund-win',
    init : function(){
        this.launcher = {
            text: 'Fund Raising (Private Area)',
            iconCls:'fund',
            handler : this.createWindow,
            scope: this
        }
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('fund-win');
	var box = Ext.get('x-desktop').getBox(true);
	
        if(!win){
            win = desktop.createWindow({
                id: 'fund-win',
                title: 'Fund Raising (Private Area)',
                width:'85%',
		height: box.height - 100,
                iconCls: 'fund',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
                border:false,
                layout: 'fit',
                layoutConfig: {
                    animate:false
                },
                items: [
			new Ext.TabPanel({
			  activeTab:0,
			  items: [
				new Ext.ux.ManagedIFrame.Component({
					defaultSrc: 'http://docs.google.com/a/metroleo.org.hk/View?id=d2pp6wh_56hg34rrgf',
					title: 'Resources Summary'
				})
			  ]
			})
                ]
            });
        }
        win.show();
    }
});

MyDesktop.FacebookWindow = Ext.extend(Ext.app.Module, {
    id:'facebook-win',
    init : function(){
        this.launcher = {
            text: 'WorldLearn Resources',
            iconCls:'facebook',
            handler : this.createWindow,
            scope: this
        }
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('facebook-win');
	var box = Ext.get('x-desktop').getBox(true);
	
        if(!win){
            win = desktop.createWindow({
                id: 'facebook-win',
                title: 'Facebook Pages',
                width:'85%',
                height:box.height - 100,
                iconCls: 'facebook',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
                border:false,
		tools: [{
		    id:'pin',
		    on:{
			click: function(){
				var win = MyDesktop.getDesktop().getWindow('facebook-win');
				var box = Ext.get('x-desktop').getBox(true);
				win.restore();
				win.setPosition(0,0);
				win.setSize(box.width - 280, box.height);
			}
		    }
		}],
                layout: 'fit',
                layoutConfig: {
                    animate:false
                },

                items: [
			new Ext.TabPanel({
			  activeTab:0,
			  items: [
				new Ext.ux.ManagedIFrame.Component({
					defaultSrc: 'http://www.facebook.com/home.php#/group.php?gid=2335351663',
					title: 'Metroleo'
				}),
				new Ext.ux.ManagedIFrame.Component({
					defaultSrc: 'http://www.facebook.com/home.php#/group.php?gid=123337867891',
					title: 'Summer Camp 2009'
				}),
				new Ext.ux.ManagedIFrame.Component({
					defaultSrc: 'http://www.facebook.com/group.php?gid=2349717455',
					title: 'Quality Education Alliance'
				}),
				new Ext.ux.ManagedIFrame.Component({
					defaultSrc: 'http://www.facebook.com/home.php#/group.php?gid=2343739781',
					title: 'Leo District 303'
				})
			  ]
			})
                ]
            });
        }
        win.show();
    }
});

MyDesktop.MemberWindow = Ext.extend(Ext.app.Module, {
    id:'member-win',
    init : function(){
        this.launcher = {
            text: 'Member Area (Private)',
            iconCls:'member',
            handler : this.createWindow,
            scope: this
        }
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('member-win');
	
        if(!win){
            win = desktop.createWindow({
                id: 'member-win',
                title: 'Member Area (Private)',
                width:'85%',
                height:600,
                iconCls: 'member',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
                border:false,
                layout: 'fit',
                layoutConfig: {
                    animate:false
                },
                items: [
			new Ext.TabPanel({
			  activeTab:0,
			  items: [
				new Ext.ux.ManagedIFrame.Component({
					defaultSrc: 'http://docs.google.com/a/metroleo.org.hk/View?id=d7vwwsv_11pgsdjfgp',
					title: 'Resources Summary'
				}),
				new Ext.ux.ManagedIFrame.Component({
					defaultSrc: 'https://docs.google.com/a/metroleo.org.hk/View?id=d7vwwsv_28f5cptx43',
					title: 'District Contact'
				}),
				new Ext.ux.ManagedIFrame.Component({
					defaultSrc: 'http://docs.google.com/a/metroleo.org.hk/View?id=d7vwwsv_12fwddn7z2',
					title: 'How to use Metroleo FTP'
				})
			  ]
			})
                ]
            });
        }
        win.show();
    }
});


// Array data for the grid
Ext.grid.dummyData = [
    ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
    ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
    ['American Express Company',52.55,0.01,0.02,'9/1 12:00am'],
    ['American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am'],
    ['AT&T Inc.',31.61,-0.48,-1.54,'9/1 12:00am'],
    ['Caterpillar Inc.',67.27,0.92,1.39,'9/1 12:00am'],
    ['Citigroup, Inc.',49.37,0.02,0.04,'9/1 12:00am'],
    ['Exxon Mobil Corp',68.1,-0.43,-0.64,'9/1 12:00am'],
    ['General Electric Company',34.14,-0.08,-0.23,'9/1 12:00am'],
    ['General Motors Corporation',30.27,1.09,3.74,'9/1 12:00am'],
    ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
    ['Honeywell Intl Inc',38.77,0.05,0.13,'9/1 12:00am'],
    ['Intel Corporation',19.88,0.31,1.58,'9/1 12:00am'],
    ['Johnson & Johnson',64.72,0.06,0.09,'9/1 12:00am'],
    ['Merck & Co., Inc.',40.96,0.41,1.01,'9/1 12:00am'],
    ['Microsoft Corporation',25.84,0.14,0.54,'9/1 12:00am'],
    ['The Coca-Cola Company',45.07,0.26,0.58,'9/1 12:00am'],
    ['The Procter & Gamble Company',61.91,0.01,0.02,'9/1 12:00am'],
    ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am'],
    ['Walt Disney Company (The) (Holding Company)',29.89,0.24,0.81,'9/1 12:00am']
];


Ext.onReady(function(){
		/*
var p = new Ext.Container({
        collapsible:true,
        renderTo: 'x-background',
	layout:'vbox',
	height: '100%',
	width: '100%',
	style: 'z-index:2; position:relative;',
	layoutConfig: {
	    align : 'center',
	    pack  : 'center'
	},
	items: [
		new Ext.BoxComponent({
		    autoEl: {
			tag: 'img',
			width: 400,
			height: 55,
			src: 'files/images/metroleo_banner.png'
		    }
	        }),
		new Ext.ux.ManagedIFrame.Component({
			width: 700,
			height: 450,
			defaultSrc: 'https://spreadsheets.google.com/a/metroleo.org.hk/viewform?hl=en&formkey=dGtPOWM2NEI5cGdMMEJhVlhnZ29Menc6MA..',
			title: 'Activity Sign up'
		})
	]
    });
    */
});

