
<div id='browsedocsWrapper'>
<div class="browseheader" id="browsedocs">
    <a name="browsedocs">{{ T "docs_label_browse" }}</a>
  </div>
<div class="browsedocs">
{{ template "docs-browse-section" (dict "ctx" . "page" .) }}
</div><!-- end browsedocs -->

{{ define "docs-browse-section" }}
{{ $pages := .page.Pages }}
{{ $sections := .page.Sections }}
{{ with $.ctx.Site.Params.language_alternatives }}
  {{ range . }} 
    {{ with (where $.page.Translations ".Lang" . ) }}
    {{ $p := index . 0 }}
    {{ $pages =  $pages | lang.Merge $p.Pages }}
    {{ $sections =  $sections | lang.Merge $p.Sections }}
    {{ end }}
  {{ end }}
{{ end }}
{{ $pages := where $pages ".Params.toc_hide" "!=" true }}
{{ $sections := where $sections ".Params.toc_hide" "!=" true }}
{{ if not .page.Parent.IsHome }}
<div class="browsesection">
  <div class="docstitle">
    <h3><a href="{{ .page.RelPermalink }}">{{ .page.Params.bigheader | default .page.Title }}</a></h3>
  </div>
  {{ if ge (len $pages) 1 }}
  <div class="pages">
  {{ $num_pages := len $pages }}
  {{ if gt $num_pages 0 }}
  {{ $column_size :=  (div $num_pages 3.0) | math.Ceil | int | default 1 }}
  {{  range $i, $e := $pages.ByWeight }}
    {{ $offset := mod $i $column_size |  add 1 }}
    {{ if eq $offset 1 }}
      <div class="browsecolumn">
    {{ end }}
    {{ $isForeignLanguage := (ne .Lang $.ctx.Lang)}}
    <a href="{{ .RelPermalink }}"{{ if $isForeignLanguage }} target="_blank" {{ end }}>{{ printf "%02d - %s" (add $i 1) .LinkTitle }}{{ if $isForeignLanguage }} <small>({{ .Lang | upper }})</small>{{ end }}</a><br>
    {{ if or (eq $offset $column_size) (eq (add $i 1) $num_pages)}}
      </div>
    {{ end }}
  {{ end }}
  {{ end }}
  </div><!-- end pages -->
  {{ end }}
</div><!-- end browsesection -->
{{ end }}
{{ range $sections.ByWeight }}
{{ template "docs-browse-section" (dict "ctx" $.ctx "page" .)  }}
{{ end }}
{{ end }}
