{% extends "layout.html" %}
{% block head %}
    <link type="text/css" rel="stylesheet" href="/media/js/date_input/date_input.css"/>
    <script type="text/javascript" src="/media/js/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="/media/js/date_input/jquery.date_input.js"></script>
    <script type="text/javascript">
      $($.date_input.initialize);
      $.extend(DateInput.DEFAULT_OPTS, {
        stringToDate: function(string) {
          var matches;
          if (matches = string.match(/^(\d{4,4})-(\d{2,2})-(\d{2,2})$/)) {
            return new Date(matches[1], matches[2] - 1, matches[3]);
          } else {
            return null;
          };
        },
      
        dateToString: function(date) {
          var month = (date.getMonth() + 1).toString();
          var dom = date.getDate().toString();
          if (month.length == 1) month = "0" + month;
          if (dom.length == 1) dom = "0" + dom;
          return date.getFullYear() + "-" + month + "-" + dom;
        },

        setPosition: function() {
          var offset = this.input.offset();
          this.rootLayers.css({
            top: this.input.top,
            left: this.input.left
          });
          
          if (this.ieframe) {
            this.ieframe.css({
              width: this.dateSelector.outerWidth(),
              height: this.dateSelector.outerHeight()
            });
          };
        }
      });
    </script>
  {% block date_input %}
  {% endblock %}
{% endblock %}
{% block search %}
<div id="search">
  <form action="/ts/search/" method="post">
    <input type="text" name="search_term" />
    <input type="submit" value="Search" />
  </form>
</div>
{% endblock %}
{% block info %}
<div id="info">
  <div id="tickets">tickets</div>
  <ul>
    <li><a href="/ts/filter?status=new">new: {{new}}</a></li>
    <li><a href="/ts/filter?status=!new&status=!resolved">open: {{open}}</a></li>
    <li><a href="/ts/filter?resp={{user}}&status=!resolved">own: {{my}}</a></li>
  </ul>
</div>
{% endblock %}
{% block menu %}
    <div id="menu">
      <ul>
        <li><a href="/ts/new">New ticket</a></li>
        <li><a href="/ts/index">Ticket index</a></li>
        <li>&nbsp;&nbsp;Filter tickets
          <ul>
            <li><a href="/ts/filter?status=new" class="first" title="unassigned tickets">New</a></li>
            <li><a href="/ts/filter?status=!new&status=!resolved" title="tickets that are not new and not resolved">Open</a></li>
            <li><a href="/ts/filter?resp={{user}}&status=!resolved" title="tickets assigned to you">Owned</a></li>
            <li><a href="/ts/filter" class="last">Custom filter</a></li>
          </ul>
{% if queues %}
          &nbsp;&nbsp;Queues
          <ul>
            {% for queue in queues %}
            <li><a href="/ts/filter?queue={{queue}}">{{queue}}</a></li>
            {% endfor %}
          </ul>
{% endif %}
        </li>
      </ul>
    </div>
{% endblock %}
