<?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>
		<script type="text/javascript" src="/_layouts/flex/includes/js/base.js"><js /></script>

		<xsl:apply-templates />

	</xsl:template>

	<xsl:template name="Empty">
		No posts available.
	</xsl:template>

	<xsl:template match="AggregateResult">
		<xsl:variable name="items" select="//Item" />

		<div style="float: right; margin: 5px;">

			<xsl:variable name="BlogServerRelativeUrl" select="CargoXml/Blog/@Url" />
			<xsl:variable name="searchjs">SearchBlog('<xsl:value-of select="$BlogServerRelativeUrl" />/Search.aspx', '<xsl:value-of select="@ID" />_keywords')</xsl:variable>


			<span style="margin: 0px 0px 0px 2px;">
				<table cellspacing="0" cellpadding="0" border="0">
					<tr>
						<td style="padding: 2px 2px 0px 0px; vertical-align: top;">
							<a href="{@ExecutionWebServerRelativeUrl}/_layouts/flex/syndication.ashx?id={@ID}" target="_blank"><img src="/FlexCollateral/Syndication.jpg" border="0" title="Syndication" alt="Syndication" /></a>
						</td>
						<td style="padding-right: 5px; vertical-align: top;">
							<input type="text" id="{@ID}_keywords" value="" style="width: 100px;" onkeypress="if (window.event.keyCode==13 &amp;&amp; this.value != '') {$searchjs};" />
						</td>
						<td style="vertical-align: top;">
							<button id="{@ID}_search" onclick="{$searchjs};">Search</button>
						</td>
					</tr>
				</table>
			</span>

		</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>
