/*
 * Desktop configuration
 */

MyDesktop = new Ext.app.App({
	init :function()
	{
		Ext.QuickTips.init();
	},
	// get modules to initialize (make available to your desktop)
	getModules : function(){
		return [
			new MyDesktop.sessionSubMenu(),
			new MyDesktop.standingSubMenu(),
			new MyDesktop.predefSubMenu(),
			new MyDesktop.liveTvSubMenu(),
			new MyDesktop.desktopDefaultSessA(),
			new MyDesktop.desktopDefaultSessB(),
			new MyDesktop.desktopMedia(),
			new MyDesktop.desktopInfo(),
			new MyDesktop.HistoricModule(),
			new MyDesktop.ChatModule(),
			new MyDesktop.RadioModule(),
      new MyDesktop.LiveTv1Module(),
      new MyDesktop.LiveTv2Module(),
			new MyDesktop.FeedModule(),
      new MyDesktop.TeamspeakModule(),
      new MyDesktop.InformationsModule(),
			new MyDesktop.LiveServerAModule(),
			new MyDesktop.LiveServerA1Module(),
			new MyDesktop.LiveServerA2Module(),
			new MyDesktop.LiveServerBModule(),
			new MyDesktop.LiveServerB1Module(),
			new MyDesktop.LiveServerB2Module(),
			new MyDesktop.StandingModule(),
			new MyDesktop.StandingGT1Module(),
			new MyDesktop.StandingGT2Module(),
			new MyDesktop.StandingGT3Module(),
      new Preferences()
		];
	},
	initLayout : function() {
	},
	// config for the start menu
    getStartConfig : function(){
    	var pref = new Preferences();
		pref.app = this;
		
        return {
        	iconCls: 'user',
            title: get_cookie_race24('24H_LOG'), //get_cookie('memberName'),
            toolItems: [
            	pref.launcher
            ],
			toolPanelWidth: 110
        };
    },
    
    // get user preferences, modules to load into Start Menu and Quick Start
    getDesktopConfig : function(){
		// can hard code the module id's
/*		Ext.Ajax.request({
			success: function(o){
				var decoded = Ext.decode(o.responseText);
				
				if(decoded.success){
					this.initDesktopConfig(decoded.config);
				}else{
					// error
				}
			},
			failure: function(){
				// error
			},
			scope: this,
			url: 'php/DesktopConfig.php'
		});
*/    	var o = {
			'desktopcontextmenu': [
				'preferences-win'
			],
			'quickstart': [
				'defaultA-desktop',
				'defaultB-desktop'
			],
			'startmenu': [
				'chat-win',
				'radio-win',
				'livetv-menu',
				'livesession-menu',
				'classement-menu',
				'feed-win',
				'teamspeak-win',
				'historic-win',
				'informations-win',
				'predef-menu'
			]
		}
		this.initDesktopConfig(o);
    }
});

MyDesktop.getDim = function()
{
		var desktop = MyDesktop.desktop;
        
        if (desktop == null)
	        return;
		
		if (navigator.appName=='Netscape') {
			screenWidth = desktop.getWinWidth() - 14; // - corrections
			screenHeight = desktop.getWinHeight() - 8; // - corrections
			
			//Gaps for ajust window at the desktop
			winGapX = 0;
			winGapY = 20;
			
		} else {
			screenWidth = desktop.getWinWidth() - 14; // - corrections
			screenHeight = desktop.getWinHeight() - 20; // - corrections
			
			//Gaps for ajust window at the desktop
			winGapX = 0;
			winGapY = 34;
		}
		
		screenWidth1_4 = screenWidth / 4;
		screenHeight1_4 = screenHeight / 4;
		
		screenWidth3_4 = (screenWidth / 4) * 3;
		screenHeight3_4 = (screenHeight / 4) * 3;
		
		screenWidth1_3 = screenWidth / 3;
		screenHeight1_3 = screenHeight / 3;
		
		screenWidth2_3 = (screenWidth / 3) * 2;
		screenHeight2_3 = (screenHeight / 3) * 2;
		
		screenWidth1_2 = screenWidth / 2;
		screenHeight1_2 = screenHeight / 2;
		
		centerPointLeft = screenWidth / 2;
		centerPointTop = screenHeight / 2;
		
		scroolBar = 45;

		//alert();
}

