[%- # search widget
    # this template expects these vars to be set:
    # doc.dir.abs_doc_root - doc root
    # doc.dir.path_from_base

    # search_opitons is an array and hash for generating the drop-down box.
-%]


[%- PROCESS search_options -%]
[%- USE CGI('-no_debug -no_xhtml') -%]

[%
    IF doc.meta.link == 'search/searchresults.html';
        PROCESS build_results_search_widgets;
    ELSE;
        PROCESS build_std_search_widgets;
    END;
%]

    <table border="0" cellspacing="0" cellpadding="0" width="150" align="center">
        <tr>
            <td class="menu-border" width="1" height="1"><small class="nbr"><br class="smallbr"></small></td>
            <td class="menu-border" width="148"><small class="nbr"><br class="smallbr"></small></td>
            <td class="menu-border" width="1"><small class="nbr"><br class="smallbr"></small></td>
        </tr>

        <tr>
            <td class="menu-border"><br></td>
            <td align="center" class="menu-title-bg">
                <div class="menu-title"><a href="[%- doc.dir.abs_doc_root -%]/search/swish.cgi">Search</a></div>
            </td>
            <td class="menu-border"><br></td>
        </tr>

        <tr>
            <td class="menu-border" colspan="3" height="1"><small class="nbr"><br class="smallbr"></small></td>
        </tr>

        <tr>
            <td class="menu-border"><br></td>
            <td class="search-box-bg" align="center">
                <form class="search-wrap" method="GET" action="[% doc.dir.abs_doc_root %]/search/swish.cgi" enctype="application/x-www-form-urlencoded" name="site_search_form">
                    [% PROCESS search_widget %]
                </form>
            </td>
            <td class="menu-border"><br></td>
        </tr>

        <tr>
            <td class="menu-border" colspan="3" height="1"><small class="nbr"><br class="smallbr"></small></td>
        </tr>
    </table>


[% BLOCK search_widget %]
            [% search_input %]
            [% search_options %]
            <br>
            <input type="submit" name="submit" value="search" class="inp-submit">
[% END %]

[% BLOCK build_results_search_widgets %]

    [%
        stag = "[\%"
        etag = "%\]"
    %]

    [% search_input = BLOCK %]

        [% stag %] CGI.textfield( {
                name      => 'query',
                size      => 12,
                maxlength => 200,
                class     => 'inp-text',
            } )
        [% etag %]

    [% END %]

    [% search_options = BLOCK %]

        [% stag %] CGI.popup_menu( {
                Name    => 'sbm',
                Values  => search_areas,
                Labels  => search_labels,
                class   => 'inp-select',
                })
        [% etag %]

        [% IF 0 %]
            [% stag %] IF search.results [% etag %]
                <br>
                <a href="#search_form"><span class="search-text">Advanced</span></a>
            [% stag %] END [% etag %]
        [% END %]

    [% END %]

[% END %]


[% BLOCK build_std_search_widgets %]

    [% search_input = BLOCK %]
        <input type="text" name="query" size="12" maxlength="200" value="" class="inp-text">
    [% END %]

    [%- section = PROCESS map_path_to_section path = doc.dir.path_from_base -%]

    [% search_options = BLOCK %]


        [% CGI.popup_menu( {
                Name    => 'sbm',
                Values  => search_areas,
                Labels  => search_labels,
                Default => section,
                Class => 'inp-select',
                })
        %]
    [% END %]
[% END %]

[%- BLOCK map_path_to_section -%]
    [%-
        FOR item = search_path_map;
            IF path.search( item.path );
                item.section;
                RETURN;
            END;
        END;
    -%]
[%- END -%]         



