document.domain="caixun.com";
imgDownPath="../image/img_down.gif";
greenStyle="#078f07";
var imgIndex = 0;
var reflashInterval = 10000;//十秒
var defContext="fundsdata";
var screen_height;
if(screen.width == 1280){
	if(screen.height == 1024){
		screen_height=802;
	}else{
		screen_height=593;
	}
}else{
	screen_height=533;
}

function changeStyle(){
  document.domain=domainStr;
}
//修改主页面中iframe子页面的样式
function changeIframeStyle() {
  var _url = parent.location.toString();
  var paramStr;
  var iStart = _url.indexOf('?');
  if (iStart > 0){
    paramStr = _url.substr(iStart + 1);
    //获取样式单文件名称
    var cssFileName = getParameter("style",paramStr);
    if(null != cssFileName && "" != cssFileName) {
      var html_doc = document.getElementsByTagName('head')[0];
      var cssFiles = cssFileName.split(",")
      for(var i = 0;i < cssFiles.length;i ++) {
        var jsFile = document.createElement('link');
        jsFile.setAttribute('rel', 'stylesheet');
        jsFile.setAttribute('type', 'text/css');
        jsFile.setAttribute('href', '../css/' + cssFiles[i] + ".css");
        html_doc.appendChild(jsFile);
      }
    }
  } 
}
//判断浏览器类型
window.navigatorType = new function(){
  this.isOpera=(window.opera&&navigator.userAgent.match(/opera/gi))?true:false;
  this.isIE=(!this.isOpera&&document.all&&navigator.userAgent.match(/msie/gi))?true:false;
  this.isSafari=(!this.isIE&&navigator.userAgent.match(/safari/gi))?true:false;
  this.isGecko=(!this.isIE&&navigator.userAgent.match(/gecko/gi))?true:false;
  this.isFirefox=(!this.isIE&&navigator.userAgent.match(/firefox/gi))?true:false;
};
// check for XPath implementation
if( document.implementation.hasFeature("XPath", "3.0")) {
   // prototying the XMLDocument
   XMLDocument.prototype.selectNodes = function(cXPathString, xNode){
      if( !xNode ) { xNode = this; } 
      var oNSResolver = this.createNSResolver(this.documentElement)
      var aItems = this.evaluate(cXPathString, xNode, oNSResolver, 
                   XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
      var aResult = [];
      for( var i = 0; i < aItems.snapshotLength; i++)
      {
         aResult[i] =  aItems.snapshotItem(i);
      }
      return aResult;
   }
   // prototying the Element
   Element.prototype.selectNodes = function(cXPathString) {
      if(this.ownerDocument.selectNodes)
      {
         return this.ownerDocument.selectNodes(cXPathString, this);
      }
      else{throw "For XML Elements Only";}
   }
   // prototying the XMLDocument
   XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode) {
      if( !xNode ) { xNode = this; } 
      var xItems = this.selectNodes(cXPathString, xNode);
      if( xItems.length > 0 )
      {
         return xItems[0];
      }
      else
      {
         return null;
      }
   }   
   // prototying the Element
   Element.prototype.selectSingleNode = function(cXPathString) {    
      if(this.ownerDocument.selectSingleNode)
      {
         return this.ownerDocument.selectSingleNode(cXPathString, this);
      }
      else{throw "For XML Elements Only";}
   }   
   XMLDocument.prototype.__defineGetter__("xml" ,  function (){
         try {
             return   new  XMLSerializer().serializeToString( this );
        } catch (ex){
             var  d  =  document.createElement( " div " );
            d.appendChild( this .cloneNode( true ));
             return  d.innerHTML;
        }
    });
    Element.prototype.__defineGetter__("xml" ,  function (){
         try {
             return   new  XMLSerializer().serializeToString( this );
        } catch (ex){
             var  d  =  document.createElement( " div " );
            d.appendChild( this .cloneNode( true ));
             return  d.innerHTML;
        }
    });
    XMLDocument.prototype.__defineGetter__("text" ,  function (){
         return   this .firstChild.textContent
    });
    Element.prototype.__defineGetter__("text" ,  function (){
         return   this .textContent
    });
}
function getContext() {
  path = this.location.pathname;
  context = path.substring(0, path.indexOf('/',2));
  if (context.indexOf('/') != 0) {
    context = '/'+context;
  }
  var r=path.match(/\/data\/[0-9]+\/(.*).shtm/g);//内码路径
  if(null!=r){
    context = '/'+defContext;
  }
  return context;
}
/*创建xml对象*/
function importXML(file) {
  var xmlDoc = null;
  if (window.navigatorType.isIE) {
    xmlDoc = importXMLIE(file);
  } else {
    xmlDoc = importXMLFF(file);
  }
  return xmlDoc;
}
function importXMLIE(file) {
  var xmlhttp = getXMLHTTP();
  var xmlDoc=null;
  xmlhttp.open("GET",file, false);
  xmlhttp.send("");
  if (xmlhttp.readyState==4) {
    if(xmlhttp.status==200){
      xmlDoc = xmlhttp.responseXML;
      return xmlDoc;
    }
  }
}
function importXMLFF(file) {
  var xmlhttp = getXMLHTTP();
  var xmlDoc = null;
  xmlhttp.open("GET",file, false);
  xmlhttp.overrideMimeType("text/html;charset=gb2312"); 
  xmlhttp.send("");
  if (xmlhttp.readyState==4) {
    if(xmlhttp.status==200){
      var parser = new DOMParser();
      xmlDoc = parser.parseFromString(xmlhttp.responseText, "text/xml");
      return xmlDoc;
    }
  }
}
function importHTML(file) {
  var xmlhttp = getXMLHTTP();
  var xmlDoc = null;
  xmlhttp.open("GET",file, false);
  if (! window.navigatorType.isIE) {
    xmlhttp.overrideMimeType("text/html;charset=gb2312");    
  }
  xmlhttp.setRequestHeader("charset","gb2312");
  xmlhttp.send("");
  if (xmlhttp.readyState==4) {
    if(xmlhttp.status==200){
      if (window.navigatorType.isIE) {
        return bytes2BSTR(xmlhttp.responseBody);
      } else {
        return xmlhttp.responseText;
      }
    }
  }
}

/*基金代码切换*/
function searchFund(objName) {
  var codeObj = document.getElementById(objName);
  var code = trim(codeObj.value);
  if (code.length <= 0) {
      alert("请输入基金代码");
  } else {
    var _doc = importXML("../fundsnap.xml");
    if ("undefined" != typeof(_doc) && null != _doc) {
      var fundnode = _doc.selectSingleNode("/base/list/row[./zhengquandm = '" + code + "']");
      if (null == fundnode || "undefined" == typeof(fundnode)) {
        alert("该基金代码不存在");
      } else {
        window.open(getContext() + "/" + code + "/LastNewOverView.shtm","_self");
      }
    } else {
      window.open(getContext() + "/" + code + "/LastNewOverView.shtm","_self");
    }
  }
  return false;
}
/*基金代码切换*/
function changeFundCode(fundcode) {
  window.open(getContext() + "/" + fundcode + "/LastNewOverView.shtm","_self");
}

function getFundType(code) {
  var fundType = "";
  var _doc = importXML("../fundsnap.xml");
  var fundnode = _doc.selectSingleNode("/base/list/row[./zhengquandm = '" + code + "']");
  if (null == fundnode || "undefined" == typeof(fundnode)) {
    alert("该基金代码不存在");
  } else {
    var node = fundnode.selectSingleNode("jijinlx");
    fundType = node.text;
  }
  return fundType;
}

function getFundNameByCode(code) {
  var resultName = "";
  var _doc = importXML("../fundsnap.xml");
  if ("undefined" != typeof(_doc) && null != _doc) {
    var xpath = "//base/list/row[./zhengquandm = '" + code + "']";
    var fundnode = _doc.selectSingleNode(xpath);
    if (null != fundnode && "undefined" != typeof(fundnode)) {
      var node = fundnode.selectSingleNode("jijinjc");
      resultName = node.text;
    }
  }
  return resultName;
}
function getFundInvestType(code) {
  var investType = "";
  var _doc = importXML("../fundsnap.xml");
  var fundnode = _doc.selectSingleNode("//base/list/row[./zhengquandm = " + code + "]");
  if (null == fundnode || "undefined" == typeof(fundnode)) {
    alert("该基金代码不存在");
  } else {
    var node = fundnode.selectSingleNode("touzilx");
    investType = node.text;
  }
  return investType;
}
/* 以下是解决页面head中数据块的js */
function setTab(name,cursel,n){   
  for(i=1;i<=n;i++){
    var menu=document.getElementById(name+i);   
    var con=document.getElementById("con_"+name+"_"+i);   
    menu.className=i==cursel?"selected":"unselected";
    con.style.display=i==cursel?"block":"none";
  }   
  if (window.navigatorType.isIE) {
    var contentTable = document.getElementById("contextTable");
    if (null != contentTable && "undefined" != typeof(contentTable)) {
      if(1 != cursel){
        contentTable.style.display = "none";
      } else {
        contentTable.style.display = "block";
      }
    }
  }
}

function initShareIndex() {
  //获取行情数据
  var stockcode = document.getElementById("stockcode").value;
  var stockname = "";
  if ("undefined" == typeof(stockcode) || "" == stockcode) {
    stockcode = getCodeFromUrl();
    stockname = getStockNameByCode(stockcode);
  } else {
    stockname = document.getElementById("stockname").value;
  }
  stockQuotation(stockcode,2);
  setInterval("stockQuotation('" + stockcode + "',2)",reflashInterval);
  mastStockIndexInfo();
  setInterval("mastStockIndexInfo()",reflashInterval);
}
function getStockNameByCode(code) {
  var resultName = "";
  var _doc = importXML("../stocksnap.xml");
  if ("undefined" != typeof(_doc) && null != _doc) {
    var xpath = "//base/list/row[./agudm = '" + code + "']";   
    var stocknode = _doc.selectSingleNode(xpath);
    if (null != stocknode && "undefined" != typeof(stocknode)) {    
      var node = stocknode.selectSingleNode("agujc");
      resultName = node.text;
    }else {
      xpath = "//base/list/row[./bgudm = '" + code + "']";
      stocknode = _doc.selectSingleNode(xpath);
      if (null != stocknode && "undefined" != typeof(stocknode)) {
        var node = fundnode.selectSingleNode("bgujc");
        resultName = node.text;
      }
    }
  }
  return resultName;
}

