<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" omit-xml-declaration="yes"/>

<!--	<xsl:include href="preferences.xsl"/>   -->

	<!-- Needed Templates -->

	<xsl:template name="get-js">
	<script type="text/javascript">
	  <xsl:comment>

    var focusId=false;
    var url = false;
    var playListActive = false;
    var toggleShow = new Array();
    var fMoved = false;

    var sPlotPiece = '';
    var iPlotPage = 1;
    var iPages = 1;
    var iMaxChars = 420;
    var aiPlotStart = new Array();
    var aiPlotEnd = new Array();
    var fInfos = false;
    var fTrailer = false;
    var fPlot = true;
    var fTvShow = false;
    var sLastActiveTab = 'plot';
    var fScrollEpisodePlot = false;
    var sPlot = '';
	var sPlayUrl = '';

    // 2009-05-29: change pages if true
    var fPlay = false;


    // in here all hidden Objects are saved
    var asShowHide = new Object();
    var asClasses = new Object();
    asShowHide['box'] = true;
    asShowHide['videoSource'] = true;
    asShowHide['videoInfo'] = true;

    <xsl:if test="top250 != -1">
    	asShowHide['top250'] = true;
    </xsl:if>


    <xsl:if test="season = -1">
      asShowHide['plot'] = true;
      asShowHide['audioInfo'] = true;
    </xsl:if>

    var fEpisodeList = false;

    <!-- TV SHOW JS -->
    <xsl:if test="season != -1">
      var iEpisodesPerPage = <xsl:value-of select="$iEpisodesPerPage"/>;
      var iEpisodesLength = asEpisodePlot.length - 1;

      <xsl:if test="$tooManySeries = 'true'">
		  var iPagesEpList = Math.floor(iEpisodesLength / iEpisodesPerPage);
		  if ((iEpisodesLength % iEpisodesPerPage) <![CDATA[>]]> 0 )
		  {
		    iPagesEpList = iPagesEpList  +1;
		  }
	    </xsl:if>
	    var fLastLinkFocused = false;
		  var fFirstLinkFocused = true;
		  var fFirstCall = true;

      var episodeId = 1;
	    var episodeName = 1;
	    var showEpisdoeInfos = true;
	    var sIdLinkPrefix = 'a_e_';
	    var sIdSpanPrefix = 's_e_';
	    var sIdTvPrefix = 't_e_';
	    var iCnt = 0;
	    var iMaxChars = 540;

      asShowHide['audioInfoTv'] = true;
      fEpisodeList = true;
	    fTvShow = true;
	    fPlot = false;
	    sLastActiveTab = 'tvshow';

	    <xsl:choose>
		    <xsl:when test="$mjb.includeVideoImages='true'">
					var fUseTvImages = true;
		   	</xsl:when>
		   	<xsl:otherwise>
		   		var fUseTvImages = false;
		   	</xsl:otherwise>
    	</xsl:choose>
	    var showPlotwithBtn = false;
	    <xsl:if test="$showPlotwithBtn = 'true'">
	    	showPlotwithBtn=true;
	    </xsl:if>
	    var iEpisodeId=1;
	    var iFirstEpisodeId = 1;
	  	var iLastEpisodeId = iEpisodesLength;
	    var iLastPageId = 1;

	    var fEpisodeInfo = false;
    </xsl:if>


	</xsl:comment>
	</script>


  <xsl:if test="season != -1">

  <script type="text/javascript">
  <xsl:comment>
		var setFocusId = function(x)
		{
			focusId = sIdLinkPrefix + x;
		},

    setEpisodeUrl = function(x)
		{
			var y = iCnt + x;
			url = buildUrl(y);
			document.getElementById('openEpisode').setAttribute("href",url);
		},

    showEpisode = function(iElId, showInfos)
    {
      var x = iElId;
      var y = Math.floor(iCnt) + Math.floor(x);

      if (fFirstLinkFocused <![CDATA[&&]]> iElId != 1)
        fFirstLinkFocused = false;

      if (fLastLinkFocused <![CDATA[&&]]> iElId != iLastId)
        fLastLinkFocused = false;

      // ReverseOrder
      <xsl:if test="$doReverseEpisodes = 'true'">
		  var y = Math.floor(iEpisodesLength - iCnt - x +1);
      </xsl:if>

    	setFocusId(y);
      setEpisodeUrl(x);
    	iEpisodeId = x;

      if (showPlotwithBtn == true <![CDATA[&&]]> typeof showInfos == 'undefined' )
      	return true;

      if (showEpisdoeInfos )
        showItem('episodenInfos');

      fEpisodeInfo = true;

    	if ( episodeId == 1 )
      {
        episodeId = document.getElementById('episodeId');
      }

      if (asEpisodePlot[y].length <![CDATA[<=]]> 530)
      {
        episodeId.firstChild.nodeValue = asEpisodePlot[y];
        fScrollEpisodePlot = false;
      }

      else
      {
        sPlot = asEpisodePlot[y];
        iMaxChars = 540;
        aiPlotStart = new Array();
        splitPlot();
        iPages = aiPlotStart.length;
        showPlotPiece(1);
        fScrollEpisodePlot = true;
      }
      showItem('episodePages');


      if ( episodeName == 1 )
      {
        episodeName = document.getElementById('episodeName');
      }
      episodeName.firstChild.nodeValue = asEpisodeTitle[y];

      <xsl:if test="season != -1  and $mjb.includeVideoImages='true' ">
      if (typeof asEpisodeImage[y] != 'undefined' <![CDATA[&&]]> asEpisodeImage[y] != 'UNKNOWN' <![CDATA[&&]]> asEpisodeImage[y] != '')
      {
     	  showItem('episodeImgBack');
     	  showItem('episodeImg');
      	document.getElementById('episodeImg').setAttribute("src",asEpisodeImage[y]);
      }
      else
      {
      	hideItem('episodeImgBack');
      	hideItem('episodeImg');
      }
			</xsl:if>
    },

    hideEpisode = function(x)
    {
      if (asShowHide['episodenInfos'] == false)
        return false;

      if ( episodeId == 1 )
        episodeId = document.getElementById('episodeId');
      episodeId.firstChild.nodeValue = "";
      if ( episodeName == 1 )
        episodeName = document.getElementById('episodeName');
      episodeName.firstChild.nodeValue = "";

      if (fEpisodeInfo)
        hideItem('episodenInfos');

      focusId=false;

      <xsl:if test="season != -1  and $mjb.includeVideoImages='true' ">
      if (fEpisodeInfo)
      {
      	hideItem('episodeImgBack');
      	hideItem('episodeImg');
      	hideItem('episodePages');
      }
			</xsl:if>
			fScrollEpisodePlot = false;

			fEpisodeInfo = false;

    },

		/*
		* sets the focus to the given
		*/
		setFocus = function(x)
		{
		  if (x == 'first')
		  	x = iFirstEpisodeId;
		  else if (x == 'last')
		  	x = iLastEpisodeId;

			setFocusId(x);
		  document.getElementById(focusId).focus();
		  showEpisode(x);
		},

		/*
		* toggles Episode details on/off
		* is only needed, if showPlotwithBtn is set to true
		*/
		toggleEpisodeDetails = function()
		{
			if (typeof asShowHide['episodenInfos'] == 'undefined' || asShowHide['episodenInfos'] == false )
				showEpisode(iEpisodeId, true);
			else
				hideEpisode(iEpisodeId);
		},

		/*
		* scroll episode-list "pages" up and down
		* is only needed, if more episodes than iEpisodesPerPage are present
		* @var boolean		if true, episodes n + iEpisodesPerPage are activated
		*/
		scrollLinks = function(down)
	  {

		  var iLoop = iEpisodesPerPage;

  		if (typeof down == 'undefined')
  			iCnt = Math.floor(iCnt - iLoop);
  		else
  			iCnt = Math.floor(iCnt + iLoop);

  		var iPage = iCnt / iEpisodesPerPage +1;

  		// page 1
			if (iCnt == 0)
			{
				fLastLinkFocused = false;
			  fFirstLinkFocused = false;
			}
  		else if (iCnt <![CDATA[<]]> 0) // page -1
			{
			  if (!fFirstLinkFocused)
			  {
  				iCnt = Math.floor(iCnt + iLoop);
  				// set focus to first episode
  				setFocus(1);
  				fFirstLinkFocused = true;
  				return false;
  			}
  			else
  			{
  			  iCnt = iEpisodesLength - (iEpisodesLength - iLoop);
  			  iPage = iCnt / iEpisodesPerPage +1;
  			  fFirstLinkFocused = true;
  			  fLastLinkFocused = false;
  			}
			}
			else if (iCnt +1 <![CDATA[>]]> iEpisodesLength) //last page +1
			{
			  if (!fLastLinkFocused)
			  {
  				iCnt = Math.floor(iCnt - iLoop);
  				// set focus to last episode
  				setFocus(iEpisodesLength - iCnt);
  				fLastLinkFocused = true;
  				return false;
  			}
  			else
  			{
  			  iCnt = 0;
  			  iPage = 1;
  			  fLastLinkFocused = false;
  			  fFirstLinkFocused = true;
  			}
			}
			else if (Math.floor(iCnt + iLoop) <![CDATA[>=]]> iEpisodesLength) // last page
			{
				fLastLinkFocused = false;
			  fFirstLinkFocused = false;
			}
			else //all pages between 1 and last
			{
			  fLastLinkFocused = false;
			  fFirstLinkFocused = false;
			}
			//console.log(iCnt);

			document.getElementById('pageCount').firstChild.nodeValue = ' ' + iPage + ' / ' + iPagesEpList + ' (' + iEpisodesLength + ')';

			var iLastId = 0;

		  for (var i = 1; i <![CDATA[<=]]> iLoop; i++)
	  	{
	  	  var iElId = i;
	  	  var sLinkId = sIdLinkPrefix + iElId;
	  	  var sSpanId = sIdSpanPrefix + iElId;
	  	  var sTvId = sIdTvPrefix + iElId;


	  	  var elLink = document.getElementById(sLinkId);
	  		var elSpan = document.getElementById(sSpanId);
	  		var elTvID = document.getElementById(sTvId);
	  		<xsl:if test="$doReverseEpisodes = 'true'">
  		  var no = Math.floor(iEpisodesLength - iCnt - i +1);
  		  if (no <![CDATA[<]]> 1)
  			{
					iLastId = i;
  				elLink.setAttribute("class",'hidden');
					elSpan.setAttribute("class", 'hidden');
		  		elTvID.setAttribute("class",'hidden');
		  		asShowHide[sLinkId] = false;
		  		asShowHide[sSpanId] = false;
		  		asShowHide[sTvId] = false;
  			}
        </xsl:if>
        <xsl:if test="$doReverseEpisodes != 'true'">
  		  var no = Math.floor(iCnt + i);

  			if (no <![CDATA[>]]> iEpisodesLength)
  			{
					iLastId = i;
  				elLink.setAttribute("class",'hidden');
					elSpan.setAttribute("class", 'hidden');
		  		elTvID.setAttribute("class",'hidden');
		  		asShowHide[sLinkId] = false;
		  		asShowHide[sSpanId] = false;
		  		asShowHide[sTvId] = false;
		  		iLastPageId = 0;
  			}
  			</xsl:if>
  			else
  			{
  			  if (i > iLastPageId)
  			  {
  			   iLastPageId = i;
  			  }
		  		elLink.setAttribute("href",buildUrl(no));
		  		var iEpisodeNo = asEpisodeNo[no];
		  		if (iEpisodeNo &lt; 10)
		  		  iEpisodeNo = '0' + iEpisodeNo;
	  			var sSpanValue =iEpisodeNo + '. ' + asEpisodeTitleShort[no];

		  		<xsl:if test="$show_episode_names!='true'">
		  		  var sSeason = <xsl:value-of select="/details/movie/season" />;
  		  		if (sSeason &lt; 10)
  		  		  sSeason = '0' + sSeason;
		  			var sSpanValue =  's' + sSeason + 'e'+ iEpisodeNo;
		  		</xsl:if>

		  		elSpan.firstChild.nodeValue=sSpanValue;
		  		elTvID.setAttribute("TVID",asEpisodeNo[no]);

		  		if (asShowHide[sLinkId] == false)
		  		{
		  			elLink.setAttribute("class",'TvLink');
						elSpan.setAttribute("class", 'tabTvShow');
			  		elTvID.setAttribute("class",'tabTvShow');
			  		asShowHide[sLinkId] = true;
  		  		asShowHide[sSpanId] = true;
  		  		asShowHide[sTvId] = true;
		  		}
		  	}
	  	}

	  	if (typeof down == 'undefined' <![CDATA[&&]]> iLastPageId <![CDATA[>]]> 0)
	  	{
	  	  // litte timeout is needed - caused by dramaqueen gaya
	  	  window.setTimeout("setFocus(iLastPageId)", 1);
	  	}
	  	else
	  	  setFocus(1);
	  },



	  /*
		* show or hides the node with the given id
		*/
	  showhideEpisode = function(id, hide)
	  {

      if (typeof asShowHide[id] == 'undefined' || asShowHide[id] == true || hide == true )
        var fHide = true;
      else
        var fHide = false;

      if (fHide == false)
      {
        showItem(id)
      }
      else
      {
        fScrollEpisodePlot = false;
        hideItem(id)
      }
    },
    buildUrl = function(no)
    {
      return '<xsl:value-of select="$filePath" />' + asEpisodeUrl[no];
    };
    </xsl:comment>
	  </script>
    </xsl:if>
    <!--  END TV SHOW JS -->
    <!--  END TV SHOW JS -->
    <!--  END TV SHOW JS -->
    <script type="text/javascript">
    <xsl:comment>
    var fAllhiden = false;

    var showItem = function(id)
    {
      // if item is visible, there is nothing to do
      if (asShowHide[id] == true)
        return;

      if ( typeof asShowHide[id] == 'undefined' )
       asClasses[id] = document.getElementById(id).getAttribute('class');

      if ( typeof asClasses[id] != 'undefined' <![CDATA[&&]]> typeof asShowHide[id] != 'undefined' <![CDATA[&&]]> asClasses[id] != 'hidden' )
        var sClass = asClasses[id];
      else
        var sClass = 'visible';

      asShowHide[id] = true;
      document.getElementById(id).setAttribute('class',sClass);
    },

    hideItem = function(id)
    {

      // if item is hidden, there is nothing to do
      if (asShowHide[id] == false)
        return;

      var sClass = 'hidden';
      if ( typeof asClasses[id] == 'undefined' )
        asClasses[id] = document.getElementById(id).getAttribute('class');

      asShowHide[id] = false;
      document.getElementById(id).setAttribute('class',sClass);
    },

    hideAll = function()
    {
      for (var id in asShowHide)
      {
        if (fAllhiden == false)
        {
          if (asShowHide[id] == true)
            hideItem(id);
          else
            asShowHide[id] = true;
        }
        else
        {
          if (asShowHide[id] == false)
            showItem(id);
          else
            asShowHide[id] = false;
        }

      }

      if (fAllhiden == false)
      {

        if (sLastActiveTab == 'plot')
          hidePlot();
        else if (sLastActiveTab == 'infos')
          hideInfos();
        else if (sLastActiveTab == 'tvshow')
          hideTvShow();
        else
          hideTrailer();

        <xsl:if test="season != -1">
        if (!fTvShow)
          document.styleSheets[1].cssRules[5].style.visibility="hidden";
    	  </xsl:if>

    	  fAllhiden = true;

      }

      else
      {


        if (sLastActiveTab == 'plot')
          showPlot();
        else if (sLastActiveTab == 'infos')
          showInfos();
        else if (sLastActiveTab == 'tvshow')
          showTvShow();
        else
          showTrailer();

        <xsl:if test="season != -1">
        if (!fTvShow)
          document.styleSheets[1].cssRules[5].style.visibility="visible";
    	  </xsl:if>

        fAllhiden = false;
      }
    },

    showPlot = function ()
    {
      document.styleSheets[1].cssRules[0].style.visibility="visible";

      hideInfos();
      hideTrailer();
      <xsl:if test="season != -1">
      document.getElementById('tabPlot').focus();
      hideTvShow();
  	  </xsl:if>
      hideShowDiverses();
      document.getElementById('tabPlotImg').setAttribute('src', 'pictures/tab_plot_f3.png');
      document.getElementById('tabInfosImg').setAttribute('src', 'pictures/tab_infos.png');
      <xsl:if test="count(extras) != 0 and /details/movie/season = -1">
      document.getElementById('tabTrailerImg').setAttribute('src', 'pictures/tab_trailer.png');
      </xsl:if>

      fPlot = true;
      <xsl:if test="season != -1">
      iMaxChars = 420;
      sPlot = sPlotLong.replace(/\s\s+/g, ' ');
      aiPlotStart = new Array();
      splitPlot();
      document.getElementById('tabTvShowImg').setAttribute('src', 'pictures/tab_tvshow.png');
      iPages = aiPlotStart.length;
      showPlotPiece(1);
  	  </xsl:if>


      sLastActiveTab = 'plot';
      fScrollEpisodePlot = false;
    },

    hidePlot = function ()
    {
      document.styleSheets[1].cssRules[0].style.visibility="hidden";
      fPlot = false;
    },
    hideInfos = function ()
    {
      document.styleSheets[1].cssRules[1].style.visibility="hidden";
      fInfos = false;
    },
    hideTrailer = function ()
    {
      document.styleSheets[1].cssRules[2].style.visibility="hidden";
      fTrailer = false;
    },
    hideTvShow = function ()
    {
      document.styleSheets[1].cssRules[4].style.visibility="hidden";
      hideEpisode();
      fTvShow = false;
    },

    hideShowDiverses = function (show)
    {
      // show them
      if (typeof show == 'undefined')
      {
        if (fEpisodeList)
        {
          document.styleSheets[1].cssRules[5].style.visibility="visible";
          fEpisodeList = false;
        }
        else
         return true;
      }
      else //hide them
      {
        if (!fEpisodeList)
        {
          document.styleSheets[1].cssRules[5].style.visibility="hidden";
          fEpisodeList = true;
        }
        else
         return true;
      }

    },

    showInfos = function ()
    {
      hidePlot();
      hideTrailer();
      <xsl:if test="season != -1">
      hideTvShow();
  	  </xsl:if>
      hideShowDiverses();

      document.styleSheets[1].cssRules[1].style.visibility="visible";

      document.getElementById('tabInfosImg').setAttribute('src', 'pictures/tab_infos_f3.png');
      document.getElementById('tabPlotImg').setAttribute('src', 'pictures/tab_plot.png');
      <xsl:if test="count(extras) != 0 and /details/movie/season = -1">
      document.getElementById('tabTrailerImg').setAttribute('src', 'pictures/tab_trailer.png');
      </xsl:if>

      <xsl:if test="season != -1">
      document.getElementById('tabTvShowImg').setAttribute('src', 'pictures/tab_tvshow.png');
  	  </xsl:if>
  	  fScrollEpisodePlot = false;


      fInfos = true;
      sLastActiveTab = 'infos';
    },

    showTrailer = function ()
    {
      hidePlot();
      hideInfos();
      <xsl:if test="season != -1">
      hideTvShow();
  	  </xsl:if>

      hideShowDiverses();
      document.styleSheets[1].cssRules[2].style.visibility="visible";

      document.getElementById('tabTrailerImg').setAttribute('src', 'pictures/tab_trailer_f3.png');
      document.getElementById('tabPlotImg').setAttribute('src', 'pictures/tab_plot.png');
      document.getElementById('tabInfosImg').setAttribute('src', 'pictures/tab_infos.png');
      fTrailer = true;
      sLastActiveTab = 'trailer';
      document.getElementById('tabTrailer').focus();

    },

    showTvShow = function ()
    {
      hidePlot();
      hideInfos();
      hideShowDiverses(true);
      document.styleSheets[1].cssRules[4].style.visibility="visible";
      if (!fFirstCall)
        window.setTimeout("setFocus(1)", 1);

      document.getElementById('tabTvShowImg').setAttribute('src', 'pictures/tab_tvshow_f3.png');
      document.getElementById('tabPlotImg').setAttribute('src', 'pictures/tab_plot.png');
      document.getElementById('tabInfosImg').setAttribute('src', 'pictures/tab_infos.png');
      fTvShow = true;
      sLastActiveTab = 'tvshow';
    },

    plotDown = function()
    {
      if (iPages <![CDATA[<]]> 2)
        return false;
      else if (iPlotPage +1 <![CDATA[>]]> iPages)
      {
        iPlotPage = 0;
        plotDown();
      }
      else
      {
        iPlotPage = iPlotPage +1;
        showPlotPiece(iPlotPage);
      }
    },

    plotUp = function()
    {
      if (iPages <![CDATA[<]]> 2)
        return false;
      else if (iPlotPage - 1 <![CDATA[<]]> 1)
      {
        iPlotPage = iPages +1;
        plotUp();
      }
      else
      {
        iPlotPage = iPlotPage -1;
        showPlotPiece(iPlotPage);
      }
    },

    splitPlot = function(iCnt)
    {
      if (sPlot.length <![CDATA[<=]]> iMaxChars)
      {
        iPages = 1;
        return true;
      }

      if (typeof aiPlotStart[0] == 'undefined')
      {
        aiPlotStart[0] = 0;
      }

      if (typeof iCnt == 'undefined')
      {
        var iCnt = 0;
      }

      var iStart = iMaxChars;
      if (typeof aiPlotStart[iCnt] != 'undefined')
      {
        iStart = aiPlotStart[iCnt] + iMaxChars;
      }

      for (var t=0; t<![CDATA[<]]>100; t++)
      {
        var iEnd = iStart + 1;

        if (iEnd <![CDATA[<]]> sPlot.length)
        {
          if (sPlot.substring(iStart, iEnd) == " ")
          {
            // treffer - leerzeichen gefunden
            aiPlotEnd[iCnt] = iStart;

            if (iEnd + iMaxChars <![CDATA[>=]]> sPlot.length)
            {
              aiPlotStart[iCnt +1] = iEnd;
              aiPlotEnd[iCnt +1] = sPlot.length;
            }
            else
            {
              aiPlotStart[iCnt +1] = iEnd;
            }

            break;
          }
          else
          {
            iStart = iStart +1;

          }
        }
        else
        {
          aiPlotEnd[iCnt] = sPlot.length;

          break;
        }
      }

      if (iEnd <![CDATA[<]]> sPlot.length)
      {
        splitPlot(iCnt +1);
      }
    },

    init = function()
    {


      <xsl:if test="season = -1">
        sPlot = sPlotLong.replace(/\s\s+/g, ' ');
        splitPlot();
        iPages = aiPlotStart.length;
        showPlot();
        showPlotPiece(1);
    	</xsl:if>
    	<xsl:if test="season != -1">
    	showTvShow();
    	hideItem('episodePages');
    	fFirstCall = false;
    	</xsl:if>

    	<xsl:if test="season != -1 and $tooManySeries='true'">
    	document.getElementById('pageCount').firstChild.nodeValue = '1' + ' / ' + iPagesEpList + ' (' + iEpisodesLength + ')';
    	</xsl:if>

    	<xsl:if test="$showPosterAtStart = 'true' and $useAnimation='false'">
    	togglePoster();
    	</xsl:if>

    },
    pageDown = function()
		{
		  //alert(fPlay);
		  if (fScrollEpisodePlot || fTvShow)
		    clickDown();
			else
        nextPage();
		},
		pageUp = function()
		{
		  if (fScrollEpisodePlot || fTvShow)
		    clickUp();
			else
        previousPage();
		},
		nextPage = function()
		{
		  //document.getElementById('nextMovie').focus();
		  var jumpurl = document.getElementById('nextMovie').href;
		  location.assign(jumpurl);
		},
		previousPage = function()
		{
      var jumpurl = document.getElementById('previousMovie').href;
		  location.assign(jumpurl);
		},
    clickDown = function()
    {
      if (fPlot || fScrollEpisodePlot)
        plotDown();
			else if(fTvShow)
			{
			  <xsl:choose>
	        <xsl:when test="$tooManySeries='true'">
            scrollLinks(true);
				 	</xsl:when>
				 	<xsl:otherwise>
				 		setFocus('last');
				 	</xsl:otherwise>
				</xsl:choose>
			}
			else
			  return false;

		},
		clickUp = function()
    {
      if (fPlot || fScrollEpisodePlot)
        plotUp();
			else if(fTvShow)
			{
			  <xsl:choose>
	        <xsl:when test="$tooManySeries='true'">
            scrollLinks();
				 	</xsl:when>
				 	<xsl:otherwise>
				 		setFocus('first');
				 	</xsl:otherwise>
				</xsl:choose>
			}
			else
			  return false;
		},
    showPlotPiece = function(iPage)
    {
      var iCnt = iPage - 1;
      if (typeof aiPlotStart[iCnt] != 'undefined')
      {
        var sPlotpiece = sPlot.substring(aiPlotStart[iCnt], aiPlotEnd[iCnt]);
        if (iPage <![CDATA[<]]> iPages)
          sPlotpiece = sPlotpiece + ' ...';

        if (fPlot)
        {
        	document.getElementById('plot').firstChild.nodeValue = sPlotpiece;
          document.getElementById('plotInfo').firstChild.nodeValue = iPage +' / '+ iPages;
        }
        else if (fTvShow)
        {
          document.getElementById('episodeId').firstChild.nodeValue = sPlotpiece;
          document.getElementById('episodePages').firstChild.nodeValue = iPage +' / '+ iPages;
        }
      }
      else
        return false;
    };



		</xsl:comment>
		</script>

		<script type="text/javascript">
		<xsl:comment>
		// animation vars
    var fFirstRun = true;
    var iImgX = <xsl:value-of select="$posters.width" />;
    var iPosXStart = 500;
    var iPosX = 0;
    var iZoomX = 0;
    var iStep = 50;
    var elImage = false;
    var elImageDiv = false;
    var fZoomIn = false;
    var fZoomOut = false;

    var fUseAnimation = <xsl:value-of select="$useAnimation" />;

		var zoomIn = function()
    {

      zoomInit();

      if (!fZoomIn)
      {
        elImageDiv.setAttribute('class', 'abs poster');
        fZoomIn = true;
        fZoomOut = false;
      }

      if (iZoomX <![CDATA[>]]>= iImgX)
        return false;

      if (iZoomX + iStep <![CDATA[<]]> iImgX)
        iZoomX = iZoomX + iStep;
      else
        iZoomX = iImgX;

      setImagePos();

      if (iZoomX + iStep <![CDATA[<]]> iImgX)
			{
      	window.setTimeout("zoomIn()", 0);
			}
			else
			{
			  iZoomX = iImgX;
        setImagePos();
			}
    },
    zoomOut = function()
    {
      zoomInit();

      if (!fZoomOut)
      {

        fZoomIn = false;
        fZoomOut = true;
      }

      if (iZoomX == 0)
        return false;

      if (iZoomX - iStep <![CDATA[>]]> 0)
        iZoomX = iZoomX - iStep;
      else
        iZoomX = 0;

      setImagePos();

      if (iZoomX - iStep <![CDATA[>]]> 0)
			{
      	window.setTimeout("zoomOut()", 0);
			}
			else
			{
			  iZoomX = 0;
        setImagePos(0);
        elImageDiv.setAttribute('class', 'abs poster hidden');
        window.setTimeout("hideAll()", 0);
			}
    },
    setImagePos = function()
    {
      elImage.setAttribute("width",iZoomX);
      elImage.setAttribute("height",0);

      if (iZoomX <![CDATA[>]]> 0)
      {
        if (fZoomIn)
        {
          iPosX = Math.round(iPosX - iStep/2);
        }
        else
        {
          iPosX = Math.round(iPosX + iStep/2);
        }
      }
      else
      {
        iPosX = iPosXStart;
      }

      document.styleSheets[1].cssRules[6].style.left = iPosX + 'px';
    },
    togglePoster = function()
    {

      if (fUseAnimation)
      {
        if (fFirstRun || fZoomOut)
        {
          hideAll();
          zoomIn();
        }
        else
        {
          zoomOut();
          //window.setTimeout("hideAll()", 1000);

        }

      }
      else
      {
        if (fFirstRun || fZoomOut)
          showPoster();
        else
          hidePoster();
      }


    },
    showPoster = function()
    {
      elImageDiv = document.getElementById('imageDiv');
      elImageDiv.setAttribute('class', 'abs poster');
      fFirstRun = false;
      fZoomOut = false;
    },
    hidePoster = function()
    {
      elImageDiv = document.getElementById('imageDiv');
      elImageDiv.setAttribute('class', 'abs poster hidden');
      fZoomOut = true;
    },

    zoomInit = function()
    {
      if (fFirstRun)
      {
				elImage = document.getElementById('image');
				elImageDiv = document.getElementById('imageDiv');
				iPosX = iPosXStart;
				fFirstRun = false;
      }
    };
    </xsl:comment>
		</script>
	</xsl:template>
	
	
		 <!-- GT MOD TV SHOWS JS-->
		 <!-- GT MOD TV SHOWS JS-->
		 <!-- GT MOD TV SHOWS JS-->
	<xsl:template name="get-gttv-js">
	<script type="text/javascript">
		<xsl:comment>
		// series config vars