//-----------------------------------------------------------------------------------//
//-----------------------------------Live TV 1--------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.LiveTv1Module = Ext.extend(Ext.app.Module, {
	appType : 'TV1',
    id : 'tv1-win',
    
    init : function(){
        this.launcher = {
            text: 'Chaine 1',
            iconCls:'livetv',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('tv1-win');
        var win1 = desktop.getWindow('tv2-win');
        
        if (win1) { win1.close(); }
        
        if(!win){
					MyDesktop.getDim();
          win = desktop.createWindow({
                id: 'tv1-win',
                title:'Live TV - Chaine 1',
                x:10,
                y:10,
                width:screenWidth1_3,
                height:screenHeight1_2,
								resizable : false,
                iconCls: 'livetv',
                animCollapse:false,
                border:false,
                shim:false,
                constrainHeader:true,
//              body: new Ext.ux.ManagedIFrame({autoCreate:{ src:'tv/tv.html', frameBorder: 0, cls:'x-panel-body ',width: '100%', height: '100%'}}),
				html:  '<body><IFRAME SRC="tv/tv2.php?height=' + (screenHeight1_2 - 90) + '&chaine=1" style="border:0px none; padding:0px; width:100%; height:100%;"></IFRAME></body>'
            });
        }
        win.show();
        return win;
    }
});


//-----------------------------------------------------------------------------------//
//-----------------------------------Live TV--------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.LiveTv2Module = Ext.extend(Ext.app.Module, {
	appType : 'TV2',
    id : 'tv2-win',
    
    init : function(){
        this.launcher = {
            text: 'Chaine 2',
            iconCls:'livetv',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('tv2-win');
        var win1 = desktop.getWindow('tv1-win');
        
        if (win1) { win1.close(); }
        
        if(!win){
					MyDesktop.getDim();
          win = desktop.createWindow({
                id: 'tv2-win',
                title:'Live TV - Chaine 2',
                x:10,
                y:10,
                width:screenWidth1_3,
                height:screenHeight1_2,
								resizable : false,
                iconCls: 'livetv',
                animCollapse:false,
                border:false,
                shim:false,
                constrainHeader:true,
//              body: new Ext.ux.ManagedIFrame({autoCreate:{ src:'tv/tv.html', frameBorder: 0, cls:'x-panel-body ',width: '100%', height: '100%'}}),
				html:  '<body><IFRAME SRC="tv/tv2.php?height=' + (screenHeight1_2 - 90) + '&chaine=2" style="border:0px none; padding:0px; width:100%; height:100%;"></IFRAME></body>'
            });
        }
        win.show();
        return win;
    }
});



//-----------------------------------------------------------------------------------//
//-----------------------------------Chat--------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.ChatModule = Ext.extend(Ext.app.Module, {
	appType : 'Chat',
    id : 'chat-win',
    
    init : function(){
        this.launcher = {
            text: 'Chat',
            iconCls:'tchat',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('chat-win');
        
        MyDesktop.getDim();
        
        if (navigator.appName=='Netscape') {
	        w = (screenWidth2_3 - winGapX);
	        h = (screenHeight1_2 - winGapY);
    	  } else {
    	  	w = (screenWidth2_3 - winGapX) + 26;
	        h = (screenHeight1_2 - winGapY) + 34;
    	  }
        
        if(!win){
            win = desktop.createWindow({
                id: 'chat-win',
                title:'Chat',
                x:10,
                y:10,
                width:screenWidth2_3,
                height:screenHeight1_2,
                iconCls: 'tchat',
                shim:false,
                resizable: false,
                animCollapse:false,
                layout: 'fit',
                border:false,
                constrainHeader:true,
								//html: '<iframe id="iframLSDChat" name="iframLSDChat" src="LSDChat/index.php?w=' + w + '&h=' + h + '" style="border:0px; margin:0; padding:0; width:' + w + 'px; height:' + h + 'px;"></iframe>'
								html: '<iframe id="iframLSDChat" name="iframLSDChat" src="LSDChat/index.php?w=' + w + '&h=' + h + '" style="border:0px; margin:0; padding:0; width:100%; height:100%;"></iframe>'
								});
        }
        win.show();
        return win;
    }
});

//-----------------------------------------------------------------------------------//
//---------------------------------------HISTORIC------------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.HistoricModule = Ext.extend(Ext.app.Module, {
	appType : 'historic',
    id : 'historic-win',
    
    init : function(){
        this.launcher = {
            text: 'Historique',
            iconCls:'histo',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('chat-win');
        if(!win){
					MyDesktop.getDim();
           win = desktop.createWindow({
                id: 'historic-win',
                title:'Historique',
                width:screenWidth-150,
                height:screenHeight-100,
                iconCls: 'histo',
                shim:false,
                animCollapse:false,
                layout: 'fit',
                border:false,
                constrainHeader:true,
				html: '<body><IFRAME SRC="http://87.118.110.131/enduro200806_stathistoric.php" style="border:0px none;width:100%;height:100%;"></IFRAME></body>'
            });
        }
        win.show();
        return win;
    }
});

