<html>
<body>
  <form>
  <input type="hidden" name="CSId"/>
  {
  search-keys := if ($touchpoint) then
                   {"author": "100", "title": "200", "free": "-1", "keywords": "50", "isbn": "490", "year": "280"}
                 else  
                   {"author": "100", "title": "331", "free": "-1", "keywords": "902", "isbn": "540", "year": "425"},
  search-form := form(.),  
  let $homeBranchView := (id("selectedViewBranchlib"), id("selectedBranchView"))[1]
  let $selects := //select
  let $labeledSelects := map:merge(
                           for $select in //select 
                           let $id := $select/@id
                           let $label := $select/preceding-sibling::label[1][@for = $select/@id]
                           where $label
                           return {$label: $select})
  let $searchBranchView := ($selects[@id=("selectedSearchBranchlib", "Suche in Zweigstelle")], $labeledSelects?("Suche nach Standort", "Suche in Zweigstelle","Sammlungen"))[1]
  let $mediaTypeView := (id("Medienart"), $labeledSelects?Erscheinungsform)[1]
  let $languageView := (id("Sprache"), $labeledSelects?Sprache)[1]
  return (
    search-params := ("title", "author", "free", "keywords", "year", "isbn", 
      $homeBranchView !   {"name": "libraryHomeBranch", "options": .//option, "caption": "Zweigstelle (für Bestellungen)" },
      $searchBranchView ! {"name": "libraryBranch",     "options": .//option, "caption": "Zweigstelle (für Suche)" },
      $mediaTypeView ! {"name": "mediaType", "options": .//option},
      $languageView ! {"name": "language", "options": .//option}
    ),
    search-restriction-keys := {"libraryHomeBranch": $homeBranchView/@name,
                                "libraryBranch": $searchBranchView/@name,
                                "mediaType": $mediaTypeView/@name,
                                "language": $languageView/@name
                               },
    $selects[@id = "searchCategories_0"]//option/(
      let $text := string()
      let $key := if (starts-with($text, "Schlagwort")) then "keywords"
            else if (starts-with($text, "ISBN")) then "isbn"
            else ()
      where $key
      let $value := @value
      where $value ne $search-keys?($key)
      return $search-keys($key) := $value
    )

  )
  }
  </form>
  <!--  both id lists:  sisis: firsts, touchpoint: last -->
</body>
</html>
  
