function getFlashDataOfSSHQ (sshq)
{
	return "{'SJ':"+sshq.SJ+",'ZQDM':'"+sshq.ZQDM+"','ZRSP':"+sshq.ZRSP+",'JRKP':"+sshq.JRKP+",'ZJCJ':"+sshq.ZJCJ+",'CJSL':"+sshq.CJSL+",'CJJE':"+sshq.CJJE+",'CJBS':"+sshq.CJBS+",'ZGCJ':"+sshq.ZGCJ+",'ZDCJ':"+sshq.ZDCJ+",'JSD1':"+sshq.JSD1+",'JSD2':"+sshq.JSD2+",'inside':"+sshq.inside+",'outside':"+sshq.outside+",'yield':"+sshq.yield+",'BJW1':"+sshq.BJW1+",'BJW2':"+sshq.BJW2+",'BJW3':"+sshq.BJW3+",'BJW4':"+sshq.BJW4+",'BJW5':"+sshq.BJW5+",'BSL1':"+sshq.BSL1+",'BSL2':"+sshq.BSL2+",'BSL3':"+sshq.BSL3+",'BSL4':"+sshq.BSL4+",'BSL5':"+sshq.BSL5+",'SJW1':"+sshq.SJW1+",'SJW2':"+sshq.SJW2+",'SJW3':"+sshq.SJW3+",'SJW4':"+sshq.SJW4+",'SJW5':"+sshq.SJW5+",'SSL1':"+sshq.SSL1+",'SSL2':"+sshq.SSL2+",'SSL3':"+sshq.SSL3+",'SSL4':"+sshq.SSL4+",'SSL5':"+sshq.SSL5+"}";
}

function Stock ()
{
	this.day;
	this.marketDM;	//市场代码，sz,sh
	this.ZQDM;	//证券代码
	this.ZQJC;	//证券简称
	this.SCDM;	//市场代码
	this.PJJC;	//拼音简称
	
	this.max_CJSL = 10;
	this.MAX_ZDF = 0.0;
	
	this.lastSSHQ = null;
	
	this.minuteHQs = new Array ();
	
	this.dayHQs	= new Array ();
	
	this.weekHQs = new Array ();
	
	this.monthHQs = new Array ();
	
	this.setLastSSHQ = function (sshq)
	{
		this.lastSSHQ = sshq;
	}
	
	this.getLastSSHQ = function ()
	{
		return this.lastSSHQ;
	}
	
	this.getMinuteCount = function ()
	{
		return this.minuteHQs.length;
	}
	
	this.addMinuteHQ = function (minuteHQ)
	{
		this.minuteHQs[this.minuteHQs.length] = minuteHQ;
	}
	
	this.getMinuteHQs = function ()
	{
		return this.minuteHQs;
	}
	
	this.getMinuteHQ = function (index)
	{
		if (index < 0 || index >= this.minuteHQs.length)
			return null;
		else
			return this.minuteHQs[index];
	}
}

function SSHQ ()
{
	this.SJ;
	this.ZQDM;
	this.SCDM;
	this.ZRSP;
	this.JRKP;
	//分笔个数
	this.itemNum;
	//内盘
	this.inside;
	//外盘
	this.outside;
	/**市盈率1     */
	this.HQSYL1;
	/**市盈率2     */
	this.HQSYL2;
	this.ZJCJ;
	this.CJSL;
	this.CJJE;
	this.CJBS;
	this.ZGCJ;
	this.ZDCJ;
	this.JSD1;
	this.JSD2;
	
	//市盈率
	this.yield;
	
	//五档盘口买卖价格
	this.SJW1;
	this.SJW2;
	this.SJW3;
	this.SJW4;
	this.SJW5;
	this.BJW1;
	this.BJW2;
	this.BJW3;
	this.BJW4;
	this.BJW5;
	
	//五档盘口买卖数量
	this.SSL1;
	this.SSL2;
	this.SSL3;
	this.SSL4;
	this.SSL5;
	this.BSL1;
	this.BSL2;
	this.BSL3;
	this.BSL4;
	this.BSL5;
}

function MinuteHQ ()
{
	this.index;
	this.minute;
	this.ZJCJ;
	this.CJSL;
	this.CJJJ;
	this.CJJE;
	this.BSL;
	this.SSL;
	this.lead;
}

