<xsl:stylesheet version="1.0"	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                                xmlns:str="http://exslt.org/strings"
                                extension-element-prefixes="str">

<xsl:import href="ppp/str.xsl" />

<xsl:output method="xml" omit-xml-declaration="yes"/>

<xsl:include href="preferences.xsl"/>
<xsl:include href="skin-options.xsl"/>
<xsl:include href="templates.xsl" />
<xsl:include href="tv-detail.xsl" />

<xsl:include href="./ppp/ppp-options.xsl" />
<xsl:include href="./ppp/ppp-templates.xsl" />
<xsl:include href="./ppp/ppp-detail-templates.xsl" />

<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />

<!-- truncate-phrase style sheet by Aaron Straup Cope http://www.aaronstraupcope.com -->
<xsl:include href="./ppp/truncate-phrase/truncate-phrase.xsl" />
<xsl:variable name="doReverseEpisodes">
	<xsl:choose>
		<xsl:when test="$reverseEpisodeOrder='true'">true</xsl:when>
		<xsl:when test="$reverseEpisodeOrder='false'">false</xsl:when>
		<xsl:otherwise>false</xsl:otherwise>
	</xsl:choose>
</xsl:variable>
<xsl:variable name="useAnimation">
	<xsl:choose>
		<xsl:when test="/details/movie/season != '-1' and $tvShow.useAnimation = 'true'">true</xsl:when>
    <xsl:when test="/details/movie/season = '-1' and $movie.useAnimation = 'true'">true</xsl:when>
		<xsl:otherwise>false</xsl:otherwise>
	</xsl:choose>
</xsl:variable>
<xsl:variable name="actorNum">
	<xsl:choose>
		<xsl:when test="/details/movie/season = '-1'">
			<xsl:value-of select="$actors.max.cnt" />
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="$actors.tv.max.cnt" />
		</xsl:otherwise>
	</xsl:choose>
</xsl:variable>
<xsl:variable name="actorNumAdj" select="$actorNum + 1" />

<xsl:variable name="iEpisodesPerPage" select="100" />
<xsl:variable name="tooManySeries">
	<xsl:choose>
		<xsl:when test="count(/details/movie/files/file/filePlot) &gt; $iEpisodesPerPage">true</xsl:when>
		<xsl:otherwise>false</xsl:otherwise>
	</xsl:choose>
</xsl:variable>

<xsl:template match="/">
<xsl:for-each select="details/movie">
<html>
<head>
  <link rel="StyleSheet" type="text/css" href="exportdetails_item_popcorn.css"></link>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <title><xsl:value-of select="title"/></title>

	<script type="text/javascript">
		asEpisodePlot = new Array('0');
    asEpisodeTitle = new Array('0');
    asEpisodeImage = new Array('0');
    asEpisodeTitleShort = new Array('0');
    asEpisodeNo = new Array('0');
	asEpisodeUrl = new Array('0');
	</script>
	<xsl:call-template name="get-episode-infos" />

<xsl:variable name="plot">
  <xsl:choose>
    <xsl:when test="plot = '' or plot = 'UNKNOWN'">
      <xsl:text>Plot unavailable.</xsl:text>
    </xsl:when>
    <xsl:otherwise>
	<xsl:variable name="temp-plot1">
      <xsl:call-template name="search-and-replace">
        <xsl:with-param name="input">
		  <xsl:if test="$mjb.internet.plugin!='com.moviejukebox.plugin.SratimPlugin'">
            <xsl:value-of select="plot"/>
		  </xsl:if>
		  <xsl:if test="$mjb.internet.plugin='com.moviejukebox.plugin.SratimPlugin'">
			<xsl:value-of disable-output-escaping="yes" select='translate(plot,"{}","&lt;&gt;")' />
		  </xsl:if>
        </xsl:with-param>
        <xsl:with-param name="search-string">"</xsl:with-param>
        <xsl:with-param name="replace-string">\"</xsl:with-param>
      </xsl:call-template>
      </xsl:variable>
      <xsl:variable name="temp-plot2">
      <xsl:call-template name="search-and-replace">
        <xsl:with-param name="input">
          <xsl:value-of select="$temp-plot1"/>
        </xsl:with-param>
        <xsl:with-param name="search-string">--</xsl:with-param>
        <xsl:with-param name="replace-string">-</xsl:with-param>
      </xsl:call-template>
      </xsl:variable>
      <xsl:variable name="temp-plot">
      <xsl:choose>
        <xsl:when test="substring($temp-plot2, (string-length($temp-plot2) - string-length('-')) + 1) = '-'">
          <xsl:value-of select="substring($temp-plot2, 1, (string-length($temp-plot2) - 1))"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$temp-plot2"/>
        </xsl:otherwise>
      </xsl:choose>
      </xsl:variable>
      <xsl:value-of select="$temp-plot"/>
    </xsl:otherwise>
  </xsl:choose>
  </xsl:variable> 

  <script type="text/javascript">
  <xsl:comment>
  	var sPlotLong = "<xsl:value-of select="translate($plot,'&#xA;','')"/>"
  </xsl:comment>
  </script>
  <xsl:call-template name="get-js" />
  
	</head>
<xsl:variable name="star_rating">true</xsl:variable>

	<xsl:choose>
	  <xsl:when test="season=-1">

