<div class="whiteSpace"></div>
<div class="container">
<div class="row">
<div class="span3">
<% @description = @league.description %>
<% if @portfolio.id.nil? %>
  <%= form_for [@league, @portfolio] do |f| %>
    <%= f.submit "Join this League", class: "btn btn-primary btn-quarter fixedButtons" %>
  <% end %> 
<% else %>
  <% if @portfolio.manager %>
    <%= button_to "League Settings", edit_league_path(@league), :method=>:get,  :class=>"btn btn-primary btn-quarter fixedButtons" %>
  <% else %>
    <%= button_to "Leave this League", league_portfolio_path(@league, @portfolio),:method=>:delete, :class=>"btn btn-primary btn-quarter fixedButtons" %>
  <% end %> 
<% end %>

</div>
<div class="span3">
  <table class="btn-table">
    <tr class="cell-height">
      <td class="btn-table-cell top-cell">Members</td>
    </tr>
    <tr>
      <td class="btn-table-cell bottom-cell"><%=@portfolios.length%></td>
    </tr>
  </table>
</div>
<div class="span3">
  <table class="btn-table">
    <tr class="cell-height">
      <td class="btn-table-cell top-cell">Start Date</td>
    </tr>
    <tr>
      <td class="btn-table-cell bottom-cell"><%=@league.start_date%></td>
    </tr>
  </table>
</div>
<div class="span3">
  <table class="btn-table">
    <tr class="cell-height">
      <td class="btn-table-cell top-cell">End Date</td>
    </tr>
    <tr>
      <td class="btn-table-cell bottom-cell"><%=@league.end_date%></td>
    </tr>
  </table>
</div>
</div>
<div class="row">
<div class="span12 whiteSpace"></div>
</div>
<div class="row">
  <div class="span3">
    <%= image_tag @league.icon.url, :class=>"bordz"%>
  </div>
  <table class="table table-bordered table-striped table-highlight span4 league-table">
    <thead>
      <tr>
        <th>#</th>
        <th>User</th>
        <th>Account created</th>
      </tr>
    </thead>
    <tbody>
    
      <% for port in @sortedPort %>
      <% portfolio = Portfolio.find(port[0]) %>

        <tr>
          <td><%= port[1] %></td>
          <td><a href="<%=league_portfolio_path(@league.id,portfolio.id)%>"><%if User.all[portfolio.user_id-1]%><%= User.all[portfolio.user_id-1].name  %><% end %></a></td>
          <td><%=portfolio.updated_at%></td>
        </tr>
      <% end %>
    </tbody>  
    </tbody>
  </table>
  <div class="span5">
    <div class="input-append">
    <%= form_for(Comment.new) do |f| %>
      <% if @focus %>
        <%= f.text_field :comment, :autofocus => true %>
      <% else %>
        <%= f.text_field :comment %>
      <% end %>
      <%= f.hidden_field :location_id, :value => @league.id %>
      <%= f.hidden_field :comment_type, :value => 1 %>
      <%= f.submit "Send", :class=>"btn" %>
    <% end %>
    </div>
    <% for comment in Comment.where("location_id = ? AND comment_type = ?", @league.id, 1).reverse[0,20] %>
      <% @curUser = User.find(comment.user_id)  %>
      <div class="post-container">                
        <div class="post-thumb"><%= link_to image_tag(@curUser.picture.url(:tiny),:class=>"rounded"), user_path(@curUser.id)%></div>
        <div class="post-content">
          <h4 class="fleft"><%=@curUser.name%></h4><h5 class="fright"><%= comment.posted_at.strftime("%b %d %I:%M%p") %></h5><br>
          <p class="commentFix"><%=comment.comment%></p>
        </div>
      </div>
      <div class="fivePix fixwidth"></div>
    <% end %>
</div>


<!-- Save for later for pagination
<h1><%= @league.name %></h1>
<%= will_paginate(@portfolios) %>

<ul class="portfolios">
  <%= render @portfolios %>
</ul>

<%= will_paginate(@portfolios) %>
-->

</div>
</div>
