<% render_sidebar = sidebar_content? %>
<% render_left_sidebar = !in_mobile_view? && content_for?(:left_sidebar) %>
<!DOCTYPE html>
<html lang="<%= current_language %>">
<%= render :partial => 'layouts/base_html_header' %>
<body class="<%= body_css_classes %><%= sidebar_expanded?('hide_sidebar', true) ? '' : ' nosidebar' %>">
<%= call_hook :view_layouts_base_body_top %>
<div id="wrapper">

  <% enable_flyout = false %>
  <% if enable_flyout %>
    <div class="flyout-menu js-flyout-menu">
      <% if User.current.logged? || !Setting.login_required? %>
        <div class="flyout-menu__search">
          <%= form_tag({:controller => 'search', :action => 'index', :id => @project}, :method => :get) do %>
            <%= hidden_field_tag(controller.default_search_scope, 1, :id => nil) if controller.default_search_scope %>
            <%= label_tag 'flyout-search', '&#9906;'.html_safe, :class => 'search-magnifier search-magnifier--flyout' %>
            <%= text_field_tag 'q', @question, :id => 'flyout-search', :class => 'small js-search-input', :placeholder => l(:label_search) %>
          <% end %>
        </div>
      <% end %>

      <% if User.current.logged? %>
        <div class="flyout-menu__avatar
          <% if !Setting.gravatar_enabled? %>flyout-menu__avatar--no-avatar
          <% end %>">
          <% if Setting.gravatar_enabled? %>
            <%= link_to(avatar(User.current, :size => "80"), user_path(User.current)) %>
          <% end %>
          <%= link_to_user(User.current, :format => :username) %>
        </div>
      <% end %>

      <% if display_main_menu?(@project) %>
        <h3><%= l(:label_project) %></h3>
        <span class="js-project-menu"></span>
      <% end %>

      <h3><%= l(:label_general) %></h3>
      <span class="js-general-menu"></span>

      <span class="js-sidebar flyout-menu__sidebar"></span>

      <h3><%= l(:label_profile) %></h3>
      <span class="js-profile-menu"></span>

    </div>
  <% end %>

  <div id="wrapper2">
    <div id="wrapper3">

      <%= render :partial => 'layouts/base_body_header' %>
      <%= render :partial => 'layouts/easy_servicebar', :locals => {:render_sidebar => render_sidebar} %>
      <% if render_left_sidebar %>
        <div id="easy_left_servicebar">
          <%= yield :left_sidebar %>
        </div>
      <% end %>

      <div id="main">
        <%= render :partial => 'layouts/easy_project_header' %>
        <% if render_sidebar %>
          <div id="sidebar">
            <div id="sidebar_inner">
              <% if content_for?(:easy_page_layout_service_box_primary_actions) %>
                <div class="primary-actions">
                  <%= yield(:easy_page_layout_service_box_primary_actions) %>
                </div>
              <% end -%>
              <div id="sidebar_content">
                <div class="easy-scroller">
                  <div>
                    <% if content_for?(:easy_page_layout_service_box) || content_for?(:easy_page_layout_service_box_top) %>
                      <div id="easy_page_layout_service_box">
                        <%= yield(:easy_page_layout_service_box_top) %>
                        <%= yield(:easy_page_layout_service_box) %>
                      </div>
                    <% end -%>
                    <%= yield :sidebar %>
                  </div>
                </div>
              </div>
              <div id="sidebar_footer">
                <div id="sidebar_exports">
                  <%= yield :sidebar_exports %>
                  <%= view_layouts_base_sidebar_hook_response %>
                </div>
              </div>
              <span class="sidebar-control"><a href="javascript:EASY.utils.toggleSidebar();" title="Toggle sidebar"></a></span>
            </div>
          </div>
        <% end -%>

        <div id="content">
          <%= render_flash_messages %>
          <%= content_tag(:div, :class => 'easy-content-page') do %>
            <%= yield %>
            <%= call_hook :view_layouts_base_content %>
          <% end -%>
        </div>
      </div>

    </div>

    <%= render(:partial => 'layouts/base_body_footer_wrapper') %>

  </div>
</div>
<%= call_hook :view_layouts_base_body_bottom %>
<%= yield :body_bottom %>
</body>
</html>
