var User_Favoriteuid=MyFund[0];
var User_FavoriteFund=MyFund[1];
var User_FavoriteFundname=MyFund[2];
var PHP_SITE='http://'+location.host;
try {
    document.execCommand("BackgroundImageCache", false, true)
} 
catch (e) {
}
function SortData(obj, isAdvance,MyFundstr){
   ClearTitle();
    var sortMode = "0";
   if (obj.getAttribute("order") != "") {
        sortMode = obj.getAttribute("order");
    }
    BindData(isAdvance, obj.title, sortMode);
    var title = obj.title.replace("当天", "");
    if (sortMode != "1") {
        obj.setAttribute("order", "1");
        obj.innerHTML = title + "<img src='/images/shanxia2_1.gif' align='absmiddle' border='0' />";
    }
    else {
        obj.setAttribute("order", "0");
        obj.innerHTML = title + "<img src='/images/shanxia2_2.gif' align='absmiddle' border='0' />";
    }
  window.ChangeMode();
    var myfundstr=MyFundstr;
  if(myfundstr != "" && myfundstr != undefined){
   window.hightMyFund(myfundstr);
  }
}

function ClearTitle(){
    var tableHeader = document.getElementById("tableHeader");
    var links = tableHeader.getElementsByTagName("A");
    for (var i = 0; i < links.length; i++) {
        links[i].innerHTML = links[i].title.replace("当天", "");
    }
}

function sortbyCode(x, y){
    if (x[0] < y[0]) {
        return 1;
    }
    else {
        return -1;
    }
}

function sortbyName(x, y){
    return y[1].localeCompare(x[1]);
}

function sortbyCNV(x, y){
    if (x[2] < y[2]) {
        return 1;
    }
    else {
        return -1;
    }
}

function sortbyCTNV(x, y){
    if (x[3] < y[3]) {
        return 1;
    }
    else {
        return -1;
    }
}

function sortbyPNV(x, y){
    if (x[4] < y[4]) {
        return 1;
    }
    else {
        return -1;
    }
}

function sortbyPTNV(x, y){
    if (x[5] < y[5]) {
        return 1;
    }
    else {
        return -1;
    }
}

function sortbyDisValue(x, y){
    if (x[6] < y[6]) {
        return 1;
    }
    else {
        return -1;
    }
}

function sortbyPercent(x, y){
    if (x[7] < y[7]) {
        return 1;
    }
    else {
        return -1;
    }
}
var highSign="";//高亮标志 hsz,高于大盘， lsz低于大盘 