<body bgproperties="fixed" bgcolor="#000000" onloadset="play" topmargin="0" leftmargin="0">
<!--<xsl:attribute name="onloadset"><xsl:value-of select="//index[@current='true']/@name"/></xsl:attribute>-->
	<xsl:attribute name="background">
		<xsl:value-of select="fanartFile" />
	</xsl:attribute>


<table height="720" border="0" cellspacing="0" cellpadding="0">
<xsl:if test="$extras='false'"><xsl:attribute name="width">1280</xsl:attribute></xsl:if>
<xsl:if test="$extras='true'"><xsl:attribute name="width">2560</xsl:attribute></xsl:if>
	<tr>
		<td height="720" valign="top">
			<xsl:attribute name="width">570</xsl:attribute>
			<xsl:attribute name="align">right</xsl:attribute>
			<xsl:attribute name="background">pictures/alaska/diffuse-l.png</xsl:attribute>

<table border="0" cellspacing="0" cellpadding="0">
	<tr><td height="80" width="215" align="center"><img src="pictures/alaska/movies.png"/></td><td width="324"/></tr>
	<tr>
		<td align="right" valign="top">
			<table border="0" cellspacing="0" cellpadding="0"><!-- deviate studio -->
				<tr>
					<td height="66" width="97" background="pictures/alaska/flags/studio-frame.png" align="center" valign="middle">
						<xsl:call-template name="studio"/>
					</td>
					<td width="16"/>
				</tr>
			</table><!-- /deviate studio -->
		</td>
		<td>
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td height="480" width="324">
						<xsl:attribute name="background">
							<xsl:value-of select="detailPosterFile"/>
						</xsl:attribute>
						<img>
							<xsl:if test="count(//movie/extras/extra) = 0">
								<xsl:attribute name="src">pictures/alaska/overlay.png</xsl:attribute>
							</xsl:if>
							<xsl:if test="count(//movie/extras/extra) &gt; 0">
								<xsl:attribute name="src">pictures/alaska/trailer.png</xsl:attribute>
							</xsl:if>
						</img>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr><!-- deviate flags -->
		<td class="alaska-rating"/>
		<td height="44" valign="bottom">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td><img src="pictures/alaska/flags/star.png"/></td>
					<td background="pictures/alaska/flags/star-frame.png" width="50" align="center" class="alaska-rating">
						<xsl:choose>
							<xsl:when test="rating='0' or rating='10' or rating='20' or rating='30' or rating='40' or rating='50' or rating='60' or rating='70' or rating='80' or rating='90'">
								<xsl:value-of select="concat(rating div 10,'.00')" />
							</xsl:when>
							<xsl:when test="rating='100'">
								<xsl:value-of select="concat(rating div 10,'.0')" />
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="concat(rating div 10,'0')" />
							</xsl:otherwise>
						</xsl:choose>
					</td>
					<td width="14"/>
					<td background="pictures/alaska/flags/output.png" width="41" align="center" class="alaska-flags">
						<xsl:call-template name="alaskavideoOutput"/>
					</td>
					<td background="pictures/alaska/flags/source-frame.png" width="63" align="center">
						<xsl:call-template name="alaskavideoSource"/>
					</td>
					<td background="pictures/alaska/flags/aspectratio.png" width="35" class="alaska-flags" align="center">
						<xsl:value-of select="substring(substring-before(resolution,'x') div substring-after(resolution,'x'),1,4)" />
					</td>
					<td width="14"/>
					<xsl:call-template name="alaskaaudioCodec"/>
				</tr>
			</table>
		</td>
	</tr><!-- /deviate flags -->
</table>

		</td>

		<td><xsl:attribute name="background">pictures/alaska/diffuse-r.png</xsl:attribute>
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td>
<td width="*" height="720" align="left" valign="top">

<table border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td colspan="2">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td colspan="3" height="156" valign="bottom">
						<table border="0" cellspacing="0" cellpadding="0">
							<tr><td width="15"/>
								<td class="alaska-title">
									<xsl:choose>
										<xsl:when test="string-length(title)&lt;50">
											<xsl:value-of select="translate(title, $smallcase, $uppercase)" />
										</xsl:when>
										<xsl:otherwise>
											<xsl:value-of select="translate(substring(title,1,45), $smallcase, $uppercase)"/>...
										</xsl:otherwise>
									</xsl:choose>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td align="center" valign="middle" width="200" height="90">
						<xsl:if test="certification != 'UNKNOWN' and certification != '' and certification != 'Not Rated'">
							<xsl:call-template name="certification" />
						</xsl:if>
					</td>
					<td align="center" width="150" class="alaska-info">
						<xsl:if test="year != 'UNKNOWN'">
							<xsl:choose>
								<xsl:when test="year/@index != ''">
									<xsl:value-of select="year" />
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="year" />
								</xsl:otherwise>
							</xsl:choose>
						</xsl:if>
					</td>
					<td class="alaska-info">&#160;
						<xsl:if test="runtime != 'UNKNOWN'">
							<xsl:value-of select="translate(runtime, $smallcase, $uppercase)" /> 
						</xsl:if>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td width="135" height="23"/><td class="alaska-detail">
			<xsl:if test="director != 'UNKNOWN'">
				<xsl:choose>
					<xsl:when test="director/@index != ''">
						<xsl:value-of select="translate(director, $smallcase, $uppercase)" /> 
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="translate(director, $smallcase, $uppercase)" /> 
					</xsl:otherwise>
				</xsl:choose>
			</xsl:if>
		</td>
	</tr>
	<tr>
		<td height="23"/><td class="alaska-detail">
			<xsl:if test="count(writers/writer) != 0">
				<xsl:for-each select="writers/writer[position() &lt;= 3]">
					<xsl:if test="position()!=1"> / </xsl:if>
						<xsl:choose>
							<xsl:when test="@index != ''">
								<xsl:value-of select="translate(., $smallcase, $uppercase)" /> 
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="translate(., $smallcase, $uppercase)" /> 
							</xsl:otherwise>
						</xsl:choose>
				</xsl:for-each>
			</xsl:if>	
		</td>
	</tr>
	<tr><td height="15"/></tr>
	<tr>
		<td width=""/>
		<td valign="top" height="72">
			<xsl:if test="count(cast/actor) != 0">
				<xsl:for-each select="cast/actor[position() &lt;= 3]"><!-- up to 3 cast members -->
					<table border="0" cellpadding="0" cellspacing="0"><tr><td class="alaska-detail" height="23">
						<xsl:if test="position()!=1">  </xsl:if>
							<xsl:choose>
								<xsl:when test="@index != ''">
									<xsl:value-of select="translate(., $smallcase, $uppercase)" />
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="translate(., $smallcase, $uppercase)" />
								</xsl:otherwise>
							</xsl:choose>
					</td></tr></table>
				</xsl:for-each>
			</xsl:if>
		</td>
	</tr>
	<tr><td height="8"/></tr>
	<tr>
		<td colspan="2">