function initFund() {
  //初始化菜单
  initMenu();
  addMenuEvents('menu_height');
  //设置个股走势图为默认显示
  var _url = window.location.toString();
  var marketParasReg = new RegExp("act_img");
  if(null != marketParasReg.exec(_url)) {
    setTab('one',2,2)
  }
  //设置菜单颜色
  var modulename = document.getElementById("modulename");
  if ("undefined" == typeof(modulename) || null == modulename) {
    changeColorBaseUrl();
  } else {
    changeColor(document.getElementById(modulename.value));    
  }
  setMenuHeight();
  //走势图alt
  if(document.getElementById("shTendencyImg")){
  	var shTendencyImg=document.getElementById("shTendencyImg");
  	if((window.navigatorType.isIE && shTendencyImg.readyState!="complete") || (window.navigatorType.isFireFox && !shTendencyImg.complete)){
  		shTendencyImg.alt="该股首日上市，暂无对比图";
  		shTendencyImg.title="该股首日上市，暂无对比图";
  	}
	}
	if(document.getElementById("szTendencyImg")){
  	var szTendencyImg=document.getElementById("szTendencyImg");
  	if((window.navigatorType.isIE && szTendencyImg.readyState!="complete") || (window.navigatorType.isFireFox && !szTendencyImg.complete)){
  		szTendencyImg.alt="该股首日上市，暂无对比图";
  		szTendencyImg.title="该股首日上市，暂无对比图";
  	}
	}
	if(document.getElementById("StoImg")){
  	var StoImg=document.getElementById("StoImg");
  	if((window.navigatorType.isIE && StoImg.readyState!="complete") || (window.navigatorType.isFireFox && !StoImg.complete)){
  		StoImg.alt="该基金首日上市，暂无对比图";
  		StoImg.title="该基金首日上市，暂无对比图";
  	}
	}
  //获取行情数据
  var code = "";
  var fundname = "";
  var fundType = "";
  var fundcode = document.getElementById("fundcode");
  if ("undefined" == typeof(fundcode) || "" == fundcode.value) {
    code = getCodeFromUrl();
    fundname = getFundNameByCode(code);
    fundType = getFundType(code);
  } else {
    code = fundcode.value;
    fundname = document.getElementById("fundname").value; 
    fundType = document.getElementById("fundtype").value;    
  }
  var typeID = 0;

  if (fundType.indexOf("封闭式") >= 0) {

          
//三行改为两行显示
  	var tempHtml="<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
      tempHtml+="<tr>";
  	  tempHtml+="<th id=\"disfundname\"></th>"
  	  tempHtml+="<td id=\"disfundcode\"></td>";
      tempHtml+="</tr>";
      tempHtml+="<tr id=\"nowprice\" class=\"nowprice_up\">";
        tempHtml+="<th></th>";
        tempHtml+="<td></td>";
      tempHtml+="</tr>";
    tempHtml+="</table>";

  	document.getElementById("QuotationCodeName").innerHTML=tempHtml;
  	document.getElementById("QuotationCodeName").className="closecodename";
    code=document.getElementById("productid").value;//内码
    closeFundQuotation(code,0);
  	setInterval("closeFundQuotation('" + code + "',0)",reflashInterval);
  } else {
    typeID = 2;
    openFundQuotation(code,0);
  }
  //fundQuotation(code,typeID);
  mastFundIndexInfo();
  setInterval("mastFundIndexInfo()",reflashInterval);
  
  updateFundNetValueIncRate();//开基日增长率前十名
}
function initFund404() {
  var code = getCodeFromUrl();
  var _doc = importXML("../fundsnap.xml");
  var fundnode = _doc.selectSingleNode("/base/list/row[./zhengquandm = '" + code + "']");
  if (null == fundnode || "undefined" == typeof(fundnode)) {
    document.getElementById('errorCodeDiv').style.display = "block";
    document.getElementById('QuotationTab').style.display = "none";
    document.getElementById('Tab').style.display = "none";
  } else {
    document.getElementById('Tab').style.display = "block";
    initFund();
    //判断基金投资类型 获取include页面
    var assetUrl = "/include/jcsj/fundAssetSummary/" + code + ".html";
    loadPageToDiv(assetUrl,'fundAssetSummary')
    investType = getFundInvestType(code);
    var investUrl = "./StockCompagesLast.shtm";
    if ("债券型" == investType) {
      investUrl = "./FundBondLast.shtm";
    }
    loadPageToDiv(investUrl,'invest')
  }
}
function getCodeFromUrl() {
  var _url = window.location.toString();
  var codeReg = new RegExp("\/(listeddata|fundsdata|comp|fund|stock_dp|fund_dp|listeddataTest|fund_web)\/([0-9A-Za-z]{0,})\/");
  var codes = codeReg.exec(_url);
  if(null!=codes)
  	return codes[2];
  else{
  	var query_string=document.getElementById("query_string").value;
  	if ("undefined" != typeof(query_string) || "" != query_string) {
  		var code=getParamValue("code",query_string);
  		if("null"==code || null==code || ""==code)
  		  return null;
  		else
  			return code;
  	}
  }
  alert
  return null;
}

function changeColorBaseUrl() {
  var _url = window.location.toString();
  var pageNameReg = new RegExp("\/([A-Za-z0-9_-]+)\.shtm");
  var pageNames = pageNameReg.exec(_url);
  var pageName = pageNames[1].split("_")[0];
  var menuObj = document.getElementById(pageName);
  if ("undefined" == typeof(menuObj) || null == menuObj) {
    menuObj = document.getElementById(pageName + "S");
  }
  if ("undefined" == typeof(menuObj) || null == menuObj) {
    menuObj = document.getElementById(pageName + "F");
  }
  if ("undefined" == typeof(menuObj) || null == menuObj) {
    defaultColor();
  } else { 
    changeColor(menuObj);
  }
}

function getXMLHTTP(){
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        xmlhttp = false;
      }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}

function splitQuotationArray(cols,resultStr) {
  var colArray = cols.split(",");
  var re = /\r|\n| /g;
  var results = resultStr.replace(re,"");  
  var tmpArray = results.split("|");
  var resultArray = new Array(tmpArray.length - 1);
  for (var i = 0;i < resultArray.length;i ++) {
    var tempStr = "var valueArray = {";
    var valueArray = tmpArray[i].split(",");
    for (var iCnt = 0; iCnt < colArray.length;iCnt ++) {
      tempStr = tempStr + colArray[iCnt] + ":'" + valueArray[iCnt] + "',"
    }
    tempStr = tempStr.substr(0,tempStr.length -1) + "}";
    eval(tempStr);
    resultArray[i] = valueArray;
  }
  return resultArray;
}

function changImg(id,code) {
  imgIndex = id;
  if("undefined" == typeof(code) || "" == code) {
    code = document.getElementById("fundcode").value;
    if("undefined" == typeof(code) || "" == code) {
      code = getCodeFromUrl();
    }
  }
  switch (id){
   case 0:
     dirc="one";
     break;
   case 1:
     dirc="day";
     break;
   case 2:
     dirc="week";
     break;
   case 3:
     dirc="month";
     break;
   case 4:
     dirc="pre";
     break;
   case 5:
     dirc="after";
     break;
  default:
     dirc="day";
     break;
  }
  //获取行情数据
  var StoUrlImg="http://gif.caixun.com/web2/stock/current/" + dirc + "/" + code + ".gif?date="+new Date();
  var stoImg = document.getElementById('StoImg');
  if (window.navigatorType.isIE) {
    var stoImgTmp = new Image();
    stoImgTmp.src = StoUrlImg;    
    if(stoImgTmp.readyState=='complete') {
      stoImg.src = stoImgTmp.src;
    }
    stoImgTmp.onreadystatechange = function() {
      if(this.readyState=='complete') {
        stoImg.src = stoImgTmp.src;
      }
    }
  } else {
    stoImg.src = StoUrlImg;    
  }
  changeClassName(document.getElementById("bt" + (id + 1)),0);
}

function parserHref(){
  var code=document.getElementById("productid");
	if("undefined"!=typeof(code) && null!=code)
	  openOneEcube("sid="+code.value);
}

/* 判断时间是否停盘 */
function getstoDate(stotime){
  var myDate = new Date();
  if(stotime.substring(0,4) != myDate.getYear() || stotime.substring(4,6) != (myDate.getMonth()+1) || stotime.substring(6,8) != myDate.getDate())
    return true;
  else
    return false;
}
/* 更改时间显示方式 */
function changeDate(nowDate){
  if ("" == nowDate) {
    return "--";
  }
  var nd = trim(nowDate);
  var year = nd.substring(0,4);
  var month = nd.substring(4,6);
  var day = nd.substring(6,8);
  var hour = nd.substring(8,10);
  var minute = nd.substring(10,12);
  var second = nd.substring(12);
  var resultDate = year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second;
  return resultDate;
}

function changeDateNoTime(nowDate) {
  if ("" == nowDate) {
    return "--";
  }
  var nd = trim(nowDate);
  var year = nd.substring(0,4);
  var month = nd.substring(4,6);
  var day = nd.substring(6,8);
  var resultDate = year+'年'+month+'月'+day+'日';
  return resultDate;
}

/* js中去空格的方法 */
function trim(str) {
  return (str + '').replace(/(\s+)$/g,'').replace(/^\s+/g,'');
}

function dataRound (num,bit) {
  if("undefined" == typeof(bit)){
    bit = 2;
  }
  var randValue = 1;
  for(var i=0;i < bit;i++){
    randValue = randValue * 10;
  }
  num = Math.round(num * randValue) / randValue;  
  return num;
}
//查看业绩预告
function showForecast(){
  var paramStr = getUrlParamStr(); 
  window.open("ViewForecast.html?" + paramStr,"","width=500px,height=360px,top=150,left=250,toolbar=no,menubar=no,scrollbars=yes,resizeable=no,location=no,status=no");
}
//公告期切换
function forward(currDate,pageName){
    if(pageName!=null || pageName.length!=0) {
        currreportDate = currDate;
        var paramStr = getUrlParamStr();
        if(""==paramStr)
        	window.location='./'+pageName+'_' + currDate + '.shtm';
        else
        	window.location='./'+pageName+'_' + currDate + '.shtm?'+paramStr;
    }
}
//分页输出页数
function writeSelectpage(curPageName,maxPageName){
  var curpage = document.getElementById(curPageName).value;
  var maxpage = document.getElementById(maxPageName).value;
  for(var page=0;page < maxpage;page++){
    if(page==curpage){
      str = "<option value = '" + page + "'  selected >第" + (page+1) + "页</option>"
    }else{
      str = "<option value = '" + page + "'>第" + (page+1) + "页</option>"
    }
    document.write(str);
  }
}
/*上一页*/
function prev(page,curpage,minpage) {
    if ( (-- curpage) >= minpage){
        pagechange(page,curpage);
    }
}
/*下一页*/
function next(page,curpage,maxpage) {
    if ( (++ curpage) < maxpage){
        pagechange(page,curpage);
    }
}
//分页 换页
function pagechange(page,index){
  var paramStr = getUrlParamStr(); 
  if ("" != paramStr) {
    paramStr = "?"+paramStr;
  }
  if (index == 0){
      window.location=page + ".shtm" + paramStr;
  }else{
      window.location=page + "_" + index + ".shtm" + paramStr;
  }
}
//查看子页面
function loadPage(_url){
  var xmlhttp = getXMLHTTP();
  xmlhttp.open("GET", _url, false);
  xmlhttp.send("");
  if (xmlhttp.readyState==4) {
    if(xmlhttp.status==200){
        var _urlpath=window.location.pathname;
        var _urlSplit=_urlpath.split("/");
        var url=_urlpath.replace(_urlSplit[_urlSplit.length-1],_url);
        if(parent.document.getElementById("currentUrl"))
          parent.document.getElementById("currentUrl").value = url;
        parent.showMenu(url.split("/")[url.split("/").length-1].replace(".html",""));
        window.location=_url;
    }else{
        alert('该股票没有此类数据!');
    }
  }
}

function writeReportDate() {
  var reportSelect = document.getElementById("reportTab");
  reportSelect.style.display = "none";
  document.write("document.write(\"<option value=\\\"Last\\\">==无报告期==</option>\");");
}
//交叉持股数据对象

function crossStock(gupiaomc,zhengquandm,jijinjc,zhehegpsl,zhanjijjzbl,zhangegultszbl) {
  this.gupiaomc = gupiaomc;
  this.zhengquandm=zhengquandm;
  this.jijinjc = jijinjc;
  this.zhehegpsl = zhehegpsl;
  this.zhanjijjzbl = zhanjijjzbl;
  this.zhangegultszbl = zhangegultszbl;
  this.zhangegultszblSum = zhangegultszbl;
  this.holdFunds = new Array();
}

function holdFund(zhengquandm,jijinjc,zhehegpsl,zhanjijjzbl,zhangegultszbl) {
  this.zhengquandm=zhengquandm;
  this.jijinjc = jijinjc;
  this.zhehegpsl = zhehegpsl;
  this.zhanjijjzbl = zhanjijjzbl;
  this.zhangegultszbl = zhangegultszbl;
}

