﻿//大中小字体控制
function SmallFont(){
    document.getElementById("Content").style.fontSize="12px";
}
function NormalFont(){
    document.getElementById("Content").style.fontSize="14px";
}
function BigFont(){
    document.getElementById("Content").style.fontSize="16px";
}
//嵌入Flash
function flash(name,w,h){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'">');
	document.write('<param name="movie" value="'+name+'">');
	document.write('<param name="quality" value="best">');
	document.write('<param name="wmode" value="Transparent">');
	document.write('<embed src="'+name+'" quality="best" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="Transparent" width="'+w+'" height="'+h+'"></embed>');
	document.write('</object>');
}
//页签控制
function SetBar(PrefixID,CurrentNo,Count,AClassName1,AClassName2)
{	
    
	for(i=1;i<=Count;i++)
	{
	    var DivName = PrefixID+i;
	    var CtlName = PrefixID+"A"+i;	    
	    var obj = document.getElementById(DivName);
		if(i==CurrentNo)
		{		    
			//obj.className=DivClassName;
			obj.style.display="";			
			document.getElementById(CtlName).className = AClassName1;
			
		}
		else
		{
			//obj.className="";
			document.getElementById(CtlName).className = AClassName2;
			obj.style.display="none";
		}
	}
}
//汇率显示
function DisplayRate(responseText,currencyPairs)
{
    if(responseText!="")
    {
         var Items = responseText.split(',');
         for(i=0;i<Items.length;i++)
         {
            var str = Items[i].split('|');
            if(str.length==11)
            {
                if(currencyPairs.indexOf(str[0])>=0)
                {                                
                    
                    if(str[1].split('=')[1]=='0')
                    {
                        document.getElementById(str[0]+'0').style.display = ""
                        document.getElementById(str[0]+'1').style.display = "none"
                    }
                    else
                    {
                        document.getElementById(str[0]+'1').style.display = ""
                        document.getElementById(str[0]+'0').style.display = "none"
                    }
                    document.getElementById(str[0]+"BID").innerHTML = str[2].split('=')[1];
                    document.getElementById(str[0]+'ASK').innerHTML = str[3].split('=')[1];
                }
            }
         }
    }           
}
function OutPutRate(responseText,currencyPairs,rowTemplate)
{
    rowTemplate ='<tr>';
    rowTemplate+='    <td height="40" align="center" class="borderBottom">';
    rowTemplate+='      <img src="/images/EUR.jpg" alt="EUR"  width="90" height="38" />';
    rowTemplate+='    </td>';
    rowTemplate+='    <td align="center" class="borderBottom">';
    rowTemplate+='      <img src="/images/USD.jpg"  alt="USD" width="90" height="38" />';
    rowTemplate+='    </td>';
    rowTemplate+='    <td align="center" class="borderBottom">';
    rowTemplate+='        <img alt=""  class="arraw" src="/images/upArraw.jpg" width="9" height="5" />';
    rowTemplate+='        <img alt=""  class="arraw" src="/images/downArraw.jpg" width="9" height="5" /> ';           
    rowTemplate+='    </td>';
    rowTemplate+='    <td align="center" class="borderBottom tabNote">';
    rowTemplate+='      BID';
    rowTemplate+='    </td>';
    rowTemplate+='    <td align="center" class="borderBottom tabNote">';
    rowTemplate+='      ASK';
    rowTemplate+='    </td>';
    rowTemplate+='    <td align="center" class="borderBottom tabNote">';
    rowTemplate+='      UPDOWN';
    rowTemplate+='    </td>';
    rowTemplate+='    <td align="center" class="borderBottom tabNote">';
    rowTemplate+='      UPDOWNPERCENT';
    rowTemplate+='    </td>';
    rowTemplate+='    <td align="center" class="borderBottom tabNote">';
    rowTemplate+='      TODAYOPENPRICE';
    rowTemplate+='    </td>';
    rowTemplate+='    <td align="center" class="borderBottom tabNote">';
    rowTemplate+='      HIGH';
    rowTemplate+='    </td>';
    rowTemplate+='    <td align="center" class="borderBottom tabNote">';
    rowTemplate+='      LOW';
    rowTemplate+='    </td>';
    rowTemplate+='    <td align="center" class="borderBottom tabNote">';
    rowTemplate+='      AMPLITUDE';
    rowTemplate+='    </td>';
    rowTemplate+='   <td align="center" class="borderBottom tabNote">';
    rowTemplate+='      LASTCLOSEPRICE';
    rowTemplate+='    </td>';
    rowTemplate+='    <td align="center" class="borderBottom tabNote">';
    rowTemplate+='      <a href="#">';
    rowTemplate+='        <img src="images/SJ_zst.jpg" width="23" height="23" border="0"  />';
    rowTemplate+='      </a>';
    rowTemplate+='    </td>';
    rowTemplate+='  </tr>';
}