<!--			<xsl:if test="$AlignRight='true' or $mjb.internet.plugin='com.moviejukebox.plugin.SratimPlugin'">
				<xsl:attribute name="align">right</xsl:attribute>
			</xsl:if>-->
			<table border="0" cellspacing="15" cellpadding="0">
				<tr>
					<td class="alaska-detail">
						<xsl:if test="$AlignRight='true' or $mjb.internet.plugin='com.moviejukebox.plugin.SratimPlugin'">
							<xsl:attribute name="align">right</xsl:attribute>
						</xsl:if>
						<xsl:if test="plot != 'UNKNOWN'">
							<xsl:call-template name="PreserveLineBreaksShort">
								<xsl:with-param name="text" select="plot"/>
							</xsl:call-template>
						</xsl:if>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>

</td>

<td width="93" height="720" align="left" valign="middle">
	<xsl:call-template name="playfile"/>
	<xsl:call-template name="trailer"/>
</td>
</td></tr></table></td>
<xsl:if test="$extras='true'">
	<td width="1280" align="right" valign="top">
		<xsl:call-template name="companion"/>
	</td>
</xsl:if>

	</tr>
</table>

</body>

    </xsl:when>
    <xsl:otherwise>

<xsl:call-template name="tv-detail"/>

	  </xsl:otherwise>
  </xsl:choose>


  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
      <!-- Navigation using remote keys: Home, PageUP/PageDown (Previous/Next) -->
	  <a>
        <xsl:attribute name="TVID">HOME</xsl:attribute>
        <xsl:attribute name="href"><xsl:value-of select="$homePage" /></xsl:attribute>
      </a>
      <a TVID="PGDN" ONFOCUSLOAD="">
	    <xsl:attribute name="name">pgdn</xsl:attribute>
        <xsl:attribute name="href"><xsl:choose><xsl:when
          test="contains(next,'UNKNOWN')"><xsl:value-of select="first" />.html</xsl:when><xsl:otherwise><xsl:value-of
          select="next" />.html</xsl:otherwise></xsl:choose></xsl:attribute>
      </a>
      <a TVID="PGUP" ONFOCUSLOAD="">
	    <xsl:attribute name="name">pgup</xsl:attribute>
        <xsl:attribute name="href"><xsl:choose><xsl:when
          test="contains(previous,'UNKNOWN')"><xsl:value-of select="last" />.html</xsl:when><xsl:otherwise><xsl:value-of
          select="previous" />.html</xsl:otherwise></xsl:choose></xsl:attribute>
      </a>
	  
	<a><xsl:attribute name="TVID">RED</xsl:attribute><xsl:attribute name="href"><xsl:value-of select="$RedURL" /></xsl:attribute></a>
	<a><xsl:attribute name="TVID">GREEN</xsl:attribute><xsl:attribute name="href"><xsl:value-of select="$GreenURL" /></xsl:attribute></a>
	<a><xsl:attribute name="TVID">YELLOW</xsl:attribute><xsl:attribute name="href"><xsl:value-of select="$YellowURL" /></xsl:attribute></a>
	<a><xsl:attribute name="TVID">BLUE</xsl:attribute><xsl:attribute name="href"><xsl:value-of select="$BlueURL" /></xsl:attribute></a>

  
  
  

  </html>
</xsl:for-each>
</xsl:template>

<!-- TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES -->
<!-- TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES -->
<!-- TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES TEMPLATES -->

