/*!
 * 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();
	},

	getModules : function(){
		return [
			new MyDesktop.WinForum(),
			new MyDesktop.WinInfla(),
			new MyDesktop.WinFoto(),
			new MyDesktop.WinSMS(),
			new MyDesktop.GridWindow(),
            new MyDesktop.TabWindow(),
			new MyDesktop.WinChat(),
            new MyDesktop.BogusMenuModule(),
			new MyDesktop.WinNews(),
			new MyDesktop.WinPubbli(),
			new MyDesktop.GoogleNews()
		];
	},

    // config for the start menu
    getStartConfig : function(){
        return {
            title: 'TimeoutWorld Desktop',
            iconCls: 'homew',
            toolItems: [{
                text:'e-m@il',
                iconCls:'mail',
                scope:this,
				handler: function(){
					Ext.MessageBox.alert('e-m@ail', 'Contatta TimeOutWorld per qualunque richiesta.<br>Scrivi a webmaster@timeoutworld.net');
				}},'-',{
                text:'Vota',
                iconCls:'feed',
                scope:this,
				handler: function(){
					window.open("http://www.migliorsito.com/cgi-bin/vota.cgi?click=114026267");
				}
            }]
        };
    }
});

MyDesktop.WinNews = Ext.extend(Ext.app.Module, {
	id:'news-win',
	init : function(){
        this.launcher = {
            text: 'TmW News',
            iconCls:'news',
            handler : this.createWindow,
            scope: this,
			hidden: true
        }
	},
		
	createWindow : function(){
		var desktop = this.app.getDesktop();
		var win = desktop.getWindow('news-win');
		if(!win){
			win = desktop.createWindow({
				id: 'news-win',
				title:'TimeoutWorld News',
				width:755,
				height:250,
				iconCls: 'news',
				shim:false,
				animCollapse:false,
				constrainHeader:true,
				layout: 'fit',
				html : '<iframe src="other-sc/news.htm" height="280" width="740"></iframe>',
				resizable: false
			});
		}
		win.show();
	}
});

MyDesktop.WinSMS = Ext.extend(Ext.app.Module, {
	id:'sms-win',
	init : function(){
        this.launcher = {
            text: 'TmW Sms',
            iconCls:'sms',
            handler : this.createWindow,
            scope: this
        }
	},
		
	createWindow : function(){
		var desktop = this.app.getDesktop();
		var win = desktop.getWindow('sms-win');
		if(!win){
			win = desktop.createWindow({
				id: 'sms-win',
				title:'TimeoutWorld SMS',
				width:615,
				height:450,
				iconCls: 'sms',
				shim:false,
				animCollapse:false,
				constrainHeader:true,
				layout: 'fit',
				html : '<iframe src="http://www.timeoutworld.net/public/sms/smspage.php" height="430" width="600" frameborder="0" scrolling="no"></iframe>',
				resizable: false
			});
		}
		win.show();
	}
});

MyDesktop.WinForum = Ext.extend(Ext.app.Module, {
	id:'forum-win',
	init : function(){
        this.launcher = {
            text: 'Forum',
            iconCls:'forum',
            handler : this.createWindow,
            scope: this
        }
	},
		
	createWindow : function(){
		var desktop = this.app.getDesktop();
		var win = desktop.getWindow('forum-win');
		if(!win){
			win = desktop.createWindow({
				id: 'forum-win',
				title:'TimeoutWorld Forum',
				width:860,
				height:550,
				iconCls: 'forum',
				shim:false,
				animCollapse:false,
				constrainHeader:true,
				layout: 'fit',
				html : '<iframe src="http://www.timeoutworld.net/public/forum3/index.php" height="516" width="844"></iframe>',
				resizable: false
			});
		}
		win.show();
	}
});

MyDesktop.WinPubbli = Ext.extend(Ext.app.Module, {
	id:'pubbli-win',
	init : function(){
        this.launcher = {
            text: 'Sponsor',
            iconCls:'pubbli',
            handler : this.createWindow,
            scope: this
        }
	},
		
	createWindow : function(){
		var desktop = this.app.getDesktop();
		var win = desktop.getWindow('forum-win');
		if(!win){
			win = desktop.createWindow({
				id: 'pubbli-win',
				title:'TimeOutWorld Sponsor',
				width:515,
				height:320,
				iconCls: 'pubbli',
				shim:false,
				animCollapse:false,
				constrainHeader:true,
				layout: 'fit',
				html : '<iframe src="other-sc/sponsor.htm" height="516" width="844"></iframe>',
				resizable: false
			});
		}
		win.show();
	}
});

MyDesktop.WinInfla = Ext.extend(Ext.app.Module, {
	id:'infolario-win',
	init : function(){
        this.launcher = {
            text: 'Infolario',
            iconCls:'infol',
            handler : this.createWindow,
            scope: this
        }
	},
		
	createWindow : function(){
		var desktop = this.app.getDesktop();
		var win = desktop.getWindow('infolario-win');
		if(!win){
			win = desktop.createWindow({
				id: 'infolario-win',
				title:'Infolario - il vocabolario informatico',
				width:607,
				height:525,
				iconCls: 'infol',
				shim:true,
				animCollapse:true,
				constrainHeader:true,
				resizable: false,
				layout: 'fit',
				html : '<iframe src="http://www.timeoutworld.net/public/vocab/visuvoc.php" height="490" width="590"></iframe>'
			});
		}
		win.show();
	}
});

MyDesktop.WinFoto = Ext.extend(Ext.app.Module, {
	id:'foto-win',
	init : function(){
        this.launcher = {
            text: 'Foto',
            iconCls:'foto',
            handler : this.createWindow,
            scope: this
        }
	},
		
	createWindow : function(){
		var desktop = this.app.getDesktop();
		var win = desktop.getWindow('foto-win');
		if(!win){
			win = desktop.createWindow({
				id: 'foto-win',
				title:'TimeoutWorld Foto - Invia la tua foto a webmaster@timeoutworld.net - Verr&agrave; pubblicata!',
				width:650,
				height:560,
				iconCls: 'foto',
				shim:true,
				animCollapse:true,
				constrainHeader:true,
				resizable: false,
				layout: 'fit',
				html : '<iframe src="http://www.timeoutworld.net/public/tmw foto/index.html" height="530" width="636" scrolling="auto" frameborder="0"></iframe>'
			});
		}
		win.show();
	}
});

MyDesktop.WinChat = Ext.extend(Ext.app.Module, {
	id:'chat-win',
	init : function(){
        this.launcher = {
            text: 'Chat',
            iconCls:'chat',
            handler : this.createWindow,
            scope: this
        }
	},
		
	createWindow : function(){
		var desktop = this.app.getDesktop();
		var win = desktop.getWindow('chat-win');
		if(!win){
			win = desktop.createWindow({
				id: 'chat-win',
				title:'TimeoutWorld Flash Chat - Chatta con tutti gli utenti di TimeOutWorld.net',
				width:550,
				height:560,
				iconCls: 'chat',
				shim:true,
				animCollapse:true,
				constrainHeader:true,
				resizable: false,
				layout: 'fit',
				html : '<iframe src="http://www.timeoutworld.net/public/chat/" height="530" width="536" scrolling="auto" frameborder="0"></iframe>'
			});
		}
		win.show();
	}
});

MyDesktop.GridWindow = Ext.extend(Ext.app.Module, {
    id:'grid-vir-win',
    init : function(){
        this.launcher = {
            text: 'Virus',
            iconCls:'virus',
            handler : this.createWindow,
            scope: this
        }
    },
	
    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('grid-vir-win');
        if(!win){
			//debugger;
            win = desktop.createWindow({
				scope: this,
                id: 'grid-vir-win',
                title:'Sezione Virus',
                width:740,
                height:480,
                iconCls: 'virus',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
				resizable: false,
                layout: 'fit',
                items: new Ext.grid.GridPanel({
							store: storeG,
							cm: new Ext.grid.ColumnModel({
								defaults: {
									width: 20,
									sortable: true
								},
								columns: [
									expander,
									{id:'virname',header: "Virus", width: 80, fixed:false,	sortable: true, dataIndex: 'virname'},
									{header: "Classe di Rischio", width: 50, fixed:false,	sortable: true, dataIndex: 'risk'},
									{header: "Data Rilevamento", width: 50, fixed:false,	sortable: true,dataIndex: 'dril', renderer: Ext.util.Format.dateRenderer('d/m/Y')},
									{header: "Data Inserimento", width: 50, fixed:false,	sortable: true,dataIndex: 'dins', renderer: Ext.util.Format.dateRenderer('d/m/Y')},
									{header: "Sistemi Operativi a rischio", width:80, fixed:false,	sortable: true, dataIndex: 'marca'}
								]
							}),
							viewConfig: {
								forceFit:true
							},
							columnLines: true,
							sm: new Ext.grid.RowSelectionModel(),
							width: 600,
							height: 300,
							plugins: [expander/*,gridSearch*/],
							collapsible: false,
							iconCls: 'virus',
							tbar: ['Cerca il tuo Virus: ',tarFind,butFind,butDone]
						})
            });
        }
        win.show();
    }
});

