<t:switch prioritized="true">

<form>
{form:=form(., {"": {"kind": "submit"}}),
 $loginlink := .//a[@id=('dnn_dnnLOGIN_loginLink', 'dnn_dnnLogin3_enhancedLoginLink')]/@href,
 if (empty($loginlink)) then $loginlink := get("urlaccount", "") || "?returnurl=" || base-uri() else ()
}
<DIV class="DnnModule-OPENSearchModule">
  <div t:condition="contains(@id, 'SearchResult_ResultArea')">
    <t:switch prioritized="true">
      <span t:condition="contains(@id, 'DataPager1')">
        <input t:condition="contains(@name, 'PreviousButton')">{prev-page := form-combine($form, .)}</input>?
        <input t:condition="contains(@name, 'NextButton')">{
          if ($current-page eq $last-visited-page) then (search-next-page-available := true()) else (), 
          next-page := form-combine($form, .)}</input>?
        <span t:condition="contains(@id, 'TotalItemsLabel')">{search-result-count := extract(normalize-space(.), "[0-9]+")}</span>
      </span>
      <div>
        <a t:condition="ends-with(@id, 'searchResultPagerTop_aPrevious')">{$prev-page := resolve-html(.)}</a>?
        <a t:condition="ends-with(@id, 'searchResultPagerTop_aNext')">{
          if ($current-page eq $last-visited-page) then (search-next-page-available := true()) else (), next-page := resolve-html(.)}</a>?
        <span t:condition="contains(@id, 'TotalItemsLabel')">{search-result-count := extract(normalize-space(.), "[0-9]+")}</span>
      </div>
    </t:switch>

  
    <div t:condition="matches(@id, '(ComprehensiveItem|divMedium|divDependentCatalogue)$')">
      <t:switch prioritized="true">
        <div>
          <div class="standardPaddingCover"/>
          <div>
            <a>{book := {"title": ., 
                         "_detailId": let $temp := extract(@href, "dnn.*btn.*Value") 
                                      return if ($temp) then $temp else @href, 
                         "_page": $current-page}}</a>
            
            <span t:condition="contains(@id, 'LblSubTitleValue')">{book.title := x"{$book.title}: {.}"}</span>? 
            
             <t:s>for $span in .//span
                  let $idlbl := $span/extract(@id, "_Lbl(.*)$", 1)[.]
                  where exists($idlbl) and not(ends-with($idlbl, "Value"))
                  let $primary-key := exists($search-reverse-keys($idlbl))
                  let $key := if ($primary-key) then $search-reverse-keys($idlbl)
                              else $span || "!"
                  let $value := join($span!following-sibling::node()!(
                    if (self::script or matches(@style, "display *: *none")) then ()
                    else if (self::a and not($primary-key)) then (. || (if (contains(@href, "http")) then x" ( {@href} )" else ""))
                    else .
                  ))
                  where $value
                  return $book($key) := $value

                     
                 </t:s>
          </div>
<!-- geht nicht, needs ajax         {..//img[ends-with(@id, "mediumImageAvailable")]!(
            if (ends-with(@src, "true.png")) then $book.status := "available"
            else if (ends-with(@src, "false.png")) then $book.status := "lend"
            else ()
          )}-->
        </div>
              
        <table><tr> <!-- old stralsund, nowhere used? -->
          <td    class="standardPaddingCover"/>
          <td  >
            <a>{book := {"title": ., "_detailId": extract(@href, "dnn.*btn.*Value"), "_page": $current-page}}</a>
            
            <span t:condition="contains(@id, 'LblSubTitleValue')">{book.title := x"{$book.title}: {.}"}</span>? 
            
            <t:s>for $span in .//span
                 let $idlbl := $span/extract(@id, "_Lbl(.*)$", 1)[.]
                 where exists($idlbl) and not(ends-with($idlbl, "Value"))
                 let $primary-key := exists($search-reverse-keys($idlbl))
                 let $key := if ($primary-key) then $search-reverse-keys($idlbl)
                             else $span || "!"
                 let $value := join($span!following-sibling::node()!(
                   if (self::a and not($primary-key)) then (. || (if (contains(@href, "http")) then x" ( {@href} )" else ""))
                   else .
                 ))
                 where $value
                 return $book($key) := $value
            
                
            </t:s>
          </td>
        </tr></table>
      </t:switch>
    </div>+ 
  </div>
</DIV>
 
<!--
<DIV id="Result" class="result">
  <div class="result_gefunden">Gefunden:<t:s>search-result-count := extract(., "[0-9 ]+$")</t:s></div>
  <TABLE class="resulttab" t:test="$search-result-count > 0">
    <TR><TH/></TR>
    <TR>
      <TD/>
      <TD>
        <A>{let $x := . return $book := {
          "author": substring-before($x, ":"), 
          "title": if (contains($x, ":")) then extract($x, "^[^:]+:(.*)-[0-9 ]+$", 1, "s") else substring-before($x, "-"), 
          "year": extract($x, "[0-9 ]+$"),
          "_detailsBackScroll": if (contains($url, "scrollAction")) then $url else $url || "?scrollAction=1",
          "_details": resolve-uri(@href) }}</A>
      </TD>
    </TR>+
  </TABLE>
  <div class="result_nav">
    <u/> <a>{search-next-page-available := true(), next-page := @href}</a>
  </div>?
</DIV>
-->
</form>



<div t:condition="(ends-with(@id, 'DivSearchResultView') or ends-with(@class, 'searchresult'))
                  and matches(., 'Ihre Suche erzielte keine Treffer|No results available')">{search-result-count := 0}</div>


<div t:condition="ends-with(@id, 'InfoMessage')">{vl:raise(.)}</div>
	
</t:switch>