//-----------------------------------------------------------------------------------//
//-----------------------------------file de la course-------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.FeedModule = Ext.extend(Ext.app.Module, {
	appType : 'Feed',
    id : 'feed-win',
    
    init : function(){
        this.launcher = {
            text: 'Le fil de la course',
            iconCls:'rss',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('feed-win');
        if(!win){
			MyDesktop.getDim();
            win = desktop.createWindow({
                id: 'feed-win',
                title:'Le fil de la course',
                width:screenWidth2_3,
                height:screenHeight2_3,
                iconCls: 'rss',
                shim:false,
                animCollapse:false,
                layout: 'fit',
                border:false,
                constrainHeader:true,
				html: '<body><IFRAME SRC="feed/view.html" style="border:0px none;width:100%;height:100%;"></IFRAME></body>'
            });
        }
        win.show();
        return win;
    }
});


//-----------------------------------------------------------------------------------//
//------------------------------------RADIO RACE24H----------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.RadioModule = Ext.extend(Ext.app.Module, {
	appType : 'Radio',
    id : 'radio-win',
    
    init : function(){
        this.launcher = {
            text: 'Live Radio',
            iconCls:'radio',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('radio-win');
        if(!win){
			MyDesktop.getDim();
            win = desktop.createWindow({
                id: 'radio-win',
                title:'Radio',
                width:380,
                height:150,
                iconCls: 'radio',
                shim:false,
								resizable : false,
                animCollapse:false,
                layout: 'fit',
                border:false,
                constrainHeader:true,
								html: '<body><IFRAME SRC="http://forum.ffsca.org/index.php?do=mp" style="border:0;" width="370"></IFRAME></body>' 
//							http://stream1.club-musix.net:8000/
//							html :  '<div><object ID="idRadio"  type="application/x-shockwave-flash" data="http://lfgtr.ffsca.org/dewplayer.swf?son=http://91.121.14.38:9000&autoplay=0" width="100" height="20" > <param name="movie" value="http://lfgtr.ffsca.org/dewplayer.swf?son=http://ffsca.org:9000/listen.pls&autoplay=0" /></object></div>'
//              html : '<img src="wallpapers/radio.gif" border="0" width="300" height="150"><div><object id="ObjectLiveRadio" height="150" width="295" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"  standby="Loading ..."><param name="Filename" value="http://stream1.club-musix.net:8000/"><param name="EnableTracker" value="0"><param name="ShowGotoBar" value="0"><param name="ShowDisplay" value="0"><param name="ShowStatusBar" value="1"><param name="ShowPositionControls" value="0"><param name="ShowTracker" value="0"><param name="TransparentAtStart" value="1"><param name="WindowlessVideo" value="-1"><param name="AutoRewind" value="1"><param name="Balance" value="1"><param name="ClickToPlay" value="0"><param name="Volume" value="50"><embed src="http://stream1.club-musix.net:8000/" width="295" height="50" Volume=50 ClickToPlay=0 Balance=1 AutoRewind=1 WindowlessVideo=-1 TransparentAtStart=1 ShowTracker=0 ShowPositionControls=0 ShowStatusBar=1 ShowDisplay=0 ShowGotoBar=0 EnableTracker=0 type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/download/default.asp" id="wmp_lecteur" filename="http://stream1.club-musix.net:8000/"></embed></object></div>'
            });
            win.show();
        }
        return win;
    }
});



//-----------------------------------------------------------------------------------//
//-----------------------------------STANDING RACE24H--------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.StandingModule = Ext.extend(Ext.app.Module, {
	appType : 'Standing',
    id : 'standing-win',
    
    init : function(){
        this.launcher = {
            text: 'Général',
            iconCls:'standing',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('standing-win');
				var win2 = desktop.getWindow('standingGT300-win');
				var win3 = desktop.getWindow('standingGT500-win');
		
				if (win2) win2.close();
				if (win3) win3.close();
		
        if(!win){
			MyDesktop.getDim();
            win = desktop.createWindow({
                id: 'standing-win',
                title:'Classement Général',
                width:screenWidth - 5,
                height:screenHeight - 5,
                iconCls: 'standing',
                shim:false,
                animCollapse:false,
                border:false,
                constrainHeader:true,
                layout: 'fit',
                html:  '<body><IFRAME SRC="http://87.118.110.131/enduro200806_statenduro.php" style="border:0px none; scrolling:no; width:100%;height:100%;"></IFRAME></body>'
            });
        }
        win.show();
        return win;
    }
});