function BindData(isAdvance, sort, sortMode){
    var netValues = eval(document.getElementById("mainContent").innerHTML);
    if (sort == "代码") {
        netValues.sort(sortbyCode);
    }
    if (sort == "名称") {
        netValues.sort(sortbyName);
    }
    if (sort == "当天单位净值") {
        netValues.sort(sortbyCNV);
    }
    if (sort == "当天累计净值") {
        netValues.sort(sortbyCTNV);
    }
    if (sort == "日增长值") {
        netValues.sort(sortbyPNV);
    }
    if (sort == "日增长率") {
        netValues.sort(sortbyPTNV);
    }
    if (sort == "估算值") {
        netValues.sort(sortbyDisValue);
    }
    if (sort == "估算增长率") {
        netValues.sort(sortbyPercent);
    }
    if (sort == "周增长") {
        netValues.sort(sortbyWeekPercentValue);
    }
    if (sort == "月增长") {
        netValues.sort(sortbyMonthPercentValue);
    }
    if (sort == "季增长") {
        netValues.sort(sortbyQuarterPercentValue);
    }
    if (sort == "半年") {
        netValues.sort(sortbyHalfPercentValue);
    }
    if (sort == "年增长") {
        netValues.sort(sortbyYearPercentValue);
    }
    
    if (sortMode == "1") {
        netValues.reverse();
    }
    var tables = [];
    var tablesTemp = [];
    
    tables.push('<table id="tblContent" cellspacing="0" bordercolordark="#ffffff" cellpadding="2" width="910" align="center" bordercolorlight="#DDDDDD" border="1">');
//	tables.push('<tr style="height: 1px"><th style="width: 40px;"></th><th style="width: 80px;"></th><th style="width: 110px;"></th><th style="width: 76px;"></th><th style="width: 76px;"></th><th style="width: 76px;"></th><th style="width: 76px;"></th><th style="width: 76px;"></th><th style="width: 76px;"></th><th style="width: 55px;"></th><th style="width: 55px;"></th><th style="width: 100px;"></th></tr>');
    var order = 1;
    for (var i = 0; i < netValues.length; i++) {
        if ((sort == "当天单位净值" || sort == "当天累计净值") && netValues[i][2] == 0) {
            PushTR(i, "--", netValues, tablesTemp, isAdvance);
        }
        else 
            if ((sort == "日增长值" || sort == "日增长率") && (netValues[i][2] == 0)) {
                PushTR(i, "--", netValues, tablesTemp, isAdvance);
            }
            else 
                if ((sort == "估算值" || sort == "估算增长率") && netValues[i][4] == 0) {
                    PushTR(i, "--", netValues, tablesTemp, isAdvance);
                }
                else {
                    PushTR(i, order, netValues, tables, isAdvance);
                    order++;
                }
    }
    tables.push(tablesTemp.join(''));
    tables.push('</table>');
    document.getElementById("divLock").innerHTML = tables.join('');
}
//-------------------------------add-------------------------------------------
function GetFavoriteColumn(code,fundName,isFavorite)
{
	var mf_array = User_FavoriteFund.split(';');
	var checked="";
	if(mf_array.length == 0){
			checked="";
	}else{
        for( var i=0;i<mf_array.length;i++)
        {
            if(mf_array[i] == code)
            {
                checked="checked";
            }
        }
    }  
	if(isFavorite == true)
    {
		return "<td width='40' height='22' align='center' title='取消我关注的基金'><INPUT type='checkbox' value='"+code+"' name='fav"+code+"' id='fav"+code+"' isFav='1'  onclick='SetMyFavoriteFund(this, \""+code+"\", \""+fundName+"\")' "+checked+"></td>";
		
    }
   return "<td width='40' height='22' align='center' title='添加我关注的基金'><INPUT type='checkbox' value='"+code+"' name='fav"+code+"' id='fav"+code+"' isFav='0'  onclick='SetMyFavoriteFund(this, \""+code+"\", \""+fundName+"\")' "+checked+"></td>";
}
var openwindowFlag = false;

var mCode = null;
var mFundName = null;
var mIsAdd = null;
var IsIE = (navigator.appName=="Microsoft Internet Explorer") && parseInt(navigator.appVersion) >=4;
function getElement(id) {
	return document.getElementById(id);
}

function createElement(type) {
	return document.createElement(type);
}

function hideElement(element) {
	if (element) {
		element.style.display = "none";
	}
}
var $C=function(tag)
{
   return document.createElement(tag);
}
var $N = function(s)
{
	return document.getElementsByName(s);
}