function CreateTableRow(containerID,currencyPairs,responseText){
    var item = "";
    var CCY1="";
    var CCY2="";
    if(currencyPairs!="")
    {
         var CCYItems = currencyPairs.split(',');
         for(i=0;i<CCYItems.length;i++){
            
            CCY1 = CCYItems[i].substring(0,3);
            CCY2 = CCYItems[i].substring(3,6);
            if(CCY1=='') {
             continue;
            }
            item ='<tr id="'+containerID+CCY1+CCY2+'TR">';
            item+='    <td height="40" align="center" class="borderBottom">';
            item+='      <img src="/images/'+CCY1+'.gif" alt="'+CCY1+'"  width="90" height="38" />';
            item+='    </td>';
            item+='    <td align="center" class="borderBottom">';
            item+='      <img src="/images/'+CCY2+'.gif"  alt="'+CCY2+'" width="90" height="38" />';
            item+='    </td>';
            item+='    <td align="center" class="borderBottom">';
            item+='        <img alt=""  class="arraw" src="/images/upArraw.jpg" style="display:none;" id="'+containerID+CCY1+CCY2+'TICKBID1" width="9" height="5" />';
            item+='        <img alt=""  class="arraw" src="/images/downArraw.jpg" style="display:none;" id="'+containerID+CCY1+CCY2+'TICKBID0" width="9" height="5" /> ';           
            item+='    </td>';
            item+='    <td align="center" class="borderBottom tabNote">';
            item+='      <span id="'+containerID+CCY1+CCY2+'BID">loading</span>';
            item+='    </td>';
            item+='    <td align="center" class="borderBottom tabNote">';
            item+='      <span id="'+containerID+CCY1+CCY2+'ASK">loading</span>';
            item+='    </td>';
            item+='    <td align="center" class="borderBottom tabNote">';
            item+='      <span id="'+containerID+CCY1+CCY2+'UPDOWN">loading</span>';
            item+='    </td>';
            item+='    <td align="center" class="borderBottom tabNote">';
            item+='      <span id="'+containerID+CCY1+CCY2+'UPDOWNPERCENT">loading</span>';
            item+='    </td>';
            item+='    <td align="center" class="borderBottom tabNote">';
            item+='      <span id="'+containerID+CCY1+CCY2+'TODAYOPENPRICE">loading</span>';
            item+='    </td>';
            item+='    <td align="center" class="borderBottom tabNote">';
            item+='      <span id="'+containerID+CCY1+CCY2+'HIGH">loading</span>';
            item+='    </td>';
            item+='    <td align="center" class="borderBottom tabNote">';
            item+='      <span id="'+containerID+CCY1+CCY2+'LOW">loading</span>';
            item+='    </td>';
            item+='    <td align="center" class="borderBottom tabNote">';
            item+='      <span id="'+containerID+CCY1+CCY2+'AMPLITUDE">loading</span>';
            item+='    </td>';
            item+='   <td align="center" class="borderBottom tabNote">';
            item+='      <span id="'+containerID+CCY1+CCY2+'LASTCLOSEPRICE">loading</span>';
            item+='    </td>';
            item+='    <td align="center" class="borderBottom tabNote">';
            item+='      <a href="/DataCenter/ChartZoom.aspx?s='+CCY1+CCY2+'&t=1440&w=760&h=480"  target="_blank">';
            item+='        <img src="images/SJ_zst.jpg" width="23" height="23" border="0"  />';
            item+='      </a>';
            item+='    </td>';
            item+='  </tr>';
            document.write(item);
           // alert(document.getElementById(containerID+CCY1+CCY2+'LOW').innerHTML);
        }
    }
    //设置汇率值
   
    //设置汇率值
}
//汇率显示
function DailyReportRate(responseText,currencyPairs)
{
    if(responseText!="")
    {
         var Items = responseText.split(',');
         for(i=0;i<Items.length;i++)
         {
            var str = Items[i].split('|');
            if(str.length==11)
            {
                if(currencyPairs.indexOf(str[0])>=0)
                {                                
                    document.getElementById(str[0]+"BID").innerHTML = str[2].split('=')[1];
                }
            }
         }
    }           
}
//打印
function Print(){
    window.print();
}
//添加收藏兼容FireFox
function AddFavorite(){
    if(document.all){
        window.external.AddFavorite(location.href, document.title);
    }
    else  if(window.sidebar){
        window.sidebar.addPanel(document.title,location.href,"");
    }
}
//首页汇率
function DisplayRateForFirst(responseText,currencyPairs)
{
    if(responseText!="")
    {
         var Items = responseText.split(',');
         for(i=0;i<Items.length;i++)
         {
            var str = Items[i].split('|');
            if(str.length==11)
            {
                if(currencyPairs.indexOf(str[0])>=0)
                {
                    //document.getElementById(str[0]).style.display="block";
                    if(str[1].split('=')[1]=='0')
                    {
                        document.getElementById(str[0]+'0').style.display = ""
                        document.getElementById(str[0]+'1').style.display = "none"
                    }
                    else
                    {
                        document.getElementById(str[0]+'1').style.display = ""
                        document.getElementById(str[0]+'0').style.display = "none"
                    }
                    var bid=str[2].split('=')[1] * 1;
                    var ask=str[3].split('=')[1] * 1;
                    if(str[0]=='DXY')
                    {
                        bid=bid.toFixed(2);
                        ask=ask.toFixed(2);
                    }
                    document.getElementById(str[0]+"BID").innerHTML = bid;
                    document.getElementById(str[0]+'ASK').innerHTML = ask;
                }
            }
         }
    }           
}
//汇率计算器

