<?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="COMMENTS">
		<input type="hidden" name="postId">
			<xsl:attribute name="value"><xsl:value-of select="@POST-ID"/></xsl:attribute>
		</input>
		<script language="javascript">	
			function deleteMessages() {
				count = comment_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/Comment/Delete?postId=<xsl:value-of select="@POST-ID"/>');

						sbApplyChangesObject.registerForcedSaving(); 
						sbNavigationObject.go();
					}
				}
				else {
					alert('<xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/SELECT-FOR-DELETE"/>');
				}
			}
			function comment_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=='comment_objectIds[]') {
						if (form.elements[n].checked) {
							++result;
						}
					}
				}
				return result;
			}	
			function comment_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=='comment_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="COMMENTS/TOOLBAR/TOOLBAR-ITEM[1]/@ACTION">
		<xsl:attribute name="onclick">sbApplyChangesObject.registerForcedSaving();sbNavigationObject.go('<xsl:value-of select="."/>');</xsl:attribute>
	</xsl:template>	
		
	<xsl:template match="COMMENTS/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="comment_setCheckboxStatus(this.checked);"/>
			</th>
			
			<th scope="col" style="padding-left: 4px; padding-right: 4px;"><xsl:value-of select="SUBJECT"/></th>

			<th scope="col" style="padding-left: 4px; padding-right: 4px;"><xsl:value-of select="AUTHOR"/></th>
			
			<th scope="col" style="padding-left: 4px; padding-right: 4px;"><xsl:value-of select="POSTED"/></th>
			
			<th style="width:1%;text-align:center; padding-left: 4px; padding-right: 4px;" scope="col">
				<xsl:value-of select="EDIT"/>
			</th>
		</tr> 
	</xsl:template>
	
	<xsl:template match="COMMENTS/PAGED-LIST/LIST/ITEM">
		<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="comment_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="SUBJECT"/></xsl:with-param>
			</xsl:call-template>
		
			<xsl:call-template name="LIST-ROW-ITEM">
				<xsl:with-param name="title"><xsl:value-of select="AUTHOR"/></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>

			<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/Comment/Edit?postId=<xsl:value-of select="PARENT-ID"/>&amp;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>