var iPageNew = 1;
var iEpPagesNew = 1;
var iEpisodeIdNew = 1;
var iEpisodesPerPageNew = 15;
var iLoopNew = iEpisodesPerPageNew;
var sIdLinkPrefixNew = 'a_e_';
var sIdSpanPrefixNew = 's_e_';
var sIdTvPrefixNew = 't_e_';
var fFirstCall = false;
var focusIdNew = ' ';
var helpx = 0;
var helpy = 0;
var fShowSeasonInfo = false;
var fmorePages = false;
var iEpisodesLength = asEpisodePlot.length - 1;
var url = false;
var Eid = 'play';
var Evod = 'vod';
var x = 0;
var rRand = 1;

//##########################################################
//## Functions Series ######################################
//##########################################################

var setVOD = function (Eid,Evod)
{

document.getElementById(Eid).removeAttribute('vod');
document.getElementById(Eid).removeAttribute('zcd');

if (Evod == 'playlist') 
	{
	var newAttribute = document.createAttribute("vod");
	newAttribute.nodeValue = "playlist";
	document.getElementById(Eid).setAttributeNode(newAttribute);

	}
	else if (Evod == 'zcd')
	{
	var newAttribute = document.createAttribute("zcd");
	newAttribute.nodeValue = "2";
	document.getElementById(Eid).setAttributeNode(newAttribute);
		
	}
	else if (Evod == 'vod')
	{
	var newAttribute = document.createAttribute("vod");
	newAttribute.nodeValue = "";
	document.getElementById(Eid).setAttributeNode(newAttribute);
	}
},

