<%= form_tag send("#{auto_complete_controller_name}_path"), :method => "get",:id =>"search-form" do %>
  <div class="input-group">
    <%= auto_complete_search(:search, params[:search].try(:squeeze," "), :placeholder => _("Filter") + ' ...').html_safe %>
    <span class="input-group-btn">
      <button class="btn btn-default" type="submit">
        <%= icon_text("search", content_tag(:span,_("Search"), :class=>"hidden-xs")) %>
      </button>
      <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
        <span class="caret"></span>
      </button>
      <ul class="dropdown-menu pull-right">
        <% bookmarks = Bookmark.my_bookmarks.controller(auto_complete_controller_name) %>
        <% bookmarks.each do |bookmark| %>
          <li><%= link_to_if_authorized bookmark.name, send("hash_for_#{bookmark.controller}_path").merge(:search => bookmark.query) %></li>
        <% end %>
        <li class="divider"></li>
        <li><%= link_to_function _('Bookmark this search'), "$('#bookmarks-modal').modal();",
                                 {:id => "bookmark", :"data-url"=> main_app.new_bookmark_path(:kontroller => auto_complete_controller_name)} %></li>
        <li><%= link_to(icon_text('question-sign', _('Documentation'), :class => 'icon-black'),
            "http://www.theforeman.org/manuals/#{SETTINGS[:version].short}/index.html#4.1.5Searching",
            :rel => 'external', :target => '_blank')
  %></li>
      </ul>
    </span>
  </div>
<% end %>

<div id="bookmarks-modal" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title"><%= _("Add Bookmark") %></h4>
      </div>
      <div class="modal-body">

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal"><%= _("Cancel") %></button>
        <button type="button" class="btn btn-primary"><%= _("Submit") %></button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
