<?xml version="1.0"?> 
<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  version="1.0"
>
<!--  
  xmlns:java="http://xml.apache.org/xslt/java"
  exclude-result-prefixes="java"
  <xsl:include href="xsl/lib/libsecurity.xsl"/>
-->
  <xsl:include href="lib/libutil.xsl"/>
  <xsl:include href="lib/libsite.xsl"/>
  <xsl:include href="lib/libcontrol.xsl"/>

  <xsl:output method="html"/>

  <xsl:param name="debug"></xsl:param>
  <xsl:param name="op.VIEW.URL">project</xsl:param>
  <xsl:param name="op.MODIFY.URL"/>
  <xsl:param name="op.DELETE.URL"/>
  <xsl:param name="op.CREATE.URL"/>
  <xsl:param name="op.SELECTCONTRIBUTORS.URL"/>
	<xsl:param name="DESIGNING">false</xsl:param>

  <xsl:param name="page"/>
  <xsl:param name="style"/>

  <xsl:param name="user"/>
  <xsl:param name="util"/>

	<!-- set if called from alert wiz -->
  <xsl:param name="buildingAlert"/>

  <xsl:template match="content">
    <xsl:call-template name="dumpSitePage">  
    	<xsl:with-param name="title">Manager</xsl:with-param>
    	<xsl:with-param name="section">configuration</xsl:with-param>
    </xsl:call-template>
	</xsl:template> 

  <xsl:template match="operation">
		<div id="centerContent">
	
		  <xsl:choose>
		    <xsl:when test="@name='VIEW'">
			 	  <xsl:call-template name="view"/>
		    </xsl:when>
	
		    <xsl:otherwise>
	unhandled operation <xsl:value-of select="@name"/>
		    </xsl:otherwise>
		    
		  </xsl:choose>
	
		</div>		
  </xsl:template>
  
  <xsl:template name="view">
		<table width="95%" class="InfoTable" align="center">
			
		<xsl:call-template name="dumpHeader"/>
	  <xsl:comment>ca.reachable.web.xmltv.FlatListingsPagePostProcessor</xsl:comment>
			<!--
		<xsl:if test="count(timeBlock)=0">
			<tr>
				<td colspan="2">No Listings</td>
			</tr>
		</xsl:if>
		<xsl:for-each select="timeBlock">
		<tr>
			<td class="infoTableHeader" style="vertical-align: top" align="right" rowspan="{count(airing)+1}" width="60" valign="top"><xsl:value-of select="@blockTime"/></td>
		</tr>
		<xsl:for-each select="airing">
			<xsl:sort select="programme/name"/>
		<tr>
<xsl:variable name="cats"><xsl:for-each select="programme/category"><xsl:value-of select="@name"/></xsl:for-each></xsl:variable>	
<xsl:variable name="catStr"><xsl:value-of select="translate($cats,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/></xsl:variable>
<xsl:variable name="isMovie"><xsl:for-each select="programme/rating"><xsl:if test="system/@name='MPAA'">true</xsl:if></xsl:for-each></xsl:variable>
<xsl:variable name="colour">
	<xsl:choose>
		<xsl:when test="contains($catStr,'adult')">#FFAAAA</xsl:when>

		<xsl:when test="$isMovie!=''">#FFCCCC</xsl:when>

		<xsl:when test="contains($catStr,'talk')">#CCAACC</xsl:when>

		<xsl:when test="contains($catStr,'news')">#AAAAEE</xsl:when>

		<xsl:when test="contains($catStr,'sports')">#ffcc00</xsl:when>
		<xsl:when test="contains($catStr,'paid programming')">#AA8800</xsl:when>

		<xsl:when test="contains($catStr,'financial')">#AAAACC</xsl:when>
		<xsl:when test="contains($catStr,'documentary')">#9999AA</xsl:when>
		<xsl:when test="contains($catStr,'history')">#9999AA</xsl:when>
		<xsl:when test="contains($catStr,'biography')">#9999AA</xsl:when>
		<xsl:when test="contains($catStr,'biography')">#9999AA</xsl:when>
		<xsl:when test="contains($catStr,'educational')">#9999CC</xsl:when>
		<xsl:when test="contains($catStr,'self improvement')">#9999CC</xsl:when>
		<xsl:when test="contains($catStr,'health')">#9999CC</xsl:when>
		<xsl:when test="contains($catStr,'religious')">#7777BB</xsl:when>

		<xsl:when test="contains($catStr,'comedy')">#99FF99</xsl:when>
		<xsl:when test="contains($catStr,'animated')">#99DD99</xsl:when>
		<xsl:when test="contains($catStr,'game')">#99CC99</xsl:when>
		<xsl:when test="contains($catStr,'science fiction')">#88CC88</xsl:when>
		<xsl:when test="contains($catStr,'sitcom')">#99BB99</xsl:when>
		<xsl:when test="contains($catStr,'reality')">#88BB88</xsl:when>
		<xsl:when test="contains($catStr,'drama')">#99AA99</xsl:when>
		<xsl:when test="contains($catStr,'crime')">#99AA99</xsl:when>
		<xsl:when test="contains($catStr,'soap')">#99AA99</xsl:when>
		<xsl:when test="contains($catStr,'action')">#BBAA99</xsl:when>

		<xsl:when test="contains($catStr,'computers')">#DDAADD</xsl:when>
		<xsl:when test="contains($catStr,'entertainment')">#CCAACC</xsl:when>
		<xsl:when test="contains($catStr,'travel')">#CCAACC</xsl:when>
		<xsl:when test="contains($catStr,'cooking')">#BBAABB</xsl:when>
		<xsl:when test="contains($catStr,'house')">#BB99BB</xsl:when>
		<xsl:when test="contains($catStr,'shopping')">#BB88BB</xsl:when>
		<xsl:when test="contains($catStr,'public')">#CC99CC</xsl:when>

	</xsl:choose>