showEpisode = function(x)
{
	helpy = x;
	url = buildUrl(x)
	if (asEpisodeTitle[helpy].length <![CDATA[>]]> 35)
   {
   document.getElementById('episodeName').setAttribute("class","tveptitle24");
      if (asEpisodeTitle[helpy].length <![CDATA[>]]> 38)
      {
      document.getElementById('episodeName').setAttribute("class","tveptitle22");
         if (asEpisodeTitle[helpy].length <![CDATA[>]]> 43)
         {
         document.getElementById('episodeName').setAttribute("class","tveptitle20");
            if (asEpisodeTitle[helpy].length <![CDATA[>]]> 46)
            {
            document.getElementById('episodeName').setAttribute("class","tveptitle18");
				if (asEpisodeTitle[helpy].length <![CDATA[>]]> 53)
				{
				document.getElementById('episodeName').setAttribute("class","tveptitle16");
				asEpisodeTitle[helpy]=asEpisodeTitle[helpy].substring(0,56)+'...'
				}
			}
         }
      }
   }
   else
   {
   document.getElementById('episodeName').setAttribute("class","tveptitle");
   }
	document.getElementById('episodeName').firstChild.nodeValue = asEpisodeTitle[helpy];
	document.getElementById('episodeId').firstChild.nodeValue = asEpisodePlot[helpy];
	document.getElementById('episodeImg').setAttribute("src",asEpisodeImage[helpy]);
	document.getElementById('openEpisode').setAttribute("href",url);

	<xsl:if test="$tv-random-episode='true'">
	var time = new Date();
    var second = time.getSeconds();
 	
	rRand = rRand + second;
	rRand = 1 + rRand - iEpisodesLength*(Math.floor(rRand/iEpisodesLength));
	var rEp = rRand;
	setVOD ('randomplay', asEpisodeVod[rEp]);
	var rUrl= asEpisodeUrl[rEp];
	document.getElementById('randomplay').setAttribute("href",rUrl);
	</xsl:if>
},