function createRequest_rate()
{
    
    var sbr1 = document.getElementById("sbr1").value;
    var sbr2 = document.getElementById("sbr2").value;
    var sVaule = document.getElementById("txtValue").value;
    
    if(sVaule=="")
    {
        alert("请填写金额!");
        return false;
    }
    if(sbr1==sbr2)
    {
        alert('请选择正确货币!');
        return false;
    }
    var sbr = sbr1+sbr2;
    var cbo = new CallBackObject();            
    cbo.OnComplete = Cbo_Completerate;
    cbo.onError = Cbo_Error_rate;
    cbo.DoCallBack("/DataCenter/CalculateRate.aspx?sbr="+sbr+"&value="+sVaule);//+"&value="+sVaule
    return false;
}
function Cbo_Completerate(responseText,responseXML)
{
   
   document.getElementById("DivValue").value = chDeci(responseText,4);
}
function Cbo_Error_rate(status,statusText,responseText)
{
    alert(responseText);
}
function chDeci(val, deci) 
{
    if (val != 0) 
    {
        deci = Math.pow(10, deci);
        val = Math.round(val*deci)/deci;
    }
    return val;
}

	
//外汇浮动Chart图
function ChangeChart(s1,s2,classname,display){
if(display){
     var html ='  <div class="zst_wh_mcleft"><strong>汇率走势图 </strong><span>货币对：'+s1+'/'+s2+'</span></div>';
         html+='   <div class="zst_wh_gdrg" style="cursor:pointer" onclick=JavaScript:ChangeChart("GBP","USD","zst_wh_dit06",false) >关闭</div>';
         html+='   <div class="zst_wh_zst"><img  onmouseout="null" src="http://202.130.151.36/webchart/webchart.aspx?s='+s1+s2+'&amp;t=30&amp;w=295&amp;h=184"name="chart1" id="chart1" /></div>';
         
         document.getElementById('displayChart').innerHTML = html;
         document.getElementById('displayChart').className = classname;
         document.getElementById('displayChart').style.display="";
         document.getElementById('InstantNews').style.display="none";
     }
     else{
         document.getElementById('displayChart').style.display="none";
         document.getElementById('InstantNews').style.display="";

     }
} 