function currencyScale(gupiaosz,yiliutgp) {
  if ((null != gupiaosz)&&("" != gupiaosz)&&(Number(gupiaosz) != 0)&&
      (null != yiliutgp)&&("" != yiliutgp)) {
    return Math.round(Number(yiliutgp) / Number(gupiaosz) * 100 * 10000) / 10000;
  }
  return 0;
}
function format(num){
    var flag=false;
    var value = "";
  if(num!=null && num.length>0){
      m = num.indexOf('.');
      if (m == -1) {
        m = num.length;
      }
      if(num.indexOf('-')==0){
          value = num.substring(1,m);
          flag=true;
      } else {
          value = num.substring(0,m);
      }
      if(value.length<=3)
        return num;
      var result=value.substr(0,value.length%3);
      for(var i=0;i<value.length/3;i++){
        result+=","+value.substr(i*3+value.length%3,3);
      }
      if(value.length%3==0){
        result=result.substr(1,result.length);
      }else {
       result=result.substr(0,result.length-1);
      }
      if(flag==true)
          return "-"+(result + num.substring(m));
      else
          return (result + num.substring(m));
  }
  return num;
}
function pointformat(data,num,flagNum) {
  var formatedData;
  if(isNaN(data))
    return data;
  var str = new String(Math.round(data * Math.pow(10,num)) / Math.pow(10,num));
  if(flagNum!=null && flagNum==4){
    formatedData = (str/Math.pow(10,num)).toString();
  }else{
    formatedData = str;
  }

  var pointPlace = formatedData.indexOf(".");
  if (pointPlace >= 0) {
    for(var i = formatedData.length - pointPlace - 1; i < num;i ++) {
      formatedData = formatedData + "0";
    }
  }else{
    formatedData = formatedData + '.'+Math.pow(10,num).toString().substring(1);
  }
  return formatedData;
}
//输出交叉持股的特殊表格

function writeCrossStockData(data) {
  var trTagList = data.getElementsByTagName('tr');
  if (trTagList.length <= 0) return;
  //整合数据

  var groupList = new Array();
  var zhangegultszbl = currencyScale(trTagList[0].cells[5].innerHTML,trTagList[0].cells[6].innerHTML);
  var crossStocktemp = new crossStock(trTagList[0].cells[0].innerHTML,trTagList[0].cells[1].innerHTML,trTagList[0].cells[2].innerHTML,trTagList[0].cells[3].innerHTML,trTagList[0].cells[4].innerHTML,zhangegultszbl);
  groupList.push(crossStocktemp);
  for(var i = 1; i < trTagList.length; i ++) {
    zhangegultszbl = currencyScale(trTagList[i].cells[5].innerHTML,trTagList[i].cells[6].innerHTML);
    if (trTagList[i].cells[0].innerHTML == groupList[groupList.length - 1].gupiaomc) {
      var holdFundTemp = new holdFund(trTagList[i].cells[1].innerHTML,trTagList[i].cells[2].innerHTML,trTagList[i].cells[3].innerHTML,trTagList[i].cells[4].innerHTML,zhangegultszbl);
      groupList[groupList.length - 1].holdFunds.push(holdFundTemp);
      groupList[groupList.length - 1].zhangegultszblSum = groupList[groupList.length - 1].zhangegultszblSum + zhangegultszbl;
    } else {
      var crossStocktemp = new crossStock(trTagList[i].cells[0].innerHTML,trTagList[i].cells[1].innerHTML,trTagList[i].cells[2].innerHTML,trTagList[i].cells[3].innerHTML,trTagList[i].cells[4].innerHTML,zhangegultszbl);
      groupList.push(crossStocktemp);
    }
  }
  //降序
  groupList.sort(
    function (a,b){
      var result=parseFloat(pointformat(a.zhangegultszblSum,4)) - parseFloat(pointformat(b.zhangegultszblSum,4))
      if(result >0)
        return -1;
      else if(result <0)
        return 1;
      else
        return 0;
    }
  );
  for(var i = 0; i < groupList.length; i ++) {
    if(i%2==0){
      document.write("<tr class=\"tbbg\">");
    }else{
      document.write("<tr class=\"tbbg2\">");
    }
    document.write("<td valign=\"middle\" class=\"tdMiddleContent borderRight tdContentTop\" align=\"middle\" rowspan=\"" + (groupList[i].holdFunds.length + 1) + "\">");
    document.write(i + 1);
    document.write("</td>");
    document.write("<td valign=\"middle\" class=\"tdLeftContent3 borderRight tdContentTop\" rowspan=\"" + (groupList[i].holdFunds.length + 1) + "\">");
    document.write(groupList[i].gupiaomc);
    document.write("</td>");
    document.write("<td class=\"tdLeftContent3 borderRight\">");
    document.write(groupList[i].jijinjc);
    document.write("</td>");
    document.write("<td class=\"tdLeftContent3 borderRight\">");
    document.write("<a class=\"reportLink\" href=\"javascript:changeFundCode('"+groupList[i].zhengquandm+"');\">");
    document.write(groupList[i].zhengquandm);
    document.write("</a></td>");
    document.write("<td class=\"tdRightContent borderRight\">");
    //format number
    if (groupList[i].zhehegpsl.length == 0) {
        document.write("<span class=\"noPublic\">未公布</span>");
    } else {
        document.write(format(groupList[i].zhehegpsl));
    }
    document.write("</td>");
    document.write("<td class=\"tdRightContent borderRight\">");
    document.write(pointformat(groupList[i].zhanjijjzbl,2));
    document.write("</td>");
    document.write("<td class=\"tdRightContent borderRight\">");
    //format number
    if (groupList[i].zhangegultszbl == 0) {
        document.write("<span class=\"noPublic\">未公布</span>");
    } else {
        document.write(pointformat(groupList[i].zhangegultszbl,4));
    }
    document.write("</td>");
    document.write("<td valign=\"middle\" class=\"tdRightContent borderBottomGd tdContentTop\" rowspan=\"" + (groupList[i].holdFunds.length + 1) + "\">");
    if (groupList[i].zhangegultszblSum == 0) {
        document.write("<span class=\"noPublic\">未公布</span>");
    } else {
        document.write(pointformat(groupList[i].zhangegultszblSum,4));
    }
    document.write("</td>");
    document.write("</tr>");
    for(var j = 0;j < groupList[i].holdFunds.length;j ++) {
      if(i%2==0){
        document.write("<tr class=\"tbbg\">");
      }else{
        document.write("<tr class=\"tbbg2\">");
      }
      document.write("<td class=\"tdLeftContent3 borderRight\">");
      document.write(groupList[i].holdFunds[j].jijinjc);
      document.write("</td>");
      document.write("<td class=\"tdLeftContent3 borderRight\">");
      document.write("<a class=\"reportLink\" href=\"javascript:changeFundCode('"+groupList[i].holdFunds[j].zhengquandm+"');\">");
      document.write(groupList[i].holdFunds[j].zhengquandm);
      document.write("</a></td>");
      document.write("<td class=\"tdRightContent borderRight\">");
      //format number
      if (groupList[i].holdFunds[j].zhehegpsl.length == 0) {
        document.write("<span class=\"noPublic\">未公布</span>");
      } else {
        document.write(format(groupList[i].holdFunds[j].zhehegpsl));
      }
      document.write("</td>");
      document.write("<td class=\"tdRightContent borderRight\">");
      document.write(pointformat(groupList[i].holdFunds[j].zhanjijjzbl,2));
      document.write("</td>");
      document.write("<td class=\"tdRightContent borderRight\">");
      if (groupList[i].holdFunds[j].zhangegultszbl == 0) {
        document.write("<span class=\"noPublic\">未公布</span>");
      } else {
        document.write(pointformat(groupList[i].holdFunds[j].zhangegultszbl,4))
      }
      document.write("</td>");
      document.write("</tr>");
    }
  }
}

function getReportService() {
  return "http://stockdata.caixun.com";
}

function obtainStylePara() {
  var htmlCss = "";
  try{
    var paramStr = getUrlParamStr();    
    htmlCss = getParamValue("style",paramStr);
    if (null == htmlCss || htmlCss.length <= 0) {
      if(parent.parent.document.getElementById("menuCss")) {
        htmlCss=parent.parent.document.getElementById("menuCss").value;
      } else if(parent.document.getElementById("menuCss")) {
        htmlCss=parent.document.getElementById("menuCss").value;
      } else {
        htmlCss=opener.parent.parent.document.getElementById("htmlCss").value;
      }
      htmlCss = htmlCss.substr(1);
    }
  }catch(E){
    try{
      htmlCss=opener.parent.document.getElementById("menuCss").value;
      htmlCss = htmlCss.substr(1);
    }catch(E){
    }
  }
  if (null != htmlCss && htmlCss.length > 0) {
    htmlCss = "style=" + htmlCss;
  }
  return htmlCss;
}
function showReportDetail(type,reportid,companyid,ddate) {
  if("null"==type && reportid=="null")
    return;
  var url;
  var feature;
  var stylePara = "";
  if (type=='TXT') {
    stylePara = obtainStylePara();
  }
  if(type=='TXT' || type=='PDF'){
     url = getReportService()+"/bgdata/reportServlet?type=" + type + "&reportid=" + reportid;
     feature ='fullscreen=1,toolbar=no,menubar=yes,resizeable=yes,scrollbars=no,location=no,status=no';
  }else if(type=='0'){
     url = getReportService()+"/bgdata/reportServlet?flag=" + type + "&companyid="+companyid.value+"&reportid=" + reportid.value;
     feature ='fullscreen=1,toolbar=no,menubar=yes,resizeable=yes,scrollbars=no,location=no,status=no';
  }else{
     url = getReportService()+"/bgdata/reportServlet?flag=" + type + "&companyid="+companyid.value+"&reportid=" + reportid.value + "&ddate="+ddate.value;
     feature ='fullscreen=1,toolbar=no,menubar=yes,resizeable=yes,scrollbars=no,location=no,status=no';
  }
  window.open(url + "&" + stylePara,"","");
}
function showSpecialReportDetail(type,reportid) {
  if("null"==type && reportid=="null")
    return;
  var url;
  var feature;
  var stylePara = "";
  if (type=='TXT') {
    Stylepara = obtainStylePara();
  }
  url = getReportService()+"/bgdata/reportServlet?type=" + type + "&reportid=" + reportid + "&flag=newdb";
  feature ='fullscreen=1,toolbar=no,menubar=yes,resizeable=yes,scrollbars=no,location=no,status=no';
  window.open(url + "&" + stylePara,"","");
}

//  光大银行公告 CEB Bank Report
//txtid 公告ID
function CEBReportById(txtid,flag){
  if("undefined"==typeof(txtid) || "" ==txtid)
    return;
  if("undefined"!=typeof(flag) || "" !=flag)
    url="http://stockdata.caixun.com/bgdata/reportServlet?type=TXT&flag=ceb&reportid="+txtid;
  else
    url=getContext()+"/reportServlet?type=TXT&flag=ceb&reportid="+txtid;
  window.open(url);
}

function initCEBReport(table){ 
	var rnum = table.rows.length;
	if(table.rows.length>10){
		var row = table.insertRow(10);   
		var cell = row.insertCell();
		cell = row.insertCell();   
		cell.height=24;
		cell.innerHTML = "&nbsp;";
		rnum = table.rows.length;
	}
  if(rnum<21){
  	for(i=rnum;i<21;i++){
			var row = table.insertRow();   
			var cell = row.insertCell();    
			cell = row.insertCell();   
			cell.height=24;
			cell.innerHTML = "&nbsp;"; 
		} 
  }
}
function SetWinHeight(obj) {
  try{
    var win=obj;
    if (document.getElementById){
      if (win && !window.opera){
        if (win.contentDocument && win.contentDocument.body.offsetHeight) {
          win.height = win.contentDocument.body.offsetHeight;
        } else if(win.Document && win.Document.body.scrollHeight) {
          win.height = win.Document.body.scrollHeight;
        }
      }
    }
  }catch(E){
    alert(E.message);
  }
}
function showContent(objName,titleObjName,pathflag,nameflag) {
  var obj = document.getElementById(objName);
  var titleObj = document.getElementById(titleObjName);
  var reportContent;
  var titleName;    
  if(typeof(titleObj.value)=='undefined'){
    titleName =  titleObj.innerHTML;
  }else{
    titleName = titleObj.value;     
  }
  titleName = replaceHtmlTag(titleName);
  if(typeof(nameflag) == 'undefined')
    titleName =document.getElementById("stockname").value + '-' + titleName;
  document.getElementsByName("_title")[0].value=titleName; 
  document.getElementsByName("_content")[0].value=obj.value;  
  var stylePara = obtainStylePara();
  feature='width=855px,height=561px,top=100,left=75,toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,status=no';
  window.open("../ViewContent.html?" + stylePara,'newwin',feature);  
}

