{% extends "telemeta/base.html" %}
{% load telemeta_tags %}
{% load i18n %}

{% block head_title %}{% trans "Geographic Navigator" %} - {{ block.super }}{% endblock %}

{% block extra_javascript %}
{% if gmap_key %}
<script src="http://www.google.com/jsapi?key={{ gmap_key }}" type="text/javascript"></script>
<script src="{{ STATIC_URL }}telemeta/js/resourcemap.js" type="text/javascript"></script>
<script type="text/javascript">
var resourceMap = new ResourceMap('.continents', {
    'countryInfoUri': '/geo/country_info/RESOURCEID/'
});
</script>
{% endif %}
{% endblock %}

{% block title %}
 <img src="{{ STATIC_URL }}telemeta/images/world_red.png" alt="geo-navigator" style="vertical-align:middle" /> {% trans "Geographic Navigator" %}
{% endblock %}

{% block title_buttons %}
        {% if continents %}
        <a href="#" onclick="resourceMap.toggle('map'); return false;" class="component button">{% trans "Map" %}</a> |
        <a href="#" onclick="resourceMap.toggle('list'); return false;" class="component button">{% trans "List" %}</a>
        {% endif %}
{% endblock %}

{% block content %}
{% if continents %}
<ul class="continents">
{% for group in continents %}
  <li class="name {% if not forloop.counter0|divisibleby:"2" %}odd{% endif %}"><b><a href="{% url "telemeta-geo-countries" group.continent.flatname %}">{{ group.continent }}</a></b>
    <ul>
    {% for country in group.countries %}
      <li id="resource-{{country.id}}" class="country_name resourcemap-element">
        <a href="{% url "telemeta-geo-country-collections" group.continent.flatname country.flatname %}">
          <span class="resourcemap-name">{{ country }}</span></a>
        {% if not country.latitude|is_none and not country.longitude|is_none %}
        <input type="hidden" class="resourcemap-lat" value="{{country.latitude}}" />
        <input type="hidden" class="resourcemap-lng" value="{{country.longitude}}" />
        {% endif %}
      </li>
    {% endfor %}
    </ul>
  </li>
{% endfor %}
</ul>
{% else %}
<p>No data</p>
{% endif %}
{% endblock %}
