<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:import href="section.xsl"/>
	<xsl:output method="html" indent="yes" omit-xml-declaration="yes"/>
	<xsl:template match="/">
		<xsl:choose>
			<xsl:when test="ShowPage/Modus='outline'">
				<xsl:apply-templates select="ShowPage" mode="outline"/>
			</xsl:when>
			<xsl:when test="ShowPage/Modus='presentation'">
				<xsl:apply-templates select="ShowPage" mode="presentation"/>
			</xsl:when>
      <xsl:when test="ShowPage/Modus='simple'">
        <xsl:apply-templates select="ShowPage" mode="simple"/>
      </xsl:when>
      <xsl:otherwise>
				<xsl:apply-templates select="ShowPage"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="ShowPage">
		<xsl:variable name="bgcolor">
			<xsl:choose>
				<xsl:when test="count(bgcolor)">
					<xsl:value-of select="bgcolor"/>
				</xsl:when>
				<xsl:otherwise>#440000</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<html>
			<head>
				<title>
					<xsl:value-of select="sTitle"/>
				</title>
			</head>
      <xsl:choose>
        <xsl:when test="Agent='iPhone'">
			    <body style="background-color: {$bgcolor}; margin: 0px; text-align:center;">
				    <xsl:apply-templates select="." mode="navi"/>
            <xsl:for-each select="//img">
              <br/>
              <img src="@src"/>
              <br/>
            </xsl:for-each>
            <xsl:for-each select="Subobj">
              <br/>
              <img src="?f={@id}"/>
              <br/>
            </xsl:for-each>
				    <xsl:apply-templates select="." mode="navi"/>
          </body>
        </xsl:when>
        <xsl:otherwise>
			    <frameset cols="*,140"  frameborder="0" border="0">
            <xsl:choose>
              <xsl:when test="count(//img) and count(Subobj)=0">
                <frame src="{Script}?f={@id}&amp;ex={//img[position()=1]/@src}&amp;m=simple" name="presentation"/>
              </xsl:when>
              <xsl:otherwise>
 				    <frame src="{Script}?f={@id}&amp;ex={Subobj[position()=1]/@id}&amp;v=presentation.xsl&amp;m=presentation" 
					    name="presentation"/>
               
              </xsl:otherwise>
            </xsl:choose>
				    <frame src="{Script}?f={@id}&amp;m=outline&amp;v=presentation.xsl"/>
			    </frameset>
          
        </xsl:otherwise>
      </xsl:choose>
		</html>
	</xsl:template>
	<xsl:template match="ShowPage" mode="outline">
		<xsl:variable name="bgcolor">
			<xsl:choose>
				<xsl:when test="count(bgcolor)">
					<xsl:value-of select="bgcolor"/>
				</xsl:when>
				<xsl:otherwise>#440000</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="bdcolor">
			<xsl:choose>
				<xsl:when test="count(bdcolor)">
					<xsl:value-of select="bdcolor"/>
				</xsl:when>
				<xsl:otherwise>#666600</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<html>
			<body style="background-color: {$bgcolor}; margin: 0px; text-align:center;">
				<xsl:apply-templates select="." mode="navi"/>
        <xsl:if test="count(//img) and count(Subobj)=0">
          <xsl:for-each select="//img">
            <a href="{Script}?f={/ShowPage/@id}&amp;ex={@src}&amp;m=simple"
              target="presentation" title="{sTitle}">
              <div>
                <xsl:attribute name="style">
                  border: 1px solid <xsl:value-of select="$bdcolor"/>;
                  height: 110px; width: 110px;
                  background-image: URL(icon.aspx?f=<xsl:value-of select="@src"/>);
                  background-repeat: no-repeat;
                  background-position: center center;
                </xsl:attribute>
              </div>
            </a>
          </xsl:for-each>
        </xsl:if>
				<xsl:for-each select="Subobj">
					<a href="{Script}?f={../@id}&amp;ex={@id}&amp;v=presentation.xsl&amp;m=presentation&amp;ex={$bgcolor}" 
						target="presentation" title="{sTitle}">
						<div>
							<xsl:attribute name="style">
							border: 1px solid <xsl:value-of select="$bdcolor"/>; 
							height: 110px; width: 110px; 
							background-image: URL(<xsl:apply-templates select="." mode="link"/>);
							background-repeat: no-repeat;
							background-position: center center;
						</xsl:attribute>
						</div>
					</a>
					<xsl:text> </xsl:text>
				</xsl:for-each>
				<xsl:apply-templates select="." mode="navi"/>
			</body>
		</html>
	</xsl:template>
	<xsl:template match="ShowPage" mode="navi">
		<xsl:variable name="bgcolor">
			<xsl:choose>
				<xsl:when test="count(bgcolor)">
					<xsl:value-of select="bgcolor"/>
				</xsl:when>
				<xsl:otherwise>#440000</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="bdcolor">
			<xsl:choose>
				<xsl:when test="count(bdcolor)">
					<xsl:value-of select="bdcolor"/>
				</xsl:when>
				<xsl:otherwise>#666600</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<div>
			<xsl:attribute name="style">
				border: 1px solid <xsl:value-of select="$bdcolor"/>; 
				height: 20px; width: 110px; display: inline; 
			</xsl:attribute>
			<a href="{Script}?f={@super}" target="_top">
				<img border="0" src="{ImgDir}/super.gif" alt="{$lsHome}"/>
			</a>
			<xsl:text> </xsl:text>
			<a href="{Script}" target="_top">
				<img border="0" src="{ImgDir}/homepage.gif" alt="{$lsUp}"/>
			</a>
			<xsl:text> </xsl:text>
			<xsl:if test="contains(Edit/@link,'m=edit')">
				<xsl:if test="count(Subobj)=0 and count(//img)=0">
					<a href="{Script}?f={@id}&amp;m=delete" target="_top">
						<img border="0" src="{ImgDir}/delete.gif" alt="{$lsDeleteSection}"/>
					</a>
					<xsl:text> </xsl:text>
				</xsl:if>
				<a href="{Script}?f={@id}&amp;m=update&amp;next=NewPrivateFile" target="_top">
					<img border="0" src="{ImgDir}/settings.gif" alt="{$lsAppendFile}"/>
				</a><xsl:text> </xsl:text>
				<a href="{Script}?f={@id}&amp;m=edit" target="_top">
					<img border="0" src="{ImgDir}/edit.gif" alt="{$lsEditSection}"/>
				</a><xsl:text> </xsl:text>
			</xsl:if>
		</div>					
	</xsl:template>
	<xsl:template match="ShowPage" mode="presentation">
		<xsl:variable name="bgcolor">
			<xsl:choose>
				<xsl:when test="count(bgcolor)">
					<xsl:value-of select="bgcolor"/>
				</xsl:when>
				<xsl:otherwise>#440000</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<html>
			<body style="background-color: {$bgcolor}; margin: 0px; text-align:center;">
		    <a href="{Script}?f={ex}&amp;v=imgview.xsl" target="blank">
			    <div>
                    <xsl:attribute name="title">
                        <xsl:value-of select="//img[@src=/ShowPage/ex]/@alt"/>
                    </xsl:attribute>
				    <xsl:attribute name="style">
					    height: 99%; width: 99%; 
					    background-image: URL(<xsl:apply-templates select="Script"/>?f=<xsl:value-of select="ex"/>);
					    background-repeat: no-repeat;
					    background-position: center center;
				    </xsl:attribute>
			    </div>
		    </a>
			</body>
		</html>
	</xsl:template>
  <xsl:template match="ShowPage" mode="simple">
    <xsl:variable name="bgcolor">
      <xsl:choose>
        <xsl:when test="count(bgcolor)">
          <xsl:value-of select="bgcolor"/>
        </xsl:when>
        <xsl:otherwise>#440000</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <html>
      <body style="background-color: {$bgcolor}; margin: 0px; text-align:center;">

          <div>
              <xsl:attribute name="title">
                  <xsl:value-of select="//img[@src=/ShowPage/ex]/@alt"/>
              </xsl:attribute>
              <xsl:attribute name="style">
              height: 99%; width: 99%;
              background-image: URL(<xsl:value-of select="ex"/>);
              background-repeat: no-repeat;
              background-position: center center;
            </xsl:attribute>
          </div>

      </body>
    </html>
  </xsl:template>
	<xsl:template match="Subobj" mode="link">
		<!-- Extrahieren von Icon -->
		<xsl:choose>
			<xsl:when test="sTemplate='PrivateFile'">
				icon.aspx?f=<xsl:value-of select="@name"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="substring-before(.,'pub/')"/>pub/icon/<xsl:value-of select="substring-after(.,'pub/')"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

</xsl:stylesheet>