buildUrl = function(no)
{
      return asEpisodeUrl[no];
};
	
initNew = function ()
{
	showEpisode(1);
<xsl:if test="($roundedcorners='redefined') or ($tv-banners-set='redefined') or ($tv-banners='redefined')">
getParams();</xsl:if>
	document.getElementById('episodeImg').setAttribute("class","");
	document.getElementById('episodeImgBack').setAttribute("class","");
	document.getElementById('episodenInfos').setAttribute("class","");
	iEpisodeIdNew = 1;
	iPageNew = 1;
	iEpPagesNew = Math.floor(1) + Math.floor((iEpisodesLength-1)/iEpisodesPerPageNew);
	if (iEpPagesNew <![CDATA[>]]> 1) 
	{
	fmorePages = true;
	document.getElementById('pageCountNew').firstChild.nodeValue = '1' + ' / ' + iEpPagesNew + ' (' + iEpisodesLength + ')';
	}
},

clickDownNew = function ()
{
	if ((iEpisodeIdNew / (iPageNew * iEpisodesPerPageNew)) == 1 ) 
	{
		if (fmorePages == true)
		{
			iPageNew = iPageNew + 1;
			iEpisodeIdNew = iEpisodeIdNew + 1;
			toggletab();
			window.setTimeout("showNfocus()", 1);
		}
		else
		{
			iEpisodeIdNew = 1;
			showNfocus();
		}
	}
	else
	{
		iEpisodeIdNew = iEpisodeIdNew + 1;
		if (iEpisodeIdNew <![CDATA[>]]> iEpisodesLength) 
		{
			iEpisodeIdNew = 1;
			if (fmorePages == true)
			{
				iPageNew = 1;
				toggletab();
				window.setTimeout("showNfocus()", 1);
			}
			else
			showNfocus();
		}
		else
		showNfocus();
	}
},

clickUpNew = function ()
{
	if ((iEpisodeIdNew - ((iPageNew-1) * iEpisodesPerPageNew)) == 1 ) 
	{
	document.getElementById('gtPlay').focus();
	}
	else
	{
	iEpisodeIdNew = iEpisodeIdNew - 1;
	showNfocus();
	}
},

toggleLeft = function ()
{
	if (fmorePages == true)
	{
	if (iPageNew == 1) 
	{
	iPageNew = iEpPagesNew;
	iEpisodeIdNew = iEpisodeIdNew + ((iEpPagesNew-1) * iEpisodesPerPageNew);
	if (iEpisodeIdNew <![CDATA[>]]>  iEpisodesLength) 
		{
		iEpisodeIdNew = iEpisodesLength;
		}
	}
	else
	{
	iPageNew = iPageNew - 1;
	iEpisodeIdNew = iEpisodeIdNew - iEpisodesPerPageNew;
	}
	toggletab();
	window.setTimeout("showNfocus()", 1);
	}
	else
	showNfocus();
},

toggleRight = function ()
{
	if (fmorePages == true)
	{
	if (iPageNew == iEpPagesNew) 
	{
	iPageNew = 1;
	iEpisodeIdNew = iEpisodeIdNew - ((iEpPagesNew-1) * iEpisodesPerPageNew);
	}
	else
	{
	iPageNew = iPageNew + 1;
	iEpisodeIdNew = iEpisodeIdNew + iEpisodesPerPageNew;
	if (iEpisodeIdNew <![CDATA[>]]>  iEpisodesLength) iEpisodeIdNew = iEpisodesLength;
	}
	toggletab();
	window.setTimeout("showNfocus()", 1);
	}
	else
	showNfocus();
},

toggletab = function ()
{
	for (var i = 1; i <![CDATA[<=]]> iLoopNew; i++)
	{
	var iElIdNew = i;
	var sLinkIdNew = sIdLinkPrefixNew + iElIdNew;
	var sSpanIdNew = sIdSpanPrefixNew + iElIdNew;
	var sTvIdNew = sIdTvPrefixNew + iElIdNew;
	
	var elLinkNew = document.getElementById(sLinkIdNew);
	var elSpanNew = document.getElementById(sSpanIdNew);
	var elTvIDNew = document.getElementById(sTvIdNew);
	var noNew = Math.floor(((iPageNew-1) * iLoopNew) + i);
	if (noNew <![CDATA[<]]> (iEpisodesLength+1))
		{
			if (fTVplaylist == true) {elLinkNew.setAttribute("href",asEpisodePlaylist[noNew]);}
			else {
				var sUrlNew = asEpisodeUrl[noNew];
				elLinkNew.setAttribute("href",sUrlNew);
				setVOD (sLinkIdNew, asEpisodeVod[i]);
				}
			var sMouseOverValueNew = 'return showEpisode(' + noNew + ')';
			elLinkNew.setAttribute("onmouseover",sMouseOverValueNew);
	
			var iEpisodeNoNew = asEpisodeNo[noNew];
			if (iEpisodeNoNew <![CDATA[<]]>  10) 
			{
				iEpisodeNoNew = '0' + iEpisodeNoNew;
			}
			var sSpanValueNew =iEpisodeNoNew + '. ' + asEpisodeTitleShort[noNew];

			elSpanNew.firstChild.nodeValue=sSpanValueNew;
			elTvIDNew.setAttribute("TVID",asEpisodeNo[noNew]);
		}
		else
		{
			elLinkNew.setAttribute("href"," ");
			elLinkNew.setAttribute("onmouseover"," ");
			elSpanNew.firstChild.nodeValue=" ";
			elTvIDNew.setAttribute("TVID"," ");
		}
	
	}			
	document.getElementById('pageCountNew').firstChild.nodeValue =' ' + iPageNew + ' / ' + iEpPagesNew + ' (' + iEpisodesLength + ')';
},

showNfocus = function ()
{
	helpy = iEpisodeIdNew - ((iPageNew-1) * iEpisodesPerPageNew);
	focusIdNew = sIdLinkPrefixNew + helpy;
	document.getElementById(focusIdNew).focus();
	showEpisode (iEpisodeIdNew);
},

setFocusNew = function(x)
{
	helpx = x;
	iEpisodeIdNew = helpx + ((iPageNew-1) * iEpisodesPerPageNew);
	fShowSeasonInfo = false;
	showNfocus ();
},

showSeasonInfo = function ()
{
	if (fShowSeasonInfo == true)
	{
	showNfocus();
	fShowSeasonInfo = false;
	}
	else
	{
	document.getElementById('episodeName').firstChild.nodeValue = sTitleLong;
	document.getElementById('episodeId').firstChild.nodeValue = sPlotLong;
	fShowSeasonInfo = true;
	}
},

setParams = function(destination) 
// pass the sort option and the now value to the help screen
{
var test5=decodeURIComponent(destination);
location.assign(test5);
}

getParams = function()
{    
   var params = location.search.substring(1);
   
   var temp = params.split(',');
   if (temp[0] == 1) 
	{
	var goback= temp[2];
	document.getElementById('backbutton').setAttribute("href","javascript:setParams('"+escape(goback)+".html?1,"+temp[1].toString()+","+temp[3].toString()+","+temp[4]+"')");
	}
   else {document.getElementById('backbutton').setAttribute("href","javascript:history.back();");}
};
				</xsl:comment>
		</script>
	</xsl:template>
	

	
	<xsl:template name="get-gtlowlist-js">
	<script type="text/javascript">
		<xsl:comment>
		// series config vars
		var iPage = 1;
		var iPageMax = asPlotPart.length - 1;
		var iWatch = 0;
		var iWatchMax = asWatchbar.length - 1;
		var helpx = ' ';
		var helpy = new Array('0');
		var asFile = new Array('0');
		var imgId= ' ';
		var imgChangeOn = ' ';
		var imgChangeOff = ' ';
		var imgPrefix = 'pictures/gtmod/';
		var x = 0;
		var fLowlist =true;

