// JScript 文件

//生成交易表
function showTradeBox( id, objs)
{
	var obj = objs[0];
	var s = "";
	s += "<table cellpadding='0' cellspacing='0' border='0' width='100%' height='197'>";
	s += "<tr><td colspan='2' height='20' width='100%'>&nbsp;&nbsp;<img src='image/stock2/lab_tjsj.gif'/></td></tr>"
	s += "<tr><td colspan='2' class='show_trade'>统计日期&nbsp;<b>" + obj[0].toLocaleDateString() + "</b></td></tr>";
	s += "<tr><td class='show_trade'>最新价(元)</td><td class='show_trade_v'>" + formatPrice(obj[1]) + "</td></tr>";
	s += "<tr><td class='show_trade'>5日换手(%)</td><td class='show_trade_v'>" + formatPrice(obj[2]) + "%</td></tr>";
	s += "<tr><td class='show_trade'>52周最高价(元)</td><td class='show_trade_v'>" + formatPrice(obj[3]) + "</td></tr>";
	s += "<tr><td class='show_trade'>52周最低价(元)</td><td class='show_trade_v'>" + formatPrice(obj[4]) + "</td></tr>";
	s += "<tr><td class='show_trade'>最近6个月涨跌幅(%)</td><td class='show_trade_v'>" + formatPrice(obj[5]) + "%</td></tr>";
	s += "<tr><td class='show_trade'>最近12个月涨跌幅(%)</td><td class='show_trade_v'>" + formatPrice(obj[6]) + "%</td></tr>";
	s += "<tr><td class='show_trade'>最近45日平均价(元)</td><td class='show_trade_v'>" + formatPrice(obj[7]) + "</td></tr>";
	s += "<tr><td class='show_trade'>最近45日平均成交量(百万股)</td><td class='show_trade_v'>" + formatPrice(obj[8]) + "</td></tr>";
	s += "<tr><td colspan='2' height='5'></td></tr></table>";
	document.getElementById(id).innerHTML = s;	
}

//生成基础数据表
function showBaseBox(id, objs)
{
	var obj = objs[0];
	var cols = base_cols;
	
	var s = "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
	for (var i = 0; i < cols.length; i++)
	{
		if (i % 3 == 0)
			s += "<tr>";
		s += "<td width='18%' class='show_base'>" + cols[i] + "</td>";
		s += "<td width='15%' class='show_base_v'>" + getString(obj[i]) + "</td>";
		if (i % 3 == 2)
			s += "</tr>";
	}
	
	if (cols.length % 3 != 0)
		s += "<tr>";
		
	document.getElementById(id).innerHTML = s;
	return;
	
	
//	var s = "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
//	s += "<tr><td width='20%' class='show_base'>总股本(百万股):</td>";
//	s += "<td width='15%' class='show_base_v'>" + obj[0] + "</td>";
//	s += "<td width='20%' class='show_base'>每股收益(元):</td>";
//	s += "<td width='15%' class='show_base_v'>" + obj[1] + "</td>";
//	s += "<td width='17%' class='show_base'>最近股息(元):</td>";
//	s += "<td width='18%' class='show_base_v'>" + obj[2] + "</td></tr>";

//	s += "<tr><td width='20%' class='show_base'>流通股(百万股):</td>";
//	s += "<td width='15%' class='show_base_v'>" + obj[3] + "</td>";
//	s += "<td width='20%' class='show_base'>每股盈利(元):</td>";
//	s += "<td width='15%' class='show_base_v'>" + obj[4] + "</td>";
//	s += "<td width='17%' class='show_base'>年股息率(%):</td>";
//	s += "<td width='18%' class='show_base_v'>" + obj[5] + "</td></tr>";
//	
//	s += "<tr><td width='20%' class='show_base'>总市值(百万元):</td>";
//	s += "<td width='15%' class='show_base_v'>" + obj[6] + "</td>";
//	s += "<td width='20%' class='show_base'>每股现金流(元):</td>";
//	s += "<td width='15%' class='show_base_v'>" + obj[7] + "</td>";
//	s += "<td width='17%' class='show_base'>每股公积(元):</td>";
//	s += "<td width='18%' class='show_base_v'>" + formatPrice(obj[8]) + "</td></tr>";
//	
//	s += "<tr><td width='20%' class='show_base'>市盈率:</td>";
//	s += "<td width='15%' class='show_base_v'>" + obj[9] + "</td>";
//	s += "<td width='20%' class='show_base'>每股净资产(元):</td>";
//	s += "<td width='15%' class='show_base_v'>" + formatPrice(obj[10]) + "</td>";
//	s += "<td width='17%' class='show_base'>所属行业:</td>";
//	s += "<td width='18%' class='show_base_v' title='" + obj[11] + "'>" + getTitleString(obj[11],5) + "</td></tr>";
//	
//	s += "<tr><td width='20%' class='show_base'>总股本(百万股):</td>";
//	s += "<td width='15%' class='show_base_v'>" + obj[12] + "</td>";
//	s += "<td width='20%' class='show_base'>每股未分配(元):</td>";
//	s += "<td width='15%' class='show_base_v'>" + formatPrice(obj[13]) + "</td>";
//	s += "<td width='17%' class='show_base'>所属地域:</td>";
//	s += "<td width='18%' class='show_base_v'>" + obj[14] + "</td></tr>";
//	s += "</table>";
//	document.getElementById(id).innerHTML = s;
}

