﻿//大中小字体控制
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 DailyReportRate(responseText,currencyPairs)
{
    if(responseText!="")
    {
         var Items = responseText.split(',');
         for(i=0;i<Items.length;i++)
         {
            var str = Items[i].split('|');
            if(str.length==6)
            {
                if(currencyPairs.indexOf(str[0])>=0)
                {                                
                    document.getElementById(str[0]+"BID").innerHTML = str[2].split('=')[1];
                }
            }
         }
    }           
}
//汇率显示
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==6)
            {
                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"
                    }
                    document.getElementById(str[0]+"BID").innerHTML = str[2].split('=')[1];
                    document.getElementById(str[0]+'ASK').innerHTML = str[3].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 DisplayRate(responseText,currencyPairs)
{
    if(responseText!="")
    {
         var Items = responseText.split(',');
         for(i=0;i<Items.length;i++)
         {
            var str = Items[i].split('|');
            if(str.length==6)
            {
                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"
                    }
                    document.getElementById(str[0]+"BID").innerHTML = str[2].split('=')[1];
                    document.getElementById(str[0]+'ASK').innerHTML = str[3].split('=')[1];
                }
            }
         }
    }           
}
//汇率计算器

function createRequest_rate()
{
    
    var sbr1 = document.getElementById("sbr1").value;
    var sbr2 = document.getElementById("sbr2").value;
    var sVaule = document.getElementById("ForexCalc1_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="";

     }
} 