var $ = function(s)
{
	return document.getElementById(s);
}
function SetMyFavoriteFund(obj, code, fundName)
{
    if (this.IsIE && window.parent.document.readyState != "complete") 
    {        
        window.setTimeout(SetMyFavoriteFund, 1000, obj, code, fundName);
        return;
    }  
	if(!User_Favoriteuid || typeof(User_FavoriteFund) == 'undefined')
    {
        window.location.href=PHP_SITE+"/login.php";
    }else{
    
        var isAdded = false;
		 if(obj.getAttribute("isFav") != null && obj.getAttribute("isFav") == "1")
        {        
			obj.setAttribute("isFav", "0");
            obj.setAttribute("title", "添加到我关注的基金");
             isAdded = false;
        }
        else
        {
            var codess = User_FavoriteFund.split(';');
		
            if(codess.length > 79)
            {
                alert('关注的基金不能超过80只。');
                return false;
            }        
            obj.setAttribute("isFav", "1");
            obj.setAttribute("title", "取消我关注的基金");
            isAdded = true;
        }  
        if(openwindowFlag == false)
        {
			mCode = code;     
            mFundName = fundName;
            mIsAdd = isAdded;
            parent.createWindow();  
			
        } 
        else
        {
            checkWindowAll(code, fundName, isAdded);
        }
	}
}
function createWindow()
{
    parent.openwindow("Fav_fund");
    openwindowFlag = true;
	checkWindowAll(mCode, mFundName, mIsAdd);
}
function checkWindowAll(mCode, fundName, isAdded)
{
   parent.checkall(mCode, fundName, isAdded, "Fav_fund");  
    ResetMyFavoriteFund(mCode, isAdded, fundName);
}
var showOpenWindowFlag = false;
function openwindow(name)//生成层
{
   var ojbWindow = $("comparewindow");
   if(ojbWindow != null)
   {
       ojbWindow.parentNode.removeChild(ojbWindow); 
   }
   
   showOpenWindowFlag = true;
   
   var div=$C("ul");
   document.body.appendChild(div);
   div.className="openwindow";
   div.id="comparewindow";
   div.style.display = "none";   
   div.innerHTML='<div style="color:#ff0000;font-size:14px;" id="showall"><img border="0" style="margin-right:5px;cursor:pointer;float:right;"  align="absmiddle" onclick="HideWindow();" title="关闭" src="/images/close_button.gif" /><span id="productTitle">您已经选择的基金</span></div><div class="hide" id="showproduct"><ol  id="list"></ol></div><span style="text-align:center;display:block;"><a href="javascript:void(0)" onclick="SaveFunds(this,\''+name+'\')"><img src="/images/SaveButton.gif" width="53" height="22"></a><span></div>';
   setInterval("autowidth()",100);
   if(typeof(User_FavoriteFundname) != 'undefined' && typeof(User_FavoriteFund) != 'undefined')
   {
       var codes = User_FavoriteFund.split(';');
       var name1 =  User_FavoriteFundname.split(';');
       var name =  "";
       for(var i=0;i<codes.length;i++)
       {
           if(codes[i] != "")
           {
               name = name1[i];
               if(name == 'undefined')
               {
                    name = name1[i];
               }
               checkall(codes[i], name, true, "Fav_fund", true);
           }
       } 
   }
}
function autowidth()//重置层的位置
{
   var div=$("comparewindow");

   myoffset = 10;

   if(this.IsIE)
   {
     //myoffset = 15;
   }
   
   div.style.top=(parseInt(document.documentElement.scrollTop,10)+(document.documentElement.clientHeight - div.offsetHeight) - myoffset) + 'px';
   div.style.left=parseInt((document.documentElement.clientWidth - div.offsetWidth - 50), 10) + 'px';
  
   if($("comparewindow").style.display != "block")
   {
      if(showOpenWindowFlag == true)
      {
        $("comparewindow").style.display = "block";  
      }
   }
   if($("showproduct").className != "show")
   {       
       $("showproduct").className="show";
   }
}
function checkall(fundId,fundName,isChecked,name, isFirstLoad)//触发生成list
{  
   var value=fundId+","+fundName;
       
   if(isChecked)
   {
	  createlist(value,name, isFirstLoad);  
   }
   else
   {       
      var listobj=$(fundId);
      if(listobj != null)
      {
         listobj.parentNode.removeChild(listobj);    
      }
   }
}
function ResetMyFavoriteFund(code, isAdded,funname)//刷新列表
{
	var codes = User_FavoriteFund.split(';');
	var codesname = User_FavoriteFundname.split(';');
    var newcodes = [];
	 var newcodesname = [];
    if(codes.length == 0)
    {
        newcodes.push(code);
    }
    else
    {
        var tag = false;
        for(i=0;i<codes.length;i++)
        {
            if(codes[i] == code)
            {
                tag = true;
            }
            else
            {
                newcodes.push(codes[i]);
				newcodesname.push(codesname[i]);
            }
        }
        if(isAdded == true && tag == false)
        {
            newcodes.push(code);
			newcodesname.push(funname);
        }
    }     
    User_FavoriteFund = newcodes.join(';');  
	User_FavoriteFundname = newcodesname.join(';');  
}
function createlist(list, name, isFirstLoad)//生成列表
{    
    var strs=list.split(",");
    var li=$C("li");
    var color = "";
    if(typeof isFirstLoad != 'undefined' && isFirstLoad == true)
    {        
        $("list").appendChild(li);
    }
    else
    {
        li.style.color = "#FF6600";
        $("list").insertBefore(li, $("list").firstChild);
    }
    
    li.id=strs[0];    
    li.innerHTML="<img border='0' style='margin-right:5px;width:10px;height:10px;cursor:pointer;' onclick='delchoose(this,\""+name+"\",\""+strs[1]+"\")' title='删除此行' src='/images/close.jpg' />&nbsp;"+strs[1];
}
function delchoose(obj,name,values)//删除列表
{
    var parent=obj.parentNode;
    var id=parent.id;
    var value=id+","+values;
    parent.parentNode.removeChild(parent);
    
   delchooseMyFavoriteFund(id);
}
function delchooseMyFavoriteFund(code)//更新页面中的复选框
{
    var eid = 'fav' + code;
    var obj = document.getElementById(eid);
    
    if(obj != null)
    {
        e = obj;
		if(e.checked == true){
          e.checked = false;
		  }else{
		  e.checked = true;
		  }
        /*image.className = 'fav1';*/
        obj.setAttribute("isFav", "0");
        obj.setAttribute("title", "添加到我关注的基金");        
    }    
    ResetMyFavoriteFund(code, false);
}
function HideWindow()//关闭窗口
{
    showOpenWindowFlag = false;
	openwindowFlag = false;  
    var ojbWindow = $("comparewindow");
    ojbWindow.style.display = "none";    
}
function SaveFunds(obj,tag)
{
    var showproduct=$("productTitle");
    showproduct.innerHTML="正在保存中....";
    
    var codes = [];
    objs = $("list").childNodes;
    if(objs.length > 80)
    {
        alert('保存失败。因为我关注的基金不能超过80只。');
        return;
    }
    for(var i=0;i<objs.length;i++)
    {
        codes.push(objs[i].id);
    }
    favCodes = codes.join(";");
    var time = new Date();
    var progress_url = PHP_SITE+"/api/savemyfund.php?my_fund="+escape(favCodes);
	if (window.XMLHttpRequest) {
		var req = new XMLHttpRequest();
		req.open("GET", progress_url, true);
		req.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=gb2312');
	} else if (window.ActiveXObject) {
		var req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.open("GET", progress_url, true);
			req.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=gb2312');
		}
	}
	req.onreadystatechange = function(){ 
		  if (req.readyState == 4 && req.status == 200){ 
			   var str = req.responseText; 
			   if(str==1){
				   showproduct.innerHTML="保存成功！";
					HideWindow();
				   }else{
					showproduct.innerHTML="保存失败！";   
				}
		  }
	 }
	 req.send(null);
	return false;	
}
//-------------------------end----add--------------------------------------

