<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:template match="/">
		<style type="text/css">
			@import url(/_layouts/flex/includes/css/base.css);
		</style>
		<xsl:apply-templates />

	</xsl:template>

	<xsl:template name="Empty">
		No content available.
	</xsl:template>

	<xsl:template match="AggregateResult">
		<xsl:variable name="items" select="//Item" />
		
		<div style="float: right; margin: 5px;">
			<a href="{@ExecutionWebServerRelativeUrl}/_layouts/flex/syndication.ashx?id={@ID}" target="_blank"><img src="/FlexCollateral/Syndication.jpg" border="0" title="Syndication" alt="Syndication" /></a>
		</div>

		<div class="flex-agg">
			<xsl:choose>
				<xsl:when test="count($items)=0">
					<xsl:call-template name="Empty"	/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates select="$items" />
				</xsl:otherwise>
			</xsl:choose>
		</div>
	</xsl:template>

	<xsl:template match="Item">

		<div class="flex-agg-item">
			<div class="flex-title">
				<a href="{@ServerRelativeUrl}"><xsl:value-of select="@Title" /></a>
			</div>
			<div class="flex-byline">
				<xsl:value-of select="@PublishingStartDateFormatted" /> by <xsl:value-of select="@FlexAuthor" />
				<span style="margin-left: 10px;"><a href="{@ServerRelativeUrl}">#</a></span>
				<xsl:if test="@ShowComments = '1'">
					<span style="margin-left: 10px;"><a href="{@ServerRelativeUrl}#comments">Comments (<xsl:value-of select="@CommentCount" />)</a></span>
				</xsl:if>
				<xsl:if test="@AllowNewComments = '1'">
					<span style="margin-left: 10px;"><a href="{@ServerRelativeUrl}#addcomment">Add a new comment</a></span>
				</xsl:if>
			</div>
			<div class="flex-agg-body">
				<xsl:value-of select="FlexHtml1" disable-output-escaping="yes" />
			</div>
			<div style="clear: both;"></div>
			<xsl:if test="position() != last()">
				<hr class="flex-agg-separator" />
			</xsl:if>
		</div>

	</xsl:template>


</xsl:stylesheet>