<xsl:template name="zcd">
  <xsl:param name="url"/>
  <xsl:param name="container"/>

  <xsl:if test="$container = 'ISO' or (substring($url, (string-length($url) - string-length('.ISO')) + 1) = '.ISO') or (substring($url, (string-length($url) - string-length('.iso')) + 1) = '.iso')">
    <xsl:attribute name="zcd">2</xsl:attribute>
  </xsl:if>

  <xsl:if test="$container = 'IMG' or (substring($url, (string-length($url) - string-length('.IMG')) + 1) = '.IMG') or (substring($url, (string-length($url) - string-length('.img')) + 1) = '.img')">
    <xsl:attribute name="zcd">2</xsl:attribute>
  </xsl:if>

  <xsl:if test="substring($url, (string-length($url) - string-length('VIDEO_TS')) + 1) = 'VIDEO_TS'">
    <xsl:attribute name="zcd">2</xsl:attribute>
  </xsl:if>

  <xsl:if test="substring($url, (string-length($url) - string-length('/')) + 1) = '/'">
    <xsl:attribute name="zcd">2</xsl:attribute>
  </xsl:if>
</xsl:template>

<xsl:template name="PreserveLineBreaksShort"><!-- WatchBar ON -->
    <xsl:param name="text"/>
    <xsl:choose>
        <xsl:when test="contains($text,'&#xA;')">
            <xsl:value-of select="substring-before($text,'&#xA;')"/>
            <br/>
            <xsl:call-template name="PreserveLineBreaksShort">
                <xsl:with-param name="text">
				  <xsl:if test="$mjb.internet.plugin!='com.moviejukebox.plugin.SratimPlugin'">
					<xsl:value-of select="substring-after($text,'&#xA;')"/>
				  </xsl:if>
				  <xsl:if test="$mjb.internet.plugin='com.moviejukebox.plugin.SratimPlugin'">
					<xsl:value-of disable-output-escaping="yes" select='translate(substring-after($text,"&#xA;"),"{}","&lt;&gt;")' />
				  </xsl:if>
                </xsl:with-param>
            </xsl:call-template>
        </xsl:when>
		<xsl:when test="string-length($text)&lt;$PlotLength">
				  <xsl:if test="$mjb.internet.plugin!='com.moviejukebox.plugin.SratimPlugin'">
					<xsl:value-of select="$text"/><!-- old -->
				  </xsl:if>
				  <xsl:if test="$mjb.internet.plugin='com.moviejukebox.plugin.SratimPlugin'">
					<xsl:value-of disable-output-escaping="yes" select='translate($text,"{}","&lt;&gt;")'/>
				  </xsl:if>
		</xsl:when>
        <xsl:otherwise>
				  <xsl:if test="$mjb.internet.plugin!='com.moviejukebox.plugin.SratimPlugin'">
					<xsl:value-of select="substring($text,1,($PlotLength)-4)"/>...<!-- old -->
				  </xsl:if>
				  <xsl:if test="$mjb.internet.plugin='com.moviejukebox.plugin.SratimPlugin'">
					<xsl:value-of disable-output-escaping="yes" select='translate(substring($text,1,($PlotLength)-4),"{}","&lt;&gt;")'/>...
				  </xsl:if>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template name="PreserveLineBreaksLong"><!-- WatchBar OFF -->
    <xsl:param name="text"/>
    <xsl:choose>
        <xsl:when test="contains($text,'&#xA;')">
            <xsl:value-of select="substring-before($text,'&#xA;')"/>
            <br/>
            <xsl:call-template name="PreserveLineBreaksLong">
                <xsl:with-param name="text">
				  <xsl:if test="$mjb.internet.plugin!='com.moviejukebox.plugin.SratimPlugin'">
					<xsl:value-of select="substring-after($text,'&#xA;')"/>
				  </xsl:if>
				  <xsl:if test="$mjb.internet.plugin='com.moviejukebox.plugin.SratimPlugin'">
					<xsl:value-of disable-output-escaping="yes" select='translate(substring-after($text,"&#xA;"),"{}","&lt;&gt;")' />
				  </xsl:if>
                </xsl:with-param>
            </xsl:call-template>
        </xsl:when>
		<xsl:when test="string-length($text)&lt;($PlotLength)+150">
				  <xsl:if test="$mjb.internet.plugin!='com.moviejukebox.plugin.SratimPlugin'">
					<xsl:value-of select="$text"/><!-- old -->
				  </xsl:if>
				  <xsl:if test="$mjb.internet.plugin='com.moviejukebox.plugin.SratimPlugin'">
					<xsl:value-of disable-output-escaping="yes" select='translate($text,"{}","&lt;&gt;")'/>
				  </xsl:if>
		</xsl:when>
        <xsl:otherwise>
				  <xsl:if test="$mjb.internet.plugin!='com.moviejukebox.plugin.SratimPlugin'">
					<xsl:value-of select="substring($text,1,($PlotLength)+146)"/>...<!-- old -->
				  </xsl:if>
				  <xsl:if test="$mjb.internet.plugin='com.moviejukebox.plugin.SratimPlugin'">
					<xsl:value-of disable-output-escaping="yes" select='translate(substring($text,1,($PlotLength)+146),"{}","&lt;&gt;")'/>...
				  </xsl:if>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template name="trailer">
			   <xsl:for-each select="extras/extra[position() &lt;= 1]">
					<a>
						<xsl:attribute name="TVID">INFO</xsl:attribute>
						<xsl:attribute name="onkeydownset">pgdn</xsl:attribute>
						<xsl:attribute name="onkeyupset">pgup</xsl:attribute>
						<xsl:attribute name="name">trailer</xsl:attribute>
						<xsl:attribute name="onkeyrightset">trailer</xsl:attribute>
							<xsl:choose><xsl:when test="$extras='true'">
							<xsl:attribute name="onkeyleftset">refresh</xsl:attribute>
							</xsl:when><xsl:otherwise>
							<xsl:attribute name="onkeyleftset">pgup</xsl:attribute>
							</xsl:otherwise></xsl:choose>
						<xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
							<xsl:call-template name="zcd">
								<xsl:with-param name="url" select="."/>
							</xsl:call-template>
								<xsl:if test="//movie/prebuf != '-1'">
									<xsl:attribute name="prebuf"><xsl:value-of select="//movie/prebuf" /></xsl:attribute>
								</xsl:if>
								<xsl:attribute name="vod"/>
						</a>
				</xsl:for-each>
