[% META title = 'Addressbook' %]

  <div id="headimg">
    <img src="/grafik/area.jpg" width="869" height="69" alt="" />
  </div>
  <div id="headtxt">[% Catalyst.loc('Your personal addressbook.') %]</div>

  <div id="main">

    <div id="topmsg">
      <p> [% messages.topmsg %] </p>
    </div>
    <div id="toperr">
      <p> [% messages.toperr %] </p>
      <p> [% messages.prov_error %] </p>
    </div>

    <div class="sperrehead">
      <h3>[% Catalyst.loc('Contacts') %]</h3>
      <h2 class="umleitungfuer">[% Catalyst.loc('Contacts for [_1]', subscriber.active_number) %]</h2>
    </div>

    <div id="spalten31">

      <div class="spalte1">

        <p class="kontaktneu">
          <label for="addrbook_new">[% Catalyst.loc('create new contact') %]</label>
          <form action="/addressbook/edit" method="post">
            <input type="hidden" name="addrbook_id" value="0" />
            <input type="image" class="hidden" src="/grafik/dot_trans.gif" alt="" id="addrbook_new" />
          </form>
        </p>
        <p class="anruflisteordnen">
          [% Catalyst.loc('Filter:') %] &nbsp;
          <a href="/addressbook?charsel=" class="[% UNLESS docharsel %]on[% END %]">[% Catalyst.loc('all') %]</a> 

          [% FOREACH contactindex = subscriber.contacts %]
          <a href="/addressbook?charsel=[% contactindex.index %]"
             class="[% IF docharsel && charsel == contactindex.index %]on[% END %]">[% contactindex.index %]</a> 
          [% END %]

          <br />

          [% Catalyst.loc('Order by') %]: &nbsp;
          <a href="/addressbook?sortsel=firstname" class="[% IF sortsel == 'firstname' %]on[% END %]">[% Catalyst.loc('firstname') %]</a> 
          <a href="/addressbook?sortsel=lastname" class="[% IF sortsel == 'lastname' %]on[% END %]">[% Catalyst.loc('lastname') %]</a>
          <a href="/addressbook?sortsel=company" class="[% IF sortsel == 'company' %]on[% END %]">[% Catalyst.loc('company') %]</a>
        </p>

        <table class="anrufliste kontaktliste kontaktlistebig">

        [% i = 0 %]
        [% FOREACH contactindex = subscriber.contacts %]

        [% IF docharsel && charsel != contactindex.index %][% NEXT %][% END %]

          <tr class="anruflisteheader">
            <td colspan="5">
              <h3>[% contactindex.index %]</h3>
            </td>
          </tr>

          [% FOREACH contactentry = contactindex.contacts %]

            [% IF contactentry.id == detail %]
            <tr class="kontaktopen">
            [% ELSE %]
            <tr class="[% contactentry.background %]">
            [% END %]
              <td class="anrufperson">
                <a href="/addressbook?detail=[% IF contactentry.id == detail %]0[% ELSE %][% contactentry.id %][% END %]" class="kontaktmehr">
                  [% contactentry.firstname %] [% contactentry.lastname %]
                </a>
              </td>
              <td class="anruffirma">[% contactentry.company %]</td>
              <td class="anrufnummer">
                [% IF contactentry.phonenumber || contactentry.mobilenumber || contactentry.homephonenumber %]
                [% i = i + 1 %]
                <div class="yui-skin-sam" id="cd[% i %]">
                  [% contactentry.phonenumber || contactentry.mobilenumber || contactentry.homephonenumber %]
                  <img src="/grafik/call.gif" width="12" height="14" alt="" title="[% Catalyst.loc('show actions') %]"
                       onclick="cl_pop('cd[% i %]','[% contactentry.phonenumber ||
                                                       contactentry.mobilenumber ||
                                                       contactentry.homephonenumber %]')" />
                </div>
                [% END %]
              </td>
              <form id="addrbookedit" action="/addressbook/edit" method="post">
                <input type="hidden" name="addrbook_id" value="[% contactentry.id %]" />
                <td><input type="image" src="/grafik/edit.gif" alt="" id="addrbook_edit_[% contactentry.id %]"></td>
              </form>
              <form id="addrbookdelete" action="/addressbook/delete" method="post">
                <input type="hidden" name="addrbook_id" value="[% contactentry.id %]" />
                <td><input type="image" src="/grafik/delete.gif" alt="" id="addrbook_delete_[% contactentry.id %]"></td>
              </form>
            </tr>

            [% IF contactentry.id == detail %]
            <tr>
              <td colspan="5" class="kontaktopen">
                [% IF contactentry.homephonenumber || contactentry.phonenumber || contactentry.mobilenumber || contactentry.faxnumber %]
                <table>
                  <tr><td colspan="2"><h3>[% Catalyst.loc('phone numbers') %]</h3></td></tr>
                  [% IF contactentry.homephonenumber %]
                    <tr>
                      <td class="first">[% Catalyst.loc('home:') %]</td>
                      <td>
                        [% i = i + 1 %]
                        <div class="yui-skin-sam" id="cd[% i %]">
                          [% contactentry.homephonenumber %]
                          <img src="/grafik/call.gif" width="12" height="14" alt="" title="[% Catalyst.loc('show actions') %]"
                               onclick="cl_pop('cd[% i %]','[% contactentry.homephonenumber %]')" />
                        </div>
                      </td>
                    </tr>
                  [% END %]
                  [% IF contactentry.phonenumber %]
                    <tr>
                      <td class="first">[% Catalyst.loc('office:') %]</td>
                      <td>
                        [% i = i + 1 %]
                        <div class="yui-skin-sam" id="cd[% i %]">
                          [% contactentry.phonenumber %]
                          <img src="/grafik/call.gif" width="12" height="14" alt="" title="[% Catalyst.loc('show actions') %]"
                               onclick="cl_pop('cd[% i %]','[% contactentry.phonenumber %]')" />
                        </div>
                      </td>
                    </tr>
                  [% END %]
                  [% IF contactentry.mobilenumber %]
                    <tr>
                      <td class="first">[% Catalyst.loc('mobile:') %]</td>
                      <td>
                        [% i = i + 1 %]
                        <div class="yui-skin-sam" id="cd[% i %]">
                          [% contactentry.mobilenumber %]
                          <img src="/grafik/call.gif" width="12" height="14" alt="" title="[% Catalyst.loc('show actions') %]"
                               onclick="cl_pop('cd[% i %]','[% contactentry.mobilenumber %]')" />
                        </div>
                      </td>
                    </tr>
                  [% END %]
                  [% IF contactentry.faxnumber %]
                    <tr><td class="first">[% Catalyst.loc('fax:') %]</td><td>[% contactentry.faxnumber %]</td></tr>
                  [% END %]
                </table>
                [% END %]
                [% IF contactentry.email || contactentry.homepage %]
                <table>
                  <tr><td colspan="2"><h3>[% Catalyst.loc('web') %]</h3></td></tr>
                  [% IF contactentry.email %]
                    <tr><td class="first">[% Catalyst.loc('e-mail:') %]</td><td><a href="mailto:[% contactentry.email %]">[% contactentry.email %]</a></td></tr>
                  [% END %]
                  [% IF contactentry.homepage %]
                    <tr><td class="first">[% Catalyst.loc('homepage:') %]</td><td><a href="[% contactentry.homepage %]">[% contactentry.homepage %]</a></td></tr>
                  [% END %]
                </table>
                [% END %]
              </td>
            </tr>
            [% END %]

          [% END %]

        [% END %]

        </table>

      </div>
      <div class="spalte2">

        <h3>[% Catalyst.loc('Search') %]</h3>

        <form id="anrufsuche" action="">
          <label for="fsuchbegriff">[% Catalyst.loc('search term') %]</label><br />
          <input type="text" id="ffilter" name="filter" size="21" class="input21" value="[% filter %]" />
          <br clear="all" />
          <input type="image" class="hidden" src="/grafik/dot_trans.gif" alt="" id="addrbook_filter" />
          <div class="save"><label for="addrbook_filter">[% Catalyst.loc('apply filter') %]</label></div>
        </form>

      </div>

    </div>

  </div><br clear="all" />