function DayHQ ()
{
	this.day;
	this.ZRSP;
	this.KP;
	this.SP;
	this.ZGCJ;
	this.ZDCJ;
	this.CJSL;
	this.CJJE;
	this.JSD1;
	this.JSD2;
	//上涨家数
	this.SZJS;
	//下跌家数
	this.XDJS;
	
	this.MA5;
	this.MA10;
	this.MA20;
	this.MA60;
	this.CJSLMA5;
	this.CJSLMA10;
	this.EMA12;
	this.EMA26;
	this.DIF;
	this.DEA;
	this.RSI6;
	this.RSI12;
	this.RSI24;
	this.K;
	this.D;
	this.J;
}

function WeekHQ ()
{
	this.week;
	this.ZRSP;
	this.KP;
	this.SP;
	this.ZGCJ;
	this.ZDCJ;
	this.CJSL;
	this.CJJE;
	this.JSD1;
	this.JSD2;
	//上涨家数
	this.SZJS;
	//下跌家数
	this.XDJS;
}

function MonthHQ ()
{
	this.month;
	this.ZRSP;
	this.KP;
	this.SP;
	this.ZGCJ;
	this.ZDCJ;
	this.CJSL;
	this.CJJE;
	this.JSD1;
	this.JSD2;
	//上涨家数
	this.SZJS;
	//下跌家数
	this.XDJS;
}

function StockGraphics () {}
StockGraphics.div = null;
StockGraphics.g = null;
StockGraphics.stock = null;
StockGraphics.minutehqChart = null;
StockGraphics.dayhqChart = null;

StockGraphics.init = function (div)
{
	this.div = div;
	this.g = new Graphics (div);
}

StockGraphics.bindStock = function (stock)
{
	StockGraphics.stock = stock;
}

StockGraphics.resize = function (w, h)
{
	if (w > 0 && h > 0)
	{
		this.g.div.style.width = w;
		this.g.div.style.height= h;
		
		this.g.getLayout().clear();
		this.dayhqChart = null;
		this.draw ();
	}
}

StockGraphics.redraw = function ()
{
	this.g.getLayout().clear();
	this.dayhqChart = null;
	this.draw ();
}

StockGraphics.draw = function ()
{
	this.minutehqChart = new MinuteHQChart (this.g);
	
	this.minutehqChart.init ();
	
	var minuteCount = this.stock.minuteHQs.length;
	
	setTimeout ("StockGraphics.minutehqChart.drawMinuteCJSL(0," + minuteCount + ")", 300);
	setTimeout ("StockGraphics.minutehqChart.drawMinuteCJJJ(0," + minuteCount + ")", 200);
	setTimeout ("StockGraphics.minutehqChart.drawMinuteZJCJ(0," + minuteCount + ")", 80);
	setTimeout ("StockGraphics.minutehqChart.drawPriceLabel()", 50);
	this.minutehqChart.drawBackground ();
}