clickLeft = function ()
{
if (iWatchMax != 0)
{
imgId = 'img' + asWatchbar[iWatch];
imgChangeOff = imgPrefix + imgId + 'off.png';
document.getElementById(imgId).setAttribute("src",imgChangeOff);
if (iWatch == 0) {iWatch = iWatchMax;}
else {iWatch = iWatch - 1;}
imgId = 'img' + asWatchbar[iWatch];
imgChangeOn = imgPrefix + imgId + 'on.png';
document.getElementById(imgId).setAttribute("src",imgChangeOn);
iPage = 1;
showPage();
}
},

clickRight = function ()
{
if (iWatchMax != 0)
{
imgId = 'img' + asWatchbar[iWatch];
imgChangeOff = imgPrefix + imgId + 'off.png';
document.getElementById(imgId).setAttribute("src",imgChangeOff);
if (iWatch == iWatchMax) {iWatch = 0;}
else {iWatch = iWatch + 1;}
imgId = 'img' + asWatchbar[iWatch];
imgChangeOn = imgPrefix + imgId + 'on.png';
document.getElementById(imgId).setAttribute("src",imgChangeOn);
iPage = 1;
showPage();
}
},

showPage = function()
{
helpx = asWatchbar [iWatch];
if (helpx == 'Plot')
	{
	iPageMax = asPlotPart.length - 1;
	helpy[0] = asPlotPart[iPage];
	asFile = sFileURL.split(",");
	helpy[1] = asFile[0];
	helpy[2] = asFile[1];
	}
else if (helpx == 'Bonus')
	{
	iPageMax = asBonus.length - 1;
	helpy = asBonus[iPage].split(",");

	}
else if (helpx == 'Extra')
	{
	iPageMax = asExtra.length - 1;
	helpy = asExtra[iPage].split(",");

	}
else if (helpx == 'Trailer')
	{
	iPageMax = asTrailer.length - 1;
	helpy = asTrailer[iPage].split(",");

	}
else if (helpx == 'Multi')
	{
	iPageMax = asMultiPart.length - 1;
	helpy = asMultiPart[iPage].split(",");

	}


document.getElementById('play').removeAttribute('vod');
document.getElementById('play').removeAttribute('zcd');

if (helpy[2] == 'playlist') 
	{
	var newAttribute = document.createAttribute("vod");
	newAttribute.nodeValue = "playlist";
	document.getElementById('play').setAttributeNode(newAttribute);

	}
	else if (helpy[2] == 'zcd')
	{
	var newAttribute = document.createAttribute("zcd");
	newAttribute.nodeValue = "2";
	document.getElementById('play').setAttributeNode(newAttribute);
		
	}
	else if (helpy[2] == 'vod')
	{
	var newAttribute = document.createAttribute("vod");
	newAttribute.nodeValue = "";
	document.getElementById('play').setAttributeNode(newAttribute);
	}
	
document.getElementById('gtPlot').firstChild.nodeValue = helpy[0];
document.getElementById('pages').firstChild.nodeValue = ' '+ iPage + ' / ' + iPageMax + ' ';
document.getElementById('play').setAttribute("href",helpy[1]);
},

pageDown = function()
{
if (iPageMax != 1)
{
if (iPage == iPageMax) {iPage = 1;}
else {iPage = iPage + 1;}
showPage();
}
},

pageUp = function()
{
if (iPageMax != 1)
{
if (iPage == 1)
{
iPage = iPageMax;
}
else 
{
iPage = iPage - 1;
}
showPage();
}
},
toggleWatchbar = function()
{
	if (fWatch == false) 
	{
	document.getElementById('watchbar').setAttribute("class","");
	fWatch = true;
	}
	else 
	{
	document.getElementById('watchbar').setAttribute("class","hidden");
	fWatch = false;
	}
},

toggleLowlist = function()
{
	if (fLowlist == false) 
	{
	document.getElementById('lowlist').setAttribute("class","");
	document.styleSheets[1].cssRules[3].style.visibility='visible';
	document.styleSheets[1].cssRules[5].style.visibility='visible';
	document.styleSheets[1].cssRules[7].style.visibility='visible';
	fLowlist = true;
	}
	else 
	{
	document.getElementById('lowlist').setAttribute("class","hidden");
	document.styleSheets[1].cssRules[3].style.visibility='hidden';
	document.styleSheets[1].cssRules[5].style.visibility='hidden';
	document.styleSheets[1].cssRules[7].style.visibility='hidden';
	fLowlist = false;
	}
},

setParams = function(destination) 
// pass the sort option and the now value to the help screen
{
var test5=decodeURIComponent(destination);
location.assign(test5);
}

getParams = function()
{    
   var params = location.search.substring(1);
   
   var temp = params.split(',');
   if (temp[0] == 1) 
	{
	var goback= temp[2];
	var destination = escape(goback)+".html?1,"+temp[1].toString()+","+temp[3].toString()+","+temp[4];
	var test5 = decodeURIComponent(destination);
	location.assign(test5);
	}
   else {
	//document.getElementById('backbutton').setAttribute("href","javascript:history.back();");
	//document.getElementById('backbutton').removeAttribute('onclick');
	window.history.back();
	}
};



		
		</xsl:comment>
		</script>
	</xsl:template>
	
	
	<xsl:template name="split-plot">
	<xsl:param name="sPlot" />
	<xsl:param name="iMaxChars" />
		<xsl:choose>
	<xsl:when test="string-length($sPlot)  &lt; number($iMaxChars)+1">
	<script type="text/javascript">
		<xsl:comment>
		asPlotPart.push("<xsl:value-of select="$sPlot"/>");
		</xsl:comment>
		</script>
	</xsl:when>
	<xsl:otherwise>
		<xsl:variable name="sPart" >
		<xsl:call-template name="truncate_phrase">
            			 	<xsl:with-param name="phrase">
            			  <xsl:value-of select="$sPlot"/> 
            			 	</xsl:with-param>
                           <xsl:with-param name="length" select="$iMaxChars" />
            		 		<xsl:with-param name="truncate_to_word_boundary" select="1" />
            	  	</xsl:call-template>
					</xsl:variable>
	<script type="text/javascript">
		<xsl:comment>
		asPlotPart.push("<xsl:value-of select="$sPart"/>");
		</xsl:comment>
		</script>
		
		<xsl:call-template name="split-plot">
		<xsl:with-param name="sPlot" select="substring($sPlot,string-length($sPart)-1)"/>
		<xsl:with-param name="iMaxChars" select="$iMaxChars"/>
		</xsl:call-template>
		</xsl:otherwise>
	</xsl:choose>
	</xsl:template>
	
	<xsl:template name="get-episode-infos">
		<xsl:variable name="teiler" select="if ((round((count(/details/movie/files/file)+4) div 10)) &gt; 1) then (round((count(/details/movie/files/file)+4) div 10)+1) else 2" />
		<xsl:for-each select="files/file[position()&lt;$teiler]">

			<xsl:call-template name="setEpisodeArrays">
			 <xsl:with-param name="count" select="position()" />
			</xsl:call-template>
		</xsl:for-each>
	</xsl:template>


	<xsl:template name="setEpisodeArrays">
		<xsl:param name="count" />
		<xsl:variable name="max" select="$count * 10 +1" />
		<xsl:variable name="min" select="$max - 11" />
		<xsl:variable name="position" select="$count * 10 +1" />

