{% load admin_static %}
{% load i18n %}

<div id="toolbar">

{% if cl.search_fields %}
	<form id="changelist-search" action="" method="get">
	
		<div id="changelist-searcharea"><!-- DIV needed for valid HTML -->
		<label for="searchbar">
			<img src="{% static "img/admin/icon_searchbox.png" %}" alt="Search" />
		</label>
		
		<input type="text" size="40" name="{{ search_var }}" value="{{ cl.query }}" id="searchbar" />
		<input class="btn-search" type="submit" value="{% trans 'Search' %}" />
		
		{% if show_result_count %}
			<span class="small quiet">
			{% blocktrans count cl.result_count as counter %}1 result{% plural %}{{ counter }} results{% endblocktrans %} (<a href="?{% if cl.is_popup %}pop=1{% endif %}">{% blocktrans with cl.full_result_count as full_result_count %}{{ full_result_count }} total{% endblocktrans %}</a>)
			</span>
		{% endif %}
		{% for pair in cl.params.items %}
			{% ifnotequal pair.0 search_var %}<input type="hidden" name="{{ pair.0 }}" value="{{ pair.1 }}"/>{% endifnotequal %}
		{% endfor %}
		</div>
		
	</form>

{% endif %}
{% if cl.has_filters %}
  <button id="toolbar_search_btn">+ Filtro</button>
{% endif %}

</div>
<script type="text/javascript">
    if (document.getElementById("searchbar") != null) { document.getElementById("searchbar").focus(); }
    
    $("#toolbar_search_btn").click(function() {
	  $("#changelist-filter").toggleClass("hide");
	});
</script>
