protected void contents_SelectedTopicChanged(object sender, EventArgs e)
        {
            if (!changingSelection)
            {
                changingSelection = true;
                ContentsSelected  = true;

                if (DocSiteNavigator.NavigateToTopic(contents.SelectedTopic, false))
                {
                    index.SelectedHelpFile = DocSiteNavigator.ResolveTopicHelpFile(contents.SelectedTopic, false);
                }

                changingSelection = false;
            }
        }
        private void SyncSidebar()
        {
            string topic = null, helpFile = null;

            if (!Page.IsPostBack)
            {
                if (Request.QueryString["filenotfound"] != null)
                {
                    ContentPath = DocSiteNavigator.FileNotFoundPath;
                }
                else
                {
                    topic    = Request.QueryString["topic"];
                    helpFile = Request.QueryString["helpfile"];

                    if (!string.IsNullOrEmpty(topic))
                    {
                        topic = DocSiteNavigator.FormatTopic(topic, false);
                    }
                }
            }
            else
            {
                string topicPath = ContentUrl.Value;

                if (!string.IsNullOrEmpty(topicPath))
                {
                    Uri topicUri;

                    if (Uri.TryCreate(topicPath, UriKind.RelativeOrAbsolute, out topicUri) &&
                        (!topicUri.IsAbsoluteUri || topicUri.Host.Equals(Request.Url.Host, StringComparison.OrdinalIgnoreCase)))
                    {
                        helpFile = topicUri.AbsolutePath;

                        if (helpFile.StartsWith("/") || helpFile.StartsWith(@"\"))
                        {
                            helpFile = helpFile.Substring(1);
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(helpFile))
            {
                helpFile = DocSiteNavigator.ResolveTopicHelpFile(topic, false) ?? DocSiteNavigator.HelpFileNotFoundPath;
            }

            if (string.IsNullOrEmpty(topic))
            {
                topic = DocSiteNavigator.ResolveHelpFileTopic(helpFile, false);

                if (topic == null)
                {
                    helpFile = DocSiteNavigator.HelpFileNotFoundPath;
                }
            }

            ContentPath = helpFile;

            DocSiteSidebar sidebar = ((DocSite)Page.Master).Sidebar;

            if (!sidebar.TableOfContents.SelectedTopic.Equals(topic, StringComparison.Ordinal))
            {
                sidebar.Initialize(topic, helpFile);
            }
        }