<?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="CATEGORIES">
		<script language="javascript">	
			function deleteCategories() {
				count = countSelectedCheckBoxes();
				if (count > 0) {
					if (confirm(count + ' <xsl:value-of select="//LOCALE/SURE-TO-DELETE"/>')) {
						var form = document.forms['SB_WizardForm'];
						form.tab.value = 'categories';
						form.action = '<xsl:value-of select="/SITEBUILDER-PAGE/VIEW-CONTENT/@ACTION"/>/Modules/Blogger/Category/Delete';
						
						top.sbApplyChangesObject.registerForcedSaving(); 
						sbNavigationObject.go();
					}
				}
				else {
					alert('<xsl:value-of select="//LOCALE/SELECT-FOR-DELETE"/>');
				}
			}
			function 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=='category_objectIds[]') {
						if (form.elements[n].checked) {
							++result;
						}
					}
				}
				return result;
			}	
			function 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=='category_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="CATEGORIES/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="setCheckboxStatus(this.checked);"/>
			</th>
			
			<th style="width:1%;">&#35;</th>
			<th style="padding-left: 4px; padding-right: 4px;"><xsl:value-of select="NAME"/></th>
			<th style="padding-left: 4px; padding-right: 4px;"><xsl:value-of select="NUMBER-OF-POSTS"/></th>


			<th style="width:1%;"><div style="width:1px; height:1px;"><span></span></div></th>
			<th style="width:1%;"><div style="width:1px; height:1px;"><span></span></div></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="CATEGORIES/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="category_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="POSITION"/></xsl:with-param>
			</xsl:call-template>

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

			<td style="width:1%; text-align:center; padding-left: 4px; padding-right: 4px;">
				<xsl:if test="not(IS-FIRST=1)">
					<a>
						<xsl:attribute name="href">#</xsl:attribute>
						<xsl:attribute name="onclick">top.sbApplyChangesObject.registerForcedSaving(); setWizardFormAction('<xsl:value-of select="/SITEBUILDER-PAGE/VIEW-CONTENT/@ACTION"/>/Modules/Blogger/Category/Up?id=<xsl:value-of select="ID"/>');sbNavigationObject.go();</xsl:attribute>
						<img style="border-width:0px;width:16px;height:16px" src="{$skinPath}/images/sequence-up.gif"/>
					</a>
				</xsl:if>
			</td>

			<td style="width:1%; text-align:center; padding-left: 4px; padding-right: 4px;">
				<xsl:if test="not(IS-LAST=1)">
					<a>
						<xsl:attribute name="href">#</xsl:attribute>
						<xsl:attribute name="onclick">top.sbApplyChangesObject.registerForcedSaving(); setWizardFormAction('<xsl:value-of select="/SITEBUILDER-PAGE/VIEW-CONTENT/@ACTION"/>/Modules/Blogger/Category/Down?id=<xsl:value-of select="ID"/>');sbNavigationObject.go();</xsl:attribute>
						<img style="border-width:0px;width:16px;height:16px" src="{$skinPath}/images/sequence-down.gif"/>
					</a>
				</xsl:if>
			</td>

			<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: top.sbApplyChangesObject.registerForcedSaving();sbNavigationObject.go('<xsl:value-of select="$baseUrl"/>/Wizard/Edit/Modules/Blogger/Category/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>