<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <link rel="stylesheet" href="{{ .Site.BaseURL }}css/main_menu.css">
  <script type="text/javascript" src="{{ .Site.BaseURL }}js/main_menu.js"></script>
</head>

<body>

  {{ if .Site.Menus.main }}
    <ul class="accordion right-side">
      {{ range .Site.Menus.main.ByWeight }}
        {{ if .HasChildren }}
          <!--button class="button">{{/* .Name */}}</button-->
          <!-- Special action: "lab" -->
          {{ if eq .Identifier "lab" }}
            <button class="button active">{{ .Name }}</button>
            <div class="nest">
              <div>
                {{ range .Children }}
                  {{ $nm := .Name }}
                  {{ $w := .Weight }}
                  {{ $pt := .URL | relLangURL }}
                  <!-- Fetch image path -->
                  {{ range $.Site.RegularPages }}
                    {{ if (.Param "mktile") }}
                      {{ if eq .Weight $w }}
                      <a href="{{ .Permalink }}" class="labtile"><img src="{{ $.Site.BaseURL }}{{ .Param "image" }}" alt={{ $nm }} title={{ $nm }}><div class="caption">{{ $nm }}</div></a>
                      {{ end }}
                    {{ end }}
                  {{ end }}
                {{ end }}
              </div>
            </div>
          <!-- END Special action: "lab" -->

          <!-- Default action -->
          {{ else }}
            <button class="button">{{ .Name }}</button>
            <div class="nest" style="display: none;">
              <!-- Fetch description -->
	      {{ with $.Site.GetPage .Identifier }}
                <p>{{ .Content }}</p>
              {{ end }}
              
              <!-- Construct children list -->
	      <ul class="accordion_1">
                {{ range .Children }}
                  <li><a href="{{ .URL | relLangURL }}">{{ .Name }} </a></li>
                {{ end }}
              </ul>
            </div>
          <!-- END Default action -->
          {{ end }}
        {{ else }}

          <!-- Special action: "event" -->
          {{ if eq .URL "/events" }}
            <button class="button active">{{ .Name }}</button>
            <div class="nest">
              {{ with $.Site.GetPage "/post" }}
                <h3>{{ .Params.heading }}</h3>
              {{ end }}

              {{ range $catkey, $catlist := $.Site.Taxonomies.categories }}
                {{ if eq $catkey "event" }}
                  {{ range (.Pages.ByParam "eventEndDate").Reverse }}
                    {{ if le now .Params.eventEndDate }}
                    <div class="eventbox">
                        {{ if ne (.Params.eventStartDate) (.Params.eventEndDate) }}
                          <div class="eventdate">{{ dateFormat "2 Jan, 2006" .Params.eventStartDate }}-{{ dateFormat "2 Jan, 2006" .Params.eventEndDate }}
                            <a href="{{ $.Site.BaseURL }}tags/{{ .Params.tags }}/" class="tagbutton {{ .Params.tags }}">{{ .Params.tags }}</a>
                          </div>
                        {{ else }}
                          <div class="eventdate">{{ dateFormat "2 Jan, 2006" .Params.eventEndDate }}
                            <a href="{{ $.Site.BaseURL }}tags/{{ .Params.tags }}/" class="tagbutton {{ .Params.tags }}">{{ .Params.tags }}</a>
                          </div>
                        {{ end }}
                      <h2>{{ .Title }}</h2>
                      <p>{{ .Content }}</p>
                      <p><a href="{{ .Permalink }}" class="read-more">続きを読む</a></p>
                    </div>
                    {{ end }}
                  {{ end }}
                  {{ with $.Site.GetPage "/post" }}
                    <h3>{{ .Content }}</h3>
                  {{ end }}
                {{ end }}
              {{ end }}

            </div>
          <!-- END Special action: "events" -->

          {{ else }}
            <a href="{{ .URL }}"><button class="pseudo_button">{{- .Name -}}</button></a>
          {{ end }}

        {{ end }}
      {{ end }}
    </ul>
  {{ end }}



</body>
