<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <%= stylesheet_link_tag 'standard','superfish','niftyCorners', 'jquery-ui-1.8.15.custom', :cache => 'tracks-cached' %>
    <%= stylesheet_link_tag "print", :media => "print" %>
    <%= javascript_include_tag 'jquery-1.6.2.min', 'jquery-ui-1.8.15.custom.min',
      'jquery.truncator','jquery.jeditable.mini', 'jquery.cookie', 'jquery.blockUI',
      'jquery.form',
      :cache => 'jquery-cached' %>
    <%= javascript_tag_for_i18n_datepicker %>
    <%= javascript_include_tag 'hoverIntent','superfish','application',
      'accesskey-hints','niftycube','swfobject',
      :cache => 'tracks-cached' %>
    <%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %>
    <%= javascript_tag "var SOURCE_VIEW = '#{@source_view}';" %>
    <%= javascript_tag "var TAG_NAME = '#{@tag_name}';" if @tag_name %>
    <%= csrf_meta_tag %>
    <script type="text/javascript">
      var defaultContexts = <%= default_contexts_for_autocomplete rescue '{}' %>;
      var defaultTags = <%= default_tags_for_autocomplete rescue '{}' %>;
      var dateFormat = '<%= date_format_for_date_picker %>';
      var weekStart = '<%= current_user.prefs.week_starts %>';
      function relative_to_root(path) { return '<%= root_url %>'+path; };
      <% if current_user.prefs.refresh != 0 -%>
        setup_auto_refresh(<%= current_user.prefs["refresh"].to_i*60000 %>);
      <% end -%>
      <% unless controller.controller_name == 'feed' or session['noexpiry'] == "on" -%>
        setup_periodic_check("<%=url_for(:controller => "login", :action => "check_expiry")%>", 5*60);
      <% end -%>
      setup_periodic_check("<%=check_deferred_todos_path(:format => 'js')%>", 10*60, 'POST');
      <%= generate_i18n_strings %>
    </script>
    <link rel="shortcut icon" href="<%= url_for(:controller => 'favicon.ico') %>" />
    <%= auto_discovery_link_tag(:rss, {:controller => "todos", :action => "index", :format => 'rss', :token => "#{current_user.token}"}, {:title => t('layouts.next_actions_rss_feed')}) %>
    <link rel="search" type="application/opensearchdescription+xml" title="Tracks" href="<%= search_plugin_path %>" />
    <title><%= @page_title %></title>
  </head>

  <body class="<%= @controller.controller_name %>">
    <div id="topbar">
      <div id="date">
        <h1>
          <% if @count -%>
            <span id="badge_count" class="badge"><%= @count %></span>
          <% end -%>
          <%= l(Date.today, :format => current_user.prefs.title_date_format) %>
        </h1>
      </div>
      <div id="minilinks">
        <%= link_to(t('layouts.toggle_notes'), "#", {:accesskey => "S", :title => t('layouts.toggle_notes_title'), :id => "toggle-notes-nav"}) %>
        &nbsp;|&nbsp;
        <%= link_to( t('common.logout') + " (#{current_user.display_name}) »", logout_path) %>
      </div>
      <div id="navcontainer">
        <ul class="sf-menu">
          <li><%= navigation_link(t('layouts.navigation.home'), home_path, {:accesskey => "t", :title => t('layouts.navigation.home_title')} ) %></li>
          <li><%= navigation_link(t('layouts.navigation.starred'), tag_path("starred"), :title => t('layouts.navigation.starred_title')) %></li>
          <li><%= navigation_link(t('common.projects'), projects_path, {:accesskey=>"p", :title=>t('layouts.navigation.projects_title')} ) %></li>
          <li><%= navigation_link(t('layouts.navigation.tickler'), tickler_path, {:accesskey =>"k", :title => t('layouts.navigation.tickler_title')} ) %></li>
          <li><a href="#"><%= t('layouts.navigation.organize') %></a>
            <ul>
              <li><%= navigation_link( t('common.contexts'), contexts_path, {:accesskey=>"c", :title=>t('layouts.navigation.contexts_title')} ) %></li>
              <li><%= navigation_link( t('common.notes'), notes_path, {:accesskey => "o", :title => t('layouts.navigation.notes_title')} ) %></li>
              <li><%= navigation_link( t('layouts.navigation.recurring_todos'), {:controller => "recurring_todos", :action => "index"}, :title => t('layouts.navigation.recurring_todos_title')) %></li>
            </ul>
          </li>
          <li><a href="#"><%= t('layouts.navigation.view') %></a>
            <ul>
              <li><%= navigation_link( t('layouts.navigation.calendar'), calendar_path, :title => t('layouts.navigation.calendar_title')) %></li>
              <li><%= navigation_link( t('layouts.navigation.completed_tasks'), done_overview_path, {:accesskey=>"d", :title=>t('layouts.navigation.completed_tasks_title')} ) %></li>
              <li><%= navigation_link( t('layouts.navigation.feeds'), {:controller => "feedlist", :action => "index"}, :title => t('layouts.navigation.feeds_title')) %></li>
              <li><%= navigation_link( t('layouts.navigation.stats'), {:controller => "stats", :action => "index"}, :title => t('layouts.navigation.stats_title')) %></li>
            </ul>
          </li>
          <li><a href="#">Admin</a>
            <ul>
              <li><%= navigation_link( t('layouts.navigation.preferences'), preferences_path, {:accesskey => "u", :title => t('layouts.navigation.preferences_title')} ) %></li>
              <li><%= navigation_link( t('layouts.navigation.export'), {:controller => "data", :action => "index"}, {:accesskey => "i", :title => t('layouts.navigation.export_title')} ) %></li>
              <% if current_user.is_admin? -%>
                <li><%= navigation_link(t('layouts.navigation.manage_users'), users_path, {:accesskey => "a", :title => t('layouts.navigation.manage_users_title')} ) %></li>
              <% end -%>
            </ul>
          </li>
          <li><a href="#">?</a>
            <ul>
              <li><%= link_to t('layouts.navigation.integrations_'), integrations_path %></li>
              <li><%= link_to t('layouts.navigation.api_docs'), rest_api_docs_path %></li>
            </ul>
          </li>
          <li><%= navigation_link(image_tag("system-search.png", :size => "16X16", :border => 0), {:controller => "search", :action => "index"}, :title => t('layouts.navigation.search')) %></li>
        </ul>
      </div>
      <%= render_flash %>
    </div>

    <div id="content" class="<%= @controller.controller_name %>">
      <%= yield %>
    </div>

    <%= render :partial => "shared/footer" %>
  </body>
</html>
