<div
    xmlns:jsp="http://java.sun.com/JSP/Page"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:mm="http://www.mmbase.org/mmbase-taglib-2.0"
    xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
    xmlns:mm-sr="http://www.mmbase.org/tags/mm/searchrelate"
    id="mm_searchrelate"
    >
  <!--
    xmlns:mm-sr="urn:jsptagdir:/WEB-INF/tags/mm/searchrelate/"


  -->
  <jsp:output omit-xml-declaration="true" />
  <fmt:bundle basename="org.mmbase.searchrelate.resources.searchrelate">

    <mm:content
        type="text/html"
        expires="-1">
      <mm:cloud rank="basic user">

        <mm:import externid="prefix" />
        <mm:import externid="currentTitle" />


        <mm:import id="repository" from="session" externid="${prefix}repository"  required="true"/>
        <mm:import id="current"    from="session" externid="${prefix}current"    required="true"/>


        <mm:log level="debug">prefix: ${prefix} </mm:log>
        <mm:log level="debug">rep: ${repository.sql} </mm:log>
        <mm:log level="debug">cur: ${current.sql} </mm:log>

        <div class="kupu-toolbox extra-box">
          <h1 class="kupu-toolbox-heading-closed" title="click to fold">${empty currentTitle ? 'related' : currentTitle}</h1>
          <div>
            <mm-sr:relate repository="${repository}"
                          current="${current}"
                          create="true"
                          unrelate="true"
                          submit="#kupu-save-button" pagesize="3">

              <jsp:attribute name="currentTitle">
                <h2>
                  <c:choose>
                    <c:when test="${empty currentTitle}">
                      <fmt:message key="currently" />
                    </c:when>
                    <c:otherwise>${currentTitle}</c:otherwise>
                  </c:choose>
                </h2>
              </jsp:attribute>
              <jsp:attribute name="repositoryTitle">
              <h2>
                <fmt:message key="allnodes">
                  <fmt:param><mm:nodeinfo nodetype="${repository.nodeManager.name}" type="guinodemanager" /></fmt:param>
                </fmt:message>
              </h2>
              </jsp:attribute>
            </mm-sr:relate>
          </div>
        </div>
        <script type="text/javascript">
          $(document).ready(function() {
          $('#mm_searchrelate h1').each(function() {
            $(this).find("+ div").css("display", "none");
          });
          $('#mm_searchrelate h1').click(function() {
              var h1 = this;
              $(this).find("+ div").each(function() {
                 var c = $(this).css("display");
                 $(this).css("display", c == 'none' ? 'block' : 'none');
                 if (c == 'none') {
                   $(h1).addClass("kupu-toolbox-heading-opened");
                   $(h1).removeClass("kupu-toolbox-heading-closed");
                   } else {
                   $(h1).addClass("kupu-toolbox-heading-closed");
                   $(h1).removeClass("kupu-toolbox-heading-opened");
                   }
                 });
          });
          });
        </script>
      </mm:cloud>
    </mm:content>
  </fmt:bundle>
</div>