function PushTR(i, order, netValues, tables, isAdvance){
    var percentColor, disValueColor, percent, disValue;
    percent = netValues[i][5];
    percentColor = "";
    if (percent) {
        if (percent > 0) {
            percentColor = "style='color:red'";
        }
        else 
            if (percent < 0) {
                percentColor = "style='color:green'";
            }
    }
    
    disValue = netValues[i][4];
    disValueColor = "";
    if (disValue) {
        if (disValue > 0) {
            disValueColor = "style='color:red'";
        }
        else 
            if (disValue < 0) {
                disValueColor = "style='color:green'";
            }
    }

	gdisValue = netValues[i][6];
    gdisValueColor = "";
    if (gdisValue) {
        if (gdisValue > 0) {
            gdisValueColor = "style='color:red'";
        }
        else 
            if (gdisValue < 0) {
                gdisValueColor = "style='color:green'";
            }
    }

	 gpercent = netValues[i][7];
    gpercentColor = "";
    if (gpercent) {
        if (gpercent > 0) {
            gpercentColor = "style='color:red'";
        }
        else 
            if (gpercent < 0) {
                gpercentColor = "style='color:green'";
            }
    }
    
    var bgcolor = "#FFFFFF";
    var fundcode = netValues[i][0];
    tables.push('<tr width=910 align="center" style="cursor:pointer;" type="code" code="' + netValues[i][0] + '" onmouseout="changebg(this)" onmouseover="changebg1(this)" onclick="changebg2(this)">');
	//------------------add-----------------------------------
	 if (!isAdvance) {
		 var flag_array = User_FavoriteFund.split(';');
		var thisfundflag=false;
		if(flag_array.length == 0){
				thisfundflag=false;
		}else{
			for( var k=0;k<flag_array.length;k++)
			{
				if(flag_array[k] == netValues[i][0])
				{
					thisfundflag=true;
				}
			}
		}  
	 tables.push(GetFavoriteColumn(netValues[i][0],netValues[i][1],thisfundflag));
	 }
	//-----------------end-add-------------------------------------
     tables.push('<td width="40" height="22" align="center">' + order +'</td>');
         tables.push('<td width="60" align="center"><a target="_blank" href="./fund/view_fund.php?FundID='+netValues[i][0]+'" class="link12_black">'+netValues[i][0]+'</a></td>');
         tables.push('<td width="119"><a target="_blank" href="./fund/view_fund.php?FundID='+netValues[i][0]+'" class="link12_blue">'+netValues[i][1]+'</a></td>');
         tables.push('<td width="80" align="center" title="最新单位净值">'+(netValues[i][2] ==0 || netValues[i][2] == "" ? "--" : FormatNumber(netValues[i][2], 4))+'</td>');
         tables.push('<td width="80" align="center" title="最新累计净值">'+(netValues[i][3] ==0 || netValues[i][3] == "" ? "--" : FormatNumber(netValues[i][3], 4))+'</td>');
         tables.push('<td width="80" align="center" title="日增长值"'+ disValueColor+'>'+(netValues[i][2] == 0 && netValues[i][3] == 0 && (netValues[i][4] ==0 || netValues[i][4] == "") ? "--" : FormatNumber(netValues[i][4], 4))+'</td>');
         tables.push('<td width="80" align="center" title="日增长率" ' + percentColor + '>'+(netValues[i][2] == 0 && netValues[i][3] == 0 && (netValues[i][5] == 0 || netValues[i][5] == "") ? "--" : (FormatNumber(netValues[i][5], 2)+ "%"))+'</td>');
         tables.push('<td width="80" align="center" title="估算值">'+(netValues[i][6] == 0 || netValues[i][6] == "" ? "--" : FormatNumber(netValues[i][6], 4))+'</td>');
         tables.push('<td width="80" align="center" title="估算增长率" ' + gpercentColor + '>'+(netValues[i][7] == 0 || netValues[i][7] == "" ? "--" : (FormatNumber(netValues[i][7], 2)+ "%"))+'</td>');
    if (!isAdvance) {
		var State="",title1="";
			if (netValues[i][8]!=""){
				 if(netValues[i][8]=="0"){
					netValues[i][8]="封闭期内";
				 }
				if(netValues[i][8]=="打开申购"){
						State=netValues[i][8];
				}else{
					State='<font color=red>'+netValues[i][8]+'</font>';
				}
				if(netValues[i][9]!=""){
					title1="title='"+netValues[i][9]+"'";
				}else{
					title1="";
				}
			}else{
				State='<font color=red>----</font>';
			}
			tables.push("<td style='width: 90px;' " + title1 + ">" +State + "</td>");
    }
    
tables.push('<td width="121" align="center"><a href=./fund/view_fund_history.php?FundID=' + netValues[i][0] + ' class="link12_blue" target="_blank">历史净值</a>&nbsp;<a href=http://bbs.tttz.com/forumdisplay.php?fid=' + netValues[i][10] + ' class="link12_blue" target="_blank">讨论</a></td>');
    tables.push("</tr>");
}