</xsl:template>

<xsl:template name="companion">
	<table border="0" cellspacing="0" cellpadding="0">
	<tr><td align="right" width="500" bgcolor="Black-alpha2">
<a>
<xsl:attribute name="name">refresh</xsl:attribute>
<xsl:attribute name="onkeyleftset">last</xsl:attribute>
<xsl:attribute name="onkeyupset">last</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="details" /></xsl:attribute>
[<xsl:value-of select="$BackToDetails"/>]
</a>
	</td></tr>

                <xsl:if test="year/@index != ''"><tr><td align="right" bgcolor="Black-alpha2"><!--when-->
                  <a>
                    <xsl:attribute name="href"><xsl:value-of select="year/@index" />.html</xsl:attribute>
					<xsl:attribute name="onkeyleftset">refresh</xsl:attribute>
					<xsl:attribute name="name">extras</xsl:attribute>
                    <xsl:value-of select="year" />
                  </a>
                </td></tr></xsl:if>
<tr><td align="right" bgcolor="Black-alpha2">
            <xsl:if test="count(genres) != 0">
              <xsl:for-each select="genres/genre[position() &lt;= $genres.max]">
			  <table border="0" cellpadding="0" cellspacing="0"><tr><td>
                <xsl:if test="position()!= 1">  </xsl:if>
                <xsl:choose>
                  <xsl:when test="@index != ''">
                    <a>
                      <xsl:attribute name="href"><xsl:value-of select="@index" />.html</xsl:attribute>
					  <xsl:attribute name="onkeyleftset">refresh</xsl:attribute>
					  <xsl:attribute name="name">extras</xsl:attribute>
                      <xsl:value-of select="." /> 
                    </a>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="." /> 
                  </xsl:otherwise>
                </xsl:choose>
				</td></tr></table>
              </xsl:for-each>
            </xsl:if>
</td></tr>
                <xsl:if test="director/@index != ''"><tr><td align="right" bgcolor="Black-alpha2"><!--when-->
                  <a>
                    <xsl:attribute name="href"><xsl:value-of select="director/@index" />.html</xsl:attribute>
					<xsl:attribute name="onkeyleftset">refresh</xsl:attribute>
					<xsl:attribute name="name">extras</xsl:attribute>
                    <xsl:value-of select="director" /> 
                  </a>
                </td></tr></xsl:if>

                <xsl:if test="country != 'UNKNOWN' and country/@index != ''"><tr><td align="right" bgcolor="Black-alpha2"><!--when-->
                  <a>
                    <xsl:attribute name="href"><xsl:value-of select="country/@index" />.html</xsl:attribute>
					<xsl:attribute name="onkeyleftset">refresh</xsl:attribute>
					<xsl:attribute name="name">extras</xsl:attribute>
                    <xsl:value-of select="country" />
                  </a>
                </td></tr></xsl:if>
<tr><td align="right" bgcolor="Black-alpha2">
			<xsl:if test="count(cast/actor) != 0">
              <xsl:for-each select="cast/actor[position() &lt;= $actors.max]">
			  <table border="0" cellpadding="0" cellspacing="0"><tr><td bgcolor="Black-alpha2">
                <xsl:if test="position()!=1">  </xsl:if>
                <xsl:choose>
                  <xsl:when test="@index != ''">
                    <a>
                      <xsl:attribute name="href"><xsl:value-of select="@index" />.html</xsl:attribute>
					  <xsl:attribute name="onkeyleftset">refresh</xsl:attribute>
					  <xsl:attribute name="name">extras</xsl:attribute>
                      <xsl:value-of select="." /> 
                    </a>
                  </xsl:when>
                  <xsl:otherwise>
<!--                    <xsl:value-of select="." /> -->
                  </xsl:otherwise>
                </xsl:choose>
				</td></tr></table>
              </xsl:for-each>
			</xsl:if>
</td></tr>
<tr><td bgcolor="Black-alpha2">.</td></tr>
		<xsl:if test="count(files/file) != 1">
			   <xsl:for-each select="files/file"><!--[position() &lt;= 1]-->
					<tr><td align="right" bgcolor="Black-alpha2">
					<a>
						<xsl:attribute name="onkeyleftset">refresh</xsl:attribute>
						<xsl:attribute name="name">extras</xsl:attribute>
						<xsl:attribute name="href"><xsl:value-of select="fileURL" /></xsl:attribute>
							<xsl:call-template name="zcd">
								<xsl:with-param name="url" select="fileURL"/>
								<xsl:with-param name="container" select="//movie/container"/>
							</xsl:call-template>
								<xsl:if test="//movie/prebuf != '-1'"><xsl:attribute name="prebuf"><xsl:value-of select="//movie/prebuf" /></xsl:attribute></xsl:if>
								<xsl:attribute name="vod"/>
							<xsl:text>Part </xsl:text><xsl:value-of select="@firstPart" /><xsl:text> - </xsl:text><xsl:value-of select="@title" />
						</a>
						</td></tr>
				</xsl:for-each>
		</xsl:if>
