<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <!-- =============================================================== -->
  <!--  person-edit.xsl (v004)                                         -->
  <!--  17.03.06 - kristian.syversen@usit.uio.no                       -->
  <!-- =============================================================== -->


  <!-- =============================================================== -->
  <!--  Main element of document type is matchet in system-edit.xsl    -->
  <!-- =============================================================== -->

  <!-- prefixes (text element definitions) -->
  <xsl:import href="person-translations.xsl" />

  <!-- resources -->
  <xsl:import href="../../../system/system-edit-v001.xsl"/>
 
  <!-- components -->
  <xsl:import href="../../../common/components/override-ldap/v001/override-ldap-edit.xsl" />
  <xsl:import href="../../../common/components/structuredtext/v002/structuredtext-edit.xsl" />

  <!-- common -->
  <xsl:include href="../../../felles/ressurser/output-method-html-v001.xsl" />


  <!-- =============================================================== -->
  <!--  Override template form system-edit.xsl here                    -->
  <!--  See paragraph "Template name API" im system-edit.xsl for       -->
  <!--  further information on this feature                            -->
  <!-- =============================================================== -->

  <!-- Define if system-edit should insert "Edit <elementname>" at top level -->
  <xsl:variable name="label-toplevel-elements" select="'no'" />

  <!-- css-classes for this doc-type can be inserted here -->
  <xsl:template name="css-classes" />

  <!-- shortcuts for insertion of bottom elements can be specified here -->
  <xsl:template name="shortcutlinks-put-bottom" />



  <!-- =============================================================== -->
  <!--  Doctype specific templates for VIEW (with edit link) here:     -->
  <!-- =============================================================== -->

  <xsl:template match="institute">
    <b>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.institute'"/>
      </xsl:call-template>
    </b>&#160;
    <xsl:value-of select="." />
    <xsl:call-template name="insert-edit-link" />
  </xsl:template>
  
  
  <xsl:template match="category">
    <b>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.category'"/>
      </xsl:call-template>
    </b>&#160;
    <xsl:value-of select="." />
    <xsl:call-template name="insert-edit-link" />
  </xsl:template>
  

  <xsl:template match="username">
    <b>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.username'"/>
      </xsl:call-template>
    </b>&#160;
    <xsl:value-of select="." />
    <xsl:call-template name="insert-edit-link" />
  </xsl:template>
  

  <xsl:template match="override-user-details">
    <b>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.override_user_details'"/>
      </xsl:call-template>
    </b>&#160; 
    <xsl:value-of select="." />
    <xsl:call-template name="insert-edit-link" />
  </xsl:template>


  <xsl:template match="user-image">
    <b>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.user_image'"/>
      </xsl:call-template>
    </b>&#160;
    <xsl:value-of select="." /> 
    <xsl:call-template name="insert-edit-link" />
  </xsl:template> 


  <xsl:template match="highres-image-link">
    <b>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.image_link'"/>
      </xsl:call-template>
    </b>&#160;    
    <xsl:if test=".!=''">
      <a href="{.}">
        <xsl:call-template name="person-document-phrase">
          <xsl:with-param name="identifier" select="'person.press_image'"/>
        </xsl:call-template> 
      </a>
    </xsl:if>
    <xsl:call-template name="insert-edit-link" />
    <span style="color:grey;"><small><i>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.only_displayed_if_entered'"/>
      </xsl:call-template>
    </i></small></span> 
  </xsl:template> 


  <xsl:template match="room">
    <b>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.room'"/>
      </xsl:call-template>
    </b>&#160;
    <xsl:value-of select="." />
    <xsl:call-template name="insert-edit-link" />
  </xsl:template>
  
  
  <xsl:template match="office-hours">
    <b>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.office_hours'"/>
      </xsl:call-template>
    </b>&#160;
    <xsl:value-of select="." />
    <xsl:call-template name="insert-edit-link" />
    <span style="color:grey;"><small><i>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.only_displayed_if_entered'"/>
      </xsl:call-template>
    </i></small></span>    
  </xsl:template>  
  
 
  <xsl:template match="key-frida">
    <xsl:variable name="key" select="." />
    <b>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.key_frida'"/>
      </xsl:call-template>
    </b>&#160;
    <xsl:value-of select="$key" />
    <xsl:if test="not($key='')">  
      <xsl:variable name="frida">http://wo.uio.no/as/WebObjects/frida.woa/wa/fres?inst=185&#038;pnr=</xsl:variable>
      <xsl:variable name="search-and-sort">&#038;action=sok&#038;visParametre=1&#038;sort=ar</xsl:variable>
      (<i><a href="{$frida}{$key}{$search-and-sort}">lenke til FRIDA</a></i>)
    </xsl:if>  
    
    
    <xsl:call-template name="insert-edit-link" />
    <span style="color:grey;"><small><i>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.only_displayed_if_entered'"/>
      </xsl:call-template>
    </i></small></span>      
  </xsl:template>
  
  
  <xsl:template match="show-homepage-link">
    <b>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.show_homepage_link'"/>
      </xsl:call-template>
    </b>&#160;
    <xsl:value-of select="." /> 
    <xsl:call-template name="insert-edit-link" />
  </xsl:template> 
    
  
  <xsl:template match="background">
    <b>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.background'"/>
      </xsl:call-template>:
    </b>&#160;
    <xsl:call-template name="insert-edit-link" />
    <!-- if-test is only to ensure consistent layout -->
    <xsl:if test="not(.='') and ./node()"> 
      <xsl:apply-templates />
    </xsl:if>
  </xsl:template>
  

  <xsl:template match="vocation">
    <xsl:choose>
      <xsl:when test="//category/text()='technical-administrative'">
        <b>
          <xsl:call-template name="person-document-phrase">
            <xsl:with-param name="identifier" select="'person.vocation_technical_administrative'"/>
          </xsl:call-template>:
        </b>&#160; 
        <xsl:call-template name="insert-edit-link" />
      </xsl:when>  
      <xsl:otherwise>
        <b>
          <xsl:call-template name="person-document-phrase">
            <xsl:with-param name="identifier" select="'person.vocation_scientific'"/>
          </xsl:call-template>:
        </b>&#160;  
        <xsl:call-template name="insert-edit-link" />
      </xsl:otherwise>
    </xsl:choose>
    <xsl:call-template name="list-structuredtext" />
  </xsl:template>
  
  
  <xsl:template match="competence">
    <b>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.competence'"/>
      </xsl:call-template>:
    </b>&#160;
    <xsl:call-template name="insert-edit-link" />
    <xsl:call-template name="list-structuredtext" />
  </xsl:template>  
  

  <xsl:template match="projects">
    <xsl:choose>
      <xsl:when test="//category/text()='technical-administrative'">
        <xsl:variable name="output">
          <xsl:call-template name="person-document-phrase">
            <xsl:with-param name="identifier" select="'person.projects_technical_administrative'"/>
          </xsl:call-template>
        </xsl:variable>
        <b>
          <xsl:value-of select="concat( normalize-space($output), ':' )" />
        </b>&#160; 
        <xsl:call-template name="insert-edit-link" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:variable name="output">
          <xsl:call-template name="person-document-phrase">
            <xsl:with-param name="identifier" select="'person.projects_scientific'"/>
          </xsl:call-template>
        </xsl:variable>
        <b>
          <xsl:value-of select="concat( normalize-space($output), ':' )" />
        </b>&#160; 
        <xsl:call-template name="insert-edit-link" />
      </xsl:otherwise>
    </xsl:choose>    
    <xsl:call-template name="list-structuredtext" />
  </xsl:template>


  <xsl:template match="publications">  
    <b>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.selected_publications'"/>
      </xsl:call-template>:
    </b>&#160; 
    <xsl:call-template name="insert-edit-link" />
    <xsl:call-template name="list-structuredtext" />
  </xsl:template>
  
  
  <xsl:template match="other">  
    <b>
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.other'"/>
      </xsl:call-template>:
    </b>&#160; 
    <xsl:call-template name="insert-edit-link" />
    <xsl:call-template name="list-structuredtext" />
  </xsl:template>
  


  <!-- =============================================================== -->
  <!--  Templates for EDIT here:                                       -->
  <!--  (elements to be edited must have: mode="edit")                 -->
  <!-- =============================================================== -->

  <xsl:template match="institute" mode="edit">
     <table border="0" cellspacing="1" cellpadding="5">
      <tr>
        <td>
          <b>
            <xsl:call-template name="person-document-phrase">
              <xsl:with-param name="identifier" select="'person.edit_institute'"/>
            </xsl:call-template>
          </b>
        </td>   
      </tr>
      <tr>
        <td colspan="2">
          <xsl:call-template name="insert-inputfield">
            <xsl:with-param name="size" select="25" />
          </xsl:call-template>
        </td>
      </tr>
    </table>
  </xsl:template>


  <xsl:template match="category" mode="edit">
     <table border="0" cellspacing="1" cellpadding="5">
      <tr>
        <td>
          <b>
            <xsl:call-template name="person-document-phrase">
              <xsl:with-param name="identifier" select="'person.edit_category'"/>
            </xsl:call-template>
          </b>
        </td> 
      </tr>
      <tr>
        <td colspan="2">
          <xsl:call-template name="insert-dropdown">
            <xsl:with-param name="name-value-list"
              select="'Teknisk-Administrativ=technical-administrative,
                       Vitenskapelig=scientific'" />
          </xsl:call-template>
        </td>
      </tr>
    </table>
  </xsl:template>
  

  <xsl:template match="username" mode="edit">
    <table border="0" cellspacing="1" cellpadding="5">
      <tr>
        <td>
          <b>
            <xsl:call-template name="person-document-phrase">
              <xsl:with-param name="identifier" select="'person.edit_username'"/>
            </xsl:call-template>
          </b>
        </td> 
      </tr>
      <tr>
        <td colspan="2">
          <xsl:call-template name="insert-inputfield">
            <xsl:with-param name="size" select="15" />
          </xsl:call-template>
        </td>
      </tr>
    </table>
  </xsl:template>
  

  <xsl:template match="override-user-details" mode="edit">
    <xsl:variable name="yes-choice">
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.yes_choice'"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="no-choice">
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.no_choice'"/>
      </xsl:call-template>    
    </xsl:variable>    
    <table border="0" cellspacing="1" cellpadding="5">
      <tr>
        <td>
          <b>
            <xsl:call-template name="person-document-phrase">
              <xsl:with-param name="identifier" select="'person.override_user_details'"/>
            </xsl:call-template>
          </b>
        </td> 
      </tr>
      <tr>  
        <td>
          <xsl:call-template name="insert-radiobutton">
            <xsl:with-param name="label" select="$no-choice" />
            <xsl:with-param name="value" select="'No'" />
          </xsl:call-template>
        </td>  
      </tr>
      <tr>  
        <td>
          <xsl:call-template name="insert-radiobutton">
            <xsl:with-param name="label" select="$yes-choice" />
            <xsl:with-param name="value" select="'Yes'" />
          </xsl:call-template>
        </td>    
      </tr>
    </table>
  </xsl:template> 
   
  
  <xsl:template match="user-image" mode="edit">
    <xsl:variable name="yes-choice">
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.yes_choice'"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="no-choice">
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.no_choice'"/>
      </xsl:call-template>    
    </xsl:variable>
    <table border="0" cellspacing="1" cellpadding="5">
      <tr>
        <td>
          <b>
            <xsl:call-template name="person-document-phrase">
              <xsl:with-param name="identifier" select="'person.user_image'"/>
            </xsl:call-template>
          </b>
        </td>
      </tr>
      <tr>  
        <td>
          <xsl:call-template name="insert-radiobutton">
            <xsl:with-param name="label" select="$yes-choice" />
            <xsl:with-param name="value" select="'Yes'" />
          </xsl:call-template>
        </td>
      </tr>
      <tr>  
        <td>
          <xsl:call-template name="insert-radiobutton">
            <xsl:with-param name="label" select="$no-choice" />
            <xsl:with-param name="value" select="'No'" />
          </xsl:call-template>
        </td>      
      </tr>
    </table>
  </xsl:template>
  
  
  <xsl:template match="highres-image-link" mode="edit">
     <table border="0" cellspacing="1" cellpadding="5">
      <tr>
        <td>
          <b>
            <xsl:call-template name="person-document-phrase">
              <xsl:with-param name="identifier" select="'person.edit_image_link'"/>
            </xsl:call-template>
          </b>
        </td>   
      </tr>
      <tr>
        <td colspan="2">
          <xsl:call-template name="insert-inputfield">
            <xsl:with-param name="size" select="75" />
          </xsl:call-template>
          &#160;&#160;
          <xsl:call-template name="insert-browsebutton" />
        </td>
      </tr>
    </table>
  </xsl:template>  
  
  
  <xsl:template match="room" mode="edit">
    <table border="0" cellspacing="1" cellpadding="5">
      <tr>
        <td>
          <b>
            <xsl:call-template name="person-document-phrase">
              <xsl:with-param name="identifier" select="'person.edit_room'"/>
            </xsl:call-template>
          </b>
        </td> 
      </tr>
      <tr>
        <td colspan="2">
          <xsl:call-template name="insert-inputfield">
            <xsl:with-param name="size" select="25" />
          </xsl:call-template>
        </td>
      </tr>
    </table>
  </xsl:template>


  <xsl:template match="office-hours" mode="edit">
    <table border="0" cellspacing="1" cellpadding="5">
      <tr>
        <td>
          <b>
            <xsl:call-template name="person-document-phrase">
              <xsl:with-param name="identifier" select="'person.edit_office_hours'"/>
            </xsl:call-template>
          </b>
        </td> 
      </tr>
      <tr>
        <td colspan="2">
          <xsl:call-template name="insert-inputfield">
            <xsl:with-param name="size" select="50" />
          </xsl:call-template>
        </td>
      </tr>
    </table>
  </xsl:template>
  
  
  <xsl:template match="key-frida" mode="edit">
    <table border="0" cellspacing="1" cellpadding="5">
      <tr>
        <td>
          <b>
            <xsl:call-template name="person-document-phrase">
              <xsl:with-param name="identifier" select="'person.edit_key_frida'"/>
            </xsl:call-template>
          </b>
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <xsl:call-template name="insert-inputfield">
            <xsl:with-param name="size" select="25" />
          </xsl:call-template>
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <small><i>         
            <xsl:call-template name="person-document-phrase">
              <xsl:with-param name="identifier" select="'person.frida_weblink'"/>
            </xsl:call-template>
            <xsl:choose>
              <xsl:when test="not(.='')">
                'http://wo.uio.no/as/WebObjects/frida.woa/wa/fres?inst=185&#038;pnr=<b><xsl:value-of select="."/></b>&#038;action=sok'
              </xsl:when>
              <xsl:otherwise>
                'http://wo.uio.no/as/WebObjects/frida.woa/wa/fres?inst=185&#038;pnr=<b>[FRIDA id-nr]</b>&#038;action=sok'
              </xsl:otherwise>
            </xsl:choose>
          </i></small>
        </td>
      </tr>
    </table>
  </xsl:template>


  <xsl:template match="show-homepage-link" mode="edit">
    <xsl:variable name="yes-choice">
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.yes_choice'"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="no-choice">
      <xsl:call-template name="person-document-phrase">
        <xsl:with-param name="identifier" select="'person.no_choice'"/>
      </xsl:call-template>    
    </xsl:variable>
    <table border="0" cellspacing="1" cellpadding="5">
      <tr>
        <td>
          <b>
            <xsl:call-template name="person-document-phrase">
              <xsl:with-param name="identifier" select="'person.show_homepage_link'"/>
            </xsl:call-template>
          </b>
        </td>
      </tr>
      <tr>  
        <td>
          <xsl:call-template name="insert-radiobutton">
            <xsl:with-param name="label" select="$yes-choice" />
            <xsl:with-param name="value" select="'Yes'" />
          </xsl:call-template>
        </td>
      </tr>
      <tr>  
        <td>
          <xsl:call-template name="insert-radiobutton">
            <xsl:with-param name="label" select="$no-choice" />
            <xsl:with-param name="value" select="'No'" />
          </xsl:call-template>
        </td>      
      </tr>
    </table>
  </xsl:template> 


  <xsl:template match="background" mode="edit">
    <table border="0" cellspacing="0" cellpadding="5">
      <tr>
        <td>
          <b>
            <xsl:call-template name="person-document-phrase">
              <xsl:with-param name="identifier" select="'person.edit_background'"/>
            </xsl:call-template>
          </b>
        </td> 
      </tr>
      <tr>
        <td> 
          <xsl:call-template name="insert-textarea">
            <xsl:with-param name="rows" select="'8'" />
            <xsl:with-param name="cols" select="'100'" />
          </xsl:call-template>
        </td>
      </tr>
    </table>
  </xsl:template>
   

  <xsl:template match="vocation" mode="edit">
    <table border="0" cellspacing="0" cellpadding="5">
      <tr>
        <xsl:choose>
          <xsl:when test="//category/text()='technical-administrative'">
          <td>
            <b>
              <xsl:call-template name="person-document-phrase">
                <xsl:with-param name="identifier" select="'person.edit_vocation_technical_administrative'"/>
              </xsl:call-template>
            </b>
          </td> 
          </xsl:when>
          <xsl:otherwise>
          <td>
            <b>
              <xsl:call-template name="person-document-phrase">
                <xsl:with-param name="identifier" select="'person.edit_vocation_scientific'"/>
              </xsl:call-template>
            </b>
          </td> 
          </xsl:otherwise>
        </xsl:choose>
      </tr>
      <xsl:for-each select="./*">
        <tr>
          <td>
            <xsl:choose>
              <xsl:when test="position() = 1">
                <xsl:apply-templates select="." mode="edit"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:apply-templates select="." mode="edit-without-helptext"/>
              </xsl:otherwise>
            </xsl:choose> 
          </td>
        </tr>
      </xsl:for-each>
      <tr>
        <td valign="bottom">
          <xsl:call-template name="insert-button">
            <xsl:with-param name="elementname" select="'structuredtext-item'"/>
            <xsl:with-param name="buttonname" select="'Ny fritekst'"/>
          </xsl:call-template>
        </td>
      </tr>
    </table>
  </xsl:template>  
  
  
  <xsl:template match="competence" mode="edit">
    <table border="0" cellspacing="0" cellpadding="5">
      <td>
        <b>
          <xsl:call-template name="person-document-phrase">
            <xsl:with-param name="identifier" select="'person.edit_competence'"/>
          </xsl:call-template>
        </b>
      </td> 
      <xsl:for-each select="./*">
        <tr>
          <td>
            <xsl:choose>
              <xsl:when test="position() = 1">
                <xsl:apply-templates select="." mode="edit"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:apply-templates select="." mode="edit-without-helptext"/>
              </xsl:otherwise>
            </xsl:choose> 
          </td>
        </tr>
      </xsl:for-each>
      <tr>
        <td valign="bottom">
          <xsl:call-template name="insert-button">
            <xsl:with-param name="elementname" select="'structuredtext-item'"/>
            <xsl:with-param name="buttonname" select="'Ny fritekst'"/>
          </xsl:call-template>
        </td>
      </tr>
    </table>
  </xsl:template>  
  

  <xsl:template match="projects" mode="edit">
    <table border="0" cellspacing="0" cellpadding="5">
      <tr>
        <xsl:choose>
          <xsl:when test="//category/text()='technical-administrative'">
            <td>
              <b>
                <xsl:call-template name="person-document-phrase">
                  <xsl:with-param name="identifier" select="'person.edit_projects_technical_administrative'"/>
                </xsl:call-template>
              </b>
            </td> 
          </xsl:when>
          <xsl:otherwise>
            <td>
              <b>
                <xsl:call-template name="person-document-phrase">
                  <xsl:with-param name="identifier" select="'person.edit_projects_scientific'"/>
                </xsl:call-template>
              </b>
            </td> 
          </xsl:otherwise>
        </xsl:choose>
      </tr>
      <xsl:for-each select="./*">
        <tr>
          <td>
            <xsl:choose>
              <xsl:when test="position() = 1">
                <xsl:apply-templates select="." mode="edit"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:apply-templates select="." mode="edit-without-helptext"/>
              </xsl:otherwise>
            </xsl:choose> 
          </td>
        </tr>
      </xsl:for-each>
      <tr>
        <td valign="bottom">
          <xsl:call-template name="insert-button">
            <xsl:with-param name="elementname" select="'structuredtext-item'"/>
            <xsl:with-param name="buttonname" select="'Ny fritekst'"/>
          </xsl:call-template>
        </td>
      </tr>
    </table>
  </xsl:template>   
  
  
  <xsl:template match="publications" mode="edit">
    <table border="0" cellspacing="0" cellpadding="5">
      <tr>
        <td>
          <b>
            <xsl:call-template name="person-document-phrase">
              <xsl:with-param name="identifier" select="'person.edit_publications'"/>
            </xsl:call-template>
          </b>
        </td> 
      </tr>
      <xsl:for-each select="./*">
        <tr>
          <td>
            <xsl:choose>
              <xsl:when test="position() = 1">
                <xsl:apply-templates select="." mode="edit"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:apply-templates select="." mode="edit-without-helptext"/>
              </xsl:otherwise>
            </xsl:choose>           
          </td>
        </tr>
      </xsl:for-each>
      <tr>
        <td valign="bottom">
          <xsl:call-template name="insert-button">
            <xsl:with-param name="elementname" select="'structuredtext-item'"/>
            <xsl:with-param name="buttonname" select="'Ny fritekst'"/>
          </xsl:call-template>
        </td>
      </tr>
    </table>
  </xsl:template>
  
  
  <xsl:template match="other" mode="edit">
    <table border="0" cellspacing="0" cellpadding="5">
      <tr>
        <td>
          <b>
            <xsl:call-template name="person-document-phrase">
              <xsl:with-param name="identifier" select="'person.edit_other'"/>
            </xsl:call-template>
          </b>
          &#160;
          <i>
            <a href="http://www.usit.uio.no/it/vortex/hjelp/admin/xml-edit/formattering-tekst.html#overskrift">
              <xsl:call-template name="person-document-phrase">
                <xsl:with-param name="identifier" select="'person.edit_other_heading_help'"/>
              </xsl:call-template>
            </a>
          </i>
        </td>
      </tr>
      <xsl:for-each select="./*">
        <tr>
          <td>
            <xsl:choose>
              <xsl:when test="position() = 1">
                <xsl:apply-templates select="." mode="edit"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:apply-templates select="." mode="edit-without-helptext"/>
              </xsl:otherwise>
            </xsl:choose> 
          </td>
        </tr>
      </xsl:for-each>
      <tr>
        <td valign="bottom">
          <xsl:call-template name="insert-button">
            <xsl:with-param name="elementname" select="'structuredtext-item'"/>
            <xsl:with-param name="buttonname" select="'Ny fritekst'"/>
          </xsl:call-template>
        </td>
      </tr>
    </table>
  </xsl:template>
  
  
  
  <!-- GENERAL HELPER TEMPLATES -->
  
  <!-- Generic template to <li> each separate 'structuredtext' sub-element of calling node -->
  <xsl:template name="list-structuredtext">
    <xsl:for-each select="./*">
      <xsl:apply-templates />     
    </xsl:for-each>
  </xsl:template>    
  
  
  <!-- Generic template to edit 'structuredtext' elements -->
  <!-- with helptext column -->
  <xsl:template match="structuredtext-item" mode="edit">
    <table cellpadding="0" cellspacing="0">
      <tr>
        <td>
          <xsl:call-template name="insert-textarea">
            <xsl:with-param name="rows" select="'8'" />
            <xsl:with-param name="cols" select="'100'" />
            <xsl:with-param name="helptext" select="'yes'" />
          </xsl:call-template>
        </td>
      </tr>
      <tr>
        <td>(<xsl:call-template name="insert-delete-link" />)</td>
      </tr>
    </table>
  </xsl:template>  
  
  <!-- without helptext column -->
  <xsl:template match="structuredtext-item" mode="edit-without-helptext">
    <table cellpadding="0" cellspacing="0">
      <tr>
        <td>
          <xsl:call-template name="insert-textarea">
            <xsl:with-param name="rows" select="'8'" />
            <xsl:with-param name="cols" select="'100'" />
            <xsl:with-param name="helptext" select="'no'" />
          </xsl:call-template>
        </td>
      </tr>
      <tr>
        <td>(<xsl:call-template name="insert-delete-link" />)</td>
      </tr>
    </table>
  </xsl:template>  

</xsl:stylesheet>