//生成交易表
function showCompareBox(id, objs)
{
	var obj = objs[0];
	var s = "";
	s += "<table cellpadding='0' cellspacing='0' border='0' width='100%' height='197'>";
	s += "<tr><td colspan='3' class='show_cop'>" + obj[0].toLocaleDateString() + "&nbsp;<b>" + obj[1] + "&nbsp;" + obj[2] + "</b></td></tr>";
	s += "<tr><td colspan='3' height='15'></td></tr>";
	s += "<tr><td width='60%' class='show_cop'><b>重要财务指标</b></td><td width='20%' class='show_cop_v'>" + obj[1] + "</td><td width='20%' class='show_cop_v'>行业平均</td></tr>";
	s += "<tr><td width='60%' class='show_cop'>业务收入(比去年同期)(%)</td><td width='20%' class='show_cop_v'>" + getString(obj[3])  + "</td><td width='20%' class='show_cop_v'>" + getString(obj[4]) + "</td></tr>";
	s += "<tr><td width='60%' class='show_cop'>业务利润(比去年同期)(%)</td><td width='20%' class='show_cop_v'>" + getString(obj[5])  + "</td><td width='20%' class='show_cop_v'>" + getString(obj[6]) + "</td></tr>";
	s += "<tr><td width='60%' class='show_cop'>每股盈利(比去年同期)(%)</td><td width='20%' class='show_cop_v'>" + getString(obj[7]) + "</td><td width='20%' class='show_cop_v'>" + getString(obj[8]) + "</td></tr>";
	s += "<tr><td width='60%' class='show_cop'>业务收入(三年平均增长率)(%)</td><td width='20%' class='show_cop_v'>" + getString(obj[9]) + "</td><td width='20%' class='show_cop_v'>" + getString(obj[10]) + "</td></tr>";
	s += "<tr><td width='60%' class='show_cop'>业务利润(三年平均增长率)(%)</td><td width='20%' class='show_cop_v'>" + getString(obj[11]) + "</td><td width='20%' class='show_cop_v'>" + getString(obj[12]) + "</td></tr>";
	s += "<tr><td width='60%' class='show_cop'>每股盈利(三年平均增长率)(%)</td><td width='20%' class='show_cop_v'>" + getString(obj[13]) + "</td><td width='20%' class='show_cop_v'>" + getString(obj[14]) + "</td></tr>";
	s += "<tr><td width='60%' class='show_cop'>分红(三年平均增长率)(%)</td><td width='20%' class='show_cop_v'>" + getString(obj[15]) + "</td><td width='20%' class='show_cop_v'>" + getString(obj[16]) + "</td></tr>";
	s += "<tr><td colspan='3' height='10'></td></tr></table>";
	document.getElementById(id).innerHTML = s;	
}

