<script language="JavaScript" type="text/javascript">
<!--
<?php echo $js_criteria ?>
function updateCriterias()
{
    var f = document.directory_search;

    while (f.criteria.length > 0) {
        f.criteria.options[f.criteria.length-1] = null;
    }

    for (var i = 0; i < criteriaOptions.length; i++) {
        if (criteriaOptions[i][0] == f.source.options[f.source.selectedIndex].value) {
            for (var j = 1; j < criteriaOptions[i].length; j++) {
                f.criteria.options[f.criteria.length] = new Option(criteriaOptions[i][j][1], criteriaOptions[i][j][0]);
            }
            f.criteria.selectedIndex = 0;
            return;
        }
    }
}
//-->
</script>

<form name="directory_search" action="<?php echo Horde::applicationUrl('search.php') ?>" method="get">
<input type="hidden" name="actionID" value="1" />
<?php echo Horde::formInput() ?>

<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr class="header">
    <td class="header" align="left"><b><?php echo _("Search") ?></b></td>
</tr>
</table>

<table border="0" cellpadding="0" cellspacing="5">
<tr>
    <td class="light" align="right"><b><?php echo _("Find") ?></b></td>
    <td class="item">
        <select name="criteria">
<?php echo $criteria_options ?>
        </select>
    </td>

    <td class="light" align="right"><b><?php echo _("Matching") ?></b></td>
    <td class="item">
        <input type="text" size="30" name="val" value="<?php echo $val ?>" />
    </td>

<?php if (count($cfgSources) > 1): ?>
    <td class="light" align="right"><b><?php echo _("From") ?></b></td>
    <td class="item">
        <select name="source" onchange="updateCriterias()">
<?php echo $source_options ?>
        </select>
    </td>
<?php else: ?>
    <td>
        <input type="hidden" name="source" value="<?php reset($cfgSources); echo key($cfgSources) ?>" />
    </td>
<?php endif; ?>

    <td>
        <input class="button" type="submit" value="<?php echo _("Search") ?>" />
    </td>
</tr>
</table>

<?php if (is_object($_SESSION['turba_search_results']) && ($_SESSION['turba_search_results']->count() > 0)): ?>
<br />

<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tr class="header">
    <td class="header">
        <b><?php echo _("Search&nbsp;Results") ?></b>
    </td>
    <td align="right" class="smallheader">
        <a class="menuitem" href="<?php Horde::purl('search.php?clear=1') ?>"><?php echo _("Clear Search") ?></a>
    </td>
</tr>

<tr>
    <td colspan="2" class="item">

<table border="0" cellpadding="1" cellspacing="1" width="100%">
<tr>
    <th class="item" width="<?php echo $width ?>%" align="left" nowrap="nowrap">
        <?php echo $attributes['name']['desc'] ?>
    </th>
<?php foreach ($columns as $column): ?>
    <th class="item" width="<?php echo $width ?>%" align="left" nowrap="nowrap">
        <?php echo $attributes[$column]['desc'] ?>
    </th>
<?php endforeach; ?>
</tr>
<?php endif; ?>