<tr><td bgcolor="Black-alpha2">.</td></tr>

		<xsl:if test="count(extras) != 0">
			   <xsl:for-each select="extras/extra"><!--[position() &lt;= 1]-->
					<tr><td align="right" bgcolor="Black-alpha2">
					<a>
						<xsl:attribute name="onkeyleftset">refresh</xsl:attribute>
						<xsl:attribute name="name">extras</xsl:attribute>
						<xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
							<xsl:call-template name="zcd">
								<xsl:with-param name="url" select="."/>
							</xsl:call-template>
								<xsl:if test="//movie/prebuf != '-1'">
									<xsl:attribute name="prebuf"><xsl:value-of select="//movie/prebuf" /></xsl:attribute>
								</xsl:if>
								<xsl:attribute name="vod"/>
							<xsl:value-of select="@title" />
						</a>
						</td></tr>
				</xsl:for-each>
		</xsl:if>
	<tr><td align="right" width="500" bgcolor="Black-alpha2">
<a>
<xsl:attribute name="name">last</xsl:attribute>
<xsl:attribute name="onkeyleftset">refresh</xsl:attribute>
<xsl:attribute name="onkeydownset">refresh</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="details" /></xsl:attribute>
[<xsl:value-of select="$BackToDetails"/>]
</a>
	</td></tr>
				</table>
</xsl:template>

<xsl:template name="playfile">
        <xsl:choose>
          <xsl:when test="count(files/file) = 1">
            <xsl:for-each select="files/file">
<!--                <xsl:if test="//movie/season != -1">
                  <td align="right" class="normal">
                    <xsl:value-of select="@firstPart"/>
                    <xsl:if test="@firstPart!=@lastPart">-<xsl:value-of select="@lastPart"/></xsl:if>.
                  </td>
                </xsl:if>-->
                  <a class="link"><xsl:attribute name="href">
				  
<xsl:choose>
<xsl:when test="//movie/container = 'RAR' or substring(//files/file/fileURL,string-length(//files/file/fileURL)-3,4) = '.RAR' or substring(//files/file/fileURL,string-length(//files/file/fileURL)-3,4) = '.rar'">
<xsl:value-of select="concat(//files/file/fileURL,'?playall=1')" />
</xsl:when>
<xsl:otherwise>
					<xsl:value-of select="fileURL" />
</xsl:otherwise></xsl:choose>

</xsl:attribute>
							<xsl:attribute name="onkeydownset">pgdn</xsl:attribute>
							<xsl:attribute name="onkeyupset">pgup</xsl:attribute>
							<xsl:attribute name="onkeyrightset">pgdn</xsl:attribute>

							<xsl:choose><xsl:when test="$extras='true'">
							<xsl:attribute name="onkeyleftset">refresh</xsl:attribute>
							</xsl:when><xsl:otherwise>
							<xsl:attribute name="onkeyleftset">pgup</xsl:attribute>
							</xsl:otherwise></xsl:choose>

                    <xsl:attribute name="TVID">Play</xsl:attribute>
                    <xsl:attribute name="name">play</xsl:attribute>

                    <xsl:call-template name="zcd">
                      <xsl:with-param name="url" select="fileURL"/>
                      <xsl:with-param name="container" select="//movie/container"/>
                    </xsl:call-template>

<xsl:choose>
<xsl:when test="//movie/container = 'RAR' or substring(//files/file/fileURL,string-length(//files/file/fileURL)-3,4) = '.RAR' or substring(//files/file/fileURL,string-length(//files/file/fileURL)-3,4) = '.rar'">
<xsl:attribute name="vod">playlist</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="vod"/>
</xsl:otherwise></xsl:choose>

                    <xsl:if test="//movie/prebuf != -1">
                      <xsl:attribute name="prebuf"><xsl:value-of select="//movie/prebuf" /></xsl:attribute>
                    </xsl:if>

                    <xsl:choose>
                      <xsl:when test="//movie/season = -1">
                        <img src="pictures/detail/1x688.png" onfocussrc="pictures/detail/1x688.png"/>
                      </xsl:when>
<!--                      <xsl:otherwise>
                        <img src="pictures/play_small.png" onfocussrc="pictures/play_selected_small.png" align="top"/>
                        <xsl:choose>
                          <xsl:when test="@title='UNKNOWN'">
                            <xsl:choose>
                              <xsl:when test="@firstPart!=@lastPart">
                                Episodes <xsl:value-of select="@firstPart"/> - <xsl:value-of select="@lastPart"/>
                              </xsl:when>
                              <xsl:otherwise>
                                Episode <xsl:value-of select="@firstPart"/>
                              </xsl:otherwise>
                            </xsl:choose>
                          </xsl:when>
                          <xsl:otherwise><xsl:value-of select="@title"/></xsl:otherwise>
                        </xsl:choose>
                      </xsl:otherwise>-->
                    </xsl:choose>
                  </a>
            </xsl:for-each>
          </xsl:when>

		  
		  
		  
		  
		  
		  
		  
		  
          <xsl:when test="//movie/container = 'BDAV' and //movie/season = -1">
                <a class="link">
                  <xsl:attribute name="href">
                    <xsl:value-of select="concat(/details/movie/baseFilename,'.playlist.jsp')" />
                  </xsl:attribute>
				  			<xsl:attribute name="onkeydownset">pgdn</xsl:attribute>
							<xsl:attribute name="onkeyupset">pgup</xsl:attribute>