<xsl:for-each select="/details/movie/files/file[position()&gt;$min and position()&lt;$max]">
		<script type="text/javascript">
		<xsl:comment>

		
		<xsl:variable name="parsedTitle" select="tokenize(@title,' / ')"/>

    <xsl:variable name="url2">
      <xsl:call-template name="substring-after-last">
        <xsl:with-param name="string" select="fileURL" />
        <xsl:with-param name="delimiter" select="$filePath" />
      </xsl:call-template>
    </xsl:variable>
	
	<xsl:variable name="url"><xsl:value-of select="fileURL" /></xsl:variable>
	<xsl:variable name="epVod">
		<xsl:if test="@vod and @vod='playlist'">playlist</xsl:if>
		<xsl:if test="@vod and @vod!='playlist'">vod</xsl:if>
		<xsl:if test="@zcd">zcd</xsl:if>
		<xsl:if test="@rar">rar</xsl:if>
		</xsl:variable>  
	        <xsl:variable name="sPlayUrl">
        <xsl:choose>
          <xsl:when test="//movie/container = 'RAR' or substring(fileURL,string-length(fileURL)-3,4) = '.RAR' or substring(fileURL,string-length(fileURL)-3,4) = '.rar'">
            <xsl:value-of select="concat(fileURL,'?playall=1')" />
          </xsl:when>
          <xsl:when test="//movie/container = 'VOB' or substring(fileURL,string-length(fileURL)-3,4) = '.VOB' or substring(fileURL,string-length(fileURL)-3,4) = '.vob' or //movie/container = 'ISO' or substring(fileURL,string-length(fileURL)-3,4) = '.ISO' or substring(fileURL,string-length(fileURL)-3,4) = '.iso' or //movie/container = 'IMG' or substring(fileURL,string-length(fileURL)-3,4) = '.IMG' or substring(fileURL,string-length(fileURL)-3,4) = '.img' or //movie/container = 'MDF' or substring(fileURL,string-length(fileURL)-3,4) = '.MDF' or substring(fileURL,string-length(fileURL)-3,4) = '.mdf' or //movie/container = 'NRG' or substring(fileURL,string-length(fileURL)-3,4) = '.NRG' or substring(fileURL,string-length(fileURL)-3,4) = '.nrg' or //movie/container = 'BIN' or substring(fileURL,string-length(fileURL)-3,4) = '.BIN' or substring(fileURL,string-length(fileURL)-3,4) = '.bin' or //movie/container = 'VIDEO_TS' or substring(fileURL,string-length(fileURL)-7,8) = 'VIDEO_TS' or substring(fileURL,string-length(fileURL)-7,8) = 'video_ts'">
            <xsl:value-of select="fileURL" />
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="concat(concat(concat(/details/movie/baseFilename,'.playlist'),@firstPart),'.jsp')" />
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
	  
	  <xsl:variable name="watched">
		<xsl:if test="watchedDate !=''">watched</xsl:if>
		</xsl:variable>
		
	   	<xsl:for-each select="filePlot">
        <xsl:variable name="pass" select="position()" />
        <xsl:variable name="shortTitle">
    	  	<xsl:choose>
				<xsl:when test="string-length($parsedTitle[$pass]) &lt; number($tTitleTrunca)+2">
					<xsl:value-of select="$parsedTitle[$pass]"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="substring($parsedTitle[$pass],1,$tTitleTrunca)"/>...</xsl:otherwise>
			</xsl:choose>
    		</xsl:variable>
		
		
		
		    <xsl:variable name="plot" select="." />
		    <xsl:variable name="TitleProcessed">
		    <xsl:call-template name="search-and-replace">
					 <xsl:with-param name="input"><xsl:if test="$parsedTitle[$pass] != '' and $parsedTitle[$pass] !='UNKNOWN'"><xsl:value-of select="$parsedTitle[$pass]" /></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:if test="../@lastPart &gt; ../@firstPart"> (e<xsl:value-of select="../@firstPart" />)</xsl:if>-->
		   	</xsl:variable>

		    <xsl:variable name="PlotProcessed">
		    	<xsl:variable name="tempPlot">

			     <xsl:value-of select="." />
			   <xsl:if test="$plot = '' or $plot = 'UNKNOWN'">
			      <xsl:text>Plot unavailable.</xsl:text>
			     </xsl:if>
		     </xsl:variable>
		     <xsl:call-template name="search-and-replace">
					 <xsl:with-param name="input">
					  <xsl:value-of select="$tempPlot"/>
					 </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>
		   	asEpisodeTitle.push("<xsl:value-of select="$TitleProcessed"/>");
		   	asEpisodePlot.push("<xsl:choose><xsl:when test="string-length($PlotProcessed)&lt;470"><xsl:value-of select="translate($PlotProcessed,'&#xA;','')"/></xsl:when><xsl:otherwise><xsl:value-of select="substring((translate($PlotProcessed,'&#xA;','')),1,470)"/>...</xsl:otherwise></xsl:choose>");
		   	asEpisodeUrl.push("<xsl:value-of select="$url" />");
			asEpisodeVod.push("<xsl:value-of select="$epVod" />");
			asEpisodePlaylist.push("<xsl:value-of select="$sPlayUrl" />");
		   	asEpisodeNo.push("<xsl:value-of select="@part" />");
		   	asEpisodeTitleShort.push("<xsl:value-of select="translate($shortTitle,'&#32;','&#160;')" />");
			asEpisodeWatched.push("<xsl:value-of select="$watched" />");
			
	   	</xsl:for-each>

	   	<!-- Add the TV-Show images to the data array -->
	   	<xsl:if test="$mjb.includeVideoImages='true'">
	   		<xsl:for-each select="fileImageFile">
	   		  <xsl:variable name="iPart" select="@part"/>
	   		  <xsl:variable name="sImage">
			      <xsl:choose>
			        <xsl:when test="/details/movie/files/file/fileImageURL[@part=$iPart]!='UNKNOWN'"><xsl:value-of select="."/></xsl:when>
			        <xsl:otherwise>UNKNOWN</xsl:otherwise>
			      </xsl:choose>
			    </xsl:variable>
	    	asEpisodeImage.push("<xsl:value-of select="$sImage"/>");
			  </xsl:for-each>
	   	</xsl:if>
		
		</xsl:comment>
		</script>
		</xsl:for-each>
	</xsl:template>

	<xsl:template name="substring-before-last">
		<xsl:param name="string" />
		<xsl:param name="delimiter" />
		<xsl:if test="$delimiter and contains($string, $delimiter)">
			<xsl:variable name="temp" select="substring-after($string, $delimiter)" />
			<xsl:value-of select="substring-before($string, $delimiter)" />
			<xsl:if test="contains($temp, $delimiter)">
				<xsl:value-of select="$delimiter" />
				<xsl:call-template name="substring-before-last">
					<xsl:with-param name="string" select="$temp" />
					<xsl:with-param name="delimiter" select="$delimiter" />
				</xsl:call-template>
			</xsl:if>
		</xsl:if>
	</xsl:template>
	<xsl:template name="substring-after-last">
		<xsl:param name="string" />
		<xsl:param name="delimiter" />
		<xsl:choose>
			<xsl:when test="contains($string, $delimiter)">
				<xsl:call-template name="substring-after-last">
					<xsl:with-param name="string" select="substring-after($string, $delimiter)" />
					<xsl:with-param name="delimiter" select="$delimiter" />
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$string" />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="plot">
		<xsl:param name="string" />
		<xsl:param name="delimiter" />
		<xsl:choose>
			<xsl:when test="contains($string, $delimiter)">
				<xsl:call-template name="plot">
					<xsl:with-param name="string" select="substring-before($string,$delimiter)" />
					<xsl:with-param name="delimiter" select="$delimiter" />
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$string" />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="search-and-replace">
		<xsl:param name="input" />
		<xsl:param name="search-string" />
		<xsl:param name="replace-string" />
		<xsl:choose>
			<xsl:when test="$search-string and contains($input, $search-string)">
				<xsl:value-of select="substring-before($input,$search-string)" />
				<xsl:value-of select="$replace-string" />
				<xsl:call-template name="search-and-replace">
					<xsl:with-param name="input" select="substring-after($input,$search-string)" />
					<xsl:with-param name="search-string" select="$search-string" />
					<xsl:with-param name="replace-string" select="$replace-string" />
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise><xsl:value-of select="$input" /></xsl:otherwise>
		</xsl:choose>
	</xsl:template>



	<xsl:template name="trailers">
		<!-- Begin Trailers TV -->
		<xsl:if test="count(extras) != 0 and /details/movie/season = -1">
		  <xsl:for-each select="extras/extra">
			  <xsl:if test="position() &lt; 5">
			  <xsl:variable name="tempI"><xsl:if test="$noPrefix.onlyOne = 'true' and count(/details/movie/files/file) &gt; '1' and $multipartmoviehandling = 'classic'"><xsl:value-of select="$trailer.tvid.prefix" /></xsl:if><xsl:value-of select="position()" /></xsl:variable>
			  <div>
			  <xsl:attribute name="class">tabTrailer abs text infoHeadLeft line<xsl:value-of select="position()" /></xsl:attribute>
			  <a>
					<xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
					<!-- 2009-04-17: get Link Attribute by template -->
          <xsl:call-template name="getPlayAttr">
           <xsl:with-param name="fUrl" select="." />
          </xsl:call-template>
					<xsl:attribute name="TVID" select="$tempI"/>
					<xsl:if test="position() = 1">
					<xsl:attribute name="onkeyupset">trailer</xsl:attribute>
					<xsl:attribute name="name">firstTrailer</xsl:attribute>
					</xsl:if>
					<xsl:if test="position() = count(/details/movie/extras/extra) or position() = 4 ">
					<xsl:attribute name="onkeydownset">lastTrailer</xsl:attribute>
					</xsl:if>

					<xsl:value-of select="@title"/> (<xsl:value-of  select="$tempI"/>)

					</a>
					</div>
			  </xsl:if>
				</xsl:for-each>
				<a href="#" onfocusset="firstTrailer" name="lastTrailer"></a>
		</xsl:if>
		<!-- End Trailers TV -->
	</xsl:template>

  <xsl:template name="navigation">
  <!-- Begin Navigation Movie -->
		<xsl:choose>
			<xsl:when test="season = -1">
				<!--Movies-->

				<a class="link">
          <xsl:if test="count(files/file) = '1'">
           <xsl:attribute name="href"><xsl:value-of select="//files/file/fileURL" /></xsl:attribute>
            <!-- 2009-04-17: get Link Attribute by template -->
            <xsl:call-template name="getPlayAttr">
              <xsl:with-param name="fUrl" select="files/file/fileURL" />
            </xsl:call-template>
            <xsl:attribute name="onkeyrightset">red</xsl:attribute>
          </xsl:if>
          <xsl:attribute name="onkeydownset">pagePlayDown</xsl:attribute>
          <xsl:attribute name="onkeyupset">pagePlayUp</xsl:attribute>
          <xsl:attribute name="onfocus">fPlay=true;changePgLink();</xsl:attribute>
          <xsl:attribute name="onblur">fPlay=false;changePgLink();</xsl:attribute>
          <xsl:if test="count(files/file) != '1'">
           <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>
          <xsl:attribute name="TVID">Play</xsl:attribute>
          <xsl:attribute name="name">Play</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/tab_play.png" id="tabPlayImg" onfocussrc="pictures/tab_play_f2.png" onmouseover="this.src='pictures/tab_play_f2.png'" onmouseout="this.src='pictures/tab_play.png'" />
         </a>
			</xsl:when>
			<xsl:otherwise>
			  <a>
          <xsl:if test="count(files/file) != '1'">
            <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>
          <xsl:if test="count(files/file) = '1'">
            <xsl:attribute name="href"><xsl:value-of select="/details/movie/files/file/fileURL"/></xsl:attribute>
            <xsl:call-template name="getPlayAttr">
              <xsl:with-param name="fUrl" select="/details/movie/files/file/fileURL" />
            </xsl:call-template>
          </xsl:if>
          <xsl:attribute name="id">playlist</xsl:attribute>
          <xsl:attribute name="name">Play</xsl:attribute>
          <img src="pictures/tab_play.png" id="tabPlayImg" onfocussrc="pictures/tab_play_f2.png" onmouseover="this.src='pictures/tab_play_f2.png'" onmouseout="this.src='pictures/tab_play.png'" />
        </a>
			</xsl:otherwise>


		</xsl:choose>
    <!-- END Navigation Movie -->

	</xsl:template>

	<xsl:template name="getEpisodeList">
		<xsl:param name="position" />
		 <!-- <xsl:variable name="URL" select="../fileURL" />-->
		   	<xsl:variable name="epNum" select="count(/details/movie/files/file/filePlot)" />