//-----------------------------------------------------------------------------------//
//-----------------------------------STANDING GT300 RACE24H--------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.StandingGT3Module = Ext.extend(Ext.app.Module, {
	appType : 'Standing',
    id : 'standingGT3-win',
    
    init : function(){
        this.launcher = {
            text: 'GT3',
            iconCls:'standing',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('standingGT3-win');
				var win2 = desktop.getWindow('standing-win');
				var win3 = desktop.getWindow('standingGT1-win');
				var win4 = desktop.getWindow('standingGT2-win');
				
				if (win2) { win2.close(); }
				if (win3) { win3.close(); }
				if (win4) { win4.close(); }
		
		if (win2) { win2.close(); }
		if (win3) { win3.close(); }
		
        if(!win){
			MyDesktop.getDim();
            win = desktop.createWindow({
                id: 'standingGT3-win',
                title:'Classement GT3',
                width:screenWidth - 5,
                height:screenHeight - 5,
                iconCls: 'standing',
                shim:false,
                animCollapse:false,
                border:false,
                constrainHeader:true,
                layout: 'fit',
                html:  '<body><IFRAME SRC="http://87.118.110.131/enduro200806_statenduro.php?categorie=2" style="border:0px none; scrolling:no; width:100%;height:100%;"></IFRAME></body>'
            });
        }
        win.show();
        return win;
    }
});

//-----------------------------------------------------------------------------------//
//-----------------------------------STANDING GT300 RACE24H--------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.StandingGT2Module = Ext.extend(Ext.app.Module, {
	appType : 'Standing',
    id : 'standingGT2-win',
    
    init : function(){
        this.launcher = {
            text: 'GT2',
            iconCls:'standing',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('standingGT2-win');
				var win2 = desktop.getWindow('standing-win');
				var win3 = desktop.getWindow('standingGT1-win');
				var win4 = desktop.getWindow('standingGT3-win');
				
				if (win2) { win2.close(); }
				if (win3) { win3.close(); }
				if (win4) { win4.close(); }
		
        if(!win){
			MyDesktop.getDim();
            win = desktop.createWindow({
                id: 'standingGT2-win',
                title:'Classement GT2',
                width:screenWidth - 5,
                height:screenHeight - 5,
                iconCls: 'standing',
                shim:false,
                animCollapse:false,
                border:false,
                constrainHeader:true,
                layout: 'fit',
                html:  '<body><IFRAME SRC="http://87.118.110.131/enduro200806_statenduro.php?categorie=1" style="border:0px none; scrolling:no; width:100%;height:100%;"></IFRAME></body>'
            });
        }
        win.show();
        return win;
    }
});

//-----------------------------------------------------------------------------------//
//-----------------------------------STANDING GT500 RACE24H--------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.StandingGT1Module = Ext.extend(Ext.app.Module, {
	appType : 'Standing',
    id : 'standingGT1-win',
    
    init : function(){
        this.launcher = {
            text: 'GT1',
            iconCls:'standing',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('standingGT1-win');
				var win2 = desktop.getWindow('standing-win');
				var win3 = desktop.getWindow('standingGT2-win');
				var win4 = desktop.getWindow('standingGT3-win');
				
				if (win2) { win2.close(); }
				if (win3) { win3.close(); }
				if (win4) { win4.close(); }
		
        if(!win){
        	MyDesktop.getDim();
            win = desktop.createWindow({
                id: 'standingGT1-win',
                title:'Classement GT1',
                width:screenWidth - 5,
                height:screenHeight - 5,
                iconCls: 'standing',
                shim:false,
                animCollapse:false,
                border:false,
                constrainHeader:true,
                layout: 'fit',
                html:  '<body><IFRAME SRC="http://87.118.110.131/enduro200806_statenduro.php?categorie=0" style="border:0px none; scrolling:no; width:100%;height:100%;"></IFRAME></body>'
            });
        }
        win.show();
        return win;
    }
});

//-----------------------------------------------------------------------------------//
//------------------------------------Live Server A 1&2 RACE24H----------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.LiveServerAModule = Ext.extend(Ext.app.Module, {
	appType : 'Server',
    id : 'server-a-win',
    
    init : function(){
        this.launcher = {
            text: 'Live sessions A1+A2',
            iconCls:'liveserver',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('server-a-win');
		
		//Fermuture du premier server si open
		var win2 = desktop.getWindow('server-b-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-b1-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-b2-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-a1-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-a2-win');
		if (win2) { win2.close(); }
		
        if(!win){
        	MyDesktop.getDim();
            win = desktop.createWindow({
                id: 'server-a-win',
                title:'Live sessions A1+A2',
                x:5,
                y:5,
                width:screenWidth - 5,
                height:screenHeight - 5,
                iconCls: 'liveserver',
                shim:false,
                animCollapse:false,
                layout: 'fit',
                border:false,
                constrainHeader:true,
                html : '<body><IFRAME SRC="http://87.118.110.131/enduro200806_mainlive.php?log=A1|A2&mask=-1&driver=0&mode=1" style="border:0px none; scrolling:no; width:100%;height:100%;"></IFRAME></body>'
            });
        }
        win.show();
        return win;
    }
});