var highFundArray = [];

function CombineArray(source, codes){
    var returnAry = [];
    for (var j = 0; j < codes.length; ++j) {
        for (var i = 0; i < source.length; ++i) {
            if (codes[j] == source[i]) {
                returnAry.push(codes[j]);
            }
        }
    }
    
    return returnAry;
}

function unHightFund(obj){
    var myCodes = obj.split(";");   
    var returnAry = [];
    for (var j = 0; j < highFundArray.length; ++j) {
		 var sign = "0";
        for (var i = 0; i < myCodes.length; ++i) {
            if (highFundArray[j] == myCodes[i]) {
                sign = "1";
            }
        }
        if (sign == "0") {
            returnAry.push(highFundArray[j]);
        }
    }
    
	var tblContent = document.getElementById("tblContent");
    var trs = tblContent.getElementsByTagName("TR");
    for (var i = 0; i < trs.length; i++) {
        if (trs[i].getAttribute("type") == "code") {
            trs[i].style.backgroundColor = "";
            for (var k = 0; k < returnAry.length; k++) {
                if (returnAry[k] == trs[i].getAttribute("code")) {
                    trs[i].style.backgroundColor = "#FFF7DF";
                    break;
                }
            }
        }
    }
}

function hightFund(obj){

    var myCodes = obj.split(";");
   // highFundArray = myCodes.concat(highFundArray); //加入高亮基金数组 
    highFundArray = myCodes;
    var tblContent = document.getElementById("tblContent");
    var trs = tblContent.getElementsByTagName("TR");
    for (var i = 0; i < trs.length; i++) {
        if (trs[i].getAttribute("type") == "code") {
            trs[i].style.backgroundColor = "";
            for (var k = 0; k < highFundArray.length; k++) {
                if (highFundArray[k] == trs[i].getAttribute("code")) {
                    trs[i].style.backgroundColor = "#FFF7DF";
                    break;
                }
            }
        }
    }
}