MyDesktop.TabWindow = Ext.extend(Ext.app.Module, {
    id:'tab-win',
    init : function(){
        this.launcher = {
            text: 'Sezione Download',
            iconCls:'dowl',
            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:'Sezione Download - I Magnifici 4 - Ultimo aggiornamento 06/01/2010',
                width:683,
                height:240,
                iconCls: 'dowl',
                shim:false,
                animCollapse:false,
                border:false,
                constrainHeader:true,
                layout: 'fit',
                items:
                    new Ext.TabPanel({
                        activeTab:0,
                        items: [{
                            title: 'Privacy & Sicurezza',
                            header:false,
                            html : '<iframe src="desk-dl/prisicur.htm" height="200" width="663" scrolling="auto" frameborder="0"></iframe>',
                            border:false
                        },{
                            title: 'Office & Game',
                            header:false,
                            html : '<iframe src="desk-dl/offgam.htm" height="200" width="663" scrolling="auto" frameborder="0"></iframe>',
                            border:false
                        },{
                            title: 'Audio, Video & Foto',
                            header:false,
                            html : '<iframe src="desk-dl/audio.htm" height="200" width="663" scrolling="auto" frameborder="0"></iframe>',
                            border:false
                        },{
                            title: 'Internet e Comunicazione',
                            header:false,
                            html : '<iframe src="desk-dl/internet.htm" height="200" width="663" scrolling="auto" frameborder="0"></iframe>',
                            border:false
                        }]
                    })
            });
        }
        win.show();
    }
});

