{% extends "search/base.html" %}{% load molly_utils %}{% load i18n %}

{% block pagetitle %}{% trans "Search" %}{% endblock %}
{% block title %}{% trans "Search" %}{% if results %}: {{ search_form.data.query }}{% endif %}{% endblock %}

{% block content %}

<form method="get" action="{% url search:index %}">
    <!-- Doing the devil's work below: couldn't get a CSS design to work with Blackberry 8900 so using Tables as a last resort. Tim F -->
    <h2 class="invisible">{% trans "Search" %}</h2>    
    <table class="search">
        <tbody>
            <tr>
                <td>
                    <label class="invisible" for="id_query">{% trans "Search" %}</label>
                    {{ search_form.query }}
                </td>
                <td>
                    {% ifequal style_group "dumb" %}
                        <button type="submit">{% trans "Go!" %}</button>
                    {% else %}
                        <input type="image" src="{{ STATIC_URL }}site/images/buttons/search-button.png" title="{% trans "Search" %}" alt="{% trans "Search" %}" />
                    {% endifequal %}
                </td>
            </tr>    
        </tbody>
    </table>
</form>

{# Results Page #}
{% if search_form.is_valid %}
<div class="section">
    <div class="header">
      <h2>{% trans "Results" %}</h2>
    </div>
    {% if results %}
  	<ol class="search-results">
	{% for result in results %}
	    <li>
                <a href="{{ result.url }}">
                    {% if result.application %}
                        <img src="{{ STATIC_URL }}site/images/index-icons/{{ result.application }}-bc.png" />
                    {% endif %}
                    {{ result.title|safe }}<br/>
                    {% if result.additional %}
                        <small><em>{{ result.additional|safe }}</em></small><br/>
                    {% endif %}
                    <small>{{ result.excerpt|safe }}</small>
                </a>
	    </li>
            {% endfor %}
	</ol>
    {% else %}
	<div class="note"><div class="bubble pad-10">
            {% trans "Sorry, your search returned no results." %}
        </div></div>
    {% endif %}
</div>

{# Search Elsewhere #}
<div class="section">
    <div class="header">
	<h2>Specific searches</h2> 
    </div>
    <ul class="link-list">
	{% if "contact"|app_is_loaded %}
	    <li><a href="{% url contact:result_list %}?query={{ search_form.data.query }}&amp;medium=email">E-mail addresses associated with name <em>'{{ search_form.data.query }}'</em></a></li>
	    <li><a href="{% url contact:result_list %}?query={{ search_form.data.query }}&amp;medium=phone">Phone numbers associated with name <em>'{{ search_form.data.query }}'</em></a></li>
	{% endif %}
	{% if "library"|app_is_loaded %}
	    <li><a href="{% url library:search %}?title={{ search_form.data.query }}">Library books titled with <em>'{{ search_form.data.query }}'</em></a></li>
	    <li><a href="{% url library:search %}?author={{ search_form.data.query }}">Library books authored by <em>'{{ search_form.data.query }}'</em> </a></li>
	{% endif %}
    </ul>
</div>
{# End Search Elsewhere #}

{% endif %}
{# End Results Page #}
{% endblock %}