function DisplayOtherMode(){
    var otherMode = document.getElementById("otherMode");
    if (otherMode.style.display == "none") {
        otherMode.style.display = "";
    }
    else {
        otherMode.style.display = "none";
    }
}

function hightMyFund(obj){
    var myCodes = obj.split(",");
   // highFundArray = myCodes.concat(highFundArray); //加入高亮基金数组 
    highFundArray = myCodes;
    var tblContent = document.getElementById("tblContent");
    var trs = tblContent.getElementsByTagName("TR");
    for (var i = 0; i < trs.length; i++) {
        if (trs[i].getAttribute("type") == "code") {
            trs[i].style.backgroundColor = "";
            for (var k = 0; k < highFundArray.length; k++) {
                if (highFundArray[k] == trs[i].getAttribute("code")) {
                    trs[i].style.backgroundColor = "#E0F2FE";
                    break;
                }
            }
        }
    }
}

function hightSzFund(sign){
	hightSign=sign;
	
}

function SortListTableVarMode(text, value){
    var currCodes = window.parent.currCodes;
    var tblContent = document.getElementById("tblContent");
    var trs = tblContent.getElementsByTagName("TR");
    
    if ((currCodes == null || currCodes == "0") && value == "-1") 
        value = "0";
    
    if (value == "0") //显示全部
    {
        for (var i = 0; i < trs.length; i++) {
            if (trs[i].getAttribute("type") == "code") {
                trs[i].style.display = "";
            }
        }
        
        currCodes = null;
    }
    else {
        var codes;
        if (value == "-1") {
            codes = currCodes;
        }
        else {
            codes = value.split(";");
            if (currCodes != null && text != "我关注的") {
                if (currCodes != "0") {
                    codes = window.parent.CombineArray(currCodes, codes);
                }
            }
        }
        
        //显示基金
        for (var i = 0; i < trs.length; i++) {
            if (trs[i].getAttribute("type") == "code") {
                trs[i].style.display = "none";
                for (var k = 0; k < codes.length; k++) {
                    if (codes[k] == trs[i].getAttribute("code")) {
                        trs[i].style.display = "";
                        break;
                    }
                }
            }
        }
    }
}