// for example purposes
var windowIndex = 0;

MyDesktop.BogusModule = Ext.extend(Ext.app.Module, {
    createWindow : function(src){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('bogus'+src.windowId);
        if(!win){
            win = desktop.createWindow({
                id: 'collect'+src.windowId,
                title:src.text,
                width:src.width,
                height:src.height,
                html : src.html,
                iconCls: src.iconCls,
                shim:false,
                animCollapse:false,
                constrainHeader:true
            });
        }
        win.show();
    }
});

MyDesktop.BogusMenuModule = Ext.extend(MyDesktop.BogusModule, {
    init : function(){
        this.launcher = {
            text: 'Altre Sezioni',
            iconCls: 'fold',
            handler: function() {
				return false;
			},
            menu: {
                items:[{
                    text: 'Siti prodotti da TmW',
                    iconCls:'prod',
                    handler : this.createWindow,
                    scope: this,
					width:600,
                	height:530,
                    windowId: windowIndex,
					html: '<iframe src="other-sc/prosite.htm" height="497" width="585" scrolling="auto" frameborder="0"></iframe>'
                    },{
                    text: 'Donazione',
                    iconCls:'dollar',
                    handler : this.createWindow,
                    scope: this,
					width:635,
                	height:400,
                    windowId: windowIndex,
					html: '<iframe src="other-sc/dona.html" height="400" width="620" scrolling="auto" frameborder="0"></iframe>'
                    },{
                    text: 'WebLink',
                    iconCls:'weblink',
                    handler : this.createWindow,
                    scope: this,
					width:755,
                	height:240,
                    windowId: windowIndex,
					html: '<iframe src="other-sc/weblink.htm" height="280" width="740" scrolling="auto" frameborder="0"></iframe>'
                    },{
                    text: 'Disclaimer',
                    iconCls:'disc',
                    handler : this.createWindow,
                    scope: this,
					width:700,
                	height:270,
                    windowId: windowIndex,
					html: '<iframe src="other-sc/disclaimer.htm" height="280" width="690" scrolling="auto" frameborder="0"></iframe>'
                    },{
                    text: 'Segnala il sito',
                    iconCls:'segnal',
                    handler : this.createWindow,
                    scope: this,
					width:515,
               		height:433,
                    windowId: windowIndex,
					html: '<iframe src="http://www.timeoutworld.net/public/segnala/amico.php" height="400" width="500" scrolling="auto" frameborder="0"></iframe>'
                }]
            }
        }
    }
});

