private void InitCoreIbetEngine()
        {
            if (_ibetEngine != null && _ibetEngine.ibetAgent.State == AgentState.Running)
            {
                this._ibetEngine.ibetAgent.Logout();
                this.lblIbetCurrentCredit.Caption = "-";
                this.iNew.Enabled = false;
                this.iLoadStrategy.Enabled = false;
            }
            else
            {
                BCCore.BetAccount ibetAccount = new BCCore.BetAccount();
                BCCore.BetAccount ibetAccount2 = new BCCore.BetAccount();
                
                ibetAccount.Account = config.Ibet.Account;
                ibetAccount.Password = config.Ibet.Password;
                ibetAccount.Website = config.Ibet.Website;                

                BCCore.Utis.EngineLogger logger = new BCCore.Utis.EngineLogger("log");
                if (config.Ibet2 != null)
                {
                    ibetAccount2.Account = config.Ibet2.Account;
                    ibetAccount2.Password = config.Ibet2.Password;
                    ibetAccount2.Website = config.Ibet2.Website;
                    this._ibetEngine = new IBetEngine(ibetAccount, logger, "Engine1", 
                                                      ibetAccount2, logger, "Engine2");
                }
                else
                    this._ibetEngine = new IBetEngine(ibetAccount, logger, "Engine1");
                BCCore.LoginStatus loginStatus = this._ibetEngine.ibetAgent.Login();
                //while (loginStatus == BCCore.LoginStatus.InvalidCaptcha)
                //{
                //    this._ibetEngine.ibetAgent.Login();
                //}
                
                if (loginStatus == BCCore.LoginStatus.OK)
                {
                    this.rpgIbet.Text = "IBET - " + ibetAccount.Account;
                    this._ibetEngine.UpdateCompleted += new EngineDelegate(this._ibetEngine_UpdateCompleted);
                    this._ibetEngine.ibetAgent.RefreshCredit();
                    this._ibetEngine.ibetAgent.RefreshBetList();
                    this.lblIbetCurrentCredit.Caption = this._ibetEngine.ibetAgent.Config.Balance.ToString() + " (" + this._ibetEngine.ibetAgent.Config.Cash.ToString() + ")";
                    this.btnStart.Enabled = true;
                    this.iNew.Enabled = true;
                    this.iLoadStrategy.Enabled = true;
                    this.btnIbetGetInfo.Caption = "Log Out";
                    if (config.Ibet2 != null)
                    {
                        this.iNewR2IB.Enabled = true;
                    }
                }
            }
        }
        private void InitCoreSbobetEngine()
        {
            if (_sbobetEngine != null && _sbobetEngine.sboAgent.State == AgentState.Running)
            {
                this._sbobetEngine.sboAgent.Logout();
                this.lblSbobetCurrentCredit.Caption = "-";
                this.iNewR.Enabled = false;
            }
            else
            {
                BCCore.BetAccount sboAccount = new BCCore.BetAccount();
                sboAccount.Account = this.config.Sbo.Account;
                sboAccount.Password = this.config.Sbo.Password;
                sboAccount.Website = this.config.Sbo.Website;

                BCCore.Utis.EngineLogger logger = new BCCore.Utis.EngineLogger("log");
                this._sbobetEngine = new SbobetEngine(sboAccount, logger, "Engine2");

                BCCore.LoginStatus loginStatus = this._sbobetEngine.sboAgent.Login();
                if (loginStatus == BCCore.LoginStatus.OK)
                {
                    this.rpgSbobet.Text = "SBO - " + sboAccount.Account;                                        
                    this._sbobetEngine.FullDataCompleted += new EngineDelegate(this._sbobetEngine_FullDataCompleted);
                    this._sbobetEngine.sboAgent.RefreshCredit();
                    this.lblSbobetCurrentCredit.Caption = this._sbobetEngine.sboAgent.Config.Balance.ToString();
                    this.btnStart.Enabled = true;
                    this.iNewR.Enabled = true;
                    this.btnSbobetGetInfo.Caption = "Log out";
                }
            }
        }        
        private void InitCoreIbetEngine2()
        {
            if (_ibetEngine != null && _ibetEngine.ibetAgent2.State == AgentState.Running)
            {
                this._ibetEngine.ibetAgent2.Logout();
                this.iNewR2IB.Caption = "Login to 2nd IBET";
                this.iNew2.Enabled = false;
                //this.lblIbetCurrentCredit.Caption = "-";
                //this.iNew.Enabled = false;
                //this.iLoadStrategy.Enabled = false;
            }
            else
            {
                BCCore.BetAccount ibetAccount = new BCCore.BetAccount();                
                
                ibetAccount.Account = config.Ibet2.Account;
                ibetAccount.Password = config.Ibet2.Password;
                ibetAccount.Website = config.Ibet2.Website;                
                
                BCCore.LoginStatus loginStatus = this._ibetEngine.ibetAgent2.Login();
                

                if (loginStatus == BCCore.LoginStatus.OK)
                {
                    this.rpgIbet.Text = "IBET: " + this._ibetEngine.ibetAgent.Config.Account + " vs " + ibetAccount.Account;                    
                    this._ibetEngine.ibetAgent2.RefreshCredit();
                    this._ibetEngine.ibetAgent2.RefreshBetList();
                    this.lblIbetCurrentCredit.Caption = this._ibetEngine.ibetAgent.Config.Balance.ToString() + " (" + this._ibetEngine.ibetAgent.Config.Cash.ToString() + ")"
                        + " / " + this._ibetEngine.ibetAgent2.Config.Balance.ToString() + " (" + this._ibetEngine.ibetAgent2.Config.Cash.ToString() + ")";
                    this.iNewR2IB.Caption = "Logout 2nd IBET";
                    this.iNew2.Enabled = true;
                }
            }
        }