function ModeState(obj){
    if (obj.className == "ModeLink") {
        obj.className = "ModeLinkOver";
    }
    else {
        obj.className = "ModeLink";
    }
}

var isLock = true;
function LockTitle(bool){
    isLock = bool;
    var divLock = document.getElementById("divLock");
    if (bool) {
        divLock.style.overflow = "auto";
    }
    else {
        divLock.style.overflow = "";
    }
}

function ResizeNetValueList(size){
    var divLock = null;
    if (document.getElementById) {
        divLock = document.getElementById("divLock");
    }
    else {
        eval('divLock = divLock;');
    }
    if (size == 1985) {
        divLock.style.height = "auto";
    }
    else 
        if (size == -1985) {
            divLock.style.height = "266px";
        }
        else {
            var height = parseInt(divLock.style.height.replace("px", ""));
            height = height + size;
            if (height > 100) {
                divLock.style.height = height + "px";
            }
            SetCookie("NetValueListHeight", divLock.style.height);
        }
   // window.parent.ResizeIframe();
}

function tblockctl(num) {
	
	var ele_maininfo = document.getElementById('divLock');
	var tbheight = ele_maininfo.style.height;
	var ele_lockimg = document.getElementById('lockimg');
	var ele_lockctl2 = document.getElementById('lockctl2');
	var NVTableFontSize = GetCookie("NVTableFontSize");
	if (num == 'fontsize') {
		if (NVTableFontSize == '14px') {
			var ilist = document.getElementById('tblContent');
			var d = ilist.getElementsByTagName("TD");
			for (var i = 0; i < d.length; i++) { 
			  d[i].style.fontSize='14px';
			}
		}
	} else if (num == 'setfontsize') {
		
		var ilist = document.getElementById('tblContent');
		var d = ilist.getElementsByTagName("TD");
		if (NVTableFontSize == '14px') {
			for (var i = 0; i < d.length; i++) { 
			  d[i].style.fontSize='12px';
			}
			SetCookie("NVTableFontSize", '0');
		} else {
			for (var i = 0; i < d.length; i++) { 
			  d[i].style.fontSize='14px';
			}
			SetCookie("NVTableFontSize", '14px');
		}
	}else if(num =='setheight'){
			var	NVTableLocked = GetCookie("NVTableLocked");

				if (NVTableLocked == "1") {
				ResizeNetValueList(-1985);
				SetCookie("NVTableLocked","0");
				}else if(NVTableLocked == "0"){
					SetCookie("NVTableLocked","1");
					ResizeNetValueList(1985);
				}else{
					ResizeNetValueList(-1985);
					SetCookie("NVTableLocked","0");
				}
	}
	
}