//-----------------------------------------------------------------------------------//
//------------------------------------Live Server A 1 RACE24H----------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.LiveServerA1Module = Ext.extend(Ext.app.Module, {
	appType : 'Server',
    id : 'server-a1-win',
    
    init : function(){
        this.launcher = {
            text: 'Live sessions A1',
            iconCls:'liveserver',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('server-a1-win');
		
			//Fermuture du premier server si open
			var win2 = desktop.getWindow('server-b-win');
			if (win2) { win2.close(); }
			win2 = desktop.getWindow('server-b1-win');
			if (win2) { win2.close(); }
			win2 = desktop.getWindow('server-b2-win');
			if (win2) { win2.close(); }
			win2 = desktop.getWindow('server-a-win');
			if (win2) { win2.close(); }
			win2 = desktop.getWindow('server-a2-win');
			if (win2) { win2.close(); }
		
        if(!win){
        	MyDesktop.getDim();
            win = desktop.createWindow({
                id: 'server-a1-win',
                title:'Live sessions A1',
                x:5,
                y:5,
                width:screenWidth - 5,
                height:screenHeight - 5,
                iconCls: 'liveserver',
                shim:false,
                animCollapse:false,
                layout: 'fit',
                border:false,
                constrainHeader:true,
                html : '<body><IFRAME SRC="http://87.118.110.131/enduro200806_mainlive.php?log=A1&mask=-1&driver=0&mode=1" style="border:0px none; scrolling:no; width:100%;height:100%;"></IFRAME></body>'
            });
        }
        win.show();
        return win;
    }
});

//-----------------------------------------------------------------------------------//
//------------------------------------Live Server A 2 RACE24H----------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.LiveServerA2Module = Ext.extend(Ext.app.Module, {
	appType : 'Server',
    id : 'server-a2-win',
    
    init : function(){
        this.launcher = {
            text: 'Live sessions A2',
            iconCls:'liveserver',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('server-a2-win');
		
			//Fermuture du premier server si open
			var win2 = desktop.getWindow('server-b-win');
			if (win2) { win2.close(); }
			win2 = desktop.getWindow('server-b1-win');
			if (win2) { win2.close(); }
			win2 = desktop.getWindow('server-b2-win');
			if (win2) { win2.close(); }
			win2 = desktop.getWindow('server-a-win');
			if (win2) { win2.close(); }
			win2 = desktop.getWindow('server-a1-win');
			if (win2) { win2.close(); }
		
        if(!win){
        	MyDesktop.getDim();
            win = desktop.createWindow({
                id: 'server-a2-win',
                title:'Live sessions A2',
                x:5,
                y:5,
                width:screenWidth - 5,
                height:screenHeight - 5,
                iconCls: 'liveserver',
                shim:false,
                animCollapse:false,
                layout: 'fit',
                border:false,
                constrainHeader:true,
                html : '<body><IFRAME SRC="http://87.118.110.131/enduro200806_mainlive.php?log=A2&mask=-1&driver=0&mode=1" style="border:0px none; scrolling:no; width:100%;height:100%;"></IFRAME></body>'
            });
        }
        win.show();
        return win;
    }
});

//-----------------------------------------------------------------------------------//
//------------------------------------Live Server B RACE24H----------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.LiveServerBModule = Ext.extend(Ext.app.Module, {
	appType : 'Server',
    id : 'server-b-win',
    
    init : function(){
        this.launcher = {
            text: 'Live sessions B1+B2',
            iconCls:'liveserver',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('server-b-win');
		
		//Fermuture du premier server si open
		var win2 = desktop.getWindow('server-a-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-b1-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-b2-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-a1-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-a2-win');
		if (win2) { win2.close(); }
		
        if(!win)
        {
			MyDesktop.getDim();
            win = desktop.createWindow({
                id: 'server-b-win',
                title:'Live sessions B1+B2',
                x:5,
                y:5,
                width:screenWidth - 5,
                height:screenHeight - 5,
                iconCls: 'liveserver',
                shim:false,
                animCollapse:false,
                layout: 'fit',
                border:false,
                constrainHeader:true,
                html : '<body><IFRAME SRC="http://87.118.110.131/enduro200806_mainlive.php?log=B1|B2&mask=-1&driver=0&mode=1" style="border:0px none; scrolling:no; width:100%;height:100%;"></IFRAME></body>'
            });
        }
        win.show();
        return win;
    }
});

