﻿//ext 定时器
//var runner = new Ext.util.TaskRunner();
//    
//var LastQueryOK=false;
//var setContractPricePerMinute = {
//    run:function(){
//        if(!successLogin) return;      
//        QueryUserData();
//    },
//    interval: 120000//2分钟
//}


//设置全局变量
var staticObj = {};
staticObj.timer = "";
staticObj.count = 0;


function startReload()
{
    //设置Interval
    staticObj.timer = setInterval("reloadData()",120000);
}

function stopReload()
{
    //清除Interval
    clearInterval(staticObj.timer);
}

function reloadData()
{
    staticObj.count++;    
//    date=new Date();
//    var thisAtionTime=date.getTime();
//    alert(staticObj.count+" "+thisAtionTime);    
    QueryUserData();
}



function reStarRunner()
{
    stopReload();
    startReload();
    
//     runner.stopAll();
//     //2分钟后启动
//     window.setTimeout("runner.start(setContractPricePerMinute)",120000);
}


//暂时没用
function setContractPrice()
{
     var comboContract= SouthOrderForm.getForm().findField('comboContract');
     var contractValue=comboContract.getValue();
    //var txtPrice= SouthOrderForm.getForm().findField('txtPrice'); 
    //setPriceFromContract(contractValue); 
     if(contractValue!="")
        {            
            Ext.Ajax.request(
                        {
                            url: 'QueryData/QueryContractPricey.aspx',    
                            success:function(response)
                            {
//                                var txtPrice= SouthOrderForm.getForm().findField('txtPrice'); 
//                                var comboPriceType=SouthOrderForm.getForm().findField('comboPriceTypeId');
//                                var contractValue=comboPriceType.getValue();     
//                                if(contractValue=="1")//市价
//                                   {
//                                   } else
//                                   {
//                                        txtPrice.setValue(""); 
//                                   } 
                                var result=Ext.decode(response.responseText);
                                if(result.success==true)
                                { 
                                    //var txtCount= SouthOrderForm.getForm().findField('txtCount');                                  
                                    //txtCount.setValue("1");                                    
                                    //var comboPriceType=SouthOrderForm.getForm().findField('comboPriceTypeId');
                                    //var contractValue=comboPriceType.getValue();                                                        
//                                       if(contractValue=="1")//市价
//                                       {
//                                            txtPrice.setValue("市价"); 
//                                            txtPrice.disable();
//                                       } else
//                                       {
//                                            txtPrice.setValue(""); 
//                                            txtPrice.setValue(FormatNumber(result.SettlementPrice,0));  
//                                            txtPrice.enable();
//                                       } 
                                       window.status="正常通讯中......";
                                  }else
                                  {
                                      runner.stopAll();
                                      Ext.MessageBox.confirm('确认（已断开）',result.msg,function(btn)
                                            {
                                                if(btn=='yes')
                                                {    
                                                   successLogin=false;                            
                                                   callTrade();
                                                }  			            
                                            });
                                  }
                            },
                            failure:function()
                            {
                                window.status="通讯已断开,请重新登陆......";
//                                var txtPrice= SouthOrderForm.getForm().findField('txtPrice'); 
//                                txtPrice.setValue(""); 
                                //Ext.MessageBox.alert('错误','获取合约价格失败');
                            },
                            params:{"InstrumentID":contractValue}
                        });
        }    
    
}


function setHoldingProfit(contract,price)
{
  return ;
}