<!--							<xsl:choose><xsl:when test="count(//movie/extras/extra) &gt; 0">
							<xsl:attribute name="onkeyrightset">trailer</xsl:attribute>
							</xsl:when><xsl:otherwise>-->
							<xsl:attribute name="onkeyrightset">pgdn</xsl:attribute>
<!--							</xsl:otherwise></xsl:choose>-->

							<xsl:choose><xsl:when test="$extras='true'">
							<xsl:attribute name="onkeyleftset">refresh</xsl:attribute>
							</xsl:when><xsl:otherwise>
							<xsl:attribute name="onkeyleftset">pgup</xsl:attribute>
							</xsl:otherwise></xsl:choose>

                  <xsl:attribute name="TVID">Play</xsl:attribute>
                  <xsl:attribute name="name">play</xsl:attribute>

                  <xsl:attribute name="vod">playlist</xsl:attribute>
                  <img src="pictures/detail/1x688.png" onfocussrc="pictures/detail/1x688.png"/>
                </a>
				
						                        <xsl:for-each select="files/file">
                        <xsl:sort select="@firstPart" data-type="number" order="ascending"/>
<!--                        <xsl:if test="position() = 1">
                          <a id="playLink" tvid="Play" vod="playlist">
                            <xsl:attribute name="href"><xsl:value-of select="fileURL" /></xsl:attribute>
                          </a>
                        </xsl:if>-->
                        <a>
                          <xsl:attribute name="href"><xsl:value-of select="fileURL" /></xsl:attribute>
                          <xsl:attribute name="TVID"><xsl:value-of select="@firstPart"/></xsl:attribute>
                          <xsl:attribute name="name">e<xsl:value-of select="position()"/></xsl:attribute>
                          <xsl:attribute name="onkeyleftset">e<xsl:value-of select="position()-1"/></xsl:attribute>
                          <xsl:attribute name="onkeyrightset">e<xsl:value-of select="position()+1"/></xsl:attribute>
                          <xsl:attribute name="onfocus">show(<xsl:value-of select="@firstPart"/>)</xsl:attribute>
                          <xsl:attribute name="onblur">hide()</xsl:attribute>

                          <xsl:call-template name="zcd">
                            <xsl:with-param name="url" select="fileURL"/>
                            <xsl:with-param name="container" select="//movie/container"/>
                          </xsl:call-template>

                          <xsl:attribute name="vod"/>

                          <xsl:if test="//movie/prebuf != -1">
                            <xsl:attribute name="prebuf"><xsl:value-of select="//movie/prebuf" /></xsl:attribute>
                          </xsl:if>

<!--                          <xsl:if test="position() = 1">
                            <xsl:attribute name="name">Play</xsl:attribute>
                          </xsl:if>-->

<!--                          <img src="pictures/play_small.png" onfocussrc="pictures/play_selected_small.png" align="top">
                            <xsl:attribute name="onmouseover">show(<xsl:value-of select="@firstPart"/>);</xsl:attribute>
                            <xsl:attribute name="onmouseout">hide();</xsl:attribute>
                          </img>-->
                        </a>
                        <a class="link">
                          <xsl:if test="position() = 1"> 
                            <xsl:attribute name="class">firstMovie</xsl:attribute> 
                          </xsl:if>

<!--                          <xsl:value-of select="@firstPart"/>
                          <xsl:if test="@firstPart!=@lastPart">-<xsl:value-of select="@lastPart"/></xsl:if>
                          <xsl:text>&#160; </xsl:text>-->
                        </a>
                      </xsl:for-each>
				
          </xsl:when>


		  
		  
		  
		  
		  
		  
		  
          <xsl:otherwise>
<!--              <xsl:variable name="episodeSortOrder">
                <xsl:choose>
                  <xsl:when test="$skin-reverseEpisodeOrder='true' and //movie/season != -1">
                    <xsl:text>descending</xsl:text>
                  </xsl:when>
                  <xsl:otherwise>ascending</xsl:otherwise>
                </xsl:choose>
              </xsl:variable>-->
                  <xsl:if test="($skin-playAllMovie = 'top' and //movie/season = -1) or ($skin-playAllTV = 'top' and //movie/season != -1)">
<!--                        <div id="title">&#160; </div>-->
<!-- play all -->
                        <a class="link" tvid="Play">
							<xsl:attribute name="onkeydownset">pgdn</xsl:attribute>
							<xsl:attribute name="onkeyupset">pgup</xsl:attribute>
							<xsl:attribute name="onkeyrightset">pgdn</xsl:attribute>

							<xsl:choose><xsl:when test="$extras='true'">
							<xsl:attribute name="onkeyleftset">refresh</xsl:attribute>
							</xsl:when><xsl:otherwise>
							<xsl:attribute name="onkeyleftset">pgup</xsl:attribute>
							</xsl:otherwise></xsl:choose>
							
							<xsl:attribute name="name">play</xsl:attribute>
                          <xsl:attribute name="onfocus">hide()</xsl:attribute>
						  