//-----------------------------------------------------------------------------------//
//------------------------------------Live Server B 1 RACE24H----------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.LiveServerB1Module = Ext.extend(Ext.app.Module, {
	appType : 'Server',
    id : 'server-b1-win',
    
    init : function(){
        this.launcher = {
            text: 'Live sessions B1',
            iconCls:'liveserver',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('server-b1-win');
		
		//Fermuture du premier server si open
		var win2 = desktop.getWindow('server-a-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-b-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-b2-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-a1-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-a2-win');
		if (win2) { win2.close(); }
		
        if(!win)
        {
			MyDesktop.getDim();
            win = desktop.createWindow({
                id: 'server-b1-win',
                title:'Live sessions B1',
                x:5,
                y:5,
                width:screenWidth - 5,
                height:screenHeight - 5,
                iconCls: 'liveserver',
                shim:false,
                animCollapse:false,
                layout: 'fit',
                border:false,
                constrainHeader:true,
                html : '<body><IFRAME SRC="http://87.118.110.131/enduro200806_mainlive.php?log=B1&mask=-1&driver=0&mode=1" style="border:0px none; scrolling:no; width:100%;height:100%;"></IFRAME></body>'
            });
        }
        win.show();
        return win;
    }
});

//-----------------------------------------------------------------------------------//
//------------------------------------Live Server B 2 RACE24H----------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.LiveServerB2Module = Ext.extend(Ext.app.Module, {
	appType : 'Server',
    id : 'server-b2-win',
    
    init : function(){
        this.launcher = {
            text: 'Live sessions B2',
            iconCls:'liveserver',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('server-b2-win');
		
		//Fermuture du premier server si open
		var win2 = desktop.getWindow('server-a-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-b-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-b1-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-a1-win');
		if (win2) { win2.close(); }
		win2 = desktop.getWindow('server-a2-win');
		if (win2) { win2.close(); }
		
        if(!win)
        {
			MyDesktop.getDim();
            win = desktop.createWindow({
                id: 'server-b2-win',
                title:'Live sessions B2',
                x:5,
                y:5,
                width:screenWidth - 5,
                height:screenHeight - 5,
                iconCls: 'liveserver',
                shim:false,
                animCollapse:false,
                layout: 'fit',
                border:false,
                constrainHeader:true,
                html : '<body><IFRAME SRC="http://87.118.110.131/enduro200806_mainlive.php?log=B2&mask=-1&driver=0&mode=1" style="border:0px none; scrolling:no; width:100%;height:100%;"></IFRAME></body>'
            });
        }
        win.show();
        return win;
    }
});


//-----------------------------------------------------------------------------------//
//------------------------------------Teamspeak RACE24H----------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.TeamspeakModule = Ext.extend(Ext.app.Module, {
	appType : 'Teamspeak',
    id : 'teamspeak-win',
    
    init : function(){
        this.launcher = {
            text: 'Teamspeak',
            iconCls:'ts',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('server-b-win');
        if(!win){
			MyDesktop.getDim();
            win = desktop.createWindow({
                id: 'teamspeak-win',
                title:'Teamspeak',
                x:5,
                y:5,
                height:screenHeight - 5,
                width:400,
                iconCls: 'ts',
                shim:false,
                animCollapse:false,
                layout: 'fit',
                border:false,
                constrainHeader:true,
                html : '<body><IFRAME SRC="http://87.118.110.131/enduro200806_teamspeak.php" style="border:0px none;width:100%;height:100%;"></IFRAME></body>'
            });
        }
        win.show();
        return win;
    }
});


//-----------------------------------------------------------------------------------//
//------------------------------------Informations RACE24H---------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.InformationsModule = Ext.extend(Ext.app.Module, {
	appType : 'Informations',
    id : 'informations-win',
    
    init : function(){
        this.launcher = {
            text: 'Informations',
            iconCls:'info',
            handler : this.createWindow,
            scope: this
        }
    },
	
	    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('informations-win');
        if(!win){
			MyDesktop.getDim();
            win = desktop.createWindow({
                id: 'informations-win',
                title:'Informations',
                width:600,
                height:450,
                iconCls: 'info',
                shim:false,
                animCollapse:false,
                layout: 'fit',
                border:false,
                constrainHeader:true,
                items:
	       		[{
					xtype:"tabpanel",
					activeTab:0,
					autoScroll:true,
					items:
					[{
						xtype:"panel", //<table width="100%" height="100%" style="background-color:#941010;"><tr><td align="center" valign="middle" style="color:#FFFFFF; font-size:16px; font-wieght:bold;">Bientôt disponible !</td></tr></table>
						title:"Informations Course", 
						html : '<IFRAME SRC="http://87.118.110.131/enduro200806_horaires.php" style="border:0px none;width:100%;height:100%;"></IFRAME>'
					},
					{
						xtype:"panel",
						title:"Aides et Faqs",
		                html : '<body><IFRAME SRC="http://87.118.110.131/enduro200806_aidesfaqs.php" style="border:0px none;width:100%;height:100%;"></IFRAME></body>'
					},
					{
						xtype:"panel",
						title:"Meteo",
		                html : '<body><IFRAME SRC="meteo/meteo.htm" style="border:0px none;width:100%;height:100%;"></IFRAME></body>'
					}]
		       }]
            });
        }
        win.show();
        return win;
    }
});