</xsl:variable>

			<td>
				<xsl:if test="$colour!=''"><xsl:attribute name="style">background-color: <xsl:value-of select="$colour"/></xsl:attribute></xsl:if>
				  <b><xsl:value-of select="programme/name"/></b> &#160;(<font size="-2"><xsl:value-of select="channel/num"/> - <xsl:value-of select="number(@numBlocks)*15"/> minutes
					<xsl:if test="programme/category"> [ <xsl:for-each select="programme/category"><xsl:value-of select="@name"/>&#160;</xsl:for-each>]</xsl:if>)
					</font>
					<xsl:if test="programme/desc"><br/><xsl:value-of select="programme/desc"/></xsl:if>
			</td>

		</tr>
		</xsl:for-each>
		</xsl:for-each>
-->
				  		<xsl:call-template name="dumpHeader">
				<xsl:with-param name="showNext">true</xsl:with-param>
			</xsl:call-template>
		
		</table>
  </xsl:template>

		<xsl:template name="dumpHeader">
		<xsl:param name="showNext"/>
			<tr>
				<td class="InfoTableTitle" width="100%" colspan="2">
				<table border="0" cellpadding="0" cellspacing="0" style="font-weight: 700; font-size: small">
					<tr>
						<td width="60" align="center">
							<xsl:choose>
								<xsl:when test="not($showNext)">

							&#160;&#160;&#160;<span id="timer" style="color: red">&#160;</span>
<script language="javascript">
	setDate();
	function setDate() {
		var now=new Date();
		var hrs=now.getHours();
		var mins=now.getMinutes();
		var timer=document.getElementById("timer");
		timer.innerHTML=(hrs&lt;10?"0"+hrs:hrs)+":"+(mins&lt;10?"0"+mins:mins);
		setTimeout("setDate()",15000);
	}
</script>
									
								</xsl:when>
								<xsl:otherwise>
									
									<a href="">Next<br/>2hrs</a>
									
								</xsl:otherwise>
							</xsl:choose>
							</td>
						<td width="100%" align="center">
						<div style="text-align: center">
							spanning
							<select name="span" style="border: none">
								<option>current shows</option>
								<option selected="true">2h</option>
								<option>3h</option>
								<option>4h</option>
								<option>6h</option>
							</select>
							
							showing
							<select name="filter">
								<option selected="true">all categories</option>
								<option>movies</option>
								<option>news</option>
								<option>sports</option>
								<option>series</option>
								<option>Custom Filter 1</option>
								<option>Custom Filter 2</option>
							</select>

							within
							<select name="channels">
								<option selected="true">all channels</option>
								<option>Channel Group 1</option>
								<option>Channel Group 2</option>
							</select>
						</div>														
						</td>

						<td width="100" align="right">
		<select style="text-align: center; background-color: #EEEEAA">
			<option style="text-align: center; background-color: #999999">Legend</option>
			<option style="text-align: center; background-color: #FFAAAA">adult</option>
			<option style="text-align: center; background-color: #FFCCCC">movie</option>
			<option style="text-align: center; background-color: #AAAAEE">news</option>
			<option style="text-align: center; background-color: #AAAACC">financial</option>
			<option style="text-align: center; background-color: #CCAACC">talk</option>

			<option style="text-align: center; background-color: #9999AA">documentary</option>
			<option style="text-align: center; background-color: #9999AA">history</option>
			<option style="text-align: center; background-color: #9999AA">biography</option>
			  
			<option style="text-align: center; background-color: #9999CC">health</option>
			<option style="text-align: center; background-color: #9999CC">educational</option>
			<option style="text-align: center; background-color: #9999CC">self improvement</option>

			<option style="text-align: center; background-color: #7777BB">religious</option>
			<option style="text-align: center; background-color: #99FF99">comedy</option>
			<option style="text-align: center; background-color: #99DD99">animated</option>
			<option style="text-align: center; background-color: #99CC99">game</option>
			<option style="text-align: center; background-color: #88CC88">sci-fi</option>
			<option style="text-align: center; background-color: #99BB99">sitcom</option>
			<option style="text-align: center; background-color: #88BB88">reality</option>

			<option style="text-align: center; background-color: #99AA99">drama</option>
			<option style="text-align: center; background-color: #99AA99">crime</option>
			<option style="text-align: center; background-color: #99AA99">soap</option>

			<option style="text-align: center; background-color: #CCAA99">action</option>
			<option style="text-align: center; background-color: #AA8800">paid</option>
			<option style="text-align: center; background-color: #FFCC00">sports</option>
		</select>
						</td>
					</tr>
				</table>

				
			</td>
		</tr>
	</xsl:template>


</xsl:stylesheet>