MyDesktop.GoogleNews = Ext.extend(Ext.app.Module, {
	id:'gnews-win',
	init : function(){
        this.launcher = {
            text: 'Google News On TmW',
            iconCls:'google',
            handler : this.createWindow,
            scope: this
        }
	},
		
	createWindow : function(){
		var desktop = this.app.getDesktop();
		var win = desktop.getWindow('infolario-win');
		if(!win){
			win = desktop.createWindow({
				id: 'gnews-win',
				title:'Google News On TimeOutWorld.net',
				width:333,
				height:300,
				iconCls: 'google',
				shim:true,
				animCollapse:true,
				constrainHeader:true,
				resizable: false,
				layout: 'fit',
				html : '<iframe src="other-sc/googlenews.htm" height="270" width="320"></iframe>'
			});
		}
		win.show();
	}
});

//definizione griglia virus
	Ext.grid.Data = [
		['Trojan.Xrupter','Bassa','22/03/2009','17/08/2009','Tutti Windows da 95 a Xp'],
		['Trojan.Initbar','Bassa','24/01/2009','17/08/2009','Tutti Windows da 95 a Vista'],
		['Win32.Envid@mm','Bassa','16/12/2004','17/08/2009','Tutti Windows da 95 a Xp'],
		['Sgrunt/Master69','Alta','10/04/2005','17/08/2009','Tutti Windows da 95 a Xp'],
		['Trojan.Bankpatch','Media','18/08/2008','17/08/2009','Tutti Windows da 95 a Vista'],
		['W32.Downadup','Alta','20/11/2008','23/08/2009','Tutti Windows da 95 a Vista']
	];
	
	for(var i = 0; i < Ext.grid.Data.length; i++){
		switch (i){
			case 0: {Ext.grid.Data[i].push('Xrupter e\' un cavallo di Troia che codifica i file presenti nel computer infettato. Puo\' infettare i sistemi operativi Microsoft: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000, Windows XP, Windows Server 2003.<br/><br/>Per eliminare tale malware proponiamo il RemovalTool della Symantec; <a href = "http://www.timeoutworld.net/Virus/FixXrupter.zip">clicca qui</a> per scaricarlo<br><br>Per attivare il removal tool ti baster&agrave; scompattarlo e cliccare due volte sul file .exe cosi\' ottenuto');
			break;
			}
			case 1: {Ext.grid.Data[i].push('Trojan.Initbar e\' un cavallo di troia (Trojan, vedi Infolario) che visualizza un falso messaggio di attenzione relativamente a dei 		potenziali rischi dovuti alla presenza di applicazioni infette nel pc.<br/><br/>Per eliminare tale malware proponiamo il RemovalTool della Symantec; <a href = "http://www.timeoutworld.net/Virus/FIXINITB.zip">clicca qui</a> per scaricarlo<br><br>Per attivare il removal tool ti baster&agrave; scompattarlo e cliccare due volte sul file .exe cosi\' ottenuto');
			break;
			}
			case 2: {Ext.grid.Data[i].push('Ne esistono due versioni: W32.Envid.B@mm e W32.Envid.C@mm.<br/><br/>Per eliminare tale malware proponiamo il RemovalTool della Symantec; <a href = "http://www.timeoutworld.net/Virus/FixEnvid.zip">clicca qui</a> per scaricarlo<br><br>Per attivare il removal tool ti baster&agrave; scompattarlo e cliccare due volte sul file .exe cosi\' ottenuto');
			break;
			}
			case 3: {Ext.grid.Data[i].push('Tale malware, nel computer infetto, crea nuove connessioni o sostituisce la pagina principale di Internet Explorer<br/><br/>Per eliminare tale malware proponiamo il RemovalTool di Francy De Lorenzi (KillSgrunt); <a href = "http://www.timeoutworld.net/Files%20-%20Download/killsgrunt.zip">clicca qui</a> per scaricarlo<br><br>Per attivare il removal tool ti baster&agrave; scompattarlo e cliccare due volte sul file .exe cosi\' ottenuto');
			break;
			}
			case 4: {Ext.grid.Data[i].push('Trojan.Bankpatch ha la capacita\' di rubare informazioni confidenziali dal computer infetto e di modificare degli specifici file DLL del sistema Windows.<br/><br/>Per eliminare tale malware proponiamo il RemovalTool della Symantec in grado anche di eliminare il malware Infostealer.Nadebanker; <a href = "http://www.timeoutworld.net/Virus/NortonSecurityScan.zip">clicca qui</a> per scaricarlo<br><br>Per attivare il removal tool ti baster&agrave; scompattarlo e cliccare due volte sul file .exe cosi\' ottenuto');
			break;
			}
			case 5: {Ext.grid.Data[i].push('Anche conosciuto come  Win32/Conficker.A è un worm che si diffonde sfruttando la Vulnerabilità Microsoft Windows Server Service RPC Handling Remote Code Execution. Esso tenta anche di diffondersi attraverso le condivisioni di rete protette da password deboli e blocca l’accesso ai siti Web relativi alla sicurezza.<br/><br/>Per eliminare tale malware proponiamo il RemovalTool della Symantec; <a href = "http://www.timeoutworld.net/Virus/DownupRemover.zip">clicca qui</a> per scaricarlo<br><br>Per attivare il removal tool ti baster&agrave; scompattarlo e cliccare due volte sul file .exe cosi\' ottenuto');
			break;
			}
		}
			
	}
 	var xg = Ext.grid;

    // shared reader
    var reader = new Ext.data.ArrayReader({}, [
       {name: 'virname'},
       {name: 'risk'},
       {name: 'dril', type: 'date', dateFormat: 'd/m/Y'},
       {name: 'dins', type: 'date', dateFormat: 'd/m/Y'},
       {name: 'marca'},
       {name: 'longdescr'}
    ]);

    var expander = new Ext.ux.grid.RowExpander({
        tpl : new Ext.Template(
            '<p><b>Nome virus:</b> {virname}</p>',
            '<p><b>Descrizione dettagliata:</b> {longdescr}</p>'
        )
    });
	
	var storeG = new Ext.data.Store({
				reader: reader,
				data: Ext.grid.Data,
				sortInfo: {
					field: 'dins',
					direction: 'DESC'
				}
	});
	
	/*var bar = new Ext.PagingToolbar({
			 store: storeG
			,displayInfo:true
			,pageSize:10
	});*/
	
	var tarFind = new Ext.form.TextField({
			width: 100				
	})
	
	var butFind = new Ext.Button({
			iconCls: 'cerca',
			text: 'Cerca'
	})
	
	var butDone = new Ext.Button({
			iconCls: 'cercaex',
			text: 'Annulla'
	})
	
	butFind.on({
		scope: this,
		'click': function(){
			var par = tarFind.getValue();
			storeG.filter('virname',par,true,false);
		}
	})
	
	butDone.on({
		scope: this,
		'click': function(){
			storeG.clearFilter();
		}
	})
//fine definizione griglia virus