//-----------------------------------------------------------------------------------//
//----------------------------------PREDEF BUREAU------------------------------------//
//-----------------------------------------------------------------------------------//
//DEFAULT
MyDesktop.desktopDefaultSessA = Ext.extend(Ext.app.Module, {
	appType : 'desktopA-default',
    id : 'defaultA-desktop',
    
    init : function(){
        this.launcher = {
            text: 'Session A',
            iconCls:'predef',
            handler : this.createDesktop,
            scope: this
        }
    },
	
	createDesktop : function()
	{
		var desktop = this.app.getDesktop();
		MyDesktop.getDim();
		
		//Live tv modle
		var mm = new MyDesktop.LiveTv1Module();
		mm.app = this.app;
		mm.createWindow();
		
		var win = desktop.getWindow('tv1-win');
		win.setPosition(0,0);
		win.setHeight(screenHeight1_2);
		win.setWidth(screenWidth1_2 - 100 - winGapX);
		
		//RADIO
		mm = new MyDesktop.RadioModule();
		mm.app = this.app;
		mm.createWindow();
        
    //Chat
    var win = desktop.getWindow('chat-win');
    if (!win) {
			mm = new MyDesktop.ChatModule();
			mm.app = this.app;
			mm.createWindow();
			var win = desktop.getWindow('chat-win');
		
			win.setPosition(0,screenHeight1_2 + winGapY);
			win.setHeight(screenHeight1_2 - scroolBar - winGapY);
			win.setWidth(screenWidth1_2 - 100 - winGapX);
			
			if (navigator.appName=='Netscape') {
				parent.document.getElementById('iframLSDChat').src = 'LSDChat/index.php?w=' + (screenWidth1_2 - 100 - winGapX) + '&h=' + (screenHeight1_2 - scroolBar - winGapY);
			} else {		
				parent.document.all.iframLSDChat.src = 'LSDChat/index.php?w=' + (screenWidth1_2 - 100 - winGapX + 26) + '&h=' + (screenHeight1_2 - scroolBar - winGapY + 34);
			}
		}
		
		//LIVE SERVER
		mm = new MyDesktop.LiveServerAModule();
		mm.app = this.app;
		mm.createWindow();
		var win = desktop.getWindow('server-a-win');
		win.setPosition(screenWidth1_2 - 100 - winGapX,0);
		win.setHeight(screenHeight - scroolBar);
		
    }
});


//-----------------------------------------------------------------------------------//
//----------------------------------PREDEF BUREAU------------------------------------//
//-----------------------------------------------------------------------------------//
//DEFAULT
MyDesktop.desktopDefaultSessB = Ext.extend(Ext.app.Module, {
	appType : 'desktopB-default',
    id : 'defaultB-desktop',
    
    init : function(){
        this.launcher = {
            text: 'Session B',
            iconCls:'predef',
            handler : this.createDesktop,
            scope: this
        }
    },
	
	createDesktop : function()
	{
		var desktop = this.app.getDesktop();
		MyDesktop.getDim();
		
		//Live tv modle
		var mm = new MyDesktop.LiveTv1Module();
		mm.app = this.app;
		mm.createWindow();
		
		var win = desktop.getWindow('tv1-win');
		win.setPosition(0,0);
		win.setHeight(screenHeight1_2);
		win.setWidth(screenWidth1_2 - 100 - winGapX);
		
		//RADIO
		mm = new MyDesktop.RadioModule();
		mm.app = this.app;
		mm.createWindow();
        
    //Chat
    var win = desktop.getWindow('chat-win');
    if (!win) {
			mm = new MyDesktop.ChatModule();
			mm.app = this.app;
			mm.createWindow();
			win = desktop.getWindow('chat-win');
		
			win.setPosition(0,screenHeight1_2 + winGapY);
			win.setHeight(screenHeight1_2 - scroolBar - winGapY);
			win.setWidth(screenWidth1_2 - 100 - winGapX);
			
			if (navigator.appName=='Netscape') {
				parent.document.getElementById('iframLSDChat').src = 'LSDChat/index.php?w=' + (screenWidth1_2 - 100 - winGapX) + '&h=' + (screenHeight1_2 - scroolBar - winGapY);
			} else {		
				parent.document.all.iframLSDChat.src = 'LSDChat/index.php?w=' + (screenWidth1_2 - 100 - winGapX + 26) + '&h=' + (screenHeight1_2 - scroolBar - winGapY + 34);
			}
		}
		
		//LIVE SERVER
		mm = new MyDesktop.LiveServerBModule();
		mm.app = this.app;
		mm.createWindow();
		var win = desktop.getWindow('server-b-win');
		win.setPosition(screenWidth1_2 - 100 - winGapX,0);
		win.setHeight(screenHeight - scroolBar);
    }
});

