var xmlhttp; 
var url="http://220.181.68.156/quotes/ZhjDS.txt";

function widgetOnInit()
{
  getUrlTxt(url);
}

function getUrlTxt(url){
   DownLoadFileAsync( url , 'ZhjDS.txt' , "onDownFile" );

}

function  onDownFile(fileName,errorCode)
{
  if(errorCode<1)
  {
    txtTime.caption = "未连接";
    return; 
  }
  else
  {
     parseReturnText(readFile( 'ZhjDS.txt'));
  }

}
         
/**
 * 格式化返回值
 * 值的格式为"time=04:59:30&gold=|209.52|209.12|209.92|210.00|211.73|208.42|210.21|1.00";
 */
function parseReturnText(value){
  var tmpArr;
  var time;
  var goldArr;
  if (value != null){
    tmpArr = value.split("&");
    time = tmpArr[0].substring(5,tmpArr[0].length);
    txtTime.caption=time;
    goldArr = tmpArr[1].split("|");
    txtTime.caption = time;
    txtMidden.caption = goldArr[1];
    txtBull.caption = goldArr[2];
    txtAverage.caption = goldArr[3];
    txtOpen.caption = goldArr[4];
    txtTiptop.caption = goldArr[5];
    txtMinimum.caption = goldArr[6];
    txtClosing.caption = goldArr[7];
  }
}

function timer0OnTimer()
{
  LockRefresh;
  getUrlTxt(url);
  UnLockRefresh;
}

function image0OnClick(sender)
{
  OpenLink('http://www.kitco.cn/cn/live_charts/goldcny.gif');
}

function nMenu1OnClick()
{
    OpenLink('http://www.zhihuangjin.com');
}

function nMenu2OnClick()
{
   OpenLink('http://www.kitco.cn'); 
}