/// <summary>
        /// Find the play/pause button and click it
        /// </summary>
        /// <returns></returns>
        private EventResult DoPlayOrPause()
        {
            if (DateTime.Now < _lastPlayClick.AddMilliseconds(500))
            {
                return(EventResult.Complete());
            }

            CursorHelper.MoveMouseTo(Browser.FindForm().Left + (Browser.FindForm().Width / 2) + 50, Browser.FindForm().Top + (Browser.FindForm().Height / 2));
            CursorHelper.DoLeftMouseClick();
            CursorHelper.MoveMouseTo(0, 0);
            _lastPlayClick = DateTime.Now;
            return(EventResult.Complete());
        }
        /// <summary>
        /// Process a message from the web browser
        /// </summary>
        /// <returns></returns>
        public override EventResult BrowserDocumentComplete()
        {
            switch (_currentState)
            {
            case State.LoggingIn:
                if (Url.EndsWith("/signin/skygo"))
                {
                    var jsCode = "document.getElementById('username').value = '" + _username + "';";
                    jsCode += "document.getElementById('password').value = '" + _password + "';";
                    jsCode += "document.getElementById('signinform').submit();";
                    InvokeScript(jsCode);
                    _currentState = State.LoginResult;
                }
                break;

            case State.LoginResult:
                if (Url == "http://go.sky.com/")
                {
                    _currentState            = State.None;
                    ProcessComplete.Finished = true;
                    ProcessComplete.Success  = true;
                }
                else
                {
                    return(EventResult.Error("SkyGoGeneralConnector/ProcessMessage/Expected home page after log in, was actually " + Url));
                }
                break;

            case State.PlayPage:
                if (Url.Contains("/content/videos"))
                {
                    //Browser.Refresh(WebBrowserRefreshOption.Completely);// Need to do this for some reason
                    _currentState = State.None;

                    // The js code to wait for the video to appear
                    var jsCode = "setTimeout('doMaximise()', 1000);";
                    jsCode += "function doMaximise() {";
                    jsCode += "if(document.getElementsByClassName('silverlightVodPlayerWrapper') != null) {";
                    jsCode += "    document.getElementsByClassName('silverlightVodPlayerWrapper')[0].setAttribute('style', 'position: fixed; width: 100%; height: 100%; left: 0; top: 0; background: rgba(51,51,51,0.7); z-index: 10;');";
                    jsCode += "}";
                    jsCode += "else setTimeout('doMaximise()', 1000);";
                    jsCode += "}";

                    InvokeScript(jsCode);

                    var startTime = DateTime.Now;

                    _playPressThread = new Thread(new ParameterizedThreadStart(ClickPlayAfterFullScreen));
                    _playPressThread.Start();

                    ProcessComplete.Finished = true;
                    ProcessComplete.Success  = true;

                    // Wait 15 seconds for the video to start before disabling app storage - we'll do this in a separate thread
                    if (_disableAppStorageThread == null)
                    {
                        _disableAppStorageThread = new Thread(new ParameterizedThreadStart(DisableAppStorage));
                        _disableAppStorageThread.Start();
                    }

                    Browser.FindForm().Activate();
                    Browser.FindForm().Focus();
                }
                else
                {
                    if (!Url.EndsWith("/content/videos"))
                    {
                        return(EventResult.Error("SkyGoOnDemandConnector/ProcessMessage/Expected video play page, was actually " + Url));
                    }
                }
                break;

            case State.PlayPageLiveTv:
                if (Url.Contains("/detachedLiveTv.do"))
                {
                    // After 4 seconds we'll assume the page has loaded and will click in the top corner
                    var endDate = DateTime.Now.AddSeconds(4);
                    while (DateTime.Now < endDate)
                    {
                        Application.DoEvents();
                        System.Threading.Thread.Sleep(200);
                    }

                    CursorHelper.MoveMouseTo(50, 50);
                    Application.DoEvents();
                    CursorHelper.DoLeftMouseClick();
                    Application.DoEvents();
                    HideLoading();
                    Browser.FindForm().Activate();
                    Browser.FindForm().Focus();

                    ProcessComplete.Finished = true;
                    ProcessComplete.Success  = true;
                }

                break;
            }

            return(EventResult.Complete());
        }