//MULTIMEDIA
MyDesktop.desktopMedia = Ext.extend(Ext.app.Module, {
	appType : 'desktop-media',
    id : 'media-desktop',
    
    init : function(){
        this.launcher = {
            text: 'Multimédia',
            iconCls:'predef',
            handler : this.createDesktop,
            scope: this
        }
    },
	
	createDesktop : function(){
		//CHAT
		var mm = new MyDesktop.ChatModule();
		mm.app = this.app;
		mm.createWindow();
		
		var win = desktop.getWindow('chat-win');
		win.setHeight(desktop.getWinHeight()-50);
		win.setWidth((desktop.getWinWidth()-((desktop.getWinWidth()/100)*30))-10);
		var widthPos = (desktop.getWinWidth()/100)*30;
    win.setPosition(widthPos+2,0);
    
		//Live tv modle
		var desktop = this.app.getDesktop();
		var mm = new MyDesktop.LiveTvModule();
		mm.app = this.app;
		mm.createWindow();
		
		var win = desktop.getWindow('tv1-win');
		win.setPosition(0,0);
		
		//RADIO
		mm = new MyDesktop.RadioModule();
		mm.app = this.app;
		mm.createWindow();
		
		win = desktop.getWindow('radio-win');
		var heightPos = (desktop.getWinHeight()/100)*60;
		win.setPosition(0,heightPos+3);
    //win.hide();
		
		}
});

//MULTIMEDIA
MyDesktop.desktopInfo = Ext.extend(Ext.app.Module, {
	appType : 'desktop-info',
    id : 'info-desktop',
    
    init : function(){
        this.launcher = {
            text: 'Information',
            iconCls:'predef',
            handler : this.createDesktop,
            scope: this
        }
    },
	
	createDesktop : function(){
		alert('ok');
    }
});


//-----------------------------------------------------------------------------------//
//--------------------------------------SOUS MENU------------------------------------//
//-----------------------------------------------------------------------------------//
MyDesktop.sessionSubMenu = Ext.extend(Ext.app.Module, {
	appType : 'menu',
	id : 'livesession-menu',
	items : [
		'server-a-win',
		'server-a1-win',
		'server-a2-win',
		'server-b-win',
		'server-b1-win',
		'server-b2-win'
	],

	init : function(){
		this.launcher = {
			text: 'Live session course',
			iconCls: 'liveserver',
			handler: function(){
				return false;
			},
			menu: {
				items: []
			}
		}
	}
});


MyDesktop.standingSubMenu = Ext.extend(Ext.app.Module, {
	appType : 'menu',
	id : 'classement-menu',
	items : [
		'standing-win',
		'standingGT1-win',
		'standingGT2-win',
		'standingGT3-win'
	],

	init : function(){
		this.launcher = {
			text: 'Classement',
			iconCls: 'standing',
			handler: function(){
				return false;
			},
			menu: {
				items: []
			}
		}
	}
});

MyDesktop.predefSubMenu = Ext.extend(Ext.app.Module, {
	appType : 'menu',
	id : 'predef-menu',
	items : [
		'defaultA-desktop',
		'defaultB-desktop'
		//'media-desktop'
		//'info-desktop'
	],

	init : function(){
		this.launcher = {
			text: 'Bureau prédefini',
			iconCls: 'predef',
			handler: function(){
				return false;
			},
			menu: {
				items: []
			}
		}
	}
});

MyDesktop.liveTvSubMenu = Ext.extend(Ext.app.Module, {
	appType : 'menu',
	id : 'livetv-menu',
	items : [
		'tv1-win',
		'tv2-win'
	],

	init : function(){
		this.launcher = {
			text: 'Live Tv',
			iconCls: 'livetv',
			handler: function(){
				return false;
			},
			menu: {
				items: []
			}
		}
	}
});