private void RenderFinalScript()
 {
     if (!m_deviceInfo.AllowScript)
     {
         return;
     }
     WriteStream("<script language=\"javascript\" type=\"text/javascript\">");
     WriteStream(HTML5Renderer.m_standardLineBreak);
     WriteStream("//<![CDATA[");
     WriteStream(HTML5Renderer.m_standardLineBreak);
     if (HasFindStringScript)
     {
         WriteStream("window.location.replace('#oHit0');");
     }
     if (HasInteractiveScript)
     {
         if (m_report.ShowHideToggle != null && m_deviceInfo.IsBrowserIE)
         {
             WriteStream("var ");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("showHideId=\"");
             StringBuilder stringBuilder = new StringBuilder();
             HTML5Renderer.QuoteString(stringBuilder, m_deviceInfo.HtmlPrefixId + m_report.ShowHideToggle);
             WriteStreamEncoded(stringBuilder.ToString());
             WriteStream(HTMLElements.m_quote);
             WriteStream(HTML5Renderer.m_standardLineBreak);
             WriteStream("function ");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("GoToShowHideToggle(){if (document.getElementById(");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("showHideId) != null)window.location.replace(\"#\"+ ");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("showHideId);}");
             WriteStream(HTML5Renderer.m_standardLineBreak);
         }
         if (m_pageWithSortClicks)
         {
             WriteStream("var ");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("sortUrlBase=\"");
             StringBuilder stringBuilder2 = new StringBuilder();
             HTML5Renderer.QuoteString(stringBuilder2, BuildAbsoluteBookmarkOrSortBaseUrl(isSort: true));
             WriteStream(stringBuilder2.ToString());
             WriteStream(HTMLElements.m_quote);
             WriteStream(HTML5Renderer.m_standardLineBreak);
             WriteStream("var ");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("sortDirection=\"&rs:");
             WriteStream("SortDirection");
             WriteStream("=");
             WriteStream(HTMLElements.m_quote);
             WriteStream(HTML5Renderer.m_standardLineBreak);
             WriteStream("var ");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("clearSort=\"&rs:");
             WriteStream("ClearSort");
             WriteStream("=");
             WriteStream(HTMLElements.m_quote);
             WriteStream(HTML5Renderer.m_standardLineBreak);
             WriteStream("function ");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("Sort(id, direction){var clear=true;");
             WriteStream("if (window.event && window.event.shiftKey) clear=false;");
             WriteStream("var sortUrl=");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("sortUrlBase + id + ");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("sortDirection + direction + ");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("clearSort;");
             WriteStream("if (clear) ");
             WriteStream("window.location.replace(sortUrl + \"True\");");
             WriteStream("else ");
             WriteStream("window.location.replace(sortUrl + \"False\");}");
         }
         if (m_report.SortItem != null)
         {
             WriteStream("var ");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("sortId=\"");
             StringBuilder stringBuilder3 = new StringBuilder();
             HTML5Renderer.QuoteString(stringBuilder3, m_deviceInfo.HtmlPrefixId + m_report.SortItem);
             WriteStreamEncoded(stringBuilder3.ToString());
             WriteStream(HTMLElements.m_quote);
             WriteStream(HTML5Renderer.m_standardLineBreak);
             WriteStream("function ");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("GoToSortItem(){if (document.getElementById(");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("sortId) != null)window.location.replace(\"#\"+ ");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("sortId);}");
             WriteStream(HTML5Renderer.m_standardLineBreak);
         }
         if (m_report.HasBookmarks || m_deviceInfo.NavigationId != null)
         {
             WriteStream("function ");
             WriteStream(m_deviceInfo.JavascriptPrefixId);
             WriteStream("GoToBookmark(id){window.location.replace(\"#\"+id);}");
             WriteStream(HTML5Renderer.m_standardLineBreak);
             if (m_pageWithBookmarkLinks)
             {
                 if (m_pageBookmarks == null || m_pageBookmarks.Count < 1)
                 {
                     WriteStream("var ");
                     WriteStream(m_deviceInfo.JavascriptPrefixId);
                     WriteStream("bookmarkIds = [];");
                 }
                 else
                 {
                     WriteStream("var ");
                     WriteStream(m_deviceInfo.JavascriptPrefixId);
                     WriteStream("bookmarkIds = new Array(" + m_pageBookmarks.Count + ");");
                     ICollection keys = m_pageBookmarks.Keys;
                     foreach (string item in keys)
                     {
                         WriteStream(m_deviceInfo.JavascriptPrefixId + "bookmarkIds[\"" + item + "\"] = \"" + m_pageBookmarks[item] + "\";");
                     }
                 }
                 WriteStream(HTML5Renderer.m_standardLineBreak);
                 WriteStream("var ");
                 WriteStream(m_deviceInfo.JavascriptPrefixId);
                 WriteStream("bookmarkUrlBase=\"");
                 StringBuilder stringBuilder4 = new StringBuilder();
                 HTML5Renderer.QuoteString(stringBuilder4, BuildAbsoluteBookmarkOrSortBaseUrl(isSort: false));
                 WriteStream(stringBuilder4.ToString());
                 WriteStream(HTMLElements.m_quote);
                 WriteStream(";");
                 WriteStream(HTML5Renderer.m_standardLineBreak);
                 WriteStream("function ");
                 WriteStream(m_deviceInfo.JavascriptPrefixId);
                 WriteStream("GoVisibleBookmark(idLink){if (");
                 WriteStream(m_deviceInfo.JavascriptPrefixId);
                 WriteStream("bookmarkIds == null) return;");
                 WriteStream("var isHref=true;");
                 WriteStream("if (bookmarkIds[idLink] != null) {");
                 WriteStream(m_deviceInfo.JavascriptPrefixId);
                 WriteStream("GoToBookmark(bookmarkIds[idLink]);}");
                 WriteStream("else{window.location.replace(");
                 WriteStream(m_deviceInfo.JavascriptPrefixId);
                 WriteStream("bookmarkUrlBase + '&rc:BookmarkId=' + idLink);}}");
             }
         }
     }
     WriteStream(HTML5Renderer.m_standardLineBreak);
     WriteStream(HTMLRendererResources.GetBytes("Common.js"));
     WriteStream(HTML5Renderer.m_standardLineBreak);
     RenderFitProportionalScript();
     RenderFixedHeaderScripts();
     if (m_needsCanGrowFalseScript)
     {
         WriteStream(HTMLRendererResources.GetBytes("CanGrowFalse.js"));
     }
     if (m_emitImageConsolidationScaling)
     {
         WriteStream(HTMLRendererResources.GetBytes("ImageConsolidation.js"));
     }
     WriteStream("//]]>");
     WriteStream(HTML5Renderer.m_standardLineBreak);
     WriteStream("</script>");
 }