Ext.BLANK_IMAGE_URL = '/nqcommon/js/ext/resources/images/default/s.gif';
Ext.SSL_SECURE_URL="/nqcommon/js/ext/resources/images/default/s.gif";
Ext.useShims=true;

App = {
	/******************************************* Application variables ************************************/	
	debug:false,
	version:'100',
	site:'swlive',
	mode:'ie6',
	noOfAboutLinks:0,
	disableCodeInUserLang:true, //disables the translation of codes
	commonDir:Settings.commonDir,
	domainExt:Settings.domainExt, 
	domainLocal:Settings.domainLocal,
	domainContentExt:Settings.domainContentExt,
	domainLiveExt:Settings.domainLiveExt,
	domainLocalProtocol:Settings.domainLocalProtocol,
	domainExtDefaultProtocol:Settings.domainExtDefaultProtocol,
	liveDataDefaultProtocol:Settings.liveDataDefaultProtocol,
	user:{SubName:"",MappedUID:"",ETRADE_ALLOWED:""	},	
	/*
	liveDataDir:{cse:"/protectedfiles/live_cse/",ase:"/protectedfiles/live_ase/"},
	liveDataDomain:{cse:"etrading.alexistablet",ase:"etrading.alexistablet"},
	*/ 

	//liveDataProxy:{cse:"/test/proxy.cfm?url=",ase:""},
	//liveDataDir:{cse:"/restricted/live/",ase:"/restricted/live_ase/"},
	liveDataProxy:{cse:"",ase:""},
	liveDataDir:{cse:"/restricted/live_cse/",ase:"/restricted/live_ase/"},
	liveDataDomain:Settings.liveDataDomain,
	delayedDataProxy:{cse:"",ase:""},
	delayedDataDir:{cse:"/restricted/delayed_cse/",ase:"/restricted/delayed_ase/"},
	delayedDataDomain:Settings.liveDataDomain,
	storeCompress:Settings.storeCompress?Settings.storeCompress:false,
	compressFolder:'',
	
	defaultDateFormat:'j/n/Y',
	quotePanelRefreshInterval:60000, //determines how often the quote panel can be refreshed - use approx 30000 for live ?
	imgSearch:"/nqcommon/js/ext/plugins/filter-grid/img/find.png",
	storesLoadCount:0,
	storesMaxLoadCount:2,
	init:function(){
	App.storeCache=new Array();
	App.storeCache["dictionary"]=true;
	App.storeCache["indexnames"]=true;
	App.storeCache["categories"]=true;
	App.storeCache["symbols"]=true;
	App.storeCache["markets"]=true;
	if(App.storeCompress){App.compressFolder='compress/';}
		App.logger=new App.components.logger();
		this.pBar=new App.components.progressBar({x:250,y:250});
		this.pBar.show();
		this.pBar.update(.1,"Initialising");
		$("topContent").style.display="none";
		$("topData").style.display="block";
		dataLoaded=1;
		App.lang=typeof(App_lang)!="undefined"?App_lang:"en"; //can pass app lang in calling html page as App_lang
		App.oRenderers=new App.renderers();
		//this.pBar.update(.1,"Loading dictionaries");

		App.dictionary=new App.dictionaryManager({lang:App.lang});

		App.dictionary.addListener("load",function(){
			oGraphs=new App.components.graph({preInit:true});
			App.features=new App.featuresManager();
			var packages="";
			if(typeof p!="undefined"){
				packages=","+p+",";
			}

     		App.features.addFeature("prices_live_cse",{id:"prices_live_cse",altId:"prices_delayed_cse",enabled:(packages.indexOf(",c,")>=0)})
    		App.features.addFeature("prices_delayed_cse",{id:"prices_delayed_cse",altId:"prices_live_cse",enabled:!(packages.indexOf(",c,")>=0)})

    		App.features.addFeature("prices_live_ase",{id:"prices_live_ase",altId:"prices_delayed_ase",enabled:(packages.indexOf(",a,")>=0)})
    		App.features.addFeature("prices_delayed_ase",{id:"prices_delayed_ase",altId:"prices_live_ase",enabled:!(packages.indexOf(",a,")>=0)})

    		App.features.addFeature("etrading",{id:"etrading",altId:"etrading-loggedout",enabled:false})
    		App.features.addFeature("etrading-loggedout",{id:"etrading-loggedout",altId:"etrading",enabled:true})

			App.stores=new App.storesManager();

			App.pBar.update(.3,"Loading data");
			App.stores.addListener("allstoresloaded",function(){
					App.stores.registerListeners();
				//alert("completo")
				App.pBar.update(.85,"Initialising layout");
				App.layout=new App.layout();
				App.layout.addListener("layoutcomplete",function(){
					//alert("lay complete")
					App.logger.log("finished");
					App.logger.show();
					App.layout.statsToolbar.onRender();
					if(App.features.isFeatureEnabled("prices_live_cse")){
						var loadStore=App.stores.prices["cse"];
					}else{
						var loadStore=App.stores.pricesDelayed["cse"];
					}
					loadStore.addListener("load",function(){
						App.pBar.reading.hide();
						App.setSelectedCode("CPB");
					},this,{single:true})
					
					App.pBar.update(.95,"Loading prices");
					App.tasks.runner = new Ext.util.TaskRunner();
					//DNF: 20080805
					//App.stores.prices.cse.loadRemote(); //DNF only temp enable following 2 lines
					//App.stores.pricesDelayed.cse.loadRemote(); //DNF only temp enable following 2 lines
					App.tasks.runner.start(App.tasks.task);
					App.cmd=new App.components.cmd({local:true});

				},this)
				App.layout.init();
			},this,{single:true})
			App.stores.init();

		},this)

		App.dictionary.loadDictionaries();

	},
	initv1:function(){
		//window.onunload=function(){
			//App=null;
			//Ext=null;
		//}

		App.logger=new App.components.logger();
		this.pBar=new App.components.progressBar({x:250,y:250});
		this.pBar.show();
		this.pBar.update(.1,"Initialising");

		//App.fixes.apply();
		$("topContent").style.display="none";
		$("topData").style.display="block";
		dataLoaded=1;
		App.lang=typeof(App_lang)!="undefined"?App_lang:"en"; //can pass app lang in calling html page as App_lang
		App.oRenderers=new App.renderers();
		//this.pBar.update(.1,"Loading dictionaries");
		App.dictionary=new App.dictionaryManager({lang:App.lang});
		App.dictionary.addListener("load",function(){
			
			//App.pBar.update(.2,"Loading graphs");
			oGraphs=new App.components.graph({preInit:true});
			App.features=new App.featuresManager();
			var packages="";
			if(typeof p!="undefined"){
				packages=","+p+",";
			}
     		App.features.addFeature("prices_live_cse",{id:"prices_live_cse",altId:"prices_delayed_cse",enabled:(packages.indexOf(",c,")>=0)})
    		App.features.addFeature("prices_delayed_cse",{id:"prices_delayed_cse",altId:"prices_live_cse",enabled:!(packages.indexOf(",c,")>=0)})

    		App.features.addFeature("prices_live_ase",{id:"prices_live_ase",altId:"prices_delayed_ase",enabled:(packages.indexOf(",a,")>=0)})
    		App.features.addFeature("prices_delayed_ase",{id:"prices_delayed_ase",altId:"prices_live_ase",enabled:!(packages.indexOf(",a,")>=0)})

    		App.features.addFeature("etrading",{id:"etrading",altId:"etrading-loggedout",enabled:false})
    		App.features.addFeature("etrading-loggedout",{id:"etrading-loggedout",altId:"etrading",enabled:true})
    		App.storesMaxLoadCount=0;
    		if(App.features.isFeatureEnabled("prices_live_cse")){App.storesMaxLoadCount=App.storesMaxLoadCount+1}
    		if(App.features.isFeatureEnabled("prices_live_ase")){App.storesMaxLoadCount=App.storesMaxLoadCount+1}
    		//alert(App.storesMaxLoadCount);
			App.stores=new App.storesManager();
			App.pBar.update(.3,"Loading data");
			//alert("loading data")
			App.stores.init();
			App.stores.addListener("allStoresLoaded",function(a,b,c){
				App.storesLoadCount=App.storesLoadCount+1;
				//alert("all stores loaded"+App.storesLoadCount)
				//alert("store "+a+" loaded"+App.storesLoadCount)
				//DNF:20080604 depends how many live stores we have!
				if(App.storesLoadCount==App.storesMaxLoadCount){
					//alert("done")
					//alert("init layout")
					App.pBar.update(.6,"Initialising layout");

					App.properInit=function(){
							//DNF:20080604 may not have live stats for cse
							//alert("hee")
							if(App.storesMaxLoadCount>0){
								//alert("hee")
								//at least one live store
								if(App.features.isFeatureEnabled("prices_live_cse")){var market="cse";}
								if(App.features.isFeatureEnabled("prices_live_ase")){var market="ase";}
								App.stores.stats[market].proxy.addListener("load",function(){
									App.logger.log("finished");
									App.logger.show();
									App.pBar.hide();
									App.layout.statsToolbar.onRender();
									App.tasks.runner = new Ext.util.TaskRunner();
									App.tasks.runner.start(App.tasks.task);
									App.cmd=new App.components.cmd({local:true});
								},this,{single:true})
								if(App.features.isFeatureEnabled("prices_live_cse")){
									App.stores.stats["cse"].proxy.loadNew();
								}
								if(App.features.isFeatureEnabled("prices_live_ase")){
									App.stores.stats["ase"].proxy.loadNew();
								}
								
							}
							if(App.storesMaxLoadCount=0){
								App.pBar.hide();
								App.logger.log("finished");
								App.logger.show();
								App.tasks.runner = new Ext.util.TaskRunner();
								App.tasks.runner.start(App.tasks.task);

							}
						}

					Ext.onReady(function(){
						App.properInit.defer(10);
					})
					App.layout.init();


				}
			},this,{single:false});
		},this)
		
		App.dictionary.loadDictionaries();
		
		
		
	},
	setSelectedCode:function(code,market){
		return App.utils.setSelectedCode(code,market);
	}	
	
}
App.layout=function(){
	this.addEvents("layoutcomplete")
}
App.layout.prototype={
	init:function(){
	
		var currentObject=this;
		this.constructLayout();
	},
	getExtContentUrl:function(cUrl,attr){
		return App.utils.getExtContentUrl(cUrl,attr);

	},
	
	configContentGrids:function(){
		/******************************************************* Content grids *************************************/
		App.selectedCode=new Ext.util.MixedCollection();
		this.contentGrids=new Ext.util.MixedCollection();

		this.contentGrids.currentKey="";
		//initialise all content grids
		//Column model for news grid
		var cm=[
				{name:"id",mapping:"id",type:"int"},
				{name:"date",mapping:"date"},
				{name:"symbols",mapping:"symbols",type:"string"},
				{name:"title",mapping:"title",type:"string"},
				{name:"docs",mapping:"docs"},
				{name:"codes",mapping:"codes"}
			];
		
		var columns=
					[
		        	{id:'date',header:App.dictionary.get("date"),dataIndex:'date',sortable:true,width:50},
					{id:'title',header:App.dictionary.get("title"),dataIndex:'title',sortable:false,width:300,rendererType:'titleandcodeRenderer',renderer:function(a,b,c,d){return App.oRenderers.titleandcodeRenderer(a,b,c,d)}},
					{id:'docs',header:App.dictionary.get("downloads"),dataIndex:'docs',width:50,renderer:function(a,b,c,d){return App.oRenderers.docsRenderer(a,b,c,d)}}
					];
		this.contentGrids.add("news",{config:{id:"news",allowOpenNewTab:true,allowRefresh:true,readingBorder:false,readingTitle:false,cm:cm,columns:columns,url:this.getExtContentUrl(App.domainExt+'/nqcontent.cfm?a_name=news&type=json&'+App.dictionary.getSuffixSW()),detailUrl:this.getExtContentUrl(App.domainExt+'/nqcontent.cfm?a_name=news_view&type=json2&ann_id='),title:""/*App.dictionary.get("news")*/,tabTitle:App.dictionary.get("news")}});
		this.contentGrids.add("announce",{config:{id:"announce",allowOpenNewTab:true,allowRefresh:true,readingBorder:false,readingTitle:false,cm:cm,columns:columns,url:this.getExtContentUrl(App.domainExt+'/nqcontent.cfm?a_name=news&contenttype=announce&type=json&'+App.dictionary.getSuffixSW()),detailUrl:this.getExtContentUrl(App.domainExt+'/nqcontent.cfm?a_name=news_view&type=json2&contenttype=announce&ann_id='),title:""/*App.dictionary.get("laiki_announcements")*/,tabTitle:App.dictionary.get("laiki_announcements")}});
		this.initContentGrids();
	
	},	
	initContentGrids:function(){
		var thisGrid;
		for (var i=0;i<this.contentGrids.length;i++){
			thisGrid=this.contentGrids.get(i);
			thisGrid.grid=new App.components.contentGrid(thisGrid.config);
		}

	},	
	constructLayout3:function(){
			this.codeCombo=new App.components.codeCombo();	
			this.configContentGrids();
			/******************************************************************************************************************/
			/**********************************************            MENUS            ***************************************/
			/******************************************************************************************************************/


			this.codeMenuItemsResearch=					
					{text:App.dictionary.get("research"),group:'view',
						menu:{
							items : [
								{text:App.dictionary.get("company_profile"),id:'profile',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("insider_trading"),id:'itrade',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("investors_diary"),id:'diary',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("fundamentals"),id:'fundamentals',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("fin_statements"),id:'fstatement',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("interim_results"),id:'interim',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("major_shareholders"),id:'major_shareholders',checked:false,group:'view',handler:App.utils.codeMenuHandler}
							]
						}

					}
					
			this.codeMenuItemsTrade=					
					{text:App.dictionary.get("trade"),id:'trade',checked:false,group:'view',handler:App.utils.codeMenuHandler}			

		
			this.codeMenuItemsNews=
				
				{text:App.dictionary.get("enimerosi"),group:'view',
					menu:{
						items : [
							{text:App.dictionary.get("announcements"),id:'announce',group:'view',checked:false,handler:App.utils.codeMenuHandler}
							,{text:App.dictionary.get("news"),id:'news',group:'view',checked:false,handler:App.utils.codeMenuHandler}
						]
					}

				}
		
			this.codeMenu=new Ext.menu.Menu({
			items:[
				{text:'',id:'about',canActivate:false,icon:'/nqcommon/images/flag-cy.gif'}
				//,{text:'',id:'about2',canActivate:false}
				,'-'
				,{text:'<b>'+App.dictionary.get("set_as_selected")+'</b>',id:'setselected',handler:App.utils.codeMenuHandler}
				,this.codeMenuItemsNews
				,{text:App.dictionary.get("vportfolio_add_to"),id:'addtovportfolio',handler:App.utils.codeMenuHandler}
				//,this.codeMenuItemsResearch
				//,this.codeMenuItemsTrade
				,'-'
				,{text:App.dictionary.get("close_menu"),id:'close',handler:App.utils.codeMenuHandler}
				]
			});		
	
	
			/******************************************************************************************************************/
			/**********************************************              TOP            ***************************************/
			/******************************************************************************************************************/
			this.statsToolbar=new App.components.statusStats({market:'cse'});
			this.statusCombo=new Ext.Toolbar({
				region:'east',
				border:false,
				width:300,
				items:[this.codeCombo]
			})
			this.statusToolbar=new Ext.Panel({
				layout:'border',
				border:false,
				height:25,
				items:[
					this.statsToolbar.reading,
					this.statusCombo
				]
				
			});

			this.topPanel=new Ext.Panel({
				region:'north',
				//layout:'fit',
				height:25,
				items:[this.statusToolbar],
				border:false
			});
			
			/******************************************************************************************************************/
			/**********************************************              CENTER           ***************************************/
			/******************************************************************************************************************/
			
			this.pricesBySector=new App.components.pricesBySectorPanel({showBorderTitle:true,rpp:30,tabTitle:App.dictionary.get("by_sector")}); 	
			this.prices=new Ext.Panel({
				                        title: App.dictionary.get("prices"),
				                        layout:'fit',
//										items:[this.pricesBySector.reading]
										html:'prices'
			                    		})


			this.reading=new Ext.Panel({
			    				id:'reading',
			        			layout:'fit',
			                    disabled:false,
			                    title:App.dictionary.get("news"),
			                    tabTitlePrefix:App.dictionary.get("news"),
			                    maxTabTitleLength:15
			        		});


			var news=this.contentGrids.get("news").grid;
			var newsAdd=news.reading;
			this.reading.add(newsAdd);
			newsAdd.addListener("afterlayout",function(){
				this.contentGrids.get("news").grid.reloadStore();
			},this,{single:true})
			
			this.announce=new Ext.Panel({
			    				id:'announce',
			        			layout:'fit',
			                    disabled:false,
			                    title:App.dictionary.get("announcements"),
			                    //activeItem:0,
			                    tabTitlePrefix:App.dictionary.get("announcements"),
			                    maxTabTitleLength:15
			        		});
			var news=this.contentGrids.get("announce").grid;
			var newsAdd=news.reading;
			this.announce.add(newsAdd);
			newsAdd.addListener("afterlayout",function(){
				this.contentGrids.get("announce").grid.reloadStore();
			},this,{single:true})

			this.vPortfolio=new App.components.portfolioMng({});
			this.vPortfolioPanel=new Ext.Panel({
			    				//id:'vPortfolio',			    				
			    				border:false,
			        			layout:'border',
			                    disabled:false,
			                    title:App.dictionary.get("vportfolio"),
			                    //activeItem:0,
			                    tabTitlePrefix:App.dictionary.get("vportfolio"),
			                    maxTabTitleLength:15
			                    //items:[this.vPortfolio.reading]
			                    //html:'portfolio'
			                    
			        		})
        	this.vPortfolioPanel.reading=this.vPortfolio.reading;
        	this.vPortfolioPanel.add(this.vPortfolio.reading);


			this.marketGLV2 = new App.components.marketGLV2();	
			this.marketGLV2Panel=new Ext.Panel({
			    				id:"marketGLV2Panel",			    				
			    				border:false,
			        			layout:'border',
			                    disabled:false,
			                    title:App.dictionary.get("marketGLV"),
			                    //activeItem:0,
			                    tabTitlePrefix:App.dictionary.get("marketGLV"),
			                    maxTabTitleLength:15			                    
			 });

        	this.marketGLV2Panel.reading=this.marketGLV2.reading;
        	this.marketGLV2Panel.add(this.marketGLV2.reading);	


			this.mainContentPanel=new Ext.TabPanel({
				border:false,
				region:'center',
				activeItem:0,
				items:[this.prices,this.reading,this.announce,this.vPortfolioPanel, this.marketGLV2Panel]
			});
			
			this.mainContentPanel.addListener("render",function(){
				//this.prices.doLayout();
				//this.pricesBySector.selectCategory("0");
				//this.pricesBySector.selectCategory("8350");
				this.pricesBySector.selectMarket("0");
				this.pricesBySector.selectMarket("4");
				//this.mainContentPanel.activate(0);
				},this
				
			);

			this.mainContentPanel.addListener("afterlayout",function(){
				//this.prices.doLayout();
				//this.mainContentPanel.setActiveTab(0)
				//this.mainContentPanel.add(this.prices);
				//this.mainContentPanel.setActiveTab(0);
				
			},this)
			
			/******************************************************************************************************************/
			/**********************************************              RIGHT           ***************************************/
			/******************************************************************************************************************/
/*
			
			this.rightPanel= new Ext.TabPanel({
			                border:false,
			                //deferredRender:false, //DNF:20080529
			                //activeTab:0,
			                tabPosition:'top',
			                region:'center',
              				layoutOnTabChange :true

			            });
			
			this.rightPanelOuter=new Ext.Panel({
				region:'east',
				title:'',
				split:true,
				
				maxWidth:300,
				minWidth:300,
				width:300,
				border:false,
				autoShow:false,
				items:[this.rightPanel]
			});
			
			
		
				

			this.marketsPanel=new App.components.marketsPanel({includeGlobal:false,removeDummy:false});
			this.quotePanel=new App.components.quotePanel();
			this.rightPanel.add(this.marketsPanel.outer);
			this.rightPanel.add(this.quotePanel.selectedSecurityPanel);
			//hack because not rendered correctly!
			this.rightPanel.doLayout();

			this.marketsPanel.tabPanel.activate(0);					
			this.marketsPanel.tabPanel.remove(0);
*/



			this.rightPanel= new Ext.TabPanel({
			                border:false,
			                tabPosition:'top',
			                region:'center',
             				layoutOnTabChange :true
             				
			            });

			this.rightPanelOuter=new Ext.Panel({
				region:'east',
				layout:'border',
				title:'',
				split:true,
				maxWidth:300,
				minWidth:300,
				width:300,
				border:false,
				autoShow:false,
				items:[this.rightPanel]
			});

	if(1==1){
			this.marketsPanel=new App.components.marketsPanel({includeGlobal:false,removeDummy:true});
			this.quotePanel=new App.components.quotePanel();
			this.rightPanel.add(this.marketsPanel.outer);
			this.rightPanel.add(this.quotePanel.selectedSecurityPanel);
			//hack because not rendered correctly!
			this.rightPanel.doLayout();
			this.rightPanel.activate(1);
			//this.rightPanel.activate(0);
			this.marketsPanel.tabPanel.activate(0);
	}

	if(1==2){
			//this.marketsPanel=new App.components.marketsPanel({includeGlobal:true,removeDummy:true});
			this.marketsPanel=new Ext.Panel({title:'Markets',html:'Not implemented',layout:'fit'})
			this.quotePanel=new App.components.quotePanel();
			//this.rightPanel.add(this.marketsPanel.outer);
			this.rightPanel.add(this.marketsPanel);
			this.rightPanel.add(this.quotePanel.selectedSecurityPanel);
			
			this.rightPanel.activate(1);
			this.rightPanel.activate(0);
			//this.marketsPanel.tabPanel.activate(0);
	}


			/******************************************************************************************************************/
			/**********************************************              VIEWPORT       ***************************************/
			/******************************************************************************************************************/

	
			this.viewportOuter=new Ext.Panel({
				layout:'border',
				border:false,
				height:395,
				autoShow:false
			});
			this.viewportOuter.addListener("render",function(){
				this.viewportOuter.add(this.topPanel)		
				this.viewportOuter.add(this.rightPanelOuter)		
				this.viewportOuter.add(this.mainContentPanel)
			},this)
			
			
			this.viewportOuter.render("topData");


	},
	constructLayout:function(){
			this.codeCombo=new App.components.codeCombo();
			
			this.configContentGrids();

			/*MENU ITEMS*/
			this.codeMenuItemsNews=
					
					{text:App.dictionary.get("enimerosi"),group:'view',
						menu:{
							items : [
								{text:App.dictionary.get("announcements"),id:'announce',group:'view',checked:false,handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("news"),id:'news',group:'view',checked:false,handler:App.utils.codeMenuHandler}
							]
						}

					}
			this.codeMenuItemsResearch=					
					{text:App.dictionary.get("research"),group:'view',
						menu:{
							items : [
								{text:App.dictionary.get("company_profile"),id:'profile',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("insider_trading"),id:'itrade',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("investors_diary"),id:'diary',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("fundamentals"),id:'fundamentals',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("fin_statements"),id:'fstatement',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("interim_results"),id:'interim',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("major_shareholders"),id:'major_shareholders',checked:false,group:'view',handler:App.utils.codeMenuHandler}
							]
						}

					}
					
			this.codeMenuItemsTrade=					
					{text:App.dictionary.get("trade"),id:'trade',checked:false,group:'view',handler:App.utils.codeMenuHandler}			
					
			

			
			this.codeMenu=new Ext.menu.Menu({
				items:[
					{text:'',id:'about',canActivate:false,icon:'/nqcommon/images/flag-cy.gif'}
					//,{text:'',id:'about2',canActivate:false}
					,'-'
					,{text:'<b>'+App.dictionary.get("set_as_selected")+'</b>',id:'setselected',handler:App.utils.codeMenuHandler}
					,this.codeMenuItemsNews
					,{text:App.dictionary.get("vportfolio_add_to"),id:'addtovportfolio',handler:App.utils.codeMenuHandler}
					//,this.codeMenuItemsResearch
					//,this.codeMenuItemsTrade
					,'-'
					,{text:App.dictionary.get("close_menu"),id:'close',handler:App.utils.codeMenuHandler}
					]
			});			
			
			/*MENU ITEMS END*/	

			this.reading=new Ext.Panel({
			    				id:'reading',
			        			layout:'fit',
			                    disabled:false,
			                    title:App.dictionary.get("news"),
			                    //activeItem:0,
			                    tabTitlePrefix:App.dictionary.get("news"),
			                    maxTabTitleLength:15
			        		});
			var news=this.contentGrids.get("news").grid;
			var newsAdd=news.reading;
			this.reading.add(newsAdd);
			news.reloadStore();
			//App.pBar.update(.8);
			this.announce=new Ext.Panel({
			    				id:'announce',
			        			layout:'fit',
			                    disabled:false,
			                    title:App.dictionary.get("announcements"),
			                    //activeItem:0,
			                    tabTitlePrefix:App.dictionary.get("announcements"),
			                    maxTabTitleLength:15
			        		});
			var news=this.contentGrids.get("announce").grid;
			var newsAdd=news.reading;
			this.announce.add(newsAdd);
			news.reloadStore();


			this.prices=new App.components.pricesBySectorNew({title: App.dictionary.get("prices")});



			this.vPortfolio=new App.components.portfolioMng({});
			this.vPortfolioPanel=new Ext.Panel({
			    				//id:'vPortfolio',			    				
			    				border:false,
			        			layout:'border',
			                    disabled:false,
			                    title:App.dictionary.get("vportfolio"),
			                    //activeItem:0,
			                    tabTitlePrefix:App.dictionary.get("vportfolio"),
			                    maxTabTitleLength:15
			                    //items:[this.vPortfolio.reading]
			                    //html:'portfolio'
			                    
			        		})
        	this.vPortfolioPanel.reading=this.vPortfolio.reading;
        	this.vPortfolioPanel.add(this.vPortfolio.reading);


			this.marketGLV2 = new App.components.marketGLV2();	
			this.marketGLV2Panel=new Ext.Panel({
			    				id:"marketGLV2Panel",			    				
			    				border:false,
			        			layout:'border',
			                    disabled:false,
			                    title:App.dictionary.get("marketGLV"),
			                    //activeItem:0,
			                    tabTitlePrefix:App.dictionary.get("marketGLV"),
			                    maxTabTitleLength:15			                    
			 });
 	
        	this.marketGLV2Panel.reading=this.marketGLV2.reading;
        	this.marketGLV2Panel.add(this.marketGLV2.reading);	



			this.mainContentPanel=new Ext.TabPanel({
				border:false,
				layoutOnTabChange:true,
				activeTab: 0,
				items:[this.prices,this.reading,this.announce,this.vPortfolioPanel, this.marketGLV2Panel]
			});

			this.viewportInner=new Ext.Panel({
				region:'center',
				title:'',
				layout:'fit',
				border:false,
				items:[this.mainContentPanel]
			});
			



			this.statsToolbar=new App.components.statusStats({market:'cse'});
			

			this.statusCombo=new Ext.Toolbar({
				region:'east',
				border:false,
				width:300,
				items:[this.codeCombo]
			})

			this.statusToolbar=new Ext.Panel({
				layout:'border',
				border:false,
				height:25,
				items:[
					this.statsToolbar.reading,
					this.statusCombo
				]
				
			});
			this.topPanel=new Ext.Panel({
				region:'north',
				items:[this.statusToolbar],
				height:25,
				border:false
			});


			this.rightPanel= new Ext.TabPanel({
			                border:false,
			                //deferredRender:false, //DNF:20080529
			                //activeTab:0,
			                tabPosition:'top',
			                region:'center',
              				layoutOnTabChange :true

			            });
			
			this.rightPanelOuter=new Ext.Panel({
				region:'east',
				title:'',
				split:true,
				
				maxWidth:300,
				minWidth:300,
				width:300,
				border:false,
				autoShow:false,
				items:[this.rightPanel]
			});
			
			
		
				
			this.marketsPanel=new App.components.marketsPanelNew({graphWidth:"250",includeGlobal:true,removeDummy:true});
			this.quotePanel=new App.components.quotePanel();
							
	
			this.rightPanel.add(this.marketsPanel.reading);
			this.rightPanel.add(this.quotePanel.selectedSecurityPanel);
			//hack because not rendered correctly!
			this.rightPanel.doLayout();

			this.viewportOuter=new Ext.Panel({layout:'border',
				a1pplyTo:"topData",
				border:false,
				height:395,
				autoShow:false,
				items:[this.topPanel,this.viewportInner,this.rightPanelOuter]}
				
				
				);
			this.viewportOuter.addListener("afterlayout",function(a,b,c){
				App.layout.rightPanel.addListener("render",function(){
					App.layout.rightPanel.setHeight(App.layout.rightPanelOuter.getSize().height);
					App.layout.rightPanel.render();
					App.layout.rightPanel.activate(0);
					
					//alert("show?")
					App.layout.fireEvent("layoutcomplete");
					//App.pBar.hide();	

					//App.pBar.hide();
				})
				

			})
			
			this.viewportOuter.render("topData");


	},
	constructLayout4:function(){
			//this.mySample=new App.components.sample({param1:1,param2:2});
			/*center area layout*/
			//App.pBar.update(.7);
			this.codeCombo=new App.components.codeCombo();
			
			this.configContentGrids();

			/*MENU ITEMS*/
			this.codeMenuItemsNews=
					
					{text:App.dictionary.get("enimerosi"),group:'view',
						menu:{
							items : [
								{text:App.dictionary.get("announcements"),id:'announce',group:'view',checked:false,handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("news"),id:'news',group:'view',checked:false,handler:App.utils.codeMenuHandler}
							]
						}

					}
			this.codeMenuItemsResearch=					
					{text:App.dictionary.get("research"),group:'view',
						menu:{
							items : [
								{text:App.dictionary.get("company_profile"),id:'profile',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("insider_trading"),id:'itrade',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("investors_diary"),id:'diary',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("fundamentals"),id:'fundamentals',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("fin_statements"),id:'fstatement',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("interim_results"),id:'interim',checked:false,group:'view',handler:App.utils.codeMenuHandler}
								,{text:App.dictionary.get("major_shareholders"),id:'major_shareholders',checked:false,group:'view',handler:App.utils.codeMenuHandler}
							]
						}

					}
					
			this.codeMenuItemsTrade=					
					{text:App.dictionary.get("trade"),id:'trade',checked:false,group:'view',handler:App.utils.codeMenuHandler}			
					
			

			
			this.codeMenu=new Ext.menu.Menu({
				items:[
					{text:'',id:'about',canActivate:false,icon:'/nqcommon/images/flag-cy.gif'}
					//,{text:'',id:'about2',canActivate:false}
					,'-'
					,{text:'<b>'+App.dictionary.get("set_as_selected")+'</b>',id:'setselected',handler:App.utils.codeMenuHandler}
					,this.codeMenuItemsNews
					,{text:App.dictionary.get("vportfolio_add_to"),id:'addtovportfolio',handler:App.utils.codeMenuHandler}
					//,this.codeMenuItemsResearch
					//,this.codeMenuItemsTrade
					,'-'
					,{text:App.dictionary.get("close_menu"),id:'close',handler:App.utils.codeMenuHandler}
					]
			});			
			
			/*MENU ITEMS END*/

			this.pricesBySector=new App.components.pricesBySectorPanel({showBorderTitle:true,rpp:30,tabTitle:App.dictionary.get("by_sector")}); 	
			this.prices=new Ext.Panel({
				                        autoScroll:true,
				                        title: App.dictionary.get("prices"),
				                        layout:'fit',
				                        //height:300,
										items:[this.pricesBySector.reading]
			                    		})


					                    	
			this.reading=new Ext.Panel({
			    				id:'reading',
			        			layout:'fit',
			                    disabled:false,
			                    title:App.dictionary.get("news"),
			                    //activeItem:0,
			                    tabTitlePrefix:App.dictionary.get("news"),
			                    maxTabTitleLength:15
			        		});
			var news=this.contentGrids.get("news").grid;
			var newsAdd=news.reading;
			this.reading.add(newsAdd);
			news.reloadStore();
			//App.pBar.update(.8);
			this.announce=new Ext.Panel({
			    				id:'announce',
			        			layout:'fit',
			                    disabled:false,
			                    title:App.dictionary.get("announcements"),
			                    //activeItem:0,
			                    tabTitlePrefix:App.dictionary.get("announcements"),
			                    maxTabTitleLength:15
			        		});
			var news=this.contentGrids.get("announce").grid;
			var newsAdd=news.reading;
			this.announce.add(newsAdd);
			news.reloadStore();




			this.vPortfolio=new App.components.portfolioMng({});
			this.vPortfolioPanel=new Ext.Panel({
			    				//id:'vPortfolio',			    				
			    				border:false,
			        			layout:'border',
			                    disabled:false,
			                    title:App.dictionary.get("vportfolio"),
			                    //activeItem:0,
			                    tabTitlePrefix:App.dictionary.get("vportfolio"),
			                    maxTabTitleLength:15
			                    //items:[this.vPortfolio.reading]
			                    //html:'portfolio'
			                    
			        		})
        	this.vPortfolioPanel.reading=this.vPortfolio.reading;
        	this.vPortfolioPanel.add(this.vPortfolio.reading);

			this.marketGLV2 = new App.components.marketGLV2();	
			this.marketGLV2Panel=new Ext.Panel({
			    				id:"marketGLV2Panel",			    				
			    				border:false,
			        			layout:'border',
			                    disabled:false,
			                    title:App.dictionary.get("marketGLV"),
			                    //activeItem:0,
			                    tabTitlePrefix:App.dictionary.get("marketGLV"),
			                    maxTabTitleLength:15			                    
			 });
 	
        	this.marketGLV2Panel.reading=this.marketGLV2.reading;
        	this.marketGLV2Panel.add(this.marketGLV2.reading);	

			this.mainContentPanel=new Ext.TabPanel({
				border:false,
				layoutOnTabChange:true,
				items:[this.prices,this.reading,this.announce,this.vPortfolioPanel, this.marketGLV2Panel]
			});
			
			//App.pBar.update(.9);
			this.mainContentPanel.addListener("render",function(){
				this.mainContentPanel.activate(0);
				this.prices.doLayout();
				//this.pricesBySector.selectCategory("0");
				//this.pricesBySector.selectCategory("8350");
				//20080804 this.pricesBySector.selectMarket("0");
				//20080804 this.pricesBySector.selectMarket("4");
				},this
				
			);
			
			this.viewportInner=new Ext.Panel({
				region:'center',
				title:'',
				layout:'fit',
				border:false,
				items:[this.mainContentPanel]
			});
			



			this.statsToolbar=new App.components.statusStats({market:'cse'});
			

			this.statusCombo=new Ext.Toolbar({
				region:'east',
				border:false,
				width:300,
				items:[this.codeCombo]
			})
			

/*
			this.statusToolbarInner=new Ext.Panel({
				region:'center',
				layout:'fit',
				border:false,
				height:25,
				items:[
					this.statsToolbar
					//this.statsToolbar2,
				]
				
			});
*/
			this.statusToolbar=new Ext.Panel({
				layout:'border',
				border:false,
				height:25,
				items:[
					this.statsToolbar.reading,
					this.statusCombo
				]
				
			});


			/*
			this.mainToolbar=new Ext.Toolbar({
				height:25,
				items:[
					'&nbsp;&nbsp;&nbsp;'+App.dictionary.get("selected_security")+': ',
					this.codeCombo
				]
			});
			*/
			this.topPanel=new Ext.Panel({
				region:'north',
				items:[this.statusToolbar],
				height:25,
				border:false
			});
			

			this.rightPanel= new Ext.TabPanel({
			                border:false,
			                //deferredRender:false, //DNF:20080529
			                //activeTab:0,
			                tabPosition:'top',
			                region:'center',
              				layoutOnTabChange :true

			            });
			
			this.rightPanelOuter=new Ext.Panel({
				region:'east',
				title:'',
				split:true,
				
				maxWidth:300,
				minWidth:300,
				width:300,
				border:false,
				autoShow:false,
				items:[this.rightPanel]
			});
			
			
		
				
			this.marketsPanel=new App.components.marketsPanelNew({graphWidth:"250",includeGlobal:true,removeDummy:true});
			//this.marketsPanel=new App.components.marketsPanel({includeGlobal:false,removeDummy:false});
			this.quotePanel=new App.components.quotePanel();
							
	
			this.rightPanel.add(this.marketsPanel.reading);
			this.rightPanel.add(this.quotePanel.selectedSecurityPanel);
			//hack because not rendered correctly!
			this.rightPanel.doLayout();

			//this.marketsPanel.tabPanel.activate(0);					
			//this.marketsPanel.tabPanel.remove(0);

			
			
								
			
								
								
							

			this.viewportOuter=new Ext.Panel({layout:'border',
				a1pplyTo:"topData",
				border:false,
				height:395,
				autoShow:false,
				items:[this.topPanel,this.viewportInner,this.rightPanelOuter]}
				
				
				);

			this.rightPanelOuter.doLayout();

				
				App.layout.pricesBySector.reading.addListener("afterlayout",function(){
					var height=App.layout.pricesBySector.reading.getSize().height;
					if(height>0){
						//alert("set height to:"+height)
					}
					//App.layout.prices.reading.setHeight(App.layout.pricesBySector.reading.getSize().height);
				})
			
			this.viewportOuter.addListener("afterlayout",function(a,b,c){
				App.layout.rightPanel.addListener("render",function(){
					App.layout.rightPanel.setHeight(App.layout.rightPanelOuter.getSize().height);
					App.layout.rightPanel.render();



					//App.pBar.hide();
				})
				

			})

			this.viewportOuter.addListener("render",function(a,b,c){
				App.layout.rightPanel.activate(0);
				//App.layout.marketsPanel.tabPanel.activate(0);
			})
			//this.marketsPanel.addListener("s1how",function(){
				//alert("the end")
			//})
			//this.viewportOuter.doLayout();
					

			this.viewportOuter.render("topData");
			


	
	}

}
Ext.extend(App.layout,Ext.util.Observable,App.layout.prototype);


Ext.namespace("App");
Ext.namespace("App.dictionaryManager");
Ext.namespace("App.featuresManager");
Ext.namespace("App.storesManager");
Ext.namespace("App.layout");
Ext.namespace("App.components");
Ext.namespace("App.renderers");
Ext.namespace("App.utils");
Ext.namespace("App.sample");
Ext.namespace("App.content");
Ext.namespace("App.tasks");
Ext.namespace("App.fixes");
Ext.namespace("App.ws");
Ext.namespace("sw");
/*
Ext.onReady(function(){
	//alert("ready")
	App.init();
	
});
*/
if(typeof(NQJSScriptsLoaded)=="number"){NQJSScriptsLoaded=NQJSScriptsLoaded+1;}
