<% selected_tab = params[:tab] ? params[:tab].to_s : tabs.first[:name] %>

<div class="tabs">
  <ul>
    <% tabs.each do |tab| -%>
        <li><%= link_to tab[:label], tabs_contact_path(@contact, :tab => tab[:name]),
                        :id => "tab-#{tab[:name]}",
                        :class => (tab[:name] != selected_tab ? 'tab-header' : 'selected tab-header'),
                        :data => { :name => tab[:name], :partial => tab[:partial], :project_id => @project},
                        :onclick => "showContactTab('#{tab[:name]}'); this.blur(); return false;" %></li>
    <% end -%>
  </ul>
  <div class="tabs-buttons" style="display:none;">
    <button class="tab-left" onclick="moveTabLeft(this);"></button>
    <button class="tab-right" onclick="moveTabRight(this);"></button>
  </div>
</div>

<% tabs.each do |tab| %>
    <% selected = tab[:name] == selected_tab %>
    <div class='tab-placeholder tab-content <%= 'active loaded' if selected %>' id='tab-placeholder-<%= tab[:name] %>' style='<%= "display: block" if selected %>'>
      <%= render(:partial => tab[:partial]) if selected %>
    </div>
<% end %>
<script type='text/javascript'>
  $(document).ready(displayTabsButtons);
  $(window).resize(displayTabsButtons);
  $(document).ready(function(){ setupDeferredTabs('<%= load_tab_contact_path(@contact) %>') });
</script>
