<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><%= content_for?(:title) ? yield(:title) : "Huginn" %></title>
    <meta name="description" content="">
    <meta name="author" content="">
    <%= stylesheet_link_tag    "application", :media => "all" %>
    <%= javascript_include_tag "application" %>
    <%= csrf_meta_tags %>
    <%= yield(:head) %>
  </head>
  <body>
    <header class="navbar navbar-fixed-top">
      <nav class="navbar-inner">
        <div class="container">
          <%= render 'layouts/navigation' %>
        </div>
      </nav>
    </header>

    <div id="main" role="main">
      <div class="container">
        <div class="content">
           <div class="row">
            <div class="span12">
              <%= render 'layouts/messages' %>
              <%= yield %>
            </div>
          </div>
        </div>
      </div>
    </div>

    <script>
      var agentPaths = {};
      <% if current_user -%>
        var myAgents = <%= Utils.jsonify(current_user.agents.select([:name, :id, :schedule]).inject({}) {|m, a| m[a.name] = agent_path(a); m }) %>;
        $.extend(agentPaths, myAgents);
      <% end -%>
      agentPaths["All Agents Index"] = <%= Utils.jsonify agents_path %>;
      agentPaths["New Agent"] = <%= Utils.jsonify new_agent_path %>;
      agentPaths["Account"] = <%= Utils.jsonify edit_user_registration_path %>;
      agentPaths["Events Index"] = <%= Utils.jsonify events_path %>;
      agentPaths["View Agent Diagram"] = <%= Utils.jsonify diagram_agents_path %>;
      agentPaths["Run Event Propagation"] = { url: <%= Utils.jsonify propagate_agents_path %>, method: 'POST' };
      var agentNames = [];
      $.each(agentPaths, function(name, v) { agentNames.push(name); });
    </script>
  </body>
</html>
