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

  <!-- ========================================================================== -->
  <!-- generell.xsl (versjon 001) - for studier                                   -->
  <!-- ========================================================================== -->

  <!-- Felles for studiedokumenter -->
  <xsl:include href="../../ressurser/profil-v001.xsl"/>
  <xsl:include href="../../ressurser/translations-v001.xsl"/>
  <xsl:include href="../../ressurser/mapping-v001.xsl"/>

  <!-- Felles for alle dokumenter -->
  <xsl:include href="../../../system/api-v001.xsl"/>
  <xsl:include href="../../../felles/ressurser/output-method-html-v001.xsl"/>

  <!-- XSL til komponenter -->
  <xsl:include href="../../../felles/komponenter/fritekst/v001/fritekst.xsl"/>

  <xsl:template match="/">
    <html>
      <head>
        <title><xsl:value-of select="/generell/tittel/titteltekst"/></title>
        <!-- Henter metadata fra profil-v001.xsl -->
        <xsl:call-template name="inkluder-metadata-til-profil"/>
        <style TYPE="text/css"> 
          .mindremargintopp {margin-top: -7px;}  
          h1 {font-size: 200%;font-weight: bold;}
          h2 {font-size: 150%;font-weight: bold;}
          h3 {font-size: 125%;font-weight: bold;}
          h4 {font-size: 100%;font-weight: bold;}
        </style> 
      </head>
      <body>
       <xsl:call-template name="studiesti"/>
       <xsl:apply-templates/> 
      </body>
    </html>
  </xsl:template>
    
  <xsl:template match="generell">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="tittel">
    <h1 id="tekststart"><xsl:value-of select="titteltekst" /></h1>
  </xsl:template>

  <xsl:template match="spraak"/>
  
  <!-- Overstyrer for å lage mindre mellomrom mellom overskrift og fritekst -->
  <xsl:template match="fritekst">
    <xsl:choose>
      <xsl:when test="name(preceding-sibling::*[1])='overskrift' or name(preceding-sibling::*[1])='tittel'">
        <xsl:text disable-output-escaping="yes">&lt;p class="mindremargintopp"&gt;</xsl:text>
        <xsl:apply-templates/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:text disable-output-escaping="yes">&lt;p&gt;</xsl:text>
        <xsl:apply-templates/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="bilde">
    <xsl:choose>
      <xsl:when test="plassering='center'">
        <img src="{webadresse}" style="display:block" alt=""/> 
      </xsl:when>
      <xsl:otherwise>
        <img src="{webadresse}" align="{plassering}" alt=""/> 
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="overskrift">
    <xsl:if test="not(normalize-space(overskrifttekst)='')">
      <xsl:if test="overskrifttype='1'">
        <h2><xsl:value-of select="overskrifttekst"/></h2>
      </xsl:if>
      <xsl:if test="overskrifttype='2'">
        <h3><xsl:value-of select="overskrifttekst"/></h3>
      </xsl:if>
      <xsl:if test="overskrifttype='3'">
        <h4><xsl:value-of select="overskrifttekst"/></h4>
      </xsl:if>
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>