var activedRow;
var activedCell;
var activedCellIndex;
function tblCellClick(tbl, evt){
    //clear
    if (activedRow && activedRow.tagName == "TR") {
        activedRow.style.backgroundColor = "#FFFFFF";
    }
    
    //set
    evt = evt ? evt : (window.event ? window.event : null);
    var activeCell = evt.srcElement ? evt.srcElement : evt.target;
    if (activeCell && activeCell.tagName == "TD") {
        //set row
        var srcRow = activeCell.parentNode;//parentElement;
        srcRow.style.backgroundColor = "#F0FFFF";
        
        var indexCell = activeCell.cellIndex;
        if (activedCellIndex != indexCell) {
            //clear
            if (activedCellIndex) {
                for (var i = 1; i < tbl.rows.length; i++) {
                    var td = tbl.rows[i].cells[activedCellIndex];
                    if (td) 
                        td.style.backgroundColor = "";
                }
            }
            
            //set cells
            for (var i = 1; i < tbl.rows.length; i++) {
                var td = tbl.rows[i].cells[indexCell];
                if (td) 
                    td.style.backgroundColor = "#F0FFFF";
            }
        }
        
        activedRow = srcRow;
        activedCell = activeCell;
        activedCellIndex = activedCell.cellIndex;
    }
}
function isHightFund(fundcode){
	var temp=highFundArray;
	var code=fundcode;
	    for (var n = 0; n < temp.length; n++) {
        if (temp[n]==code) {
           return true;
        }
    }
	return false;
}
function changebg(obj){
	
	if (!isHightFund(obj.getAttribute("code"))) {
		if(obj.style.backgroundColor!="#eeeeee"){
		obj.style.backgroundColor = "#FFFFFF";
		}
	}
}

function changebg1(obj){
	if (!isHightFund(obj.getAttribute("code"))) {
		if(obj.style.backgroundColor!="#eeeeee"){
		obj.style.backgroundColor = "#F0FFFF";
		}
	}
}
function changebg2(obj){
	if (!isHightFund(obj.getAttribute("code"))) {
		if(obj.style.backgroundColor=="#eeeeee"){
		obj.style.backgroundColor = "#F0FFFF";
		}else{
		obj.style.backgroundColor = "#eeeeee";
		}
	}
}

function FormatNumber(srcStr, nAfterDot){
    var srcStr, nAfterDot;
    var resultStr, nTen;
    srcStr = "" + srcStr + "";
    strLen = srcStr.length;
    dotPos = srcStr.indexOf(".", 0);
    if (dotPos == -1) {
        resultStr = srcStr + ".";
        for (i = 0; i < nAfterDot; i++) {
            resultStr = resultStr + "0";
        }
        return resultStr;
    }
    else {
        if ((strLen - dotPos - 1) >= nAfterDot) {
            nAfter = dotPos + nAfterDot + 1;
            nTen = 1;
            for (j = 0; j < nAfterDot; j++) {
                nTen = nTen * 10;
            }
            resultStr = Math.round(parseFloat(srcStr) * nTen) / nTen;
			resultStr=""+resultStr+"";
			strLen=resultStr.length;
			dotPos=resultStr.indexOf(".", 0);
			 if (dotPos == -1) {
			 	resultStr = resultStr + ".";
			 	for (i = 0; i < nAfterDot; i++) {
			 		resultStr = resultStr + "0";
			 	}
			 }
			 else {
			 	for (i = 0; i < (nAfterDot - strLen + dotPos + 1); i++) {
			 		resultStr = resultStr + "0";
			 	}
			 }
            return resultStr;
        }
        else {
            resultStr = srcStr;
            for (i = 0; i < (nAfterDot - strLen + dotPos + 1); i++) {
                resultStr = resultStr + "0";
            }
            return resultStr;
        }
    }
}
			function getmainContent(){
				var netValues = eval(document.getElementById("mainContent").innerHTML);
				return netValues;
			}