 <%# TODO - DRY the whole partial with SelectorHelper? %>

<% content_for :javascripts do %>
   <%= javascript_include_tag 'jqueryui/jquery-ui-1.9.2.custom.min.js' %>
   <%= stylesheet_link_tag "//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css" %>
<% end %>

<div id='selector-widgets' class='clearfix'>

  <div data-selector='metric' id='metric-selector' class='detail-selector'>
    <div class="chart-control-buttons" id='metric-type-buttons'>
      <span data-metric-type="metric" class='current metric-type-button'>Metrics</span>
      <span class="metric-type-button" data-metric-type="method">Methods</span>
    </div>

    <% if @metrics.present? %>
      <div data-metric-unit="<%= @metrics.first.name == 'hits' ? 'hits' :  @metrics.first.unit %>" data-metric='<%= @metrics.first.name %>' id='current-metric' class="selector current-item">
	<span id='metric-name' class='item-name'><%= @metrics.first.friendly_name %>
	</span>
      </div>
    <% end -%>

    <ul style="display:none;" data-type="method" class='metric-list toggle' id="methods-ul">
      <%= render 'stats/methods_lis' %>
    </ul>

    <ul style="display:none;" data-type='metric' class='metric-list toggle' id="metrics-ul">
      <%= render 'stats/metrics_lis' %>
    </ul>
  </div>

  <div class="detail-selector">
    <div class="chart-control-buttons" id='period-buttons'>
      <span class='period' data-value='year'>Year</span>
      <span class='period current' data-value='month'>Month</span>
      <span class='period' data-value='week'>Week</span>
      <span class='period' data-value='day'>Day</span>
      <span id="submit-stats-search" style='display:none;'>Apply</span>
    </div>

    <div data-date='<%= since.to_date.strftime("%Y-%m-%d") %>' id='current-date' class="selector current-item">
      <span id='date-name' class='item-name'><%= since.strftime("%e %b") %>
      </span>
    </div>
    <div id="datepicker-box" style="display:none;" class='toggle'>
      <div id="datepicker"></div>
    </div>
  </div>

  <%# TODO: (refactor) - this is really stupid way to create a 'hidden' parameter %>
  <% timezone = current_account.provider? ? 
        current_account.timezone  : current_account.provider_account.timezone %>
        
  <input type='hidden' id="current-timezone" data-timezone='<%= timezone  %>' />


  <h3 id='total-and-period'></h3>
</div>
