<!DOCTYPE html >
<%convert_nl_br%>
<html lang="en">
<head>
  <title><%site_title%></title>
<%include include_common_head.html%>
</head>
<body id="home">
  <%~if ad_wallpaper%>
  <%ad_wallpaper%>
  <%~endif%>
  <div class="container">
    <%include include_header.html%>

    <div class="main">
      <div class="contentwrapper clearfix">
        <%~set tag = $in.tag%>
        <%~if tag ieq 'swim'%><%set tag_title = 'Swim'%>
        <%~elsif tag ieq 'bike'%><%set tag_title = 'Bike'%>
        <%~else%><%set tag_title = 'Run'%><%endif%>
        
        <%~set res = Plugins::UI::fetch_links(tag => $tag, max_hits => $config.search_maxhits, url => "$tag_title/" )%>

        <%~set title_loop = Links::Build::build('title', $tag_title)%>
        <%include include_breadcrumb.html%>
        <%~set paging = $res.paging%>
        <%~set featured_articles_loop = $res.features%>
        <%unless featured_articles_loop%>
        <p>No article found</p>
        <%endif%>

        <%~if paging and paging.current_page == 1%>
        <section class="section featured section-has-widgets fixed-height remove-sidebar">
        <div class="sidebar-b hide-on-mobile">
          <%~set adsize = '300x600'%>
          <%include include_ad.html%>
        </div><!-- end sidebar -->
        <div class="content content-has-sidebar">
          <div class="grid">
            <div class="col-1-1">
                <h1><%tag_title%></h1>
            </div>

            <%~if featured_articles_loop.length%>
            <!-- featured articles -->
            <%~set show_ad = 3%><%~set show_category = 1%>
            <%include include_featured_articles.html%>
            <%~set show_category = 0%>
            <%~endif%>
          </div>
        </div><!-- end content -->
        </section><!-- end section -->

        <%~endif%>


        <%~if paging.num_hits > 3%>
        <%if paging.current_page == 1%><div class="section-divider"></div><%endif%>
        <%~set list_view = ''%>
        <section class="section section-has-widgets section-reverse">
        <div class="sidebar-b">
          <%~set widgets_loop = Plugins::UI::fetch_widgets('category', $ID)%>
          <%~set widget_end   = $widgets_loop.length%>
          <%include include_widgets.html%>
        </div>

        <div class="content content-has-widgets">
          <div class="grid">
            <div class="col-1-1<%if paging.current_page > 1%> relative<%endif%>">
              <%~if paging.current_page > 1%>
              <h1><%tag_title%></h1>
              <div class="col-1-1 absolute-top right">
                  <%include include_paging.html%>
              </div>
              <%~endif%>

              <%~set show_category = 1%>
              <%~loop res.loop%>
              <%include link.html%>
              <%~if row_num == $num_page_break%><%lastloop%><%endif%>
              <%~endloop%>
              <%~if paging.max_hits < $paging.num_hits%>
              <div class="col-1-1 right">
                <%~set page_button = 'page_button2'%>
                <%include include_paging.html%>
              </div>
              <%~endif%>
            </div>

          </div>
          <div class="section-divider mobile"></div>
        </div><!-- end content -->
        </section><!-- end section -->
        <%~endif%>

        <div class="section-spacer"></div>

      </div><!-- End contentwrapper -->
    </div>
    <%include include_footer.html%>
  </div>
</body>
<%~include include_global_js.html%>