<tr>
<?php if (($i == 0) && !$last_field): ?>
  <td>&nbsp;</td>
<?php elseif ($i > 0): ?>
  <td><b><?php echo ($search_match == 'and') ? _("AND") : _("OR") ?></b>&nbsp;</td>
<?php endif; ?>
  <td style="padding:2px">
    <select onchange="document.search.submit();return true;" name="field[<?php echo $i ?>]">
<?php if ($last_field): ?>
      <option value=""><?php echo _("Select a field") ?></option>
      <option value=""> --------- </option>
<?php endif; ?>
<?php foreach ($fields as $key => $val): ?>
      <option value="<?php echo $key ?>"<?php if ($curr_field == $key) echo ' selected="selected"'; ?>><?php echo $val['label'] ?></option>
<?php endforeach; ?>
    </select>
  </td>
<?php if (is_null($curr_field)): ?>
  <td>&nbsp;</td>
<?php elseif (($fields[$curr_field]['type'] == IMP_SEARCH_HEADER) ||
              ($fields[$curr_field]['type'] == IMP_SEARCH_BODY)): ?>
  <td class="item0" align="left">
    <input type="text" name="search_text[<?php echo $i ?>]" size="40" <?php if (!empty($search_text[$i])) echo 'value="' . $search_text[$i] . '" '; ?>/>
    <input type="checkbox" name="search_text_not[<?php echo $i ?>]" <?php if (!empty($search_text_not[$i])) echo 'checked="checked" '; ?>/>
    <i><?php echo _("Do NOT match") ?></i>
  </td>
<?php elseif ($fields[$curr_field]['type'] == IMP_SEARCH_DATE): ?>
  <td class="item0" nowrap="nowrap" align="left">
    <?php echo Horde_Widgets::buildMonthWidget('search_date[' . $i . '][month]', isset($search_date[$i]['month']) ? $search_date[$i]['month'] : $curr_date['mon']) ?>
    <?php echo Horde_Widgets::buildDayWidget('search_date[' . $i . '][day]', isset($search_date[$i]['day']) ? $search_date[$i]['day'] : $curr_date['mday'], "onchage=\"dateCheck('on')\"") ?>
    <?php echo Horde_Widgets::buildYearWidget('search_date[' . $i . '][year]', -20, isset($search_date[$i]['year']) ? $search_date[$i]['year']: $curr_date['year'], "onchange=\"dateCheck('on'}\"") ?>
<?php if ($GLOBALS['browser']->hasFeature('javascript')) {
    Horde::addScriptFile('open_calendar.js', 'horde');
    echo '<div id="goto" class="control" style="position:absolute;visibility:hidden;padding:1px"></div>';
    echo Horde::link('', _("Select a date"), '', '', 'openCalendar(\'dateimg\', \'search_date[' . $i . ']\'); return false;') . Horde::img('calendar.gif', _("Calendar"), 'align="top" id="dateimg"', $GLOBALS['registry']->getParam('graphics', 'horde')) . '</a>';
} ?>
  </td>
<?php endif; ?>
<?php if (!$last_field): ?>
  <td>&nbsp;<input type="image" src="<?php echo $GLOBALS['registry']->getParam('graphics') . '/x.gif' ?>" onclick="document.search.delete_field_id.value=<?php echo $i ?>;document.search.actionID.value='delete_field';document.search.submit();return true;" value="<?php echo _("Remove Field From Search") ?>" /></td>
<?php elseif ($last_field && ($i != 0)): ?>
  <td>&nbsp;</td>
<?php endif; ?>
</tr>