<xsl:choose>
<xsl:when test="//movie/container = 'ISO' or substring(//files/file/fileURL,string-length(//files/file/fileURL)-3,4) = '.ISO' or substring(//files/file/fileURL,string-length(//files/file/fileURL)-3,4) = '.iso'">
							<xsl:attribute name="zcd">2</xsl:attribute>
							<xsl:attribute name="vod"></xsl:attribute>
							<xsl:attribute name="href"><xsl:value-of select="//files/file/fileURL" /></xsl:attribute>
</xsl:when>

<xsl:when test="//movie/container = 'IMG' or substring(//files/file/fileURL,string-length(//files/file/fileURL)-3,4) = '.IMG' or substring(//files/file/fileURL,string-length(//files/file/fileURL)-3,4) = '.img'">
							<xsl:attribute name="zcd">2</xsl:attribute>
							<xsl:attribute name="vod"></xsl:attribute>
							<xsl:attribute name="href"><xsl:value-of select="//files/file/fileURL" /></xsl:attribute>
</xsl:when>
<xsl:otherwise>
                          <xsl:attribute name="href"><xsl:value-of select="concat(/details/movie/baseFilename,'.playlist.jsp')" /></xsl:attribute>
                          <xsl:attribute name="vod">playlist</xsl:attribute>
</xsl:otherwise>
</xsl:choose>

                          <xsl:if test="//movie/prebuf != -1">
                             <xsl:attribute name="prebuf"><xsl:value-of select="//movie/prebuf" /></xsl:attribute>
                          </xsl:if>
                          <img src="pictures/detail/1x688.png" onfocussrc="pictures/detail/1x688.png" align="top"/>
                        </a>
<!-- play all -->
                  </xsl:if>

                      <xsl:for-each select="files/file">
                        <xsl:sort select="@firstPart" data-type="number" order="ascending"/>
<!--                        <xsl:if test="position() = 1">
                          <a id="playLink" tvid="Play" vod="playlist">
                            <xsl:attribute name="href"><xsl:value-of select="fileURL" /></xsl:attribute>
                          </a>
                        </xsl:if>-->
                        <a>
                          <xsl:attribute name="href"><xsl:value-of select="fileURL" /></xsl:attribute>
                          <xsl:attribute name="TVID"><xsl:value-of select="@firstPart"/></xsl:attribute>
                          <xsl:attribute name="name">e<xsl:value-of select="position()"/></xsl:attribute>
                          <xsl:attribute name="onkeyleftset">e<xsl:value-of select="position()-1"/></xsl:attribute>
                          <xsl:attribute name="onkeyrightset">e<xsl:value-of select="position()+1"/></xsl:attribute>
                          <xsl:attribute name="onfocus">show(<xsl:value-of select="@firstPart"/>)</xsl:attribute>
                          <xsl:attribute name="onblur">hide()</xsl:attribute>

                          <xsl:call-template name="zcd">
                            <xsl:with-param name="url" select="fileURL"/>
                            <xsl:with-param name="container" select="//movie/container"/>
                          </xsl:call-template>

                          <xsl:attribute name="vod"/>

                          <xsl:if test="//movie/prebuf != -1">
                            <xsl:attribute name="prebuf"><xsl:value-of select="//movie/prebuf" /></xsl:attribute>
                          </xsl:if>

<!--                          <xsl:if test="position() = 1">
                            <xsl:attribute name="name">Play</xsl:attribute>
                          </xsl:if>-->

<!--                          <img src="pictures/play_small.png" onfocussrc="pictures/play_selected_small.png" align="top">
                            <xsl:attribute name="onmouseover">show(<xsl:value-of select="@firstPart"/>);</xsl:attribute>
                            <xsl:attribute name="onmouseout">hide();</xsl:attribute>
                          </img>-->
                        </a>
                        <a class="link">
                          <xsl:if test="position() = 1"> 
                            <xsl:attribute name="class">firstMovie</xsl:attribute> 
                          </xsl:if>

<!--                          <xsl:value-of select="@firstPart"/>
                          <xsl:if test="@firstPart!=@lastPart">-<xsl:value-of select="@lastPart"/></xsl:if>
                          <xsl:text>&#160; </xsl:text>-->
                        </a>
                      </xsl:for-each>

<!--              <xsl:if test="($skin-playAllMovie = 'bottom' and //movie/season = -1) or ($skin-playAllTV = 'bottom' and //movie/season != -1)">
                        <div id="title">&#160; </div>
                        <a class="link">
                          <xsl:attribute name="onfocus">hide()</xsl:attribute>
                          <xsl:attribute name="href"><xsl:value-of select="concat(/details/movie/baseFilename,'.playlist.jsp')" /></xsl:attribute>
                          <xsl:attribute name="vod">playlist</xsl:attribute>
                          <xsl:if test="//movie/prebuf != -1">
                             <xsl:attribute name="prebuf"><xsl:value-of select="//movie/prebuf" /></xsl:attribute>
                          </xsl:if>
                          <img src="pictures/detail/1x688.png" onfocussrc="pictures/detail/1x688.png" align="top"/>
                        </a>
                  </xsl:if>-->

          </xsl:otherwise>
        </xsl:choose>	
</xsl:template>

</xsl:stylesheet>