<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">


  <xsl:variable name="fanart">
    <xsl:value-of select="descendant::fanart/attribute::src"/>
  </xsl:variable>
  <xsl:variable name="intensity">
    <xsl:value-of select="/descendant::fanart/attribute::intensity"/>
  </xsl:variable>
  
  <xsl:template match="/game">
    <html>
      <head>
        <link rel="stylesheet" type="text/css" href="gameLibraryScreen.css" />
      </head>
      <body>
        <xsl:attribute name="style">
          background-image: url('<xsl:value-of select="$fanart"/>')
        </xsl:attribute>
        <div id="wrapper">
          <xsl:choose>
            <xsl:when test="$intensity='high'">
              <xsl:attribute name="class">dark</xsl:attribute>
            </xsl:when>
          </xsl:choose>
          
          <xsl:choose>
            <xsl:when test="attribute::platform='XBOX'">
              <img id="platform" src="gfx/xbox.png" />
            </xsl:when>
          </xsl:choose>
          <xsl:apply-templates />
        </div>
      </body>
    </html>
  </xsl:template>
  
  <xsl:template match="@src">
    <xsl:value-of select="." />
  </xsl:template>
  
  <xsl:template match="/game/title">
    <h1> <xsl:apply-templates /> </h1>
  </xsl:template>

  <xsl:template match="/game/teaser">
    <p class="teaser"> <xsl:value-of select="text()" /> </p>
  </xsl:template>
  
  <xsl:template match="/game/synopsis">
    <p class="synopsis"> <xsl:value-of select="text()" /> </p>
  </xsl:template>
  
  <xsl:template match="/game/esbr">
    <xsl:choose>
      <xsl:when test="text()='T'">
        <img class="content-rating" src="esbr/T_small.png" />
      </xsl:when>
    </xsl:choose>
  </xsl:template>
  
  <xsl:template match="/game/max-players">
    <div class="specification"><div>
        <small>max</small>
        <strong><xsl:value-of select="text()" /></strong>
        <small>players</small>
    </div></div>
  </xsl:template>
  
  <!--======================Genres and perspectives==========================-->
  <xsl:template match="/game/genres">
        <ul id="genres">
          <xsl:apply-templates />
        </ul>
  </xsl:template>
  
  <xsl:template match="/game/perspectives">
        <ul id="perspectives">
          <xsl:apply-templates />
        </ul>
  </xsl:template>
  
  <xsl:template match="/game/perspectives/perspective|/game/genres/genre">
    <li> <xsl:value-of select="text()" /> </li>
  </xsl:template>
  
  <!--============================Graphics==================================-->
  <xsl:template match="/game/graphics/thumbnail">
    <img id="thumbnail">
      <xsl:attribute name="src"><xsl:value-of select="@src" /></xsl:attribute>
    </img>
  </xsl:template>
  
  
</xsl:stylesheet>