<!-- adm/search_engine/form.phtml -->

!default search_lang=$lang
!set wims_ref_anchor=#searchform

<fieldset class="wims_search_engine" id="searchform">
  <legend><label for="search_keywords">$name_search_engine</label></legend>

  !set wims_form_method=post
  !form new
    <input type="hidden" name="module" value="home">

    !if $wims_accessright!=$empty
      !read adm/search_engine/search_accessright.phtml
    !endif

    !set wims_ref_class=wims_button_help float_right
    !href module=adm/light&phtml=search_engine.phtml.$lang $name_search_help

    <div class="field search_field">
      <input size="25"
             type="search"
             name="search_keywords"
             value="$search_keywords"
             class="wims_home_form multicomplete"
             placeholder="$name_keywords_enter"
             results="5"
             autosave="search_keywords"
             id="search_keywords"><button class="wims_button icon_button"
                       type="submit"><span class="Searching">$N_Search</span></button>
      <span style="margin-left:2em;display:inline-block;">
        !set wims_ref_class=text_icon browse
        !href module=adm/browse $wims_name_browse
      </span>
    </div>

    !if $jquery_defined=yes
      !if $wims_class==$empty
        !set default_filters_state=false
      !else
        !set default_filters_state=0
      !endif

      <script>
        jQuery(function($$){
          // Get in sessionStorage if affined_search was previously uncollapsed
          var affined_search_state = sessionStorage.getItem("affined_search_state");
          affined_search_state = !affined_search_state ? $default_filters_state : Number(affined_search_state);
          // Display all affined search fields in a collapsible way
          $$("#affined_search").accordion({
            collapsible: true,
            active: affined_search_state,
            heightStyle: "content",
            activate : function( event, ui ) {
                affined_search_state = $$("#affined_search").accordion("option", "active");
                sessionStorage.setItem("affined_search_state", affined_search_state);
            }
          });
        } );
      </script>
    !endif

    <fieldset id="affined_search">
      <legend>$name_search_filters</legend>
      <div>
        <div class="field box halfwidth float_left">
          !!-- categories -->
          <label for="search_category">$name_search_category</label>
          !formselect search_category list $slist prompt $plist
        </div>
        <div class="field box halfwidth float_left">
          !!-- search type -->
          <label for="search_and">$name_search_method</label>
          !default search_and=no
          !formselect search_and list yes,no prompt $name_search_and
        </div>
        <div class="field box fullwidth">
          !!-- language -->
          <label for="search_lang">$wims_name_Language</label>
          !readproc languages
          !set L_language=!words2items $wims_site_languages
          !for site_lang in $L_language
            !set lang_prompt=!append item $(Lang_name_$site_lang) ($site_lang) to $lang_prompt
          !next
          !formselect search_lang list $L_language prompt $lang_prompt
        </div>

        <div class="field box fullwidth">
          <strong>$wims_name_level</strong>
          !if $jquery_defined=yes
            !read adm/search_engine/level_form.phtml
          !else
            <div class="search_level_list">
              !formcheckbox search_level list $listlevel prompt $Listlevel
            </div>
          !endif
        </div>
        !!<div class="field box fullwidth">
            !!finally Lang will be add to the searchlevel automatically for the moment
            !!<strong>$name_search_leveltrans</strong>
            !!!default search_leveltrans=1
            !!!formradio search_leveltrans list 1,0 prompt $wims_name_yes, $wims_name_no
            !!<div class="formHelp">$name_search_leveltrans_help</div>
        !!</div>
      </div>
    </fieldset>
  !formend
</fieldset>
!if $wims_class!=$empty
  <div class="wimscenter">
    !set wims_ref_class=text_icon Glossary
    !href module=adm/tool/glossary&gl=0 $wims_name_Glossary
  </div>
!endif

!if $jquery_defined=yes
  <script type="text/javascript" src="scripts/js/interface/search_engine.js"></script>
!endif

<!-- end adm/search_engine/form.phtml -->
!set srchl=$search_keywords
!reset search_category search_keywords search_level