<xsl:variable name="URL">
	<xsl:choose>
		<xsl:when test="$TVPlaylist='false'">
			<xsl:choose>
				<xsl:when test="//movie/container = 'RAR' or substring(../fileURL,string-length(../fileURL)-3,4) = '.RAR' or substring(../fileURL,string-length(../fileURL)-3,4) = '.rar'">
					<xsl:value-of select="concat(../fileURL,'?playall=1')" />
				</xsl:when>
				<!--<xsl:when test="substring(//files/file/fileURL,string-length(//files/file/fileURL)-9,10) = 'part01.rar' or substring(//files/file/fileURL,string-length(//files/file/fileURL)-9,10) = 'PART01.RAR' or substring(//files/file/fileURL,string-length(//files/file/fileURL)-10,11) = 'part001.rar' or substring(//files/file/fileURL,string-length(//files/file/fileURL)-10,11) = 'PART001.RAR'">
				
				</xsl:when>--><!-- futureproof: when multipart episodes get fixed -->
				<xsl:when test="//movie/container = 'VOB' or substring(../fileURL,string-length(../fileURL)-3,4) = '.VOB' or substring(../fileURL,string-length(../fileURL)-3,4) = '.vob' or //movie/container = 'ISO' or substring(../fileURL,string-length(../fileURL)-3,4) = '.ISO' or substring(../fileURL,string-length(../fileURL)-3,4) = '.iso' or //movie/container = 'IMG' or substring(../fileURL,string-length(../fileURL)-3,4) = '.IMG' or substring(../fileURL,string-length(../fileURL)-3,4) = '.img' or //movie/container = 'MDF' or substring(../fileURL,string-length(../fileURL)-3,4) = '.MDF' or substring(../fileURL,string-length(../fileURL)-3,4) = '.mdf' or //movie/container = 'NRG' or substring(../fileURL,string-length(../fileURL)-3,4) = '.NRG' or substring(../fileURL,string-length(../fileURL)-3,4) = '.nrg' or //movie/container = 'BIN' or substring(../fileURL,string-length(../fileURL)-3,4) = '.BIN' or substring(../fileURL,string-length(../fileURL)-3,4) = '.bin' or //movie/container = 'VIDEO_TS' or substring(../fileURL,string-length(../fileURL)-7,8) = 'VIDEO_TS' or substring(../fileURL,string-length(../fileURL)-7,8) = 'video_ts'">
					<xsl:value-of select="../fileURL" />
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="../fileURL" />
				</xsl:otherwise>
			</xsl:choose>
		</xsl:when>

		<xsl:when test="$TVPlaylist='true' and $epNum!='1' and $ForComputer='false'">
			<xsl:choose>
				<xsl:when test="//movie/container = 'RAR' or substring(../fileURL,string-length(../fileURL)-3,4) = '.RAR' or substring(../fileURL,string-length(../fileURL)-3,4) = '.rar'">
					<xsl:value-of select="concat(../fileURL,'?playall=1')" />
				</xsl:when>
				<xsl:when test="//movie/container = 'VOB' or substring(../fileURL,string-length(../fileURL)-3,4) = '.VOB' or substring(../fileURL,string-length(../fileURL)-3,4) = '.vob' or //movie/container = 'ISO' or substring(../fileURL,string-length(../fileURL)-3,4) = '.ISO' or substring(../fileURL,string-length(../fileURL)-3,4) = '.iso' or //movie/container = 'IMG' or substring(../fileURL,string-length(../fileURL)-3,4) = '.IMG' or substring(../fileURL,string-length(../fileURL)-3,4) = '.img' or //movie/container = 'MDF' or substring(../fileURL,string-length(../fileURL)-3,4) = '.MDF' or substring(../fileURL,string-length(../fileURL)-3,4) = '.mdf' or //movie/container = 'NRG' or substring(../fileURL,string-length(../fileURL)-3,4) = '.NRG' or substring(../fileURL,string-length(../fileURL)-3,4) = '.nrg' or //movie/container = 'BIN' or substring(../fileURL,string-length(../fileURL)-3,4) = '.BIN' or substring(../fileURL,string-length(../fileURL)-3,4) = '.bin' or //movie/container = 'VIDEO_TS' or substring(../fileURL,string-length(../fileURL)-7,8) = 'VIDEO_TS' or substring(../fileURL,string-length(../fileURL)-7,8) = 'video_ts'">
					<xsl:value-of select="../fileURL" />
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="concat(concat(concat(../../../baseFilename,'.playlist'),../@firstPart),'.jsp')" />
				</xsl:otherwise>
			</xsl:choose>
		</xsl:when>

		<xsl:when test="$TVPlaylist='true' and $epNum='1' and $ForComputer='false'">
			<xsl:choose>
				<xsl:when test="//movie/container = 'RAR' or substring(../fileURL,string-length(../fileURL)-3,4) = '.RAR' or substring(../fileURL,string-length(../fileURL)-3,4) = '.rar'">
					<xsl:value-of select="concat(../fileURL,'?playall=1')" />
				</xsl:when>
				<xsl:when test="//movie/container = 'VOB' or substring(../fileURL,string-length(../fileURL)-3,4) = '.VOB' or substring(../fileURL,string-length(../fileURL)-3,4) = '.vob' or //movie/container = 'ISO' or substring(../fileURL,string-length(../fileURL)-3,4) = '.ISO' or substring(../fileURL,string-length(../fileURL)-3,4) = '.iso' or //movie/container = 'IMG' or substring(../fileURL,string-length(../fileURL)-3,4) = '.IMG' or substring(../fileURL,string-length(../fileURL)-3,4) = '.img' or //movie/container = 'MDF' or substring(../fileURL,string-length(../fileURL)-3,4) = '.MDF' or substring(../fileURL,string-length(../fileURL)-3,4) = '.mdf' or //movie/container = 'NRG' or substring(../fileURL,string-length(../fileURL)-3,4) = '.NRG' or substring(../fileURL,string-length(../fileURL)-3,4) = '.nrg' or //movie/container = 'BIN' or substring(../fileURL,string-length(../fileURL)-3,4) = '.BIN' or substring(../fileURL,string-length(../fileURL)-3,4) = '.bin' or //movie/container = 'VIDEO_TS' or substring(../fileURL,string-length(../fileURL)-7,8) = 'VIDEO_TS' or substring(../fileURL,string-length(../fileURL)-7,8) = 'video_ts'">
					<xsl:value-of select="../fileURL" />
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="../fileURL" />
				</xsl:otherwise>
			</xsl:choose>
		</xsl:when>
		
		<xsl:when test="$TVPlaylist='true' and $ForComputer='true'">
			<xsl:value-of select="../fileURL" />
		</xsl:when>

	</xsl:choose>
</xsl:variable>
			<xsl:variable name="episodeTitle" select="../tokenize(@title,' / ')" />

			<xsl:variable name="pass" select="@part - ../@firstPart +1" />
      <xsl:variable name="episodeNo">
        <xsl:choose>
  			  <xsl:when test="string-length(@part) = '1'">0<xsl:value-of select="@part"/></xsl:when>
  			  <xsl:otherwise><xsl:value-of select="@part"/></xsl:otherwise>
				</xsl:choose>
			</xsl:variable>

<!--			<xsl:if test="$position &lt; 21">-->

      	<xsl:variable name="posX">
      		<xsl:choose>
      		  <xsl:when test="$position &lt; 6">epLeft</xsl:when>
      		  <xsl:when test="$position &gt; 5 and $position &lt; 11">epMid</xsl:when>
      		  <xsl:when test="$position &gt; 10 and $position &lt; 16">epMid2</xsl:when>
      		  <xsl:otherwise>epRight</xsl:otherwise>
      		</xsl:choose>
      	</xsl:variable>

      	<xsl:variable name="modulo">
      		<xsl:value-of select="$position mod 5" />
      	</xsl:variable>

      	<xsl:variable name="posY" select="if ($modulo != 0) then $modulo else 5" />

      	<xsl:variable name="epNum" select="count(/details/movie/files/file/filePlot)" />

<!--      	<div>-->
<!--      	<xsl:attribute name="class">tabTvShow abs text <xsl:value-of select="$posX" /> lineTv<xsl:value-of select="$posY" /></xsl:attribute>-->
    				 <table border="0" cellpadding="0" cellspacing="0"><tr><td>

      	  <a class="TvLink">
						<xsl:attribute name="href"><xsl:value-of select="$URL"/></xsl:attribute>
            <xsl:call-template name="getPlayAttr">
              <xsl:with-param name="fUrl" select="$URL" />
            </xsl:call-template>

						<xsl:attribute name="id">a_e_<xsl:value-of select="$position"/></xsl:attribute>
						<xsl:attribute name="name">episode<xsl:value-of select="$position"/></xsl:attribute>
						<!--<xsl:attribute name="onfocus">showEpisode(<xsl:value-of select="$position"/>)</xsl:attribute>-->
						<xsl:attribute name="onkeydownset">todown</xsl:attribute>
						<xsl:attribute name="onkeyrightset">toright</xsl:attribute>
						<xsl:attribute name="onkeyupset">toup</xsl:attribute>
						<xsl:attribute name="onkeyleftset">toleft</xsl:attribute>
						<xsl:attribute name="onmouseover">showEpisode(<xsl:value-of select="$position"/>)</xsl:attribute>