function showNewsDetail(objName,titleObjName) {
  var NewsDetailFr;
  var obj = document.getElementById(objName);
  var titleObj = document.getElementById(titleObjName);
  var reportContent;
  var titleName;    
  if(typeof(titleObj.value)=='undefined'){
    titleName =  titleObj.innerHTML;
  }else{
    titleName = titleObj.value;     
  }
  titleName = replaceHtmlTag(titleName);

  document.getElementsByName("_title")[0].value=titleName; 
  document.getElementsByName("_content")[0].value=obj.value;  
  var stylePara = obtainStylePara();
  //feature='width=1000px,height=700px,top=70,left=25,toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,status=no';
  //window.open("../NewsDetail.html?" + stylePara,'newwin',feature);
  var w=document.body.clientWidth;
  var h=document.body.clientHeight;
  var h = screen_height;
  NewsDetailFr = document.createElement("iframe");
  NewsDetailFr.setAttribute("id","newwin");
  NewsDetailFr.setAttribute("name","newwin");
  NewsDetailFr.setAttribute("frameborder",0);
  NewsDetailFr.setAttribute("SCROLLING","YES");
  NewsDetailFr.setAttribute("width",w);
  NewsDetailFr.setAttribute("height",h);
  NewsDetailFr.setAttribute("title","<img height=20 src=\"../ico/shqh.ico\"/>&nbsp;详文");
  NewsDetailFr.setAttribute("src","../NewsDetail.html?" + stylePara);

  $(NewsDetailFr).dialog({width: w, height: h+28,position:[0,0],resizable:false});
}

function replaceHtmlTag(strValue) {
  var strResult = strValue.replace(/<BR>|<br>/,"");
  return strResult;
}
function showRatioContent(objValueId,objTitleID){
var objValue = document.getElementById(objValueId);
var objTitle = document.getElementById(objTitleID);
try{
 document.getElementsByName("_title")[0].value=objTitle.value;
 document.getElementsByName("_content")[0].value=objValue.value;
  var stylePara = obtainStylePara();
  feature='width=500px,height=360px,top=150,left=250,toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,status=no';
  window.open("../ViewRatioContent.html?" + stylePara,'newwin',feature);
  }catch(E){alert(E.message);}
}

