	/********************************************************** graph component class *****************************************************************/
	App.components.graph=function(config){
		this.preInit=false;
		this.type="i";
		this.totalLength=0;
		//array that holds what the historical graph shows
		this.current=new Array();
		this.current['type']=""; //historical graph type
		this.current['totalLength']=0; //transactions total length
		this.current['code']="";
		this.isDrawing=false; //whether current graph is already drawing stuff
		this.graphWidth="290";
		Ext.apply(this, config);
		if(this.preInit){
			this.preInitJava();
		}else{
			this.init();
		}
	};
	
	App.components.graph.prototype={

		init : function(config){
			currentObject=this;
			config=config||this.config;
			/*
			this.loadingWindow=new Ext.Window({
				width:100,
				height:100,
				title:'',
				border:false,
				closable :false,
				draggable :false,
				headerAsText :false,
				hideBorders :true,
				shadow :false,
				shim :true,
				html:'loading'
			});
			*/
			this.store=App.stores.trans[this.market];


			/******************** historical prices store ******************/
			var cm=[
					{name:"id",mapping:"id"},
					{name:"code",mapping:"code",type:"string"},
					{name:"date",mapping:"date"},
					{name:"pvolume",mapping:"pvolume"},
					{name:"close",mapping:"close"}
				];
				
			this.rec=new Ext.data.Record.create(cm);
			this.recReader=new Ext.data.JsonReader({totalProperty:"results",root:"rows",id:"id"}, this.rec);
			var callUrl=App.liveDataDefaultProtocol+App.liveDataDomain[this.market]+"/get/prices_historical.cfm";
			this.storeProxy = new Ext.data.ScriptTagProxy({url: callUrl});
			this.historicalStore = new Ext.data.Store({storeId:"historicalStore",period:"",proxy: this.storeProxy,reader: this.recReader,autoLoad:false,remoteSort:true});

			this.historicalStore.addListener("beforeload",function(a,b,c){
				a.baseParams['code']=this.code;
				a.baseParams['market']=this.market;
				a.baseParams['type']=this.type;
			},this)

			/*This is the outermost component*/
			if(Ext.isGecko){
				var hideMode="visibility";
				var hideMode="offsets";
			}else{
				var hideMode="offsets";
			}
			//this.dummy=new Ext.Panel({layout:'fit',allowDomMove:false,border:false,html:this.makeJavaObject("d")});
//			this.intraday=new Ext.Panel({layout:'fit',extraCls:'nq-x-hide-display',hideMode :hideMode,allowDomMove:true,border:false,applyTo:"graphOuter_i_"+this.market/*html:this.makeJavaObject("i")*/});
//			this.period=new Ext.Panel({layout:'fit',extraCls:'nq-x-hide-display',hideMode :hideMode,allowDomMove:true,border:false,applyTo:"graphOuter_p_"+this.market/*,html:this.makeJavaObject("p")*/});
			//dnf:flotr
			this.intraday=new Ext.Panel({layout:'fit',extraCls:'nq-x-hide-display',hideMode :hideMode,allowDomMove:true,border:false,applyTo:"graphOuter_i_"+this.market/*,html:this.makeFlotrObject("i",this.market,false)*/});
			this.period=new Ext.Panel({layout:'fit',extraCls:'nq-x-hide-display',hideMode :hideMode,allowDomMove:true,border:false,applyTo:"graphOuter_p_"+this.market/*,html:this.makeFlotrObject("p",this.market,false)*/});
			this.graphType=new Ext.Panel({layout:'card',renderHidden:true,hideMode :hideMode,border:false,items:[this.intraday,this.period/*,this.dummy*/],activeItem:0});
			this.graphType.doLayout();
			
			this.reading=new Ext.Panel({
				layout:'card',
				region:this.region,
				border:false,
				hideMode :hideMode,
				//allowDomMove:false,
				items:[
					//new Ext.Panel({layout:'fit',border:false,hideMode :hideMode,bodyCls:'x-mask-loading',html:'<span class="x-mask-loading">'+App.dictionary.get("loading")+'</span>'}),
					new Ext.Panel({layout:'fit',border:false,hideMode :hideMode,
						bodyCls:'x-mask-loading',
						//h1tml:'<span class="x-mask-loading">'+App.dictionary.get("loading")+'</span>',
						html:'<img src="/nqcommon/images/ajax-loader_big.gif" border="false" width="100" height="100" style="margin-top:40px;margin-left:80px;">'						
						}),
					//new Ext.Panel({layout:'fit',border:false,html:this.makeJavaObject()}),
					this.graphType,
					new Ext.Panel({layout:'fit',border:false,hideMode :hideMode,html:App.dictionary.get("no_data_to_graph")})
				],
				activeItem:1
			});
			//this.reading.doLayout();//20080619

			//this.supressGraph=App.utils.suppressGridLoad(this.reading,this.store,this);
			
			this.reading.addListener("render",function(){
				//alert("rendering "+this.market)

				Ext.get("graphOuter_i_cse").removeClass("nq-x-hide-display");
				Ext.get("graphOuter_p_cse").removeClass("nq-x-hide-display");
				Ext.get("graphOuter_i_ase").removeClass("nq-x-hide-display");
				Ext.get("graphOuter_p_ase").removeClass("nq-x-hide-display");

				
			},this,{single:true})
			/*
			this.loadingWindow=new Ext.Window({
				width:100,
				height:100,
				title:'',
				border:false,
				closable :false,
				draggable :false,
				headerAsText :false,
				hideBorders :true,
				bodyBorder :false,
				shadow :false,
				//plain:true,
				shim :true,
				html:'<img src="/nqcommon/images/ajax-loader_big.gif" border="false" width="100" height="100" style="margin-top:40px;margin-left:80px;">'
			});
			this.loadingWindow.addListener("beforeshow",function(){
				try{
					var pos=this.graphType.getPosition();
					this.loadingWindow.setPosition(pos);
					var size=this.graphType.getSize();
					this.loadingWindow.setSize(size);
				}catch(e){}
			},this,{single:false})
			*/
			this.reading.doLayout();



		},
		setCode:function(code){
			if (!App.content.isReallyVisible(this.reading)){
				return
			}
			if(code!=this.code){
				this.dataChanged();
			}
			this.code=code;
		},
		dataChanged:function(){
			var changed=false;
			if(this.type=="i"){
				//intraday - changed if new transaction record detected
				if(typeof(this.store.totalLength)!="undefined"){
					changed=this.store.totalLength!=this.totalLength;
					this.totalLength=this.store.totalLength;
				}
			}else{
				//Period graph
				//dirty if:
				// historical store does not contain data for current code
				// price store .close <> current.close
				//check date of last record if == last update date
				if(
					typeof(this.historicalStore.totalLength)=="undefined" 
					|| this.historicalStore.totalLength==0
					|| this.historicalStore.period!=this.type
					
				){
					//store requires update
					changed=true;
				}else{
					//alert("data not changed")
					changed=false;
					try{
						if(this.historicalStore.data.items[0].data.close!=this.code){
							changed=true;
						}
						
					}catch(e){}

				}

			}
			return changed;
		},
		startUpdate:function(){
//flotr			Ext.get("graphOuter_i_cse").setHeight(0);
//flotr			Ext.get("graphOuter_i_ase").setHeight(0);
			Ext.get("graphOuter_i_cse").removeClass("x-hide-display");
			Ext.get("graphOuter_p_cse").removeClass("x-hide-display");
			Ext.get("graphOuter_i_ase").removeClass("x-hide-display");
			Ext.get("graphOuter_p_ase").removeClass("x-hide-display");
			
			try{
				this.reading.layout.setActiveItem(0);
				var type="p";
				if(this.type=="i"){
					type="i";
				}
//flotr				this.getJavaObject(type).style.height="0px";
//flotr				this.getJavaObject(type).style.width="0px";
				var l=Ext.get("loading_"+type+"_"+this.market);
				
			}catch(e){}
			//this.loadingWindow.show();
		},
		endUpdate:function(totalRecords){
			if (typeof(totalRecords)=="undefined"){
				totalRecords=999;
			}
			if(totalRecords>=0){
				this.reading.layout.setActiveItem(1);
				//make widht and height change on jobject 
			}
			if(totalRecords==0){
				this.reading.layout.setActiveItem(2);
			}
			var type="p";
			if(this.type=="i"){
				type="i";
			}
			try{
				var l=Ext.get("loading_"+type+"_"+this.market);
				l.dom.innerHTML="&nbsp;";
//flotr				this.getJavaObject(type).style.height="200px";
//flotr				this.getJavaObject(type).style.width="270px";
				
				//var g=Ext.get("graph_"+type+"_"+this.market);
				//g.unmask();			
			}catch(e){}
			//this.loadingWindow.hide();
			
		},
		updateContent:function(market,code,force,dueToPriceTrigger){
			if(typeof(force)=="undefined"){force=false;}
			this.market=market;
			if(typeof(dueToPriceTrigger)=="undefined"){dueToPriceTrigger=false;}
			if (!force){
				if (!App.content.isReallyVisible(this.reading)){
					//alert("not visible - returning")
					return;
						
				}
			}
			//alert("graphs.js graphs.updateContent")
			if(this.type=="i"){
				this.graphType.layout.setActiveItem(0);
			}else{
				//alert("make graph period")
				//we reached this poing either because 
				//1. transactions have been reloaded 
				//2. period changed
				//3. code changed
				//4. tab is activated
				//5. chance we may already be drawing - or waitiing for store to load - set isDrawing flag and reset it on end.
				//must check and act accordingly!
				try{
					this.graphType.layout.setActiveItem(1);
					/*stupid but works - something wrong with size when ase is selected*/
					this.graphType.layout.activeItem.setWidth(100);
					this.graphType.layout.activeItem.setHeight(100);
				}catch(e){
				//seems graph panel is not ready
				return;
				}

			}
			var dirty=this.code!=code;
			this.setCode(code);
			if(!dirty){
				dirty=this.dataChanged();
			}
			var storeNeedsUpdate=dirty;
			
			if(force){
				dirty=true;
			}
			if(dueToPriceTrigger){
				dirty=true;
			}
			
			
			if(dirty){
				if (App.content.isReallyVisible(this.reading)){
					if(this.type=="i"){
						if (1==2 && (Ext.isSafari || Ext.isGecko)){
							this.endUpdate();
						}
						this.graphType.layout.setActiveItem(0);

						this.drawIntraday.defer(1, this);
						//this.drawIntraday();
					}else{
						this.graphType.layout.setActiveItem(1);
						if(storeNeedsUpdate){
							this.historicalStore.addListener("load",function(a,b,c){
								this.isLoading=false;
								a.period=this.type;
								//alert("loaded store!")
								if (1==2 && (Ext.isSafari || Ext.isGecko)){
									this.endUpdate();
								}
								this.drawPeriod.defer(1, this,[dueToPriceTrigger]);
							},this,{single:true})
							//this.isLoading=true;
							this.historicalStore.load();
						}else{
							if (1==2 && (Ext.isSafari || Ext.isGecko)){
								this.endUpdate();
							}
							this.drawPeriod.defer(1, this);
						}
						//alert("other graph period")
					}
					//code to gen graph here!
					//alert("graph updating content code:"+code+" records:"+this.store.totalLength)
				}
			}else{
				if(this.type!="i"){
					//alert("no update")
				}
			}
		
		},
		drawPeriod:function(dueToPriceTrigger){	
			if(typeof dueToPriceTrigger=="undefined"){dueToPriceTrigger=false;}
			var minValue=999999999 ;
			var maxValue=0.0;
			
			var showName=0;
			var labelEvery = 5; //total number of x axis labels
				
			/*****************************@george************************************************/
			//define variables 0.0 else truncated
			var minValueCode=1000000.0;
			var maxValueCode=0.0;
			var maxValueVolume=0.0;
			var rangeCode=0.0;
			var scale=0.0;
			var codeClose=0.0;
			var moveUp = 0.0;
			var scaleVolumeChart = new Array();
			var scaleCodeChart = new Array();
			/*****************************@george************************************************/			
			
			//DNF:flotr
			var aChartValues=new Array();
			var aChartValues2=new Array();			
			var aChartTicks=new Array();
			
			//append todays price to the historical store
			
			var oStore=App.stores.prices[this.market];
			if(oStore.version && oStore.version==2){
				var price=oStore.allStore.getById(this.code);
			}else{
				var price=oStore.proxy.tempdata.get(this.code);
			}

			try{
				if (typeof(price!="undefined")){
					var recordT=new this.rec;
					var record=recordT.copy();
					record.set('id',99999999999999);
					record.set('code',this.code);
					record.set('close',price.data.close.toString());
					record.set('date',price.data.date);
					record.set('pvolume',price.data.pvolume);
				}
			}catch(e){}

			//check if record for today exists
			try{
				var len=this.historicalStore.data.length
				var existingRecord=this.historicalStore.data.items[len-1];
				if(typeof(existingRecord)=="undefined" || existingRecord.data.date!=price.data.date){
					this.historicalStore.data.add(record);
					this.historicalStore.commitChanges();
				}else{
					//replace record
					if(existingRecord.data.close==price.data.close && dueToPriceTrigger){
						this.endUpdate(this.historicalStore.data.length);
						return;
					}
					existingRecord.data.close=price.data.close;
					existingRecord.data.pvolume=price.data.pvolume;
					this.historicalStore.commitChanges();
				}										
			}catch(e){}

			var trnCount=this.historicalStore.data.length;

			if (trnCount<=1){
				//DNF: Nothing to graph must do something here					
				this.endUpdate(0)
				pGraphHasData=false;
				return false;
			}

			var n;
			var row;				
			//var labelInterval=Math.ceil(trnCount/labelEvery);
			var labelInterval=Math.floor(trnCount/labelEvery);
			if(labelInterval==0){
				labelInterval=1;
			}
			//alert(labelInterval)

			for (n=0;n<(trnCount);n++){				
				row=this.historicalStore.data.items[n].data;
				if (row['close']>0){
					if (n%labelInterval==0){showName=1} else {showName=0}
																	
					var dt=row['date'].substring(2,10) 
					var cl=dt.substring(6,8)+"/" +dt.substring(3,5)
					var dtLong=dt.substring(6,8)+"/" +dt.substring(3,5)+"/"+dt.substring(0,2)

					aChartValues[aChartValues.length]=[aChartValues.length,eval(row['close']),dtLong,eval(row['pvolume'])];
					aChartValues2[aChartValues2.length]=[aChartValues2.length,eval(row['pvolume'])];

					/****************************@george Min/Max Code Max Volume**************************/					
					scaleCodeChart[scaleCodeChart.length]=[scaleCodeChart.length,eval(row['close']),dtLong,eval(row['pvolume'])];
					scaleVolumeChart[scaleVolumeChart.length]=[scaleVolumeChart.length,eval(row['pvolume'])];					
					
					codeClose=eval(row['close']);
					if(  codeClose > maxValueCode ){
						maxValueCode = codeClose; 
					}
					
					if( codeClose < minValueCode ){
						minValueCode = codeClose; 
					}
					
					if( eval(row['pvolume']) > maxValueVolume ){
						maxValueVolume = eval(row['pvolume']);
					}
					
					/****************************************************************************/					
					if (showName==1){
						aChartTicks[aChartTicks.length]	=[aChartValues.length-1,cl];
					}
					else {
						//chartLabels = chartLabels + " ";
						//aChartTicks[aChartTicks.length]	=[aChartTicks.length,null];
					}						
				}
			}
			
			//if there is only a single value			
			if ( minValueCode== maxValueCode){								
				this.endUpdate(0);
				pGraphHasData=false;
				return false;
			}			
			
//			minValue=Math.floor(minValueCode*10)/10;
//			maxValue=Math.ceil(maxValueCode*10)/10;
//			minValue=minValue.toString()			
//			alert("minValue:"+minValue+" minValueCode:"+minValueCode+ " maxValue:"+maxValue+" maxValueCode:"+maxValueCode);



			/***********************************@george SCALE*********************************************************/
		    rangeCode = maxValueCode - minValueCode;
		    scale = (rangeCode/3)/maxValueVolume;
		    
		    for(i = 0; i < aChartValues2.length; i++){
		    	scaleVolumeChart[i][1]=(scale*scaleVolumeChart[i][1])+minValueCode;
		    }
		    								 
			var moveUp=(rangeCode/3);
			moveUp = moveUp+(moveUp*0.25); 
			for(i = 0; i < aChartValues.length; i++){
				scaleCodeChart[i][1] = scaleCodeChart[i][1] + moveUp;
			}
																		
			var yChartTicks = new Array();
			yChart1=(((maxValueVolume*scale)/2)+minValueCode);
			yChart2=(maxValueVolume*scale)+minValueCode;
			yChartTicks[yChartTicks.length]=[yChart1,App.oRenderers.money(maxValueVolume/2).toString()];
			yChartTicks[yChartTicks.length]=[yChart2,App.oRenderers.money(maxValueVolume).toString()];

			var interval=0.0;
			var count=5;
			interval = (maxValueCode-minValueCode)/count;
			var yChart=0.0;
			var decimalPlaces = 2;
						
			if(interval<= 0.01)
				decimalPlaces = 3;
			else if(interval<= 0.001)			
				decimalPlaces = 4;
																				
			for(i=0; i < count+1; i++){
					yChart = minValueCode+moveUp+(interval*i);
					yChartTicks[yChartTicks.length]=[yChart, (minValueCode+(interval*i)).toFixed(decimalPlaces).toString()];					
			}											
			
			/************************************************************************************************/
		    
			/***********************************@george Ofset on Top***********************************/			
			var offset = 0.0;
			//var rangeCode = aChartValues[0][1] - aChartValues[aChartValues.length-1][1];			
			offset = rangeCode * 0.1;		
			/************************************************************************************************/		    
		    			 
			oJ=this.getFlotrObject("p");
						    
		    var f = Flotr.draw($(oJ.id), [ {data:scaleCodeChart,lines:{show:true}}, {data:scaleVolumeChart,bars:{show:true}}],{
		    	mouse:{
		    		track:true,
		    		trackFormatter: function(obj){
		    				var id=eval(obj.x); 			    				
		    				return aChartValues[id][2]+': &euro;'+aChartValues[id][1].toFixed(3)+' Vol:&euro;'+App.oRenderers.money(aChartValues[id][3]);			    						
		    			 },
				lineColor: 'purple',
				margin: 0,
				sensibility: 1, 
				trackDecimals: 3			    		
		    	},
		    	xaxis:{
		    		ticks:aChartTicks
		    	}
		    	,yaxis:{
		    		tickDecimals:decimalPlaces,
		    		ticks:yChartTicks,
		    		min:minValueCode, //-offset,
		    		max:maxValueCode+(moveUp)+offset
		    	},
		    	shadowSize: 4 
		    });
			 
			pGraphHasData=true;

			this.endUpdate(trnCount)
			return;
		},
		drawIntraday:function(){	
			var minVal=1000000;
			var maxVal=0.0;

			var chartValues=0;			
			var labelEvery = 7; //total number of x axis labels: The Market is open 7 hours

			//DNF:flotr
			var aChartValues=new Array();						
			var aChartTicks2 = new Array();

			var eRow=0;
			var n;
			var row;
			
			//var price=App.stores.prices[this.market].proxy.tempdata.get(this.code);
			var oStore=App.stores.prices[this.market];
			if(oStore.version && oStore.version==2){
				var price=oStore.allStore.getById(this.code);
			}else{
				var price=oStore.proxy.tempdata.get(this.code);
			}


			var nYclose=0
			try{
			if (typeof(price!="undefined")){
				var nYclose=price.data.yltrans; ///find this!
				//alert(nYclose)
			}
			}catch(e){}
			var trnCount=this.store.totalLength;
			if (trnCount<=1){
				//DNF: Nothing to graph must do something here	
				this.endUpdate( 0/*trnCount*/)
				pGraphHasData=false;
				return false;
			}

			var prevRow="";					
			for (n=trnCount-1;n>=0;n--){
				row=this.store.proxy.tempdata.items[n].data;
				var isNewData=true;
				if(prevRow!=""){
					if(prevRow['price']==row['price'] && prevRow['time']==row['time']){
						var isNewData=false;						
					}						
				}				
				prevRow=row;
				if (row['price']>0 && isNewData){
					eRow=eval(row['price']);										
					aChartValues[aChartValues.length]=[aChartValues.length,eval(row['price']),row['time']];					
				}			
			}
									
			var labelInterval=Math.ceil(aChartValues.length/labelEvery);
			var i=0;
			for( chartValues=0; chartValues<aChartValues.length; chartValues++){
				
				if(minVal>aChartValues[chartValues][1])
					minVal=aChartValues[chartValues][1];
				
				if(maxVal<aChartValues[chartValues][1])
					maxVal=aChartValues[chartValues][1];
				
				if(chartValues%labelInterval==0){					
					aChartTicks2[aChartTicks2.length]=[/*i*/chartValues, aChartValues[chartValues][2]];
					i++;
				}				
			}

			var yChartValues = new Array();
			//yChartValues = [ [aChartValues[0][0], nYclose], [aChartValues[Math.floor((aChartValues.length-1)*0.25)][0], nYclose], [aChartValues[Math.floor((aChartValues.length-1)*0.5)][0], nYclose], [aChartValues[Math.floor((aChartValues.length-1)*0.75)][0], nYclose], [aChartValues[aChartValues.length-1][0], nYclose]];				
			yChartValues = [ [aChartValues[0][0], nYclose], [aChartValues[aChartValues.length-1][0], nYclose]];
			
			
			/***********************************@george Ofset on Top/Bottom***********************************/
			if( nYclose < minVal ){
				minVal=nYclose;
			}								
			if( nYclose > maxVal ){
				maxVal=nYclose;
			}			
			
			var offset = 0.0;
			//var rangeCode = aChartValues[0][1] - aChartValues[aChartValues.length-1][1];
			var rangeCode = maxVal-minVal;
			offset = rangeCode * 0.05;		
			/************************************************************************************************/													

			/** @george **/			
			var yTicks=10;
			/* 
			 * if the range is between 0.01 and 0.09 then yTicks is reduce to six instead of ten
			 * This is so that yAxis labels come with only 3 decimal places else it comes with 4 decimal places
			*/
			//if(rangeCode<=0.09)
			//	yTicks=6;
																	
 			oJ=this.getFlotrObject("i");
			this.flotr = new Flotr.draw($(oJ.id), [ {data:aChartValues,lines:{show:true}}, {data:yChartValues,lines:{show:true, lineWidth: 1}, color:'red', mouse:{track: false}}],{
				mouse:{
			    	track:true,
			    	trackFormatter: function(obj){
			    			var id=eval(obj.x); 
			    			//return obj.data[id][2] +': &euro;'+obj.data[id][1].toFixed(3);
			    			return aChartValues[id][2] +': &euro;'+aChartValues[id][1].toFixed(3);
			    	},
					lineColor: 'purple',
					margin: 0,
					sensibility: 1, 
					trackDecimals: 3			    		
			    	},
			    	xaxis:{
			    		ticks:aChartTicks2			    		
			    		//min:aChartTicks2[0][0],
			    		//max:aChartTicks2[aChartTicks2.length-1][0],
			    		//,max:8.35
			    		//noTicks:7
			    	},
			    	yaxis:{
			    		noTicks: yTicks,
			    		tickDecimals:3,
			    		min: minVal - offset,
			    		max: maxVal + offset
			    	},			    	
		    		shadowSize: 4 		
			    		    	
			   });

			this.endUpdate(trnCount)						
		},
		
		getFlotrObject:function(type){
			return Ext.get("graph_"+type+"_"+this.market);
		},
		getJavaObject:function(type){
			//DNF:flotr
			return this.getFlotrObject(type);
			//return eval("document.BarChart"+this.market);
			
			return eval("document.BarChart_"+type+"_"+this.market);
			return document.getElementById("BarChart_"+type+"_"+this.market)
		},
		makeJavaObject2:function(type){
			//type is either "i" or "p"
			var rValue=''
				+'<div id="graphOuter2_'+type+'_'+this.market+'">'
				+'<div id="graph_'+type+'_'+this.market+'">'
				+'<div id="loading_'+type+'_'+this.market+'" style="position:absolute;top:0px;height:200px;width:300px;background-color:blue;background:url(/nqcommon/images/ajax-loader_big.gif);">&nbsp;</div>'
				//+'<iframe id="iframe_'+type+'_'+this.market+'" src="BLOCKED SCRIPT;" style="position:absolute;top:0px;left:0px;width:200px;height:300px;"></iframe>'
				+'<applet code="com.objectplanet.chart.ChartApplet"'
				//+' CODEBASE="http://etrading.alexistablet/etrading/"'
				+' archive="http://etrading.alexistablet/etrading/chart.jar" width="270" height="200" id="BarChart_'+type+'_'+this.market+'" MAYSCRIPT>'
				+	 '<PARAM NAME="type" VALUE="application/x-java-applet;version=1.2.2">'
				+	 '<PARAM NAME="wmode" VALUE="transparent">'
				+	 '<PARAM NAME="scriptable" VALUE="true">'
				+	 '<param name="chart" value="line">'
				+	 '<param name="background" value="white">'
				+this.initJavaParams(type)
				+'</applet>';
				+'</div>';
				+'</div>';

			return rValue;
		},
		preInitJava:function(){
			//preinitialises java objects and makes sure they are loaded
			//alert("pre-initting graphs");

			dh=Ext.DomHelper;
			b=Ext.get('tmpDiv');
			dh.insertAfter(b,this.makeJavaObject("i","cse",true));
			dh.insertAfter(b,this.makeJavaObject("p","cse",true));
			dh.insertAfter(b,this.makeJavaObject("i","ase",true));
			dh.insertAfter(b,this.makeJavaObject("p","ase",true));
			//dnf: flotr
			return true;
			this.task={
				run:function(){
					//test
					var initted=true;
					for(var i=0;this.noOfApplets-1;i++){
						if(!document.applets[i].isActive()){
							initted=false;
						}
					}
					if(initted){
						//alert(document.applets.length+" charts active")
						//alert(document.applets.length);
						this.o.checkJavaInit.stop(this);

					}else{
						if(this.taskRunCount>10){
							alert("applets could not initialise")
							this.o.checkJavaInit.stop(this);
						}
					}
					
				},
				interval:1000,
				o:this,
				noOfApplets:1
			}
			//DNF:20080623
			this.checkJavaInit=new Ext.util.TaskRunner();
			this.checkJavaInit.start(this.task);
		},
		makeFlotrObject:function(type,market,preInit){
			if(typeof(market)=="undefined"){
				market=this.market;
			}
			var addClass="";
			if(typeof(preInit)!="undefined"){
				addClass="x-hide-display nq-x-hide-display";
			
			}

			//type is either "i" or "p"
//				+'<div id="loading_'+type+'_'+market+'" style="height:2px;width:2px;">&nbsp;</div>'
			var rValue=''
				+'<div class="'+addClass+'" id="graphOuter_'+type+'_'+market+'">'
				+'<div id="graph_'+type+'_'+market+'" style="margin-left:5px;width:'+this.graphWidth+'px;height:200px;">'
				+'</div>'
				+'</div>';
			return rValue;
		},
		makeJavaObject:function(type,market,preInit){
			//DNF: flotr test
			return this.makeFlotrObject(type,market,preInit);
			
			if(typeof(market)=="undefined"){
				market=this.market;
			}
			var addClass="";
			if(typeof(preInit)!="undefined"){
				addClass="x-hide-display nq-x-hide-display";
			
			}

			//type is either "i" or "p"
			var rValue=''
				+'<div class="'+addClass+'" id="graphOuter_'+type+'_'+market+'">'
				+'<div id="loading_'+type+'_'+market+'" style="position:absolute;float:left;top:0px;background-repeat:no-repeat;background-position:85px 30px;background-image:url(/nqcommon/images/ajax-loader_big.gif);height:200px;width:340px;">&nbsp;</div>'
				+'<div id="graph_'+type+'_'+market+'">'
				+'<applet code="com.objectplanet.chart.ChartApplet"'
				//+' CODEBASE="http://etrading.alexistablet/etrading/"'
				+' archive="/nqcommon/java/chart.jar" width="270" height="200" id="BarChart_'+type+'_'+market+'" MAYSCRIPT>'
				+	 '<PARAM NAME="type" VALUE="application/x-java-applet;version=1.2.2">'
				+	 '<PARAM NAME="wmode" VALUE="transparent">'
				+	 '<PARAM NAME="scriptable" VALUE="true">'
				+	 '<param name="chart" value="line">'
				+	 '<param name="background" value="white">'
				+this.initJavaParams(type)
				+'</applet>';
				+'</div>';
				+'</div>';

			return rValue;
		},
		initJavaParams:function(type){
			if (type=="i"){
				var rValue=''			
					+'<param name="chart" value="line">'
					+'<param name=background value=white>'
					+'<param name=lineWidth value=1>'
					+'<param name=sampleDecimalCount value="2">'
					+'<param name=background			value= white>'
					+'<param name=seriesCount		value= 1>'
					+'<param name=valueLabelsOn		value= true>'
					+'<param name=valueLabelStyle		value="floating">'
					+'<param name=valueLabelStyle_1		value="floating">'
					+'<param name=valueLinesOn		value= true	>'
					+'<param name=valueLabelPrefix		value= "&euro;"	>'
					+'<param name=floatingLabelFont		value= Arial bold 14>'
					+'<param name=zoomOn			value= "true"	>'
					+'<param name=autoLabelSpacingOn		value= true	>'
					+'<param name=sampleLabelStyle		value= below_and_floating>'
					+'<param name=sampleLabelsOn		value= true	>'
					//+'<param name=sampleColors		value= #000000,#FF6600,#99CC00>'
					+'<param name=sampleLabelsOn		value= true	>'
					+'<param name=sampleLabelFont		value= Arial,normal,10>'
					+'<param name=defaultGridLinesOn		value= true>'
					+'<param name=sampleHighlightOn		value= true>'
					//+'<param name=sampleHighlightImage	value= "http://etrading.alexistablet/etrading/images/spacer.gif">'
					+'<param name=singleClickURLOn		value= true	>'
					+'<param name=sampleScrollerOn		value= true	>'
					+'<param name=rangeLabelFont		value= Arial normal 10>'
					+'<param name=rangeDecimalCount		value= 2>'
					+'<param name=legendOn			value= false>'
					+'<param name=legendLabels		value= price, y close>'
					+'<param name=legendFont			value= Arial bold 11>'
					+'<param name=valueLabelFont		value= Arial normal 10>'
					+'<param name=rangeadjusteron		value="false">'
			}
			if (type=="p"){
				var rValue=''			
					+'<param name=chart value=line>'
					+'<param name=background value=white>'
					+'<param name=sampleDecimalCount value="2">'
					+'<param name=background			value= white>'
					+'<param name=lineWidth value=1>'
//					+'<param name=seriesCount		value= 1>'
					+'<param name=valueLabelsOn		value= true>'
					+'<param name=valueLabelStyle		value="floating">'
//					+'<param name=valueLabelStyle_1		value="floating">'
//					+'<param name=valueLinesOn		value= true	>'
					+'<param name=valueLabelPrefix		value= "&euro;"	>'
//					+'<param name=floatingLabelFont		value= Arial bold 14>'
					+'<param name=autoLabelSpacingOn		value= true	>'
					+'<param name=sampleLabelStyle		value= below_and_floating>'
					+'<param name=sampleLabelsOn		value= true	>'
//					+'<param name=sampleLabelFont		value= Arial,normal,10>'
//					+'<param name=defaultGridLinesOn		value= true>'
//					+'<param name=sampleHighlightOn		value= true>'
//					+'<param name=sampleHighlightImage	value= "http://etrading.alexistablet/etrading/images/spacer.gif">'
//					+'<param name=singleClickURLOn		value= true	>'
//					+'<param name=rangeLabelFont		value= Arial normal 10>'
					+'<param name=rangeDecimalCount		value= 2>'
//					+'<param name=legendOn			value= false>'
//					+'<param name=legendLabels		value= price, y close>'
//					+'<param name=legendFont			value= Arial bold 11>'
//					+'<param name=valueLabelFont		value= Arial normal 10>'
					+'<param name=rangeadjusteron		value="false">'
					+'<param name=overlay		value="bar">'
					+'<param name=overlay_seriesRange_0		value="2">'
					+'<param name=rangeOn_2		value="true">'
					+'<param name=zoomOn			value= "true"	>'
					+'<param name=sampleScrollerOn		value= true	>'


			}
			return rValue;			
		}
	}
	
	if(typeof(NQJSScriptsLoaded)=="number"){NQJSScriptsLoaded=NQJSScriptsLoaded+1;}