<!--						<xsl:choose>
						  <xsl:when test="$position = 1">
                <xsl:attribute name="onkeyupset">yellow</xsl:attribute>
						  </xsl:when>
						  <xsl:when test="$position = 20 or $position = $epNum">
                <xsl:attribute name="onkeydownset">episode1</xsl:attribute>
						  </xsl:when>
						  <xsl:when test="$posY = 1 and $position &gt; 1">
						    <xsl:attribute name="onkeyupset">episode<xsl:value-of select="$position - 1"/></xsl:attribute>
						  </xsl:when>
						  <xsl:when test="$posY = 5 and $position &lt; 20">
						    <xsl:attribute name="onkeydownset">episode<xsl:value-of select="$position + 1"/></xsl:attribute>
						  </xsl:when>
						  <!**
						  <xsl:when test="$posY = 5 and $position= 20">
						    <xsl:attribute name="onkeydownset">scrollDown</xsl:attribute>
						  </xsl:when>
						  **>
						</xsl:choose>-->

						<!-- Navigation RIGHT for the last 5 Links  -->
<!--						<xsl:choose>
						  <xsl:when test="$epNum &gt;= 20 and $posX='epRight'">
                <xsl:attribute name="onkeyrightset">episode<xsl:value-of select="$position - 15"/></xsl:attribute>
						  </xsl:when>
						  <xsl:when test="$epNum &lt;= 20 and $position &gt; 5 and $position &gt;= $epNum - 4 ">
                <xsl:attribute name="onkeyrightset">episode<xsl:value-of select="$posY"/></xsl:attribute>
						  </xsl:when>
						</xsl:choose>-->

						<!-- Navigation LEFT for Link 1-5  -->
<!--						<xsl:choose>
						  <xsl:when test="$epNum &gt;= 20 and $position &lt; 6">
                <xsl:attribute name="onkeyleftset">episode<xsl:value-of select="$position + 15"/></xsl:attribute>
						  </xsl:when>
						  <xsl:when test="$epNum &lt;= 20 and $position &lt; 6">
						    <xsl:choose>
								  <xsl:when test="$epNum &gt;= 15">
								    <xsl:if test="$position + 15 &lt;= $epNum"><xsl:attribute name="onkeyleftset">episode<xsl:value-of select="$position + 15"/></xsl:attribute></xsl:if>
								    <xsl:if test="$position + 15 &gt; $epNum"><xsl:attribute name="onkeyleftset">episode<xsl:value-of select="$position + 10"/></xsl:attribute></xsl:if>
								  </xsl:when>
								  <xsl:when test="$epNum &gt;= 10">
		                <xsl:if test="$position + 10 &lt;= $epNum"><xsl:attribute name="onkeyleftset">episode<xsl:value-of select="$position + 10"/></xsl:attribute></xsl:if>
								    <xsl:if test="$position + 10 &gt; $epNum"><xsl:attribute name="onkeyleftset">episode<xsl:value-of select="$position + 5"/></xsl:attribute></xsl:if>
								  </xsl:when>
								  <xsl:otherwise>
								    <xsl:if test="$position + 5 &lt;= $epNum"><xsl:attribute name="onkeyleftset">episode<xsl:value-of select="$position + 5"/></xsl:attribute></xsl:if>
								  </xsl:otherwise>
								</xsl:choose>
						  </xsl:when>
						</xsl:choose>-->

 
						<span class="tabTvShow">
    					<xsl:attribute name="id">s_e_<xsl:value-of select="$position"/></xsl:attribute>
                    	<xsl:choose>
    				                  	<xsl:when test="$show_episode_names='true'">
    								<xsl:value-of select="$episodeNo"/>.
            			<xsl:call-template name="truncate_phrase">
            			 	<xsl:with-param name="phrase">
            			  <xsl:value-of select="$episodeTitle[$pass]"/> 
            			 	</xsl:with-param>
                            
            			 	<xsl:with-param name="length" select="$tTitleTrunca" />
            		 		<xsl:with-param name="truncate_to_word_boundary" select="0" />
            	  	</xsl:call-template>
            	  	<!-- <xsl:if test="$pass &gt; 1"> (e<xsl:value-of select="@part - $pass +1"/>)</xsl:if>-->
    						</xsl:when>
    						<xsl:otherwise>
    							<xsl:choose>
    								<xsl:when test="string-length(//movie/season) = '1'">s0<xsl:value-of select="//movie/season"/></xsl:when>
    								<xsl:otherwise>s<xsl:value-of select="//movie/season"/></xsl:otherwise>
    							</xsl:choose>e<xsl:value-of select="$episodeNo"/>
    						</xsl:otherwise>
    					</xsl:choose>
                        	
						<!--<img src="pictures/epoff.png" onfocussrc="pictures/epon.png"></img>&#160;--> 
  					</span>
					</a></td></tr></table>
					<!-- TODO hier mal schauen, ob das nicht besser geht onloadset usw... -->
					<a href="#" class="tabTvShow">
						<xsl:attribute name="TVID"><xsl:value-of select="@part"/></xsl:attribute>
						<xsl:attribute name="onclick">setFocusNew(<xsl:value-of select="$position"/>); return false;</xsl:attribute>
						<xsl:attribute name="id">t_e_<xsl:value-of select="$position"/></xsl:attribute>
					</a>

<!--      	</div>-->

<!--      </xsl:if>-->

	</xsl:template>

  <xsl:template name="getPlayAttr">
    <xsl:param name="fUrl"></xsl:param>
    <xsl:variable name="file-container">
      <xsl:call-template name="substring-after-last">
        <xsl:with-param name="string" select="$fUrl" />
        <xsl:with-param name="delimiter" select="'.'" />
      </xsl:call-template>
    </xsl:variable>

    <xsl:choose>
		  <xsl:when test="translate($file-container,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='vob' and $nomenus='true'">
        <xsl:attribute name="vod"/>
      </xsl:when>
      <xsl:when test="translate($file-container,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') = 'iso'
            or translate($file-container,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') = 'img'
            or translate($file-container,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') = 'mdf'
            or translate($file-container,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') = 'nrg'
            or translate($file-container,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') = 'bin'">
        <xsl:attribute name="zcd">2</xsl:attribute>
      </xsl:when>
      <xsl:when test="translate(substring($fUrl, string-length($fUrl)-7, 8),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') = 'video_ts'">
          <!-- <xsl:attribute name="zcd">2</xsl:attribute>
        <xsl:attribute name="vod"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:attribute name="vod" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template> -->
  
          <xsl:attribute name="zcd">2</xsl:attribute>
        <xsl:attribute name="vod"/>
      </xsl:when>
      <xsl:otherwise>

<xsl:choose>
<xsl:when test="$TVPlaylist='false'">
	<xsl:choose>
		<xsl:when test="//movie/container = 'RAR' or substring(../fileURL,string-length(../fileURL)-3,4) = '.RAR' or substring(../fileURL,string-length(../fileURL)-3,4) = '.rar'">
			<xsl:attribute name="vod">playlist</xsl:attribute>
		</xsl:when>
		<xsl:otherwise>
			<xsl:attribute name="vod" />
		</xsl:otherwise>
	</xsl:choose>
</xsl:when>
<xsl:when test="$TVPlaylist='true' and count(/details/movie/files/file/filePlot)!='1'">
<xsl:attribute name="vod">playlist</xsl:attribute>
</xsl:when>
<xsl:when test="$TVPlaylist='true' and count(/details/movie/files/file/filePlot)='1'">
<xsl:attribute name="vod"/>
</xsl:when>
</xsl:choose>
	  
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="imdbRating">
    <xsl:if test="rating != -1">
     <xsl:if test="$star_rating = 'true'">
      <div>
       <img><xsl:attribute name="src">pictures/detail/rating_<xsl:value-of select="round(rating div 10)*10" />.png</xsl:attribute></img>
      </div>
     </xsl:if>
     <xsl:if test="$full_rating = 'true'">
      <xsl:if test="$star_rating = 'true'">
       <div class="gold">
        IMDb: <xsl:value-of select="rating div 10" />/10
       </div>
      </xsl:if>
      <xsl:if test="$star_rating = 'false'">
       <div class="gold">
        IMDb: <xsl:value-of select="rating div 10" />/10
       </div>
      </xsl:if>
     </xsl:if>
    </xsl:if>
  </xsl:template>


  <xsl:template name="infoTabContent">
    <!-- left -->

    <div class="tabInfo abs headline infoHeadLeft screen">Source</div>
    <div class="tabInfo abs text infoTextLeft screenText"><xsl:call-template name="video-source" /></div>

    <div class="tabInfo abs headline infoHeadLeft size line2">Size</div>
    <div class="tabInfo abs text infoTextLeft sizeText line2Text"><xsl:call-template name="template-resolution" /></div>

    <div class="tabInfo abs headline infoHeadLeft audio line4">Audio</div>
    <div id="audioDiv" class="tabInfo abs text infoTextLeft audioText line4Text">
      <xsl:call-template name="audio-codec" />
     </div>

    <div class="tabInfo abs headline infoHeadLeft output line3">Output</div>
    <div class="tabInfo abs text infoTextLeft outputText line3Text">
   		<xsl:call-template name="template-videoOutput-text" />
  	</div>

    <!-- middle -->
    <div class="tabInfo abs headline infoHeadMid subtitles line1">Subtitles</div>
    <div class="tabInfo abs text subtitlesText line1Text"><xsl:call-template name="template-subtitles" /></div>

  	<div class="tabInfo abs headline infoHeadMid video">Video</div>
    <div class="tabInfo abs text infoTextMid videoText"><xsl:call-template name="video-codec" /></div>

    <div class="tabInfo abs headline infoHeadMid fps line3">Fps</div>
    <div class="tabInfo abs text infoTextMid fpsText line3Text">
   		<xsl:value-of select="fps" />
  	</div>

    <!-- right -->
    <xsl:if test="libraryDescription != 'UNKNOWN'">
      <div class="tabInfo abs headline infoHeadRight library line1">Library</div>
      <div class="tabInfo abs text infoTextRight libraryText line1Text">
        <!-- get libraryDescription title from template -->
      	<xsl:call-template name="template-libraryDescription" />
    	</div>
  	</xsl:if>
  </xsl:template>

<!--  <xsl:template name="poster">
    <div id="imageDiv" class="abs poster hidden"><img id="image"><xsl:attribute name="src" select="detailPosterFile"  /><xsl:attribute name="width" select="$posters.width"  /></img></div>
  </xsl:template>-->
</xsl:stylesheet>