function loadTables(_url,divId){
  try{
      var doc = importXML(_url);
      var divObj=document.getElementById(divId);
      if ((null != doc) && ("undefined" != typeof(doc))) {
        var tables=doc.selectNodes("//html/body/table");
        var text=tables[0].xml;
        for(var i=1;i<tables.length;i++)
          text += tables[i].xml;
        divObj.innerHTML=text;
      } else {
        divObj.innerHTML="";
      }
    }catch(exception){
      divObj.innerHTML="";
    }
}
function loadPageToDiv(_url,divId){
  try{
      var doc = importHTML(_url);
      var divObj=document.getElementById(divId);
      if ((null != doc) && ("undefined" != typeof(doc))) {
        divObj.innerHTML=doc;
      } else {
        divObj.innerHTML="";
      }
    }catch(exception){
      divObj.innerHTML="";
    }
}
function changeTDBGColor(obj,tabName,flag){
  var tab = document.getElementById(tabName);
  try{
   var rowsLen;
   if("undefined"==typeof(flag))
      rowsLen=tab.rows.length;
   else{
     if(1==flag || "1"==flag)
       rowsLen=tab.rows.length-1;
   }
    for(var i=2;i<rowsLen;i++){
      for(var j=0;j<tab.rows[i].cells.length;j++){
        var cssName=tab.rows[i].cells[j].className;
        if(cssName.indexOf("Focus")>0)
          tab.rows[i].cells[j].className=tab.rows[i].cells[j].className.replace("Focus","");
      }
    }
    for(var i=0;i<obj.cells.length;i++){
      var cssName=obj.cells[i].className;
      if(cssName.indexOf("Content3")>0 && cssName.indexOf("Focus")<0){
        obj.cells[i].className=obj.cells[i].className.replace("Content3","Content3Focus");
      }else if(cssName.indexOf("Content2")>0 && cssName.indexOf("Focus")<0){
        obj.cells[i].className=obj.cells[i].className.replace("Content2","Content2Focus");
      }else if(cssName.indexOf("Content")>0 && cssName.indexOf("Focus")<0){
        obj.cells[i].className=obj.cells[i].className.replace("Content","ContentFocus");
      }
    }
  }catch(E){alert(E.message);}
}
function initColor(tabName){
  var tab = document.getElementById(tabName);
    var text=tab.rows[2].cells[0].innerHTML;
    if(text=="" || "??"==text){
        return;
    }
    for(var i=0;i<tab.rows[2].cells.length;i++){
      tab.rows[2].cells[i].className=tab.rows[2].cells[i].className+"Focus";
    }
}
//摊薄 和 加权
function ProfigSharing(niandu,oneQuarter,twoQuarter,thrQuarter,fouQuarter,yearQuarter){
    this.niandu=niandu;
    this.oneQuarter=oneQuarter;
    this.twoQuarter=twoQuarter;
    this.thrQuarter=thrQuarter;
    this.fouQuarter=fouQuarter;
    this.yearQuarter=yearQuarter;
}
function writeData(dataSourceName,index,one,two,thr,fou){
    var dataSource = document.getElementById(dataSourceName);
    var list=new Array();
    var temp;
    var dataList=dataSource.getElementsByTagName('tr');
    var oldDate=null;

    for(var i=0;i<dataList.length;i++){
        if(null==oldDate){
            oldDate=dataList[i].cells[0].innerHTML;
            temp=new ProfigSharing();
            temp.niandu=dataList[i].cells[0].innerHTML;
        }
        if(oldDate!=dataList[i].cells[0].innerHTML){
            list.push(temp);
            temp=new ProfigSharing();
            oldDate=dataList[i].cells[0].innerHTML;
            temp.niandu=oldDate;
        }
        if(oldDate==dataList[i].cells[0].innerHTML){
            if(one==dataList[i].cells[1].innerHTML)
                temp.oneQuarter=dataList[i].cells[index].innerHTML;
            if(two==dataList[i].cells[1].innerHTML)
                temp.twoQuarter=dataList[i].cells[index].innerHTML;
            if(thr==dataList[i].cells[1].innerHTML)
                temp.thrQuarter=dataList[i].cells[index].innerHTML;
            if(fou==dataList[i].cells[1].innerHTML){
                temp.fouQuarter=dataList[i].cells[index].innerHTML;
                temp.yearQuarter=dataList[i].cells[4].innerHTML;
            }
        }
        if(i==(dataList.length-1)){
            list.push(temp);
        }
    }
    var num=0;
    for(var i=0;i<list.length;i++){
      num++;
        var year=list[i].niandu;
        var oneValue=parseFloat(list[i].oneQuarter);
        var twoValue=parseFloat(list[i].twoQuarter);
        var thrValue=parseFloat(list[i].thrQuarter);
        var fouValue=parseFloat(list[i].fouQuarter);
        var yearValue=parseFloat(list[i].yearQuarter);//年度派息/股(元)

        oneValue=(!isNaN(oneValue))?oneValue:"-";
        twoValue=(!isNaN(twoValue))?twoValue:"-";
        thrValue=(!isNaN(thrValue))?thrValue:"-";
        fouValue=(!isNaN(fouValue))?fouValue:"-";
        yearValue=(!isNaN(yearValue))?(yearValue/10):"-";
        
        if(i%2==0){
          document.write("<tr class=\"tbbg\">");
        }else{
          document.write("<tr class=\"tbbg2\">");
        }
        
        document.write("<td class=\"tdMiddleContent borderRight\">");
        document.write(year);
        document.write("</td>");
        document.write("<td class=\"tdRightContent borderRight\">");
        if(i==0 && oneValue=='-'){
          document.write("<span class=\"noPublic\">NaN</span>");
        }else{
          document.write(format(pointformat(oneValue,5)));
        }
        document.write("</td>");
        document.write("<td class=\"tdRightContent borderRight\">");
        if(i==0 && twoValue=='-'){
          document.write("<span class=\"noPublic\">NaN</span>");
        }else{
          document.write(format(pointformat(twoValue,5)));
        }
        document.write("</td>");
        document.write("<td class=\"tdRightContent borderRight\">");
        if(i==0 && thrValue=='-'){
          document.write("<span class=\"noPublic\">NaN</span>");
        }else{
          document.write(format(pointformat(thrValue,5)));
        }
        document.write("</td>");
        document.write("<td class=\"tdRightContent borderRight\">");
        if(i==0 && fouValue=='-'){
          document.write("<span class=\"noPublic\">NaN</span>");
        }else{
          document.write(format(pointformat(fouValue,5)));
        }
        document.write("</td>");
        document.write("<td class=\"tdRightContent\">");
        if(i==0 && yearValue=='-'){
          document.write("<span class=\"noPublic\">NaN</span>");
        }else{
          document.write(format(pointformat(yearValue,5)));
        }
        document.write("</td>");
        document.write("</tr>");
    }
    for(var i=num+1;i<=8;i++){
      if(i%2!=0){
        document.write("<tr class=\"tbbg\">");
      }else{
        document.write("<tr class=\"tbbg2\">");
      }
      document.write("<td class=\"borderRight\">&nbsp;");
      document.write("</td>");
      document.write("<td class=\"borderRight\">&nbsp;");
      document.write("</td>");
      document.write("<td class=\"borderRight\">&nbsp;");
      document.write("</td>");
      document.write("<td class=\"borderRight\">&nbsp;");
      document.write("</td>");
      document.write("<td class=\"borderRight\">&nbsp;");
      document.write("</td>");
      document.write("<td>&nbsp;");
      document.write("</td>");
          document.write("</tr>");
      }
}
//公告查询 纵比 横比
function companyReportQuery() {
  var paramStr = getUrlParamStr(); 
  if ("" != paramStr) {
    paramStr = "&"+paramStr;
  }
  document.write("<iframe width=\"100%\" height=\"650px\" frameborder=\"0\" scrolling=\"no\" src=\"" + getReportService() + "/bgdata/app?page=StockReportQuery&service=page" + paramStr + "\"> </iframe>");
}
function verticalComparison() {
  var stockcode = document.getElementById("stockcode").value;
  var stockname = document.getElementById("stockname").value;  
  var paramStr = getUrlParamStr(); 
  if ("" != paramStr) {
    paramStr = "&"+paramStr;
  }
  document.write("<table class=\"comparisonTable\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">");
  document.write("<tr width=\"100%\"><td width=\"100%\">");
  document.write("<iframe width=\"100%\" height=\"650px\" frameborder=\"0\" scrolling=\"no\" src=\"" + getReportService() + "/bgdata/app?page=VerticalComparison&amp;service=external&code=" + stockcode + "&stockname=" + stockname + paramStr + "\"> </iframe>");
  document.write("</td></tr>");
  document.write("</table>");
}

function horizontalComparison() {
  var stockcode = document.getElementById("stockcode").value;
  var stockname = document.getElementById("stockname").value;  
  var paramStr = getUrlParamStr(); 
  if ("" != paramStr) {
    paramStr = "&"+paramStr;
  }
  document.write("<table class=\"comparisonTable\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">");
  document.write("<tr width=\"100%\"><td width=\"100%\">");
  document.write("<iframe width=\"100%\" height=\"650px\" frameborder=\"0\" scrolling=\"no\" src=\"" + getReportService() + "/bgdata/app?page=HorizontalComparison&amp;service=external&code=" + stockcode + "&stockname=" + stockname + paramStr + "\"> </iframe>");
  document.write("</td></tr>");
  document.write("</table>");
}

function mastFundIndexInfo() {
  var cols = "8,43";
  //65536,69203,65562,69235 old 1A0001,399001,1B0008,399305
  var request_url = "/include/getMarket2.php?exchange=1&time=new&cols=" + cols + "&code=65536,69203,65562,69235&ran="+Math.random();
  var xmlhttp = getXMLHTTP();
  xmlhttp.onreadystatechange=function() {    
    if (xmlhttp.readyState==4) {
      if(xmlhttp.status==200){
        var quotationArray = splitQuotationArray(cols,xmlhttp.responseText);
        if (quotationArray.length = 4) {
          //沪市综指
          mastStockIndexInfo_1(quotationArray[0],"sh");
          //深市成指
          mastStockIndexInfo_1(quotationArray[1],"sz");
          //沪市基指
          mastStockIndexInfo_1(quotationArray[2],"shjj");
          //深市基指
          mastStockIndexInfo_1(quotationArray[3],"szjj");
        } else {
          document.getElementById("sh_12").innerHTML = "--"
          document.getElementById("sh_43").innerHTML = "--"
          document.getElementById("sz_12").innerHTML = "--"
          document.getElementById("sz_43").innerHTML = "--"
          document.getElementById("shjj_12").innerHTML = "--"
          document.getElementById("shjj_43").innerHTML = "--"
          document.getElementById("szjj_12").innerHTML = "--"
          document.getElementById("szjj_43").innerHTML = "--"
        }
      }
    }
  }
  xmlhttp.open("GET", request_url, true);
  xmlhttp.send("");
}
//行情条指数信息
function mastStockIndexInfo_1(results,indexName) {	
  document.getElementById(indexName + "_12").innerHTML = (""==results[8])?"--":results[8];
  document.getElementById(indexName + "_43").innerHTML = "";
  var col = document.createElement('font');
  if (parseFloat(results[43]) > 0) { 
    col.setAttribute('color','red');
    col.innerHTML = '↑' + results[43] + '%';
  } else if (parseFloat(results[43]) < 0) { 
    col.setAttribute('color',greenStyle);
    col.innerHTML = '↓' + results[43] + '%';
  } else {
    col.setAttribute('color','');
    col.innerHTML = (""==results[43])?"--":results[43] + '%';
  } 
  document.getElementById(indexName + "_43").appendChild(col);
}
//code:基金代码
//sign:查看类型，1.单屏
function openFundQuotation(code,sign) {
  //设置页面标题处显示的基金名称和代码  
  var fundname = document.getElementById("fundname");
  if ("undefined" == typeof(fundname) || "" == fundname.value) {
    fundname = getFundNameByCode(code);
  } else {
    fundname = fundname.value;    
  }
  
  document.getElementById("disfundname").innerHTML = ("<h2>" + fundname + "</h2> ");  
  document.getElementById("disfundcode").innerHTML = "（代码：" + code + "）"; 
  if (window.navigatorType.isIE) {
    document.getElementById("quotationinfo").innerText = "";
    document.getElementById("nowprice").innerText = "";
  } else {
    document.getElementById("quotationinfo").innerHTML = "";
    document.getElementById("nowprice").innerHTML = ""; 
  }
  
  var _doc = importXML("../OpenFundMarketInfo.xml");
  var xpath = "//base/list/row[./zhengquandm = '" + code + "']";
  var fundMarkINFNode = _doc.selectSingleNode(xpath);
  //最近净值
  var fundNetValueLast = null;
  //累计净值
  var fundNetValueSum = null;
  //基金规模
  var fundSize = null;
  //投资类型
  var fundType = null;
  //日增涨
  var fundIncreate = null;
  //日增涨率
  var fundIncreateRate = null;
  //累计增长率
  var fundIncreateRateSum = null;
  //累计分红
  var assignSum = null;
  //净值日期
  var fundNetDate = null;
  
  if (null != fundMarkINFNode && "undefined" != typeof(fundMarkINFNode)) {
    //最近净值
    fundNetValueLast = fundMarkINFNode.selectSingleNode("danweizcjz").text;
    //累计净值
    fundNetValueSum = fundMarkINFNode.selectSingleNode("leijizj").text;
    //基金规模
    fundSize = fundMarkINFNode.selectSingleNode("jijingm").text;
    //投资类型
    fundType = fundMarkINFNode.selectSingleNode("touzilx").text;
    //日增涨
    fundIncreate = fundMarkINFNode.selectSingleNode("danweizcjz_inc_range").text;
    //日增涨率
    fundIncreateRate = fundMarkINFNode.selectSingleNode("daily_inc_rate").text;
    if(!isNaN(parseFloat(fundIncreateRate))){
      fundIncreateRate=pointformat(parseFloat(fundIncreateRate),2);
    }
    //累计增长率
    fundIncreateRateSum = fundMarkINFNode.selectSingleNode("full_inc_rate").text;
    if(!isNaN(parseFloat(fundIncreateRateSum))){
      fundIncreateRateSum=pointformat(parseFloat(fundIncreateRateSum),2);
    }
    //累计分红
    assignSum = fundMarkINFNode.selectSingleNode("assignratesum").text;
    //净值日期
    fundNetDate = fundMarkINFNode.selectSingleNode("jiezhirq").text;
  }
  var nowprice = document.getElementById("nowprice");
  var fundNameCode = document.getElementById("fundNameCode");
  var thcell = document.createElement('th');
  var tdcell = document.createElement('td');
  //1.单屏机
  switch (sign){
  	case 1:
  		tdcell.innerHTML = (("" == fundIncreate)?"--":fundIncreate) + '（' + (("" == fundIncreateRate)?"--":pointformat(fundIncreateRate,2)) + '%）';
		  if(parseFloat(fundIncreate)>0) {
		    thcell.innerHTML = "<div><img src=\"../image/img_up.gif\" />" + fundNetValueLast + "</div>";
		    nowprice.className = "nowprice_up";
		  } else if(parseFloat(fundIncreate)<0) {
		    thcell.innerHTML = "<div><img src=\"" + imgDownPath + "\" />" + fundNetValueLast + "</div>";
		    nowprice.className = "nowprice_down";
		  } else {
		    thcell.innerHTML = "<div>" + fundNetValueLast + "</div>";
		    nowprice.className = "";
		  }
		  nowprice.appendChild(thcell);
		  nowprice.appendChild(tdcell);
		  //行情条信息
		  var innerHTMLTMP = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" + 
		                    "<tr>" + 
		                      "<td>单位净值（元）:" + (("" == fundNetValueLast)?"--":fundNetValueLast) + "</td>" + 
		                      "<td>单位累计净值（元）:" + (("" == fundNetValueSum)?"--":fundNetValueSum) + "</td>" + 
		                      "<td>累计净值增长率:" + (("" == fundIncreateRateSum)?"--":fundIncreateRateSum) + "%</td>" +
		                      "</tr><tr>" + 
		                      "<td>基金规模（亿份）:" + (("" == fundSize)?"--":dataRound(parseFloat(fundSize)/100000000)) + "</td>" + 
		                      "<td>累计分红额（元）:" + (("" == assignSum)?"--":dataRound(parseFloat(assignSum)/100)) + "</td>" + 
		                      "<td>投资类型:" + (("" == fundType)?"--":fundType) + "</td>"; 
		  innerHTMLTMP = innerHTMLTMP + "</tr></table>"
		  document.getElementById("quotationinfo").innerHTML = innerHTMLTMP;
  	break;
  	default:
  	  //document.getElementById("QuotationCodeName").innerHTML = "<div class=\"codename\"><table width=\"224\" border=\"0\" cellspacing=\"5\" cellpadding=\"0\"><tr><th width=\"109\" colspan=\"2\" id=\"disfundname\"></th></tr><tr><th width=\"109\" colspan=\"2\" id=\"disfundcode\"></th></tr><tr id=\"nowprice\" class=\"nowprice_up\"><th width=\"100\"></th><td width=\"109\"></td></tr></table></div>";

  		document.getElementById("StoImg").src = "http://gif.caixun.com/web2/stock/fund/current/day/"+ code +".gif"; 
  		tdcell.innerHTML = (("" == fundIncreate)?"--":fundIncreate) + '（' + (("" == fundIncreateRate)?"--":fundIncreateRate) + '%）';
		  if(parseFloat(fundIncreate)>0) {
		    fundNameCode.innerHTML = fundNameCode.innerHTML + "<span style='color:red'>" + fundIncreate + " " + fundIncreateRate + "%</span>";
		    thcell.innerHTML = "<div><img src=\"../image/img_up.gif\" />" + fundNetValueLast + "</div>";
		    nowprice.className = "nowprice_up";
		  } else if(parseFloat(fundIncreate)<0) {
		    fundNameCode.innerHTML = fundNameCode.innerHTML + "<span style='color:"+greenStyle+";'>"+fundIncreate + " " + fundIncreateRate + "%</span>";
		    thcell.innerHTML = "<div><img src=\"" + imgDownPath + "\" />" + fundNetValueLast + "</div>";
		    nowprice.className = "nowprice_down";
		  } else {
		    fundNameCode.innerHTML = fundNameCode.innerHTML + "<span>"+fundIncreate + " " + fundIncreateRate + "%</span>";
		    thcell.innerHTML = "<div>" + fundNetValueLast + "</div>";
		    nowprice.className = "";
		  }
		  nowprice.appendChild(thcell);
		  nowprice.appendChild(tdcell);
		  //行情条信息
		  var innerHTMLTMP = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" + 
		                    "<tr>" + 
		                      "<td>单位净值（元）:" + (("" == fundNetValueLast)?"--":fundNetValueLast) + "</td>" + 
		                      "<td>单位累计净值（元）:" + (("" == fundNetValueSum)?"--":fundNetValueSum) + "</td>" + 
		                      "<td>累计净值增长率:" + (("" == fundIncreateRateSum)?"--":fundIncreateRateSum) + "%</td>" +
		                      "</tr><tr>" + 
		                      "<td>基金规模（亿份）:" + (("" == fundSize)?"--":dataRound(parseFloat(fundSize)/100000000)) + "</td>" + 
		                      "<td>累计分红额（元）:" + (("" == assignSum)?"--":dataRound(parseFloat(assignSum)/100)) + "</td>" + 
		                      "<td>投资类型:" + (("" == fundType)?"--":fundType) + "</td>"; 
		  innerHTMLTMP = innerHTMLTMP + "</tr><tr><td colspan=\"3\" class=\"quotationdate\" >" + fundNetDate + "</td></tr></table>"
		  document.getElementById("quotationinfo").innerHTML = innerHTMLTMP;
		  document.getElementById("stotime").innerHTML = fundNetDate.substr(0,10);
		break;
  }
  
}

function closeFundQuotation(code,sign) {
  //设置页面标题处显示的基金名称和代码  
  var fundname = document.getElementById("fundname")
  if ("undefined" == typeof(fundname) || "" == fundname.value) {
    fundname = getFundNameByCode(code);
  } else {
    fundname = fundname.value;    
  }
  
  document.getElementById("disfundname").innerHTML = "<h2>" + fundname + "</h2>";  
  document.getElementById("disfundcode").innerHTML = "（代码：" + code + "）"; 
  
  var xmlhttp = getXMLHTTP();
  if("undefined"==typeof(sign) || "undefined"==typeof(code)){
    return;
  }
  
  var request_url;
  var cols;
  switch (sign){
    default: //封闭式
      cols = "3,4,5,6,8,11,12,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,39,40,41,43,47,49,51";
      request_url = "/include/getMarket2.php?exchange=1&cols=" + cols + "&code="+code+"&ran="+Math.random();
      break;
  }
  xmlhttp.onreadystatechange=function() {    
    if (xmlhttp.readyState==4) {
      if(xmlhttp.status==200){
        var quotationArray = splitQuotationArray(cols,xmlhttp.responseText);
        //清空       
        var quotationBar = document.getElementById("quotationinfo");
        if (null != quotationBar && "" != typeof(quotationBar)){
          if (window.navigatorType.isIE) {
            document.getElementById("quotationinfo").innerText = "";
            document.getElementById("nowprice").innerText = "";
          } else {
            document.getElementById("quotationinfo").innerHTML = "";
            document.getElementById("nowprice").innerHTML = ""; 
          }
        }
        switch (sign){
        	case 1:
        	 //获取发行份额
         
            //计算委差
            var maimaicha = quotationArray[0][49];
                        
            //计算量比            
            liangbi = dataRound(quotationArray[0][51]);
            
            //行情
            var thcell = document.createElement('th'); 
            var newPriceHtml = "最新价:" + quotationArray[0][8] + "涨跌幅:";
            var nowprice = document.getElementById("nowprice");
            var tdcell = document.createElement('td');   
            tdcell.innerHTML = (("" == quotationArray[0][47])?"--":quotationArray[0][47]) + '（' + ("" == quotationArray[0][43]?"--":quotationArray[0][43]) + '%）';
            if(parseFloat(quotationArray[0][43])>0) {            
              thcell.innerHTML = "<div><img src=\"../image/img_up.gif\" />" + quotationArray[0][8] + "</div>";
              newPriceHtml = newPriceHtml + "<span style='color:red'>↑"+quotationArray[0][43]+"%</span>";
              nowprice.className = "nowprice_up";
            } else if(parseFloat(quotationArray[0][43])<0) {              
              thcell.innerHTML = "<div><img src=\"" + imgDownPath + "\" />" + quotationArray[0][8] + "</div>";
              newPriceHtml = newPriceHtml + "<span style='color:"+greenStyle+"'>↓"+quotationArray[0][43]+"%</span>";
              nowprice.className = "nowprice_down";
            } else {              
              thcell.innerHTML = "<div>" + ("" == quotationArray[0][8]?"--":quotationArray[0][8]) + "</div>";
              newPriceHtml = newPriceHtml + "<span style='color:black'>"+("" == quotationArray[0][43]?"--":quotationArray[0][43])+"</span>";
              nowprice.className = "";
            }
            nowprice.appendChild(thcell);
            nowprice.appendChild(tdcell);
            //document.getElementById("newPriceMarkup").innerHTML = newPriceHtml;
            //行情条信息
            innerHTMLTMP = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" + 
                              "<tr>" + 
                                "<td>今开:" + (("" == quotationArray[0][4])?"--":quotationArray[0][4]) + "</td>" + 
                                "<td>最高价:" + (("" == quotationArray[0][5])?"--":quotationArray[0][5]) + "</td>" + 
                                "<td>成交额:" + (("" == quotationArray[0][14])?"--":dataRound(quotationArray[0][14]/10000)) + "万元</td>" + 
                                "<td>内盘:" + (("" == quotationArray[0][38])?"--":quotationArray[0][38]) + "</td>" + 
                                "<td>量比:" + (isNaN(liangbi)?"--":liangbi) + "</td>" +
                              "</tr><tr>" + 
                                "<td>昨收:" + (("" == quotationArray[0][11])?"--":quotationArray[0][11]) + "</td>" + 
                                "<td>最低价:" + (("" == quotationArray[0][6])?"--":quotationArray[0][6]) + "</td>" + 
                                "<td>成交量:" + (("" == quotationArray[0][12])?"--":dataRound(quotationArray[0][12],0)) + "手</td>" + 
                                "<td>外盘:" + (("" == quotationArray[0][39])?"--":quotationArray[0][39]) + "</td>";
            if (maimaicha > 0) {
              innerHTMLTMP = innerHTMLTMP + "<td>委差:" + maimaicha + "</td>"; 
            } else if (maimaicha < 0) {
              innerHTMLTMP = innerHTMLTMP + "<td>委差:" + maimaicha + "</td>"; 
            } else {
              innerHTMLTMP = innerHTMLTMP + "<td>委差:" + (isNaN(maimaicha)?"--":maimaicha) + "</td>"; 
            }                    
            //innerHTMLTMP = innerHTMLTMP + "</tr><tr><td colspan=\"5\" class=\"quotationdate\" >" + changeDate(quotationArray[0][3]) + "</td></tr></table>" 
            
            document.getElementById("quotationinfo").innerHTML = innerHTMLTMP;                        
        	break;
          default:          
            changImg(imgIndex,document.getElementById("fundcode").value);//画图
            
            //计算委差            
            var maimaicha = quotationArray[0][49];
                        
            //计算量比            
            liangbi = dataRound(quotationArray[0][51]);
            
            //行情
            var thcell = document.createElement('th'); 
            var newPriceHtml = "最新价:" + quotationArray[0][8] + " 涨跌幅:";
            var nowprice = document.getElementById("nowprice");
            var tdcell = document.createElement('td');   
            tdcell.innerHTML = (("" == quotationArray[0][47])?"--":quotationArray[0][47]) + '（' + ("" == quotationArray[0][43]?"--":quotationArray[0][43]) + '%）'; 
            if(parseFloat(quotationArray[0][43])>0) {
              document.getElementById("shangqi2_1").innerHTML = "<span style='color:red'>↑"+quotationArray[0][43]+"%</span>"; 
              document.getElementById("shangqi1_1").innerHTML = "<span style='color:red'>"+quotationArray[0][47]+"</span>";
              thcell.innerHTML = "<div><img src=\"../image/img_up.gif\" />" + quotationArray[0][8] + "</div>";
              newPriceHtml = newPriceHtml + "<span style='color:red'>↑"+quotationArray[0][43]+"%</span>";
              nowprice.className = "nowprice_up";
            } else if(parseFloat(quotationArray[0][43])<0) {
              document.getElementById("shangqi2_1").innerHTML = "<span style='color:"+greenStyle+"'>↓"+quotationArray[0][43]+"%</span>"; 
              document.getElementById("shangqi1_1").innerHTML = "<span style='color:"+greenStyle+"'>"+quotationArray[0][47]+"</span>";
              thcell.innerHTML = "<div><img src=\"" + imgDownPath + "\" />" + quotationArray[0][8] + "</div>";
              newPriceHtml = newPriceHtml + "<span style='color:"+greenStyle+"'>↓"+quotationArray[0][43]+"%</span>";
              nowprice.className = "nowprice_down";
            } else {
              document.getElementById("shangqi2_1").innerHTML = "<span style='color:black'>"+("" == quotationArray[0][43]?"--":quotationArray[0][43])+"</span>"; 
              document.getElementById("shangqi1_1").innerHTML = "<span style='color:black'>"+("" == quotationArray[0][47]?"--":quotationArray[0][47])+"</span>";
              thcell.innerHTML = "<div>" + ("" == quotationArray[0][8]?"--":quotationArray[0][8]) + "</div>";
              newPriceHtml = newPriceHtml + "<span style='color:black'>"+("" == quotationArray[0][43]?"--":quotationArray[0][43])+"</span>";
              nowprice.className = "";
            }
            nowprice.appendChild(thcell);
            nowprice.appendChild(tdcell);
            document.getElementById("newPriceMarkup").innerHTML = newPriceHtml;
            //行情条信息
            innerHTMLTMP = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" + 
                              "<tr>" + 
                                "<td>今开:" + (("" == quotationArray[0][4])?"--":quotationArray[0][4]) + "</td>" + 
                                "<td>最高价:" + (("" == quotationArray[0][5])?"--":quotationArray[0][5]) + "</td>" + 
                                "<td>成交额:" + (("" == quotationArray[0][14])?"--":dataRound(quotationArray[0][14]/10000)) + "万元</td>" + 
                                "<td>内盘:" + (("" == quotationArray[0][38])?"--":quotationArray[0][38]) + "</td>" + 
                                "<td>量比:" + (isNaN(liangbi)?"--":liangbi) + "</td>" +
                              "</tr><tr>" + 
                                "<td>昨收:" + (("" == quotationArray[0][11])?"--":quotationArray[0][11]) + "</td>" + 
                                "<td>最低价:" + (("" == quotationArray[0][6])?"--":quotationArray[0][6]) + "</td>" + 
                                "<td>成交量:" + (("" == quotationArray[0][12])?"--":dataRound(quotationArray[0][12],0)) + "手</td>" + 
                                "<td>外盘:" + (("" == quotationArray[0][39])?"--":quotationArray[0][39]) + "</td>";
            if (maimaicha > 0) {
              innerHTMLTMP = innerHTMLTMP + "<td>委差:<span class=\"up\">" + maimaicha + "</span></td>"; 
            } else if (maimaicha < 0) {
              innerHTMLTMP = innerHTMLTMP + "<td>委差:<span class=\"down\">" + maimaicha + "</span></td>"; 
            } else {
              innerHTMLTMP = innerHTMLTMP + "<td>委差:" + (isNaN(maimaicha)?"--":maimaicha) + "</td>"; 
            }                    
            innerHTMLTMP = innerHTMLTMP + "</tr><tr><td colspan=\"5\" class=\"quotationdate\" >" + changeDate(quotationArray[0][3]) + "</td></tr></table>" 
            document.getElementById("quotationinfo").innerHTML = innerHTMLTMP;
            document.getElementById("stotime").innerHTML = "[" + changeDate(quotationArray[0][3]) + "]";
            //个股走势行情信息设置
            if(parseFloat(quotationArray[0][4])>parseFloat(quotationArray[0][7])){
              document.getElementById("shangqi1_2").innerHTML = "<span style='color:red'>"+quotationArray[0][4]+"</span>";
            } else if (parseFloat(quotationArray[0][4])< parseFloat(quotationArray[0][7])) {
              document.getElementById("shangqi1_2").innerHTML = "<span style='color:"+greenStyle+"'>"+quotationArray[0][4]+"</span>";
            } else {
              document.getElementById("shangqi1_2").innerHTML = "<span style='color:black'>"+(("" == quotationArray[0][4])?"--":quotationArray[0][4])+"</span>"; 
            }
            //股票买卖
            var temp_mai = document.getElementsByName("maimai");
            //卖行情
            for(var i = 0;i < 5; i++) {
              var _index = i * 2
              temp_mai[_index].innerHTML = ("" == quotationArray[0][30 - i])?"--":quotationArray[0][30 - i];
              temp_mai[_index + 1].innerHTML = ("" == quotationArray[0][35 - i])?"--":quotationArray[0][35 - i];
            }
            //买行情
            for(var i = 0;i < 5; i++) {
              var _index = i * 2 + 10;
              temp_mai[_index].innerHTML = ("" == quotationArray[0][16 + i])?"--":quotationArray[0][16 + i];
              temp_mai[_index + 1].innerHTML = ("" == quotationArray[0][21 + i])?"--":quotationArray[0][21 + i];
            }
            //现价
            temp_mai[20].innerHTML = ("" == quotationArray[0][8])?"--":quotationArray[0][8];
            temp_mai[21].innerHTML = ("" == quotationArray[0][40])?"--":quotationArray[0][40];
              
            document.getElementById("shangqi2_2").innerHTML = ("" == quotationArray[0][5])?"--":quotationArray[0][5];
            document.getElementById("shangqi3_1").innerHTML = "--";
            document.getElementById("shangqi3_2").innerHTML = ("" == quotationArray[0][6])?"--":quotationArray[0][6];
            document.getElementById("shangqi4_1").innerHTML = ("" == quotationArray[0][12])?"--":quotationArray[0][12];
            document.getElementById("shangqi4_2").innerHTML = "--";
            document.getElementById("shangqi5_1").innerHTML = ("" == quotationArray[0][14])?"--":quotationArray[0][14];
            document.getElementById("shangqi5_2").innerHTML = ("" == quotationArray[0][38])?"--":quotationArray[0][38];
            document.getElementById("shangqi6_1").innerHTML = ("" == quotationArray[0][11])?"--":quotationArray[0][11];
            document.getElementById("shangqi6_2").innerHTML = ("" == quotationArray[0][39])?"--":quotationArray[0][39];
            document.getElementById("shangqi7_1").innerHTML = "--";
            document.getElementById("shangqi7_2").innerHTML = "--";
            //均价设置            
            if(parseFloat(quotationArray[0][4]) > 0) {
              document.getElementById("shangqi3_1").innerHTML = dataRound(parseFloat(quotationArray[0][14]) / parseFloat(quotationArray[0][12]) *100);//均价
            } else {
              document.getElementById("shangqi3_1").innerHTML = "--";
            }
            //设置委差
            if(maimaicha > 0) {
              document.getElementById("shangqi4_2").innerHTML = "<span style='color:red'>"+maimaicha+"</span>"; //委差
            } else if (maimaicha < 0 ) {
              document.getElementById("shangqi4_2").innerHTML = "<span style='color:"+greenStyle+"'>"+maimaicha+"</span>";//委差
            } else {
              document.getElementById("shangqi4_2").innerHTML = "<span style='color:black'>"+(isNaN(maimaicha)?"--":maimaicha)+"</span>";//委差
            }
            //设置换手率
            if(!isNaN(parseFloat(quotationArray[0][41]))) {
              var changelv =quotationArray[0][41];
              document.getElementById("shangqi7_1").innerHTML = changelv + '%';  //换手率
            } else {
              document.getElementById("shangqi7_1").innerHTML = "--";  //换手率
            } 
            //设置量比
            if(isFinite(liangbi)==true){
              if(liangbi != 0)
                document.getElementById("shangqi7_2").innerHTML=parseFloat(liangbi);//量比
              else document.getElementById("shangqi7_2").innerHTML="--";//量比
            }
            break;
        }        
      }
    } else {
    }
  }
  xmlhttp.open("GET", request_url, true);
  xmlhttp.send("");
}
function fundQuotation(code,sign) {
  switch (sign){
    case 2:
      openFundQuotation(code,sign);
      break;
    default:
      closeFundQuotation(code,sign);      
      setInterval("closeFundQuotation('" + code + "'," + sign + ")",reflashInterval);
      break;
  }
}
function showInfo(info,objValue,objName){
  if("undefined"==typeof(info) || "undefined"==typeof(objValue) || "undefined"==typeof(objName) )
    return;
  var name=objName.value.replace(/ |　/g,'');
  var value=objValue.value.substr(0,20).replace(/ |　/g,'');
  if(value.indexOf(name)>=0)
    info.innerHTML=objValue.value;
  else
    info.innerHTML="";
}
//其他重要事项
function writeOtherIBData(dataName){
  var data = document.getElementById(dataName);
  if(data.rows.length <= 0)
    return;

  var arrList=new Array();
  var rows=data.firstChild.rows;

  var tempDate=rows[0].cells[0].innerHTML;

  var cindex=0;
  var tindex=0;
  var line="\n--------------------------------------------------------------------\n";

  arrList[arrList.length++]=rows[0];
  for(var i=1;i<rows.length;i++){
    if(tempDate==rows[i].cells[0].innerHTML){
      arrList[arrList.length++]=rows[i];
      continue;
    }else{

      arrList.sort(
          function (a,b){
            var aStr=a.cells[1].innerHTML;
            var bStr=b.cells[1].innerHTML;
            return aStr.localeCompare(bStr);
          }
        );

        var tempType=arrList[0].cells[1].innerHTML;

        var tempContent=document.getElementById(arrList[0].cells[2].innerHTML).value;
        for(var j=1;j<arrList.length;j++){
            if(tempType==arrList[j].cells[1].innerHTML){
                tempContent=tempContent+line+document.getElementById(arrList[j].cells[2].innerHTML).value;
            }else{
              writeOtherIBTR(tempDate,tempType,tindex,cindex,tempContent);
              tindex++;
              cindex++;

              tempType=arrList[j].cells[1].innerHTML;
              tempContent=document.getElementById(arrList[j].cells[2].innerHTML).value;
          }
        }
        writeOtherIBTR(tempDate,tempType,tindex,cindex,tempContent);
          tindex++;
          cindex++;

        arrList=new Array();
      arrList[arrList.length++]=rows[i];
      tempDate=rows[i].cells[0].innerHTML;
    }
  }

   arrList.sort(
          function (a,b){
            var aStr=a.cells[1].innerHTML;
            var bStr=b.cells[1].innerHTML;
            return aStr.localeCompare(bStr);
          }
        );

        var tempType=arrList[0].cells[1].innerHTML;
        var tempContent=document.getElementById(arrList[0].cells[2].innerHTML).value;

        for(var j=1;j<arrList.length;j++){
            if(tempType==arrList[j].cells[1].innerHTML){
                //alert(j+":"+tempContents);
                tempContent=tempContent+line+document.getElementById(arrList[j].cells[2].innerHTML).value;

            }else{
              writeOtherIBTR(tempDate,tempType,tindex,cindex,tempContent);
              tindex++;
              cindex++;

              tempType=arrList[j].cells[1].innerHTML;
              tempContent=document.getElementById(arrList[j].cells[2].innerHTML).value;
          }
        }
        writeOtherIBTR(tempDate,tempType,tindex,cindex,tempContent);
}
function writeOtherIBTR(tempDate,tempType,tindex,cindex,tempContent){
try{
  if(tindex%2==0){
    document.write("<tr id=\"tr1\" jwcid=\"buyLoop\" class=\"tbbg\">");
  }else{
    document.write("<tr id=\"tr1\" jwcid=\"buyLoop\" class=\"tbbg2\">");
  }
  
  if(null!=tempContent && ""!=tempContent && "undefined"!=typeof(tempContent)){
      document.write("<td class=\"tdMiddleContent borderRight\">");
      document.write(tempDate);
      document.write("</td>");
      document.write("<td class=\"tdLeftContent3 reportTitle\">");
      document.write("<a class=\"reportLink\" href=\"javascript:showContent('cbusinesscontent"+cindex+"','cbusinesstypename"+tindex+"');\">");
      document.write(tempType);
      document.write("</a>");
      document.write("<input type=\"hidden\" name=\"cbusinesstypename"+tindex+"\" value=\""+tempType+"\"/>");
      document.write("<input type='hidden' name='cbusinesscontent"+cindex+"' value='"+tempContent+"'/>");
      document.write("</td>");
  }else{
      document.write("<td class=\"tdMiddleContent borderRight\">");
      document.write(tempDate);
      document.write("</td>");
      document.write("<td class=\"tdLeftContent3 reportTitle\">");
      document.write(tempType);
      document.write("</td>");
  }
  document.write("</tr>");

}catch(E){alert(E.message);}
}

function selectFund() {
  var feature='width=500px,height=360px,top=150,left=250,toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,status=no';
  if( window.navigatorType.isIE ) {
    var code = window.showModalDialog("../tree.html",'',feature);  
    if ("undefined" != code) {  
      setSelectCode(code);
    }
  } else {
    window.open('../tree.html','newwin','modal=yes,width=422,height=450,top=150,left=250,dialog=yes');
  }
}
function setSelectCode(code) {
  var inputObj = document.getElementById('inputcode');
  if (null != code && code.length > 0) {
      inputObj.value = code;
      //window.open("http://funds.caixun.com/fundsdata/" + code + "/LastNewOverView.shtm","_self");
      window.open(getContext() + "/" + code + "/LastNewOverView.shtm","_self");
  }  
}
function FormateTime(time){
    var newtime ;
    var tlength = time.length;
    var count = 0;
    for(var i=0;i<tlength;i++){
        if(time.charCodeAt(i)==32){
            count++;
        }
    }
    if(count != tlength){
        if(tlength == 6){
          if(time.charAt(0) == '0')
            newtime = "20" + time.substring(0,2) + '-' + time.substring(2,4) + '-' + time.substring(4);
          else
            newtime = "19" + time.substring(0,2) + '-' + time.substring(2,4) + '-' + time.substring(4);
        }

        if(tlength == 8){
          if(time.indexOf('/') == 2   || time.indexOf('\\') == 2 || time.indexOf('_') == 2 || time.indexOf('.') == 2 || time.indexOf('-') == 2){
            if(time.charAt(0) == '0')
              newtime = "20" + time.substring(0,2) + '-' + time.substring(3,5) + '-' + time.substring(6);
            else
              newtime = "19" + time.substring(0,2) + '-' + time.substring(3,5) + '-' + time.substring(6);
          }
          else{
            newtime = time.substring(0,4) + '-' + time.substring(4,6) + '-' + time.substring(6,8);
          }
        }
        if(tlength == 10){
          if(time.indexOf('/') == 4  || time.indexOf('\\') == 4 || time.indexOf('_') == 4 || time.indexOf('.') == 4 || time.indexOf('-') == 4)
            newtime = time.substring(0,4) + '-' + time.substring(5,7) + '-' + time.substring(8,10);
          if(time.indexOf('/') == 2 || time.indexOf('\\') == 2 || time.indexOf('_') == 2 || time.indexOf('.') == 2 || time.indexOf('-') == 2)
            newtime = time.substring(6,10) + '-' + time.substring(0,2) + '-' + time.substring(3,5);
        }
    }else{
        newtime = null;
    }
    if(newtime != null)
      document.write(newtime);
    else
      document.write(time);
  }
function visitedLink(objid){
/*
  try{
    var obj=document.getElementById(objid);
    var temphref=obj.href;
    obj.href="javascript:void(0);";
    if (window.navigatorType.isIE)
      obj.click();
    obj.href=temphref;
  }catch(E){alert(E.message);}
*/  
}
function specialTransform(tab,flagChar,flag) {
  var rows=tab.rows;
  for(var i=0;i<rows.length;i++){
    var cols=rows[i].cells;
    for(var j=0;j<cols.length;j++){
      var txt=cols[j].innerHTML.replace(/[,\s　]/g,"");
      if(!isNaN(txt))
          if(parseFloat(txt)==0)
            cols[j].innerHTML=flagChar;
      if(1==flag){
        if(i==12 || i==13 || i==14){
          if(cols[j].innerHTML==flagChar){
            var spanEle=document.createElement("span");
            spanEle.className="noPublic";
            spanEle.innerHTML="NaN";
            cols[j].appendChild(spanEle);
          }
        }
      }
    }
  }
}

function redirectCompReport(){
  var feature='toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,status=no';
   var paramStr = getUrlParamStr();
  if(""==paramStr)
  	window.open(getReportService() + "/bgdata/app?page=StockReportQuery&service=page",'newwin',feature);
  else
  	window.open(getReportService() + "/bgdata/app?page=StockReportQuery&service=page&"+paramStr,'newwin',feature);
}

function redirectFundReport(){
  var feature='toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,status=no';
  var paramStr = getUrlParamStr();
  if(""==paramStr)
  	window.open(getReportService() + "/bgdata/app?page=FundReportQuery&service=page",'newwin',feature);
  else
  	window.open(getReportService() + "/bgdata/app?page=FundReportQuery&service=page&"+paramStr,'newwin',feature);
}
function getDisplayUrl() {
    var display = document.getElementById("Display");
    var url = "";
    if ("undefined" == typeof display.document) {
         url = display.contentWindow.location.href;
    } else {
         url = document.Display.location.href;
    }
    return url;
}
function RefreshSession(){
  var xmlhttp = getXMLHTTP();
  xmlhttp.onreadystatechange=function() {
    if(xmlhttp.readyState==4) {
      if(xmlhttp.status==200){
      }
      if(xmlhttp.status==404){
      }
    }
  }
  xmlhttp.open("GET","/bgdata/app?service=page&page=Refresh&sp="+(new Date()).getTime(),true);
  xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  xmlhttp.send(null);
  setTimeout("RefreshSession()",600000);
}

function writeWithServiceType(sType,iSize,iTitleSize,objId){
  if (null == iSize) {
    iSize=7;
  } 
  try{
    //获取基金代码、名称
    var ccode = document.getElementById("fundcode").value;
    var cname = "";
    if ("undefined" == typeof(ccode) || "" == ccode) {
      ccode = getCodeFromUrl();
      cname = getStockNameByCode(ccode);
    } else {
      cname = document.getElementById("fundname").value;
    }
    if(null == ccode || null == cname) {
      return;
    }
    var tmpName = toDBCorCDB(cname);
    if ("" != tmpName) {
      cname = cname + "," + tmpName;
    }
    //获取指定类型的相关新闻
    var xmlUrl= "/search_in_trs.php?fundCode="+ccode+"&fundName="+cname+"&type="+sType+"&size="+iSize + "&content=0&time=" + (new Date()).getTime();    
    var xmlDoc=null;
    var xmlhttp = getXMLHTTP(); 
    xmlhttp.onreadystatechange=function() {
      if(xmlhttp.readyState==4) {
        if(xmlhttp.status==200){
          if (window.navigatorType.isIE) {
            xmlDoc = xmlhttp.responseXML;
          } else {
            var parser = new DOMParser();
            xmlDoc = parser.parseFromString(xmlhttp.responseText, "text/xml");
          }
          drawRealatedNews(xmlDoc,sType,iTitleSize,iSize,objId);
        }else if(xmlhttp.status==404){
        }
      }
    }
    xmlhttp.open("GET", xmlUrl,true);
    xmlhttp.send(null);
  }catch(exception){
    alert(exception.message);
  }
}

function drawRealatedNews(xmlDoc,sType,iTitleSize,iSize,objId) {
  var parentObj = document.getElementById(objId);
  var newsElementes = xmlDoc.selectNodes("//root/articles/article");
  var tempHtml = "";
  var id,title;
  for(var i=0;i<newsElementes.length;i++) {
    id = newsElementes[i].getAttribute('id');
    title = newsElementes[i].childNodes[0].text;
    tempHtml = tempHtml + divisionNewsURL(id,title,iTitleSize);
  }
  for(var i=newsElementes.length;i<iSize;i++) {
    tempHtml = tempHtml + "<li>";
  }
  parentObj.innerHTML = tempHtml;
}
function divisionNewsURL(id,title,iTitleSize){
  var result = "<li>·<a href=\"http://content.caixun.com/";
  result = result + id.substr(0,2) + "/" + 
                    id.substr(2,2) + "/" + id.substr(4,2) + "/" + 
                    id + ".shtm\" target=\"_blank\">" + 
                    (iTitleSize>title.length?title:(title.substr(0,iTitleSize) + "....")) + 
                    "</a>";
  return result;
}
function moreNews(sType) {
  //获取股票代码、名称
  var ccode = document.getElementById("fundcode").value;
  var cname = "";
  if ("undefined" == typeof(ccode) || "" == ccode) {
    ccode = getCodeFromUrl();
    cname = getStockNameByCode(ccode);
  } else {
    cname = document.getElementById("fundname").value;
  }
  var _url = "http://funds.caixun.com/include/newsList.php?code=" + ccode + "&name=" + cname;
  if ("industry" == sType) {
    _url = _url + "&type=analyzeResearch";
  } else if ("analyse" == sType) {
    _url = _url + "&type=industryInfo";
  } 
  window.open(_url,"_moreNews");
}
//---获取url参数
function getParameter(name,url){
  if("undefined"==typeof(url) || null==url)
    url=document.location.search;
  if("undefined"==typeof(name) || null==name)
    return null;
  var regExp = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  var result = url.substr(url.indexOf("\?")+1).match(regExp);
  if(null != result)
    return unescape(result[2]);
  else
    return null;
}

function getUrlParamStr() {
  var paramStr = "";
  var _url = window.location.toString();
  var iStart = _url.indexOf('?');
  if (iStart > 0){
    paramStr = _url.substr(iStart + 1);
  }
  return paramStr;
}

function getParamValue(paraName,paraStr) {
  var paraValue = "";
  var paraReg = new RegExp(paraName + "=[A-Za-z0-9_]+");
  var paras = paraReg.exec(paraStr);
  if (null != paras) {
    paraValue = paras[0].split("=")[1];
  }
  return paraValue;
}

function showTable(prefix,id,count){
  var tab=document.getElementById(id);
  for(var i=1;i<=count;i++){
    document.getElementById(prefix+i).style.display="none";
  }
  tab.style.display="";
}

function initialize() {
  if(parent && parent.parent) {
    parent.parent.scroll(0,0);
  }
}


function changeViewBGColor(obj){
  if(obj.className=='tendencypic1Bt' || obj.className=='tendencypic2Bt'){
    return;
  }
  if(obj.className=='tendencypicBt1Down'){
    obj.className='tendencypicBt1Up';
  }else if(obj.className=='tendencypicBt1Up'){
    obj.className='tendencypicBt1Down';
  }else if(obj.className=='tendencypicBt2Down'){
    obj.className='tendencypicBt2Up';
  }else{
    obj.className='tendencypicBt2Down';
  }
}

function changeClassName(obj,idx){
  document.getElementById('bt1').className='tendencypicBt1Down';
  document.getElementById('bt2').className='tendencypicBt1Down';
  document.getElementById('bt3').className='tendencypicBt1Down';
  document.getElementById('bt4').className='tendencypicBt1Down';
  document.getElementById('bt8').className='tendencypicBt2Down';
  if(idx==0){
    obj.className = 'tendencypic1Bt';
  }else{
    obj.className = 'tendencypic2Bt';
  } 
}
function toDBCorCDB(str) {
  var result = "";
  var reDBC = /[ａ-ｚＡ-Ｚ]+/g;
  var reCDB = /[a-zaA-Z]+/g;
  //判断字符串含全角还是半角
  if(str.match(reDBC)) {
    result = ToCDB(str);
  } else if(str.match(reCDB)) { 
    result = ToDBC(str);
  }
  return result;
}
//半角转换为全角函数 
function ToDBC(txtstring) { 
  var tmp = "";
  for(var i=0;i<txtstring.length;i++) { 
    if(txtstring.charCodeAt(i)==32) { 
      tmp= tmp+ String.fromCharCode(12288); 
    } 
    if(txtstring.charCodeAt(i)<127) { 
      tmp=tmp+String.fromCharCode(txtstring.charCodeAt(i)+65248); 
    }  
  } 
  return tmp; 
} 

//全角转换为半角函数 
function ToCDB(str) { 
  var tmp = ""; 
  for(var i=0;i<str.length;i++) { 
    if(str.charCodeAt(i)>65248&&str.charCodeAt(i)<65375) { 
      tmp += String.fromCharCode(str.charCodeAt(i)-65248); 
    } else { 
      tmp += String.fromCharCode(str.charCodeAt(i)); 
    } 
  } 
  return tmp 
}
var oldCenterHeight=null;
var menu_flag=false;
var pageType_flag=false;//个股走势标识。
function setMenuHeight(){
	var lefto=document.getElementById("menu_height");
	var centero=document.getElementById("content_div");
	var leftTop=document.getElementById("menutop");
	var leftBottom=document.getElementById("menubot");
	
	var leftH=lefto.offsetHeight+leftTop.offsetHeight+leftBottom.offsetHeight;
	if(!pageType_flag){
		var _url = window.location.toString();
	  var marketParasReg = new RegExp("act_img");
	  if(null != marketParasReg.exec(_url)) {
	    pageType_flag=true;
	    return;
	  }
  }
	if(!menu_flag && null==oldCenterHeight){
		oldCenterHeight=centero.offsetHeight;
		menu_flag=true;
	}
	
	if(leftH==oldCenterHeight){
		centero.style.height=oldCenterHeight+"px";
	  return;
	}else if(leftH>oldCenterHeight){
		document.getElementById("menu_patch").style.height=0+"px";
		centero.style.height=document.getElementById("menu_div").offsetHeight+"px";
	}else{
		document.getElementById("menu_patch").style.height=(oldCenterHeight-leftH)+"px";
		centero.style.height=oldCenterHeight+"px";
	}
}

function changetags(id){
  var div1=document.getElementById("changDiv1");
  var div2=document.getElementById("changDiv2");
  var tdColor1=document.getElementById("tdColor1");
  var tdColor2=document.getElementById("tdColor2");
  var span1=document.getElementById("span1");
  var span2=document.getElementById("span2");
  if(id == 'changDiv1'){
    div1.style.display="";
    div2.style.display="none";
    tdColor1.className="tdSpan1 tdSpanWidth1";
    tdColor2.className="tdSpan2 tdSpanWidth2";
    span1.className="span1";
    span2.className="span2";
  }else{
    div1.style.display="none";
    div2.style.display="";
    tdColor1.className="tdSpan2 tdSpanWidth1";
    tdColor2.className="tdSpan1 tdSpanWidth2";
    span1.className="span2";
    span2.className="span1";
  } 
}
  
function doOpenFilter(type,_url,flag){
	var checkbool = true;
  if((type==1 || type==3) && document.getElementById("companyValue"+flag).value=='' && document.getElementById("typeValue"+flag).value==''&& document.getElementById("sizeValue"+flag).value==''){
      checkbool = false;
  }else if(type==2 && document.getElementById("companyValue"+flag).value=='' && document.getElementById("typeValue"+flag).value==''&& document.getElementById("sizeValue"+flag).value=='' && document.getElementById("rateValue"+flag).value==''){
  		checkbool = false;
  }
  if(!checkbool){
  	alert("请选择查询条件！");
  	return false;
  }
 	_url = _url.replace('&company=&','&').replace('&type=&','&').replace('&size=&','&').replace('&rate=&rateType=T3&','&');
 	if(type!=3){
  	window.open(encodeURI(_url));
  }else{
  	var NewsDetailFr;
	  var w=document.body.clientWidth;
		var h=screen_height;
	  NewsDetailFr = document.createElement("iframe");
	  NewsDetailFr.setAttribute("id","newwin");
	  NewsDetailFr.setAttribute("name","newwin");
	  NewsDetailFr.setAttribute("frameborder",0);
		NewsDetailFr.setAttribute("scrolling","no");
		NewsDetailFr.setAttribute("width",w);
		NewsDetailFr.setAttribute("height",h);
		NewsDetailFr.setAttribute("title","<img height=20 src=\"../ico/shqh.ico\"/>&nbsp;基金筛选结果");
		NewsDetailFr.setAttribute("src",encodeURI(_url));
	
		$(NewsDetailFr).dialog({width: w, height: h+28,position:[0,0],resizable:false});
  }
}

function loadFundImg(){
}
function loadScript(sId,url){
	if(document.getElementById(sId)!=null){
		return;
	}
  var xmlhttp = getXMLHTTP();
  xmlhttp.open("GET",url, false);
  xmlhttp.send("");
  if (xmlhttp.readyState==4) {
    if(xmlhttp.status==200){
      includeJS(sId,url,xmlhttp.responseText);
      new actb(document.getElementById('inputcode'),fundArray);
    }
  }
}
function includeJS(sId,fileUrl,source) { 
  if(source != null){
    var oHead = document.getElementsByTagName('HEAD').item(0); 
    var oScript = document.createElement("script"); 
    oScript.language = "javascript"; 
    oScript.type = "text/javascript"; 
    oScript.id = sId; 
		oScript.charset= 'UTF-8';
    oScript.defer = true; 
    oScript.text = source; 
    oHead.appendChild(oScript); 
  } 
} 
//check the html file.
function existsHtml(htmlFile){
	var xmlhttp = getXMLHTTP();
  var xmlDoc=null;
  xmlhttp.open("GET",htmlFile, false);
  xmlhttp.send("");
  if (xmlhttp.readyState==4) {
    if(xmlhttp.status==200){      
      return true;
    }else if(xmlhttp.status==404){
      return false;
    }
  }
}
function fundTradeError(){
	if(!existsHtml("../OpenFundNetvalueIncRate.html")){
		    document.getElementById("OpenFundNetvalueIncRate").innerHTML="<span class=\"sectionTitle tdLeftText2 sectionLeftTitle\">开基日增长率前十名</span><br />&nbsp;&nbsp;&nbsp;该基金暂无此数据";
	 }
	  if(!existsHtml("./fundAssetSummary.html")){
	    document.getElementById("fundAssetSummary").setAttribute("align","left");
	    document.getElementById("fundAssetSummary").innerHTML="<span class=\"sectionTitle tdLeftText2 sectionLeftTitle\">资产配置</span><br />&nbsp;&nbsp;&nbsp;该基金暂无此数据<br/><br/><br/><br/>";  
	  }
	  
	  if(!existsHtml("./StockCompagesLast.shtm")){
	    document.getElementById("fundConstitue").setAttribute("align","left");
	    document.getElementById("fundConstitue").innerHTML="<span class=\"sectionTitle tdLeftText2 sectionLeftTitle\">基金重仓持股</span><br />&nbsp;&nbsp;&nbsp;该基金暂无此数据";  
	  }
	  
}
function updateFundNetValueIncRate(){
	var cols="0,1,13,15,29,50";
	var request_url = getContext()+"/getData.php?type=861-1&code=10&cols="+cols+"&ran="+Math.random();
  var xmlhttp = getXMLHTTP();
  var fundTab=document.getElementById("openFundNetValue");
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4) {
      if(xmlhttp.status==200){
        var dataArray = splitQuotationArray(cols,xmlhttp.responseText);
        if(0==dataArray.length) return;
        for(var i=2;i<fundTab.rows.length;i++){
        	fundTab.rows[i].cells[0].innerHTML=i-1;
        	fundTab.rows[i].cells[1].innerHTML=dataArray[i-2][1];
        	fundTab.rows[i].cells[2].innerHTML=dataArray[i-2][13];
        	fundTab.rows[i].cells[3].innerHTML='<span class="up">↑'+dataArray[i-2][15]+'%</span>';
        }
      }
    }
  }
  xmlhttp.open("GET", request_url, true);
  xmlhttp.send("");
}