<tr>
  <td class="control" align="left">
    <form method="post" name="contacts" action="<?php echo Horde::selfURL() ?>">
    <?php echo Horde::formInput() ?>
    <table border="0" cellpadding="0" cellspacing="1" width="100%">
    <tr>
      <th align="left" class="item" nowrap="nowrap" width="1%"><?php echo Horde::img('checkbox.gif', _("Checkbox")) ?></th>
      <th align="left" class="item" nowrap="nowrap" width="1%"><?php echo Horde::img('edit.gif', _("Edit")) ?></th>
      <th align="left" class="item" nowrap="nowrap" width="1%"><?php echo Horde::img('delete.gif', _("Delete")) ?></th>
      <th align="left" class="item" nowrap="nowrap" width="1%"><?php echo Horde::img('group.gif', _("Group")) ?></th>
      <th class="<?php echo ($prefs->getValue('sortby') == 0) ? 'selected' : 'item' ?>" width="<?php echo $width ?>%" align="left" nowrap="nowrap">
        <a class="widget" href="" onclick="Sort(0, <?php echo abs(1 - $prefs->getValue('sortdir')) ?>); return false; "><?php echo Horde::img($prefs->getValue('sortdir') ? 'za.gif' : 'az.gif', _("Sort Direction"), null, $registry->getParam('graphics', 'horde')) ?></a>
        <a class="widget" href="" onclick="Sort(0, <?php echo $prefs->getValue('sortdir') ?>); return false;"><?php echo $attributes['name']['label'] ?></a>
      </th>
    <?php for ($i = 1; $i <= count($columns); $i++): ?>
      <th class="<?php echo ($prefs->getValue('sortby') == $i) ? 'selected' : 'item' ?>" width="<?php echo $width ?>%" align="left" nowrap="nowrap">
        <a class="widget" href="" onclick="Sort(<?php echo $i ?>, <?php echo abs(1 - $prefs->getValue('sortdir')) ?>); return false; "><?php echo Horde::img($prefs->getValue('sortdir') ? 'za.gif' : 'az.gif', _("Sort Direction"), null, $registry->getParam('graphics', 'horde')) ?></a>
        <a class="widget" href="" onclick="Sort(<?php echo $i ?>, <?php echo $prefs->getValue('sortdir') ?>); return false;"><?php echo $attributes[$columns[$i-1]]['label'] ?></a>
      </th>
    <?php endfor; ?>
    </tr>
