<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/rss/1.0/" xmlns:fd="http://www.bradsoft.com/feeddemon/xmlns/1.0/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">
<xsl:output method="html"/>

<xsl:variable name="common-styles">
	<style type="text/css">

	body {
		background-color: white; 
		color: black;
		margin-top: 0px;
		margin-bottom: 0px;
		
		font-family: Arial, Verdana, Geneva, Arial, Helvetica, sans-serif; }

	table.filmstrip {
		width: 85%; }

	td.leftborder {
		background-image: url('$IMAGEDIR$bg_film_left.gif');
		width: 54px; }
	
	td.rightborder {
		background-image: url('$IMAGEDIR$bg_film_right.gif');	
		width: 59px; }

	td.filmframes { background-color: black; }
	
	span.nodescription { color: gray; }
	
	
	div.newsitembreak {
		background-color: black;
		height: 20px;
		margin: 0px 0px 0px 0px; }
	
	div.newspapertitle,
	div.channeltitle,
	div.newsitemtitle,
	div.newsitemcontent,
	div.newsitemheader,
	div.newsitemfooter {
		background-color: #FAFAFA; }
	
	div.newspapertitle,
	div.channeltitle {
		padding: 10px 10px 10px 10px; }
	
	div.newsitemtitle {
		padding: 0px 10px 0px 10px; }
	
	div.newsitemcontent {
		padding: 20px 30px 20px 30px; }
	
	div.newsitemheader,
	div.newsitemfooter {
		padding: 5px 10px 5px 10px; }
	
	div.newspapertitle,
	div.channeltitle {
		text-align: center;
		font-weight: bold;
		font-size: 140%;
		background-color: black; }
	
	div.newsitemtitle {
		font-weight: bold;
		font-size: 100%; }
	
	div.newsitemheader,
	div.newsitemfooter {
		color: #545454;
		text-align: right;
		font-size: 75%; }
	
	div.newsitemcontent {
		font-size: 80%; }
	
	div.newspapertitle { 
		background-color: black;
		color: yellow; }
	
	div.channeltitle a  { color: lime }
	div.newsitemtitle a { color: blue; }
	div.newsitemtitle a.read { color: black; }
	div.newsitemtitle a.flagged { color: red; }
	
	div.channeltitle a:hover,
	div.newsitemtitle a:hover,
	div.newsitemtitle a.read:hover,
	div.newsitemtitle a.flagged:hover  { color:blue; }
	
	a { 
		color: black; }
		
	a:hover { 
		color: blue; }
		
	a img { border: 1px; }
	
	h1,h2,h3,h4,h5,h6 { 
		font-size: 85%; 
		font-weight: bold; 
		font-style: italic;	}
	
	blockquote {
		margin-left: 5px; }
	
	code, 
	pre, 
	tt { 
		font-family: "Courier New", Courier, monospace;
		color: navy; }
	</style>
</xsl:variable>

<!-- newsitem  -->
<xsl:template match="item">
	<div class="newsitemheader">
		<xsl:choose>
			<xsl:when test="pubDate">Published: <xsl:value-of select="substring-before(pubDate,' GMT')" disable-output-escaping="yes"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="fd:dateDisplay" disable-output-escaping="yes"/>
			</xsl:otherwise>
		</xsl:choose>
	</div>
	<div class="newsitemtitle">
		<a href="{link}">
			<xsl:attribute name="class"><xsl:choose><xsl:when test="fd:state[@flagged='1']">flagged</xsl:when><xsl:when test="fd:state[@read='1']">read</xsl:when></xsl:choose></xsl:attribute>
			<xsl:value-of select="title" disable-output-escaping="yes"/>
		</a>
	</div>
	<div class="newsitemcontent">
		<xsl:value-of select="description" disable-output-escaping="yes"/>
	</div>
	<xsl:if test="category">
		<div class="newsitemfooter">
			<br/>Category: <b>
				<xsl:value-of select="category" disable-output-escaping="yes"/>
			</b>
		</div>
	</xsl:if>
	<xsl:if test="dc:subject">
		<div class="newsitemfooter">
	Subject: <b>
				<xsl:value-of select="dc:subject" disable-output-escaping="yes"/>
			</b>
		</div>
	</xsl:if>
	<xsl:if test="author">
		<div class="newsitemfooter">
	Author: <b>
				<xsl:value-of select="author" disable-output-escaping="yes"/>
			</b>
		</div>
	</xsl:if>
	<xsl:if test="comments">
		<div class="newsitemfooter">
			<a href="{comments}">[Comments]</a>
		</div>
	</xsl:if>
	<xsl:if test="enclosure">
		<div class="newsitemfooter">
			<a href="{enclosure/@url}" title="{enclosure/@type} :   {enclosure/@url}"> [Enclosure : <xsl:value-of select="round( enclosure/@length div 1024 )"/> kB ]</a>
		</div>
	</xsl:if>
	<xsl:if test="/newspaper/@type='newsitem'">
		<div class="newsitemfooter">
			<!-- 
			Important: use 'source' element here so that source channel shows for 
			newsbins and watches.  For other channels, FeedDemon sets the source
			to the channel itself.
			-->
			Source: <a href="{source/@htmlUrl}">
				<xsl:value-of select="source" disable-output-escaping="yes"/>
			</a>
			|
			<a href="{source/@url}">RSS</a>
		</div>
	</xsl:if>
</xsl:template>
<!-- channel  -->
<xsl:template match="channel">
	<xsl:variable name="chanlink" select="link"/>
	<xsl:variable name="chantitle" select="title"/>
	<div class="channel">
		<div class="channeltitle">
			<a href="{$chanlink}">
				<xsl:value-of select="title" disable-output-escaping="yes"/>
			</a>
		</div>
		<div class="newsitembreak"/>
		<xsl:for-each select="item">
			<xsl:sort select="fd:sortKey" data-type="number" order="ascending"/>
			<xsl:apply-templates select="."/>
			<div class="newsitembreak"/>
		</xsl:for-each>
	</div>
</xsl:template>
<!-- channel/group newspaper -->
<xsl:template match="newspaper[@type='group' or @type='channel']">
	<html>
		<head>
			<title>Group/Channel Newspaper</title>
			<base href="{//channel/link}" />
			<xsl:copy-of select="$common-styles"/>
		</head>
		<body>
			<center>
				<table class="filmstrip" border="0" cellspacing="0" cellpadding="0">
					<tbody>
						<tr>
							<td class="leftborder"></td>
							<td class="filmframes">
								<div class="newsitembreak"/>
								<xsl:if test="@type='group'">
								  <div class="newspapertitle">
								    <xsl:value-of select="title"/>
								</div></xsl:if>
								<xsl:for-each select="channel">
									<div class="newsitembreak"/>
									<xsl:apply-templates select="."/>
								</xsl:for-each>
							</td>
							<td class="rightborder"></td>
						</tr>
					</tbody>
				</table>
			</center>
		</body>
	</html>
</xsl:template>
<!-- single news item -->
<xsl:template match="newspaper[@type='newsitem']">
	<html>
		<head>
			<title>News Item</title>
			<base href="{//item/link}" />
			<xsl:copy-of select="$common-styles"/>
		</head>
		<body>
			<center>
				<table class="filmstrip" border="0" cellspacing="0" cellpadding="0">
					<tbody>
						<tr>
							<td class="leftborder"></td>
							<td class="filmframes">
								<div class="newspapertitle">
									<xsl:value-of select="title"/>
								</div>
								<xsl:for-each select="channel/item">
									<xsl:apply-templates select="."/>
								</xsl:for-each>
								<div class="newsitembreak"/>
							</td>
							<td class="rightborder"></td>
						</tr>
					</tbody>
				</table>
			</center>
		</body>
	</html>
</xsl:template>
</xsl:stylesheet>
