void DoPageLoad()
        {
            // called everytime the plugin is shown, after some other window was shown (also after fullscreen playback)
            if (PreviousWindowId != OnlineVideos.MediaPortal1.Player.GUIOnlineVideoFullscreen.WINDOW_FULLSCREEN_ONLINEVIDEO)
            {
                // reload settings that can be modified with the MPEI plugin
                PluginConfiguration.Instance.ReLoadRuntimeSettings();

                // if groups are now enabled/disabled we need to set the states accordingly
                if (GroupsEnabled)
                {
                    // showing sites, but groups are enabled and no group is selected -> show groups
                    if (CurrentState == State.sites && selectedSitesGroup == null)
                    {
                        CurrentState = State.groups;
                    }

                    // we might have to generate automatic groups if it is enabled now
                    if (PluginConfiguration.Instance.CachedAutomaticSitesGroups.Count == 0)
                    {
                        PluginConfiguration.Instance.BuildAutomaticSitesGroups();
                    }
                }
                else
                {
                    // showing groups, but groups are disabled -> show sites
                    if (CurrentState == State.groups)
                    {
                        CurrentState = State.sites;
                    }
                    selectedSitesGroup = null;
                }

                // reset the LoadParameterInfo
                loadParamInfo = null;

                string loadParam = null;
                // check if running version of mediaportal supports loading with parameter and handle _loadParameter
                System.Reflection.FieldInfo fi = typeof(GUIWindow).GetField("_loadParameter", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                if (fi != null)
                {
                    loadParam = (string)fi.GetValue(this);
                }
                // check for LoadParameters by GUIproperties if nothing was set by the _loadParameter
                if (string.IsNullOrEmpty(loadParam))
                {
                    loadParam = LoadParameterInfo.FromGuiProperties();
                }

                if (!string.IsNullOrEmpty(loadParam))
                {
                    Log.Instance.Info("Called with LoadParameter: '{0}'", loadParam);
                    loadParamInfo = new LoadParameterInfo(loadParam);

                    // set all state variables to reflect the state we were called with
                    currentNavigationContextSwitch = null;
                    if (!string.IsNullOrEmpty(loadParamInfo.Group))
                    {
                        SitesGroup group = PluginConfiguration.Instance.SitesGroups.FirstOrDefault(sg => sg.Name == loadParamInfo.Group);
                        if (group == null)
                        {
                            group = PluginConfiguration.Instance.CachedAutomaticSitesGroups.FirstOrDefault(sg => sg.Name == loadParamInfo.Group);
                        }
                        if (group != null)
                        {
                            selectedSitesGroup = new OnlineVideosGuiListItem(group);
                            CurrentState       = State.sites;
                        }
                    }
                    if (!string.IsNullOrEmpty(loadParamInfo.Site) && OnlineVideoSettings.Instance.SiteUtilsList.ContainsKey(loadParamInfo.Site))
                    {
                        SelectedSite     = OnlineVideoSettings.Instance.SiteUtilsList[loadParamInfo.Site];
                        CurrentState     = State.categories;
                        selectedCategory = null;
                    }
                    if (SelectedSite != null && SelectedSite.CanSearch && !string.IsNullOrEmpty(loadParamInfo.Search))
                    {
                        Display_SearchResults(loadParamInfo.Search);
                        return;
                    }
                }
            }

            Log.Instance.Info("DoPageLoad with CurrentState '{0}', PreviousWindowId '{1}'", CurrentState, PreviousWindowId);
            switch (CurrentState)
            {
            case State.groups: DisplayGroups(); break;

            case State.sites: DisplaySites(); break;

            case State.categories: DisplayCategories(selectedCategory); break;

            case State.videos: SetVideosToFacade(currentVideoList, currentVideosDisplayMode); break;

            default: SetVideosToInfoList(currentTrailerList); break;
            }
        }
        void GUIWindowManager_OnThreadMessageHandler(object sender, GUIMessage message)
        {
            if (message.Message == GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW &&
                message.TargetWindowId == 0 && message.TargetControlId == 0 && message.SenderControlId == 0 &&
                message.SendToTargetWindow == false && message.Object == null && message.Object2 == null &&
                message.Param2 == 0 && message.Param3 == 0 && message.Param4 == 0 &&
                (message.Param1 == (int)GUIWindow.Window.WINDOW_HOME || message.Param1 == (int)GUIWindow.Window.WINDOW_SECOND_HOME)
                )
            {
                if (CurrentState != State.groups && GroupsEnabled)
                {
                    // prevent message from beeing sent to MP core
                    message.SendToTargetWindow = true;
                    message.TargetWindowId = GetID;
                    message.Param1 = GetID;
                    message.Message = GUIMessage.MessageType.GUI_MSG_HIDE_MESSAGE;

                    // reset to groups view
                    SelectedSite = null;
                    selectedCategory = null;
                    selectedVideo = null;
                    currentVideoList = new List<VideoInfo>();
                    currentTrailerList = new List<DetailVideoInfo>();
                    currentNavigationContextSwitch = null;
                    loadParamInfo = null;
                    DisplayGroups();
                }
                else if (CurrentState != State.sites && !GroupsEnabled)
                {
                    // prevent message from beeing sent to MP core
                    message.SendToTargetWindow = true;
                    message.TargetWindowId = GetID;
                    message.Param1 = GetID;
                    message.Message = GUIMessage.MessageType.GUI_MSG_HIDE_MESSAGE;

                    // reset to sites view
                    selectedCategory = null;
                    selectedVideo = null;
                    currentVideoList = new List<VideoInfo>();
                    currentTrailerList = new List<DetailVideoInfo>();
                    currentNavigationContextSwitch = null;
                    loadParamInfo = null;
                    DisplaySites();
                }
            }
        }
		void DoPageLoad()
		{
			// called everytime the plugin is shown, after some other window was shown (also after fullscreen playback)
			if (PreviousWindowId != OnlineVideos.MediaPortal1.Player.GUIOnlineVideoFullscreen.WINDOW_FULLSCREEN_ONLINEVIDEO)
			{
				// reload settings that can be modified with the MPEI plugin
				PluginConfiguration.Instance.ReLoadRuntimeSettings();

				// if groups are now enabled/disabled we need to set the states accordingly
				if (GroupsEnabled)
				{
					// showing sites, but groups are enabled and no group is selected -> show groups
					if (CurrentState == State.sites && selectedSitesGroup == null) CurrentState = State.groups;

					// we might have to generate automatic groups if it is enabled now
					if (PluginConfiguration.Instance.CachedAutomaticSitesGroups.Count == 0)
						PluginConfiguration.Instance.BuildAutomaticSitesGroups();
				}
				else
				{
					// showing groups, but groups are disabled -> show sites
					if (CurrentState == State.groups) CurrentState = State.sites;
					selectedSitesGroup = null;
				}

				// reset the LoadParameterInfo
				loadParamInfo = null;

				string loadParam = null;
				// check if running version of mediaportal supports loading with parameter and handle _loadParameter
				System.Reflection.FieldInfo fi = typeof(GUIWindow).GetField("_loadParameter", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
				if (fi != null)
				{
					loadParam = (string)fi.GetValue(this);
				}
				// check for LoadParameters by GUIproperties if nothing was set by the _loadParameter
				if (string.IsNullOrEmpty(loadParam)) loadParam = LoadParameterInfo.FromGuiProperties();

				if (!string.IsNullOrEmpty(loadParam))
				{
					Log.Instance.Info("Called with LoadParameter: '{0}'", loadParam);
					loadParamInfo = new LoadParameterInfo(loadParam);

                    // set all state variables to reflect the state we were called with
                    currentNavigationContextSwitch = null;
					if (!string.IsNullOrEmpty(loadParamInfo.Group))
					{
						SitesGroup group = PluginConfiguration.Instance.SitesGroups.FirstOrDefault(sg => sg.Name == loadParamInfo.Group);
						if (group == null) group = PluginConfiguration.Instance.CachedAutomaticSitesGroups.FirstOrDefault(sg => sg.Name == loadParamInfo.Group);
						if (group != null)
						{
							selectedSitesGroup = new OnlineVideosGuiListItem(group);
							CurrentState = State.sites;
						}
					}
					if (!string.IsNullOrEmpty(loadParamInfo.Site) && OnlineVideoSettings.Instance.SiteUtilsList.ContainsKey(loadParamInfo.Site))
					{
						SelectedSite = OnlineVideoSettings.Instance.SiteUtilsList[loadParamInfo.Site];
						CurrentState = State.categories;
						selectedCategory = null;
					}
					if (SelectedSite != null && SelectedSite.CanSearch && !string.IsNullOrEmpty(loadParamInfo.Search))
					{
						Display_SearchResults(loadParamInfo.Search);
						return;
					}
				}
			}

			Log.Instance.Info("DoPageLoad with CurrentState '{0}', PreviousWindowId '{1}'", CurrentState, PreviousWindowId);
			switch (CurrentState)
			{
				case State.groups: DisplayGroups(); break;
				case State.sites: DisplaySites(); break;
				case State.categories: DisplayCategories(selectedCategory); break;
				case State.videos: SetVideosToFacade(currentVideoList, currentVideosDisplayMode); break;
				default: SetVideosToInfoList(currentTrailerList); break;
			}
		}