<!DOCTYPE html >
<%~set search_widget = 1%>
<%~set poll_widget = 1%>
<html lang="en">
<head>
    <title><%cat_full_name%>: <%forum_name%><%if this_page > 1%>: Page <%this_page%><%endif%></title>
<%include include_common_head.html%>
</head>

<%~set hidden_sort = ''%><%set hidden_page = ''%><%set form_sort = ''%><%set form_page = ''%>
<%~if in.sb%><%set hidden_sort .= ";sb=$sb"%><%set form_sort .= "<input type=\"hidden\" name=\"sb\" value=\"$sb\" />"%><%endif%>
<%~if in.so%><%set hidden_sort .= ";so=$so"%><%set form_sort .= "<input type=\"hidden\" name=\"so\" value=\"$so\" />"%><%endif%>
<%~if in.mh%><%set hidden_page .= ";mh=$mh"%><%set form_page .= "<input type=\"hidden\" name=\"mh\" value=\"$mh\" />"%><%endif%>
<%~if in.page%><%set hidden_page .= ";page=$this_page"%><%set form_page .= "<input type=\"hidden\" name=\"page\" value=\"$this_page\" />"%><%endif%>
<%~set do = ''%><%if in.do%><%set do = "do=$this_do;"%><%endif%>
<body class="page-<%page_id%>">
  <div class="container-b">
    <%include include_header.html%>

    <div class="main">
      <div class="contentwrapper clearfix">
        <div class="sidebar">
          <%include include_sidebar.html%>
        </div>
        <%~set content_header_title = $forum_name%>
        <%~set btn_new = 1%>
        <%~init array breadcrumbs%><%init hash breadcrumbs.0%>
        <%~set breadcrumbs.0.name = $forum_name%>
        <%~set breadcrumbs.0.url  = GForum::SEO::url(params => "forum=$forum_id")%>

        <%include include_breadcrumb.html%>

        <%~set paging_do = ''%>
        <%~if in.do%>
        <%~set paging_do = "do=$this_do"%>
        <%~endif%>
        <%~set pagination_options.type = 'forum'%>
        <%~set pagination_options.id = $forum_id%>
        <%~set pagination_options.params = "$paging_do$hidden_sort$hidden_page"%>
        <%~set pagination_options.page_items = $forum_total_threads%>

        <div class="content"><%-- start content--%>
          <%include include_content_header.html%>
          <div class="toolbar-b clearfix">
            <%include include_hot_topics.html%>
            <%include include_quicklaunch.html%>
          </div>

          <div class="dtable bg"><%-- start table --%>
            <div class="dhead">
              <div class="drow">
                <div class="dcell icon">&nbsp;</div>
                <div class="dcell subject">
                  <%~if sb eq post_subject and so ieq asc%><%set url_param_subject_so = 'desc'%><%else%><%set url_param_subject_so = 'asc'%><%endif%>
                  <a href="<%GForum::SEO::url(params => "${do}forum=$forum_id;sb=post_subject;so=$url_param_subject_so$hidden_page")%>" title="Sort by Subject">
                    Subject
                    <%~if sb eq post_subject%> <span class="<%if so ieq asc%>ascending<%else%>descending<%endif%>"></span><%endif~%>
                  </a>
                </div>
                <div class="dcell author">
                  <%~if sb eq post_username and so ieq asc%><%set url_param_author_so = 'desc'%><%else%><%set url_param_author_so = 'asc'%><%endif%>
                  <a href="<%GForum::SEO::url(params => "${do}forum=$forum_id;sb=post_username;so=$url_param_author_so$hidden_page")%>" title="Sort by Author"><%~%>
                    Author
                    <%~if sb eq post_username%> <span class="<%if so ieq asc%>ascending<%else%>descending<%endif%>"></span><%endif~%>
                  </a>
                </div>
                <div class="dcell views">Views</div>
                <div class="dcell replies">
                  <%~if sb eq post_replies and so ieq desc%><%set url_param_replies_so = 'asc'%><%else%><%set url_param_replies_so = 'desc'%><%endif%>
                  <a href="<%GForum::SEO::url(params => "${do}forum=$forum_id;sb=post_replies;so=$url_param_replies_so$hidden_page")%>" title="Sort by # of Replies"><%~%>
                    Replies
                    <%~if sb eq post_replies%> <span class="<%if so ieq asc%>ascending<%else%>descending<%endif%>"></span><%endif~%>
                  </a>
                </div>
                <div class="dcell date">
                  <%~if sb eq post_latest_reply and so ieq asc%><%set url_param_last_post_so = 'desc'%><%else%><%set url_param_last_post_so = 'asc'%><%endif%>
                  <a href="<%GForum::SEO::url(params => "${do}forum=$forum_id;sb=post_latest_reply;so=$url_param_last_post_so$hidden_page")%>" title="Sort by # of Replies" rel="nofollow"><%~%>
                    Last Post
                    <%~if sb eq post_latest_reply%> <span class="<%if so ieq asc%>ascending<%else%>descending<%endif%>"></span><%endif~%>
                  </a>
                </div>
              </div>
            </div>
            <div class="dbody">
            <%~loop post_loop%>
            <%~if post_locked%><%set icon_class = 'locked-thread'%>
            <%~elsif post_thread_hot%><%set icon_class = 'hot-thread'%>
            <%~elsif post_new and new_replies%><%set icon_class = 'new-replies'%>
            <%~elsif post_replies == 1%><%set icon_class = 'first-post'%>
            <%~elsif post_replies%><%set icon_class = 'thread'%>
            <%~elsif post_new%><%set icon_class = 'new-thread'%>
            <%~else%><%set icon_class = 'single-thread'%><%endif%>
              <div class="drow<%if post_sticky%> sticky-thread<%endif%>">
                <div class="dcell icon"><span class="sprite-<%icon_class%>"></span></div>
                <div class="dcell subject">
                  <%~unless post_moved and post_moved_perm < 3%>

                      <%~set forum_view = ''%>
                      <%~if in.do%>
                        <%~set forum_view = "forum_view=$this_do&"%>
                      <%~endif%>
                      <%~if post_moved%><%set url_id = $post_moved_id%><%else%><%set url_id = $post_id%><%endif%>
                      <%~set url_anchor = ""%>
                      <%~set url_param_unread = ""%>
                      <%~if current.user_default_post_display == 1 or not current.user_id%>
                          <%~if post_depth%>
                              <%~set url_anchor = "p$post_id"%>
                          <%~elsif current.user_jump_to_unread%>
                              <%~set url_param_unread = ";page=unread"%>
                              <%~set url_anchor = "unread"%>
                          <%~endif%>
                      <%~endif%>
                  <%~endunless%>

                  <%~if post_sticky%> <span class="sticky">Sticky:</span><%endif%>
                  <%~if post_moved%> <span class="moved">Moved:</span><%endif%>

                  <a href="<%GForum::SEO::url(type => "post", id => $url_id, params => "$forum_view$hidden_sort$url_param_unread", anchor => $url_anchor)%>" class="title">
                    <% post_subject %>
                  </a>
                  <div class="post-mob">
                    <span>by</span>
                    <%~set escaped_username = escape_url $post_username%>
                    <a href="<%GForum::SEO::url(params => "username=$escaped_username")%>" class="postedby"><%post_username %></a> <span>
                    <%if not post_moved%>
                    | <% post_latest_reply_date %>| <% post_replies || 0 %> replies</span> 
                    <%~if post_depth == 0%>
                    <%~set url_param_page_last = "post=last-"%>
                    <%~if post_moved%><%set url_param_page_last .= "$post_moved_id"%><%else%><%set url_param_page_last .= "$post_id"%><%endif%>
                    <%~set url_anchor = ""%>
                    <%~if post_display_is_flat%><%set url_anchor = "last"%><%endif%>
                    <a href="<%GForum::SEO::url(params => "$forum_view$hidden_sort$url_param_page_last", anchor => $url_anchor)%>" rel="nofollow" class="right-arrow">&rarr;</a>
                    <%~endif%>
                    <%~endif%>

                    <%-- Server ad on mobile --%>
                    <%~if row_num == 3 %>
                      <%~set serve_ad = 1%><%set count = 0%><%set ad_count = 1%>
                    <%~else%>
                      <%~set count += 1%><%set show_poll = $count % 25 %><%set show_ad = $count % 10 %>
                      <%~if not $show_ad %>
                        <%~set serve_ad = 1%>
                        <%~if not $show_poll%>
                          <div class="mobpoll">
                          <%include include_poll_widget.html%>
                          <%~set serve_ad = 0%><%set count = 0%>
                          </div>
                        <%endif%>
                      <%endif%>
                    <%~endif%>

                  </div>
                  <%~if $serve_ad%><%set height_choice = $ad_count % 2%>
                  <%~if not height_choice%><%set ad_height = 250%><%else%><%set ad_height = 600 %><%endif%>
                  <%~set ad_count += 1%>
                  <%include include_ad_mobile.html%>
                  <%~set serve_ad = 0%>
                  <%~endif%>
                </div>
                <div class="dcell author">
                  <%~set include_username_display = $post_username%>
                  <%include include_username.html%>
                </div>
                <div class="dcell views"><%if not post_moved%><%post_views%><%endif%></div>
                <div class="dcell replies"><%if not post_moved%><%post_replies%><%endif%></div>
                <div class="dcell date">
                  <%~if not post_moved%>
                  <%post_latest_reply_date%>
                  <span class="nowrap-text">
                    <%~if post_replies%> 
                    <%~set escaped_username = escape_url $post_latest_poster%>
                    by <a href="<%GForum::SEO::url(params => "username=$escaped_username")%>" class="postedby"><%post_latest_poster%></a>
                    <%~endif%>

                    <%~-- Show jump image for root posts --%>
                    <%~if post_depth == 0%>
                    <a href="<%GForum::SEO::url(params => "$forum_view$hidden_sort$url_param_page_last", anchor => $url_anchor)%>" rel="nofollow" class="right-arrow">&rarr;</a>
                    <%~endif%>
                  </span>
                  <%~endif%>
                </div>
              </div>
            <%~ endloop %>
            </div>
          </div><%-- end dtable --%>

          <div class="toolbar clearfix">
            <hr class="line" />
            <%~set paging_do = ''%>
            <%~if in.do%>
            <%~set paging_do = "do=$this_do"%>
            <%~endif%>
            <%~set pagination_options.type = 'forum'%>
            <%~set pagination_options.id = $forum_id%>
            <%~set pagination_options.params = "$paging_do$hidden_sort$hidden_page"%>
            <%~set pagination_options.page_items = $forum_total_threads%>

            <%include include_paging.html%>
            <%include include_forum_actions.html%>

          </div>
          <%-- ad for tablet --%> 
          <%include include_ad_tablet.html%>

        </div><%-- end content --%>
      </div><%-- end contentwrapper --%>
    </div><%-- end main --%>
    <%include include_footer.html%>
  </div>
</body>
<%~include include_global_js.html%>
</html>