StockGraphics.refreshSSHQ = function (lastSSHQ)
{
	var zColor = "red";
	var mColor = "#000000";
	var dColor = "green";
	var textColor = "a1a144";
	
	//小数位数，权证为3位，指数为0,其他为2位
    var domicalLen = 2;
    
    if (stock.SCDM == "qz")
    	domicalLen = 3;
    else if (stock.SCDM == "zs")
    	domicalLen = 0;
	
	var color;
	
	var total_BSL = lastSSHQ.BSL1 + lastSSHQ.BSL2 + lastSSHQ.BSL3 + lastSSHQ.BSL4 + lastSSHQ.BSL5;
	var total_SSL = lastSSHQ.SSL1 + lastSSHQ.SSL2 + lastSSHQ.SSL3 + lastSSHQ.SSL4 + lastSSHQ.SSL5;
	
	if (total_BSL + total_SSL > 0)
	{
		if (total_BSL > total_SSL)
		{
			document.getElementById ("WC").innerHTML = "<font color=" + zColor + ">" + (total_BSL - total_SSL) + "</font>";
			document.getElementById ("WB").innerHTML = "<font color=" + zColor + ">" + parseFloat (100.0*(total_BSL - total_SSL)/(total_BSL+total_SSL)).toFixed(2) + "%</font>";
		}
		else if (total_BSL == total_SSL)
		{
			document.getElementById ("WC").innerHTML = "<font color=" + mColor + ">0</font>";
			document.getElementById ("WB").innerHTML = "<font color=" + mColor + ">0.00%</font>";
		}
		else
		{
			document.getElementById ("WC").innerHTML = "<font color=" + dColor + ">" + (total_BSL - total_SSL) + "</font>";
			document.getElementById ("WB").innerHTML = "<font color=" + dColor + ">" + parseFloat (100.0*(total_BSL - total_SSL)/(total_BSL+total_SSL)).toFixed(2) + "%</font>";
		}
	}
	
	if (lastSSHQ.BSL5 > 0)
	{
		if (lastSSHQ.BJW5 > lastSSHQ.ZRSP)
			color = zColor;
		else if (lastSSHQ.BJW5 == lastSSHQ.ZRSP)
			color = mColor;
		else
			color = dColor;
		
		document.getElementById ("BJW5").innerHTML = "<font color=" + color + ">" + lastSSHQ.BJW5.toFixed(domicalLen) + "</font>";
		document.getElementById ("BSL5").innerHTML = "<font color=" + textColor + ">" + lastSSHQ.BSL5 + "</font>";
	}
	else
	{
		document.getElementById ("BJW5").innerHTML = "";
		document.getElementById ("BSL5").innerHTML = "";
	}
	
	if (lastSSHQ.BSL4 > 0)
	{
		if (lastSSHQ.BJW4 > lastSSHQ.ZRSP)
			color = zColor;
		else if (lastSSHQ.BJW4 == lastSSHQ.ZRSP)
			color = mColor;
		else
			color = dColor;
		
		document.getElementById ("BJW4").innerHTML = "<font color=" + color + ">" + lastSSHQ.BJW4.toFixed(domicalLen) + "</font>";
		document.getElementById ("BSL4").innerHTML = "<font color=" + textColor + ">" + lastSSHQ.BSL4 + "</font>";
	}
	else
	{
		document.getElementById ("BJW4").innerHTML = "";
		document.getElementById ("BSL4").innerHTML = "";
	}
	
	if (lastSSHQ.BSL3 > 0)
	{
		if (lastSSHQ.BJW3 > lastSSHQ.ZRSP)
			color = zColor;
		else if (lastSSHQ.BJW3 == lastSSHQ.ZRSP)
			color = mColor;
		else
			color = dColor;
		
		document.getElementById ("BJW3").innerHTML = "<font color=" + color + ">" + lastSSHQ.BJW3.toFixed(domicalLen) + "</font>";
		document.getElementById ("BSL3").innerHTML = "<font color=" + textColor + ">" + lastSSHQ.BSL3 + "</font>";
	}
	else
	{
		document.getElementById ("BJW3").innerHTML = "";
		document.getElementById ("BSL3").innerHTML = "";
	}
	
	if (lastSSHQ.BSL2 > 0)
	{
		if (lastSSHQ.BJW2 > lastSSHQ.ZRSP)
			color = zColor;
		else if (lastSSHQ.BJW2 == lastSSHQ.ZRSP)
			color = mColor;
		else
			color = dColor;
		
		document.getElementById ("BJW2").innerHTML = "<font color=" + color + ">" + lastSSHQ.BJW2.toFixed(domicalLen) + "</font>";
		document.getElementById ("BSL2").innerHTML = "<font color=" + textColor + ">" + lastSSHQ.BSL2 + "</font>";
	}
	else
	{
		document.getElementById ("BJW2").innerHTML = "";
		document.getElementById ("BSL2").innerHTML = "";
	}
	
	if (lastSSHQ.BSL1 > 0)
	{
		if (lastSSHQ.BJW1 > lastSSHQ.ZRSP)
			color = zColor;
		else if (lastSSHQ.BJW1 == lastSSHQ.ZRSP)
			color = mColor;
		else
			color = dColor;
		
		document.getElementById ("BJW1").innerHTML = "<font color=" + color + ">" + lastSSHQ.BJW1.toFixed(domicalLen) + "</font>";
		document.getElementById ("BSL1").innerHTML = "<font color=" + textColor + ">" + lastSSHQ.BSL1 + "</font>";
	}
	else
	{
		document.getElementById ("BJW1").innerHTML = "";
		document.getElementById ("BSL1").innerHTML = "";
	}
	
	if (lastSSHQ.SSL5 > 0)
	{
		if (lastSSHQ.SJW5 > lastSSHQ.ZRSP)
			color = zColor;
		else if (lastSSHQ.SJW5 == lastSSHQ.ZRSP)
			color = mColor;
		else
			color = dColor;
		
		document.getElementById ("SJW5").innerHTML = "<font color=" + color + ">" + lastSSHQ.SJW5.toFixed(domicalLen) + "</font>";
		document.getElementById ("SSL5").innerHTML = "<font color=" + textColor + ">" + lastSSHQ.SSL5 + "</font>";
	}
	else
	{
		document.getElementById ("SJW5").innerHTML = "";
		document.getElementById ("SSL5").innerHTML = "";
	}
	
	if (lastSSHQ.SSL4 > 0)
	{
		if (lastSSHQ.SJW4 > lastSSHQ.ZRSP)
			color = zColor;
		else if (lastSSHQ.SJW4 == lastSSHQ.ZRSP)
			color = mColor;
		else
			color = dColor;
		
		document.getElementById ("SJW4").innerHTML = "<font color=" + color + ">" + lastSSHQ.SJW4.toFixed(domicalLen) + "</font>";
		document.getElementById ("SSL4").innerHTML = "<font color=" + textColor + ">" + lastSSHQ.SSL4 + "</font>";
	}
	else
	{
		document.getElementById ("SJW4").innerHTML = "";
		document.getElementById ("SSL4").innerHTML = "";
	}
	
	if (lastSSHQ.SSL3 > 0)
	{
		if (lastSSHQ.SJW3 > lastSSHQ.ZRSP)
			color = zColor;
		else if (lastSSHQ.SJW3 == lastSSHQ.ZRSP)
			color = mColor;
		else
			color = dColor;
		
		document.getElementById ("SJW3").innerHTML = "<font color=" + color + ">" + lastSSHQ.SJW3.toFixed(domicalLen) + "</font>";
		document.getElementById ("SSL3").innerHTML = "<font color=" + textColor + ">" + lastSSHQ.SSL3 + "</font>";
	}
	else
	{
		document.getElementById ("SJW3").innerHTML = "";
		document.getElementById ("SSL3").innerHTML = "";
	}
	
	if (lastSSHQ.SSL2 > 0)
	{
		if (lastSSHQ.SJW2 > lastSSHQ.ZRSP)
			color = zColor;
		else if (lastSSHQ.SJW2 == lastSSHQ.ZRSP)
			color = mColor;
		else
			color = dColor;
		
		document.getElementById ("SJW2").innerHTML = "<font color=" + color + ">" + lastSSHQ.SJW2.toFixed(domicalLen) + "</font>";
		document.getElementById ("SSL2").innerHTML = "<font color=" + textColor + ">" + lastSSHQ.SSL2 + "</font>";
	}
	else
	{
		document.getElementById ("SJW2").innerHTML = "";
		document.getElementById ("SSL2").innerHTML = "";
	}
	
	if (lastSSHQ.SSL1 > 0)
	{
		if (lastSSHQ.SJW1 > lastSSHQ.ZRSP)
			color = zColor;
		else if (lastSSHQ.SJW1 == lastSSHQ.ZRSP)
			color = mColor;
		else
			color = dColor;
		
		document.getElementById ("SJW1").innerHTML = "<font color=" + color + ">" + lastSSHQ.SJW1.toFixed(domicalLen) + "</font>";
		document.getElementById ("SSL1").innerHTML = "<font color=" + textColor + ">" + lastSSHQ.SSL1 + "</font>";
	}
	else
	{
		document.getElementById ("SJW1").innerHTML = "";
		document.getElementById ("SSL1").innerHTML = "";
	}
	
	if (lastSSHQ.JSD1 > 0.0001)
		color = zColor;
	else if (lastSSHQ.JSD1 < -0.0001)
		color = dColor;
	else
		color = mColor;
	
	document.getElementById ("JSD1").innerHTML = "<font color=" + color + ">" + lastSSHQ.JSD1.toFixed(domicalLen) + "</font>";
	document.getElementById ("ZJCJ").innerHTML = "<font color=" + color + "><b>" + stock.lastSSHQ.ZJCJ.toFixed(domicalLen) + "</b></font>";
	document.getElementById ("JSD2").innerHTML = "<font color=" + color + "><b>" + stock.lastSSHQ.JSD2.toFixed(domicalLen)+ "%</b></font>";
	
	if (lastSSHQ.JRKP > lastSSHQ.ZRSP)
		color = zColor;
	else if (lastSSHQ.JRKP == lastSSHQ.ZRSP)
		color = mColor;
	else
		color = dColor;
	
	document.getElementById ("JRKP").innerHTML = "<font color=" + color + ">" + lastSSHQ.JRKP.toFixed(domicalLen) + "</font>";
	
	if (lastSSHQ.ZGCJ > lastSSHQ.ZRSP)
		color = zColor;
	else if (lastSSHQ.ZGCJ == lastSSHQ.ZRSP)
		color = mColor;
	else
		color = dColor;
	
	document.getElementById ("ZGCJ").innerHTML = "<font color=" + color + ">" + lastSSHQ.ZGCJ.toFixed(domicalLen) + "</font>";
	
	if (lastSSHQ.ZDCJ > lastSSHQ.ZRSP)
		color = zColor;
	else if (lastSSHQ.ZDCJ == lastSSHQ.ZRSP)
		color = mColor;
	else
		color = dColor;
	
	document.getElementById ("ZDCJ").innerHTML = "<font color=" + color + ">" + lastSSHQ.ZDCJ.toFixed(domicalLen) + "</font>";
	
	document.getElementById ("ZL").innerHTML = "<font color=" + textColor + ">" + (lastSSHQ.outside+lastSSHQ.inside) + "</font>";
	document.getElementById ("LB").innerHTML = "<font color=" + textColor + ">" + parseFloat(lastSSHQ.inside/lastSSHQ.outside).toFixed(2) + "</font>";
	document.getElementById ("outside").innerHTML = "<font color=" + zColor + ">" + lastSSHQ.outside + "</font>";
	document.getElementById ("inside").innerHTML = "<font color=" + dColor + ">" + lastSSHQ.inside + "</font>";
	
	document.getElementById ("ZRSP").innerHTML = "<font color=" + textColor + ">" + lastSSHQ.ZRSP.toFixed(domicalLen) + "</font>";
	document.getElementById ("yield").innerHTML = "<font color=" + textColor + ">" + lastSSHQ.yield.toFixed(domicalLen) + "</font>";
}

