<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:strip-space elements="*"/>
	<xsl:output method="html" indent="yes" encoding="utf-8"/>

	<xsl:template match="POSTS">
		<script language="javascript">
			function deletePosts() {
				count = product_countSelectedCheckBoxes();
				if (count > 0) {
					if (confirm(count + ' <xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/SURE-TO-DELETE"/>')) {
						setWizardFormAction('<xsl:value-of select="/SITEBUILDER-PAGE/VIEW-CONTENT/@ACTION"/>/Modules/Blogger/Post/Delete')

						sbApplyChangesObject.registerForcedSaving();
						sbNavigationObject.go();
					}
				}
				else {
					alert('<xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/SELECT-FOR-DELETE"/>');
				}
			}
			function product_countSelectedCheckBoxes() {
				result = 0;
				var form = document.forms['SB_WizardForm'];
				for (var n = 0; n &lt; form.elements.length; n++) {
					if (form.elements[n].type == 'checkbox' &amp;&amp; form.elements[n].name=='post_objectIds[]') {
						if (form.elements[n].checked) {
							++result;
						}
					}
				}
				return result;
			}
			function product_setCheckboxStatus(status) {
				var form = document.forms['SB_WizardForm'];
				for (var n = 0; n &lt; form.elements.length; n++) {
					if (form.elements[n].type == 'checkbox' &amp;&amp; form.elements[n].name=='post_objectIds[]') {
						if (!form.elements[n].disabled) {
							form.elements[n].checked = status;
						}
					}
				}
			}
		</script>

		<xsl:apply-templates select="TOOLBAR" />
		<xsl:apply-templates select="PAGED-LIST"/>
	</xsl:template>

	<xsl:template match="POSTS/TOOLBAR/TOOLBAR-ITEM[1]/@ACTION">
		<xsl:attribute name="onclick">sbApplyChangesObject.registerForcedSaving();sbNavigationObject.go('<xsl:value-of select="."/>');</xsl:attribute>
	</xsl:template>

	<xsl:template match="POSTS/PAGED-LIST/LIST/HEADER">
		<tr class="sb-gridview-header" align="left" style="height:24px;white-space:nowrap;">
			<th style="width:1%;text-align:center">
				<input type="checkbox" name="globalCheck" onclick="product_setCheckboxStatus(this.checked);"/>
			</th>

			<xsl:call-template name="LIST-HEADER-ITEM">
				<xsl:with-param name="tab">content</xsl:with-param>
				<xsl:with-param name="field">name</xsl:with-param>
				<xsl:with-param name="title"><xsl:value-of select="NAME"/></xsl:with-param>
				<xsl:with-param name="currentSortField"><xsl:value-of select="../../LIST/@ORDER-BY"/></xsl:with-param>
				<xsl:with-param name="currentSortType"><xsl:value-of select="../../LIST/@ORDER-TYPE"/></xsl:with-param>
			</xsl:call-template>

			<th style="padding-left: 4px; padding-right: 4px;"><xsl:value-of select="CATEGORIES"/></th>

			<xsl:call-template name="LIST-HEADER-ITEM">
				<xsl:with-param name="tab">content</xsl:with-param>
				<xsl:with-param name="field">created</xsl:with-param>
				<xsl:with-param name="title"><xsl:value-of select="POSTED-ON"/></xsl:with-param>
				<xsl:with-param name="currentSortField"><xsl:value-of select="../../LIST/@ORDER-BY"/></xsl:with-param>
				<xsl:with-param name="currentSortType"><xsl:value-of select="../../LIST/@ORDER-TYPE"/></xsl:with-param>
			</xsl:call-template>

			<th style="padding-left: 4px; padding-right: 4px;"><xsl:value-of select="COMMENTS"/></th>

			<th style="width:1%;text-align:center; padding-left: 4px; padding-right: 4px;" scope="col">
				<xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/POST-EDIT"/>
			</th>

		</tr>
	</xsl:template>

	<xsl:template match="POSTS/PAGED-LIST/LIST/ITEM">
		<xsl:variable name="currentCategory" select="../../TOOLBAR/LIST-VIEW-STATES/@SELECTED"/>
		<xsl:variable name="class">
			<xsl:call-template name="LIST-ROW-CLASS">
				<xsl:with-param name="position"><xsl:value-of select="position()"/></xsl:with-param>
			</xsl:call-template>
		</xsl:variable>

		<tr class="{$class}" style="height:24px;">
			<td style="width:1%;text-align:center;">
				<input type="checkbox" name="post_objectIds[]">
					<xsl:attribute name="value"><xsl:value-of select="ID"/></xsl:attribute>
				</input>
			</td>

			<xsl:call-template name="LIST-ROW-ITEM">
				<xsl:with-param name="title"><xsl:value-of select="NAME"/></xsl:with-param>
				<xsl:with-param name="action"><xsl:value-of select="$baseUrl"/>/Wizard/Edit/Modules/Blogger?tab=comments&amp;postId=<xsl:value-of select="ID"/></xsl:with-param>
			</xsl:call-template>

			<xsl:call-template name="LIST-ROW-ITEM">
				<xsl:with-param name="title"><xsl:value-of select="CATEGORIES"/></xsl:with-param>
			</xsl:call-template>

			<xsl:call-template name="LIST-ROW-ITEM">
				<xsl:with-param name="title"><xsl:value-of select="CREATED"/></xsl:with-param>
			</xsl:call-template>

			<xsl:call-template name="LIST-ROW-ITEM">
				<xsl:with-param name="title"><xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/VIEW-COMMENTS"/> (<xsl:value-of select="COMMENTS-COUNT"/>)</xsl:with-param>
				<xsl:with-param name="action"><xsl:value-of select="$baseUrl"/>/Wizard/Edit/Modules/Blogger?tab=comments&amp;postId=<xsl:value-of select="ID"/></xsl:with-param>
			</xsl:call-template>

			<td style="width:1%; text-align:center; padding-left: 4px; padding-right: 4px;">
				<a>
					<xsl:attribute name="href">#</xsl:attribute>
					<xsl:attribute name="onclick">javascript: sbApplyChangesObject.registerForcedSaving();sbNavigationObject.go('<xsl:value-of select="$baseUrl"/>/Wizard/Edit/Modules/Blogger/Post/Edit?id=<xsl:value-of select="ID"/>');</xsl:attribute>
					<img style="border-width:0px;width:16px;height:16px" src="{$skinPath}/icons/editsiteinwizard.png"/>
				</a>
			</td>
		</tr>
	</xsl:template>

</xsl:stylesheet>
