<script>
SourcesCharts = {
  chart: null,
  date: "<%= @date.strftime('%F') %>",

  next: function() {
    $j.getJSON("<%= url_for :action => 'referrer_sources' %>", {date: SourcesCharts.date, direction: 'next'}, function(res) {SourcesCharts.load(res);});
  },

  prev: function() {
    $j.getJSON("<%= url_for :action => 'referrer_sources' %>", {date: SourcesCharts.date, direction: 'prev'}, function(res) {SourcesCharts.load(res);});
  },

  load: function(data) {
    SourcesCharts.date = data.date;
    SourcesCharts.chart.load(data);

    for(var i=0; i<data.total_values.length; i++) {
      $j('#chart_day' + (i+1)).text(data.days[i]);
      $j('#chart_date' + (i+1)).text(data.dates[i]);
      $j('#chart_value' + (i+1)).text(data.total_values[i] == '' ? '' : data.total_values[i]);
    }

    SourcesCharts.chart.draw();
  }
}
</script>

<div class='admin_content'>

<%= subpage_display :emarketing, @subpages %>

<br/>
<br/>

<div align="center">
<%= render :partial => 'referrer_sources' %>
</div>

</div>

<script>
SourcesCharts = {
  chart: null,
  date: "<%= @date.strftime('%F') %>",

  next: function() {
    $j.getJSON("<%= url_for :action => 'referrer_sources' %>", {date: SourcesCharts.date, direction: 'next'}, function(res) {SourcesCharts.load(res);});
  },

  prev: function() {
    $j.getJSON("<%= url_for :action => 'referrer_sources' %>", {date: SourcesCharts.date, direction: 'prev'}, function(res) {SourcesCharts.load(res);});
  },

  load: function(data) {
    SourcesCharts.date = data.date;
    SourcesCharts.chart.load(data);

    for(var i=0; i<data.total_values.length; i++) {
      $j('#chart_day' + (i+1)).text(data.days[i]);
      $j('#chart_date' + (i+1)).text(data.dates[i]);
      $j('#chart_value' + (i+1)).html(data.total_values[i] == '' ? '&nbsp;' : data.total_values[i]);
    }

    SourcesCharts.chart.draw();
  }
}
</script>

<% action_panel :more => true do |p| -%>
<% end -%>

<% more_action_panel do |p| -%>
  <% @subpages.each do |page| -%>
    <%= p.link page[0], page[3] %>
  <% end -%>
<% end -%>

<hr/>

<div class='admin_content'>

<div align="center">
<%= render :partial => 'referrer_sources' %>
</div>

</div>

Add more actions button for the rest of the stats
Add more actions button for the rest of the stats