function MinuteHQChart (g)
{
	this.ZColor = "#FF0000";	//涨颜色
	this.DColor = "#007CC8";	//跌颜色
	this.ZJCJColor= "#007CC8";	//成交价实时线颜色
	this.CJJJColor= "#A1A122";	//成交均价线颜色
	this.MA5Color = "#FFFF00";	//5日均线颜色
	this.MA10Color= "#FFFF00";	//10日均线颜色
	this.MA20Color= "#FFFF00";	//20日均线颜色
	this.CJSLColor= "#007CC8";	//成交数量线颜色
	this.borderColor = "#999999";	//背景边框线颜色
	this.backgroundColor = "#ffffff";	//背景颜色
	this.timeFontColor= "#007CC8";	//时间坐标标签字体颜色
	this.markFontColor = "#FF0000";	//标注字体颜色
	
	this.g = g;
	
	this.ZJCJLine = null;
	this.CJJJLine = null;
	this.sscjLine = null;
	
	this.g.div.style.backgroundColor = this.backgroundColor;
	this.w = parseInt(this.g.div.style.width);
	this.h = parseInt(this.g.div.style.height);
	this.priceWidth		= 48;
	this.percentWidth = 59;
	this.mainWidth		= this.w - this.priceWidth - this.percentWidth;
	
	this.titleHeight	= 8;
	this.tipHeight		= 20;
	
	this.wGrid = 8;
	this.hGrid = 8;
	this.CJSLHGrid = 4;
	
	this.mainHeight		= parseInt((this.h - this.titleHeight - this.tipHeight)*2/3);
	this.CJSLHeight		= this.h - this.titleHeight - this.tipHeight - this.mainHeight;
	
	this.style = "sina";
	
	var ME = this;
	
	this.drawBackground = function ()
	{
		var l = this.priceWidth;
		var t = this.titleHeight;
		var w = this.mainWidth;
		var h = this.mainHeight;
		var rect = this.g.drawRect (new Point (l,t), w, h);
		rect.transparent();
		rect.setStrokeColor (this.borderColor);
		
		for (var i = 1; i <= this.wGrid-1; i++)
		{
			var line = this.g.drawLine (new Point(l+parseInt(i*w/this.wGrid), t), new Point(l+parseInt(i*w/this.wGrid), t+h));
			line.setStrokeColor (this.borderColor);
			line.setDashStyle ("dot");
		}
		
		for (var i = 1; i <= this.hGrid-1; i++)
		{
			var line = this.g.drawLine (new Point(l, t+parseInt(i*h/this.hGrid)), new Point(l+w,t+parseInt(i*h/this.hGrid)));
			line.setStrokeColor (this.borderColor);
			line.setDashStyle ("dot");
		}
		
		if (this.titleHeight > 15)
		{
			this.g.drawTextbox (new Point (l,1), StockGraphics.stock.ZQJC + "&nbsp;" + StockGraphics.stock.ZQDM + "&nbsp;&nbsp;&nbsp;&nbsp;<a href='dayHQ.jsp?stockID=" + StockGraphics.stock.marketDM + StockGraphics.stock.ZQDM + "'>日线</a>" + "&nbsp;&nbsp;&nbsp;&nbsp;<a href='weekHQ.jsp?stockID=" + StockGraphics.stock.marketDM + StockGraphics.stock.ZQDM + "'>周线</a>" + "&nbsp;&nbsp;&nbsp;&nbsp;<a href='monthHQ.jsp?stockID=" + StockGraphics.stock.marketDM + StockGraphics.stock.ZQDM + "'>月线</a>");
		}
		
		var zjcjText = this.g.drawTextbox (new Point (this.priceWidth+5, this.titleHeight+2), "实时走势");
		zjcjText.setFontColor (this.ZJCJColor);
		
		var cjjjText = this.g.drawTextbox (new Point (this.priceWidth+60, this.titleHeight+2), "均线");
		cjjjText.setFontColor (this.CJJJColor);
		
		t = t+h;
		h = this.CJSLHeight;
		
		rect = this.g.drawRect (new Point (l,t), w, h);
		rect.transparent();
		rect.setStrokeColor (this.borderColor);
		
		for (var i = 1; i <= this.wGrid-1; i++)
		{
			var line = this.g.drawLine (new Point(l+parseInt(i*w/this.wGrid), t), new Point(l+parseInt(i*w/this.wGrid), t+h));
			line.setStrokeColor (this.borderColor);
			line.setDashStyle ("dot");
		}
		
		for (var i = 1; i <= this.CJSLHGrid-1; i++)
		{
			var line = this.g.drawLine (new Point(l, t+parseInt(i*h/this.CJSLHGrid)), new Point(l+w,t+parseInt(i*h/this.CJSLHGrid)));
			line.setStrokeColor (this.borderColor);
			line.setDashStyle ("dot");
		}
		
		var timeCoord = Array("09:30","10:00","10:30","11:00","11:30","13:30","14:00","14:30","15:00");
		
		for (var i = 0; i <= this.wGrid; i++)
		{
			var text = this.g.drawTextbox (new Point (l+parseInt(i*w/this.wGrid)-15,t+h+5), timeCoord[i]);
			text.setFontColor (this.timeFontColor);
		}
	}
	
	this.drawPriceLabel = function ()
	{
		this.ZRSP = StockGraphics.stock.lastSSHQ.ZRSP;
		
		//小数位数，权证为3位，指数为0,其他为2位
      	var domicalLen = 2;
      	
      	if (stock.SCDM == "qz")
      		domicalLen = 3;
      	else if (stock.SCDM == "zs")
      		domicalLen = 0;
		
		var ZDF = 0.00;
		var dZDF = StockGraphics.stock.MAX_ZDF*100.0*2.0/this.hGrid;
		
		var price = this.ZRSP;
		var dp = price*StockGraphics.stock.MAX_ZDF*2.0/this.hGrid;
		
		var l = this.priceWidth;
		var t = this.titleHeight;
		var w = this.mainWidth;
		var h = this.mainHeight;
		
		if (this.priceWidth > 0)
		{
			var text = this.g.drawTextbox (new Point (0,t+h/2-6), price.toFixed(domicalLen));
			text.moveBy (l-text.getWidth()+1, 0);
		}
		
		if (this.percentWidth > 0)
			this.g.drawTextbox (new Point (l+w+2,t+h/2-6), "&nbsp;0.00%");
		
		for (var i = 1; i <= this.hGrid/2; i++)
		{
			if (this.priceWidth > 0)
			{
				var text = this.g.drawTextbox (new Point (0,t+h/2-6-parseInt(i*h/this.hGrid)), (price+i*dp).toFixed(domicalLen));
				text.moveBy (l-text.getWidth()+1, 0);
				text.setFontColor (this.ZColor);
			}
			
			if (this.percentWidth > 0)
			{
				var text = this.g.drawTextbox (new Point (l+w+2,t+h/2-6-parseInt(i*h/this.hGrid)), "+"+(ZDF+i*dZDF).toFixed(2)+"%");
				text.setFontColor (this.ZColor);
			}
		}
		
		for (var i = 1; i <= this.hGrid/2; i++)
		{
			if (this.priceWidth > 0)
			{
				var text = this.g.drawTextbox (new Point (0,t+h/2-6+parseInt(i*h/this.hGrid)), (price-i*dp).toFixed(domicalLen));
				text.moveBy (l-text.getWidth()+1, 0);
				text.setFontColor (this.DColor);
			}
			
			if (this.percentWidth > 0)
			{
				var text = this.g.drawTextbox (new Point (l+w+2,t+h/2-6+parseInt(i*h/this.hGrid)), (ZDF-i*dZDF).toFixed(2)+"%");
				text.setFontColor (this.DColor);
			}
		}
		
		for (var i = 1; i < this.hGrid/2; i++)
		{
			var dh = parseInt(this.CJSLHeight/(this.hGrid/2));
			var cjsl = parseInt(StockGraphics.stock.max_CJSL*(this.hGrid/2-i)/(this.hGrid/2));
			var text = this.g.drawTextbox (new Point(l+w+2, this.titleHeight+this.mainHeight+i*dh-6), cjsl);
			text.setFontColor (this.CJSLColor);
		}
	}
	
	this.calculatePosition = function (index, price)
	{
		var JSD = (price - StockGraphics.stock.lastSSHQ.ZRSP)/StockGraphics.stock.lastSSHQ.ZRSP;
		var x = this.priceWidth + parseInt(this.mainWidth*index/240);
		var y = this.titleHeight + this.mainHeight/2 - parseInt(JSD*this.mainHeight/2/StockGraphics.stock.MAX_ZDF);
		
		return new Point (x, y);
	}
	
	this.calculateCJSLPosition = function (index, cjsl)
	{
		var x = this.priceWidth + parseInt(this.mainWidth*(index+1)/240);
		var y = this.titleHeight + this.mainHeight + parseInt(this.CJSLHeight*(1.0 - parseFloat(cjsl/StockGraphics.stock.max_CJSL)));
		
		return new Point (x, y);
	}
	
	this.init = function ()
	{
		for (var i = 0; i < StockGraphics.stock.minuteHQs.length; i++)
		{
			StockGraphics.stock.max_CJSL = Math.max (StockGraphics.stock.max_CJSL, StockGraphics.stock.minuteHQs[i].CJSL);
		}
		
		StockGraphics.stock.MAX_ZDF = Math.max (0.025, Math.abs ((StockGraphics.stock.lastSSHQ.ZGCJ-StockGraphics.stock.lastSSHQ.ZRSP)/StockGraphics.stock.lastSSHQ.ZRSP), Math.abs ((StockGraphics.stock.lastSSHQ.ZDCJ-StockGraphics.stock.lastSSHQ.ZRSP)/StockGraphics.stock.lastSSHQ.ZRSP));
	}
	
	this.drawSSCJLine = function ()
	{
		var lastMinuteHQ = StockGraphics.stock.minuteHQs[StockGraphics.stock.minuteHQs.length-1];
		var p1 = this.calculatePosition (lastMinuteHQ.index, lastMinuteHQ.ZJCJ);
		var p2 = this.calculatePosition (lastMinuteHQ.index+1, StockGraphics.stock.lastSSHQ.ZJCJ);
		
		if (StockGraphics.minutehqChart.sscjLine)
		{
			this.g.getLayout().removeNode (StockGraphics.minutehqChart.sscjLine);
			StockGraphics.minutehqChart.sscjLine = null;
		}
		
		StockGraphics.minutehqChart.sscjLine = this.g.drawLine (p1, p2);
		StockGraphics.minutehqChart.sscjLine.setStrokeColor (this.ZJCJColor);
	}
	
	this.drawMinuteZJCJ = function (startIndex, endIndex)
	{
		if (this.ZJCJLine == null)
		{
			var zjcj = StockGraphics.stock.minuteHQs[startIndex].ZJCJ;
			
			if (zjcj < 0.0001)
			{
				StockGraphics.stock.minuteHQs[startIndex].ZJCJ = StockGraphics.stock.lastSSHQ.ZRSP;
				zjcj = StockGraphics.stock.lastSSHQ.ZRSP;
			}
			
			var p = this.calculatePosition (StockGraphics.stock.minuteHQs[startIndex].index, zjcj);
			this.ZJCJLine = this.g.drawTrace ("m " + p.toString() + " l " + p.toString() + " e");
			this.ZJCJLine.setStrokeColor (this.ZJCJColor);
			
			startIndex+=1;
		}
		
		for (var i = startIndex; i < endIndex; i++)
		{
			var zjcj = StockGraphics.stock.minuteHQs[i].ZJCJ;
			
			if (zjcj < 0.0001 && i > 0)
			{
				StockGraphics.stock.minuteHQs[i].ZJCJ = StockGraphics.stock.minuteHQs[i-1].ZJCJ;
				zjcj = StockGraphics.stock.minuteHQs[i].ZJCJ;
			}
			
			var p = this.calculatePosition (StockGraphics.stock.minuteHQs[i].index, zjcj);
			var obj = this.ZJCJLine.getHtmlElement();
			obj.path= (obj.path+"").replace('e','') + p.toString() + " e";
		}
	}
	
	this.drawMinuteCJJJ = function (startIndex, endIndex)
	{
		if (this.CJJJLine == null)
		{
			var cjjj = StockGraphics.stock.minuteHQs[startIndex].CJJJ;
			
			if (cjjj < 0.0001)
			{
				StockGraphics.stock.minuteHQs[startIndex].CJJJ = StockGraphics.stock.lastSSHQ.ZRSP;
				cjjj = StockGraphics.stock.lastSSHQ.ZRSP;
			}
			
			var p2 = this.calculatePosition (StockGraphics.stock.minuteHQs[startIndex].index, cjjj);
			this.CJJJLine = this.g.drawTrace ("m " + p2.toString() + " l " + p2.toString() + " e");
			this.CJJJLine.setStrokeColor (this.CJJJColor);
			
			startIndex+=1;
		}
		
		for (var i = startIndex; i < endIndex; i++)
		{
			var cjjj = StockGraphics.stock.minuteHQs[i].CJJJ;
			
			if (cjjj < 0.0001 && i > 0)
			{
				StockGraphics.stock.minuteHQs[i].CJJJ = StockGraphics.stock.minuteHQs[i-1].CJJJ;
				cjjj = StockGraphics.stock.minuteHQs[i].CJJJ;
			}
			
			var p2 = this.calculatePosition (StockGraphics.stock.minuteHQs[i].index, cjjj);
			var obj2 = this.CJJJLine.getHtmlElement();
			obj2.path= (obj2.path+"").replace('e','') + p2.toString() + " e";
		}
	}
	
	this.drawMinuteCJSL = function (startIndex, endIndex)
	{
		for (var i = startIndex; i < endIndex; i++)
		{
			if (StockGraphics.stock.minuteHQs[i].CJSL <= 0)
				continue;
			
			var p3 = this.calculateCJSLPosition (StockGraphics.stock.minuteHQs[i].index, StockGraphics.stock.minuteHQs[i].CJSL);
			
			var cjslLine = this.g.drawLine (p3, new Point(p3.x, this.titleHeight + this.mainHeight + this.CJSLHeight));
			
			cjslLine.setStrokeColor (this.CJSLColor);
		}
	}
}