//生成财务数据
function ShowTables(i,id,cols,finance,DiscObj)
{
	var length = DiscObj[i*3-2] - DiscObj[i*3-3] + 1;
	var start = DiscObj[i*3-3]-1;
	var end = DiscObj[i*3-2]-1;
	var s = "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
	s += "<tr><td width='90' class='show_cop' style='font-weight:bold;'>" + DiscObj[i*3-1] + "</td>";
	for(j = 0;j < finance.length; j++)
	{
		s += "<td width='70'class='show_cop' style='text-align:right'>" + formatDateToYMD(finance[j][0])  + "</td>";
	}
	s += "</tr>";
	for(k = start; k <= end; k++)
	{
		s += "<tr>";
		s += "<td width='100' class='show_cop'>" + cols[k] + "</td>"; 
		for(l = 0; l < finance.length; l++)
		{
			s += "<td width='70'class='show_cop_v' style='text-align:right'>" + getString(finance[l][k]) + "</td>";
		}
		s += "</tr>";
	}
	s += "</table>";
	document.getElementById(id).innerHTML = s;
}

function showDocBox(id, objs)
{
	var s = "<table cellpadding='0' cellspacing='0' border='0' width='100%'  height='100%'>";
	s += "<tr><td width='100%' height='33'><table cellpadding='0' cellspacing='0' border='0' width='100%' height='33'>";
	s += "<tr><td width='8' height='33' background='image/stock2/main_top_l.jpg'></td>";
	s += "<td width='334' height='33' background='image/stock2/main_top_bg.jpg' class='show_doc'>最新报告：<a href='Report_summary.aspx?id=" + objs[0][0] + "' class='show_doc' target='_blank'>" + objs[0][1] + "</a></td>";
	s += "<td width='120' height='33' background='image/stock2/main_top_bg.jpg' class='show_doc_time'>投资评级:<font color='#990000'>&nbsp;" + objs[0][2] + "</font></td>";
	s += "<td width='130' height='33' background='image/stock2/main_top_bg.jpg' class='show_doc_time'>日期:<font color='#990000'>&nbsp;" + objs[0][3].toLocaleDateString() + "</font></td>";
	s += "<td width='8' height='33' background='image/stock2/main_top_r.jpg'></td></tr></table></td></tr>";
	s += "<tr><td colspan='5' background='image/stock2/main_bg.jpg' class='show_doc_char'>" + getTitleString(objs[0][4], 160) + "...&nbsp;[<a href='Report_summary.aspx?id=" + objs[0][0] + "' class='n_lead' target='_blank' >查看报告全文</a>]</td></tr>";
	s += "<tr><td colspan='5' height='13'  background='image/stock2/main_bot.jpg'></td></tr></table>";
	document.getElementById(id).innerHTML = s;
}

function showDocBoxHY(id, objs,compare)
{
	var s = "<table cellpadding='0' cellspacing='0' border='0' width='100%'  height='100%'>";
	s += "<tr><td width='100%' height='33'><table cellpadding='0' cellspacing='0' border='0' width='100%' height='33'>";
	s += "<tr><td width='8' height='33' background='image/stock2/main_top_l.jpg'></td>";
	s += "<td width='334' height='33' background='image/stock2/main_top_bg.jpg' class='show_doc'>最新报告：[" + compare[0][2] + "]<a href='Report_summary.aspx?id=" + objs[0][0] + "' class='show_doc' target='_blank'>" + objs[0][1] + "</a></td>";
	s += "<td width='120' height='33' background='image/stock2/main_top_bg.jpg' class='show_doc_time'>投资评级:<font color='#990000'>&nbsp;" + objs[0][2] + "</font></td>";
	s += "<td width='130' height='33' background='image/stock2/main_top_bg.jpg' class='show_doc_time'>日期:<font color='#990000'>&nbsp;" + objs[0][3].toLocaleDateString() + "</font></td>";
	s += "<td width='8' height='33' background='image/stock2/main_top_r.jpg'></td></tr></table></td></tr>";
	s += "<tr><td colspan='5' background='image/stock2/main_bg.jpg' class='show_doc_char'>" + getTitleString(objs[0][4], 160) + "...&nbsp;[<a href='Report_summary.aspx?id=" + objs[0][0] + "' class='n_lead' target='_blank' >查看报告全文</a>]</td></tr>";
	s += "<tr><td colspan='5' height='13'  background='image/stock2/main_bot.jpg'></td></tr></table>";
	document.getElementById(id).innerHTML = s;
}

function showStockBox(id,objs,gpdm,docobjs)
{
	var s = "<table cellpadding='0' cellspacing='0' border='0' width='100%'  height='100%'>";
	s += "<tr><td width='60' height='30' class='report_char'>股票名称</td><td width='110' class='s_name'>" + objs[0][1] + "</td>";
	s += "<td width='60' class='report_char'>股票代码</td><td width='90' class='s_code'>" + gpdm + "</td>";
	s += "<td width='60' class='report_char'>投资评级</td><td width='120' class='s_name'>" + docobjs[0][2] + "</td>";
	s += "<td width='60' class='report_char'>所属行业</td><td width='180' class='s_type'>" + objs[0][2] + "</td>";
	s += "<td width='70' ><a href='F10Viewer.aspx?code=" + gpdm + "'><img src='image/stock/F10.gif' border='0'/></a></td></tr></table>";
	document.getElementById(id).innerHTML = s;
}
function showStockBox2(id,objs,gpdm)
{
	var s = "<table cellpadding='0' cellspacing='0' border='0' width='100%'  height='100%'>";
	s += "<tr><td width='100%' height='30' class='report_char' style='vertical-align: middle;'>股票名称&nbsp;<span width='120' class='s_name' style='text-align:center'>" + objs[0][1] + "</span>";
	s += "&nbsp;股票代码&nbsp;<span width='90' class='s_code'>" + gpdm + "</span>";
	//s += "&nbsp;投资评级&nbsp;<span width='120' class='s_name2'>暂无</span>";
	s += "&nbsp;所属行业&nbsp;<span width='175' class='s_type'>" + objs[0][2] + "</span>";
	s += "&nbsp;<a href='F10Viewer.aspx?code=" + gpdm + "'><span style='vertical-align: middle;'><img src='image/stock/F10.gif' border='0'/></span></a></td></tr></table>";
	document.getElementById(id).innerHTML = s;
}

// 壹贰叁肆伍陆柒捌玖拾壹贰叁肆伍陆

function formatTrade(datas,type)
{
	var s = "<table cellpadding='0' cellspacing='0' border='0' width='90%'>";
	if(type == "个股")
		s += "<tr><td width='65%'class='report_char'style='height:18px'><b>股票代码</b></td>";
	else
		s += "<tr><td width='50%'class='report_char'style='height:18px'><b>行业名称</b></td>";
	s += "<td class='report_char'style='height:18px'><b>投资评级</b></td></tr>"
	for(var i = 0; i < datas.length; i++)
	{
		var obj = datas[i];
		if(i%2 == 0)	
			s += "<tr bgcolor='#f4f4f4'>";
		else
			s += "<tr>";
		if(type == "个股")	
		{
			s += "<td width='68%'class='report_char'style='height:18px'><a href='StockFull_index.aspx?gpdm=" + obj[3] + "' class='s_tablehead' target='_blank' title='点击进入" + obj[1] + "个股完全档案'>" + obj[1] + "</a></td>";
			s += "<td width='32%'class='report_char'style='height:18px'><a href='Report_summary.aspx?id=" + obj[0] + "' class='s_tablehead2' target='_blank' title='点击进入" + obj[1] + "研究报告'>" + obj[2] + "</a></td>";
		}
		else
		{
			s += "<td width='68%'class='report_char'style='height:18px'>" + obj[0] + "</td>";
			s += "<td width='32%'class='report_char'style='height:18px'>" + obj[1] + "</td>";
		}
		s += "</tr>";
	}
	s += "</table>";
	return s;
}