<?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 src='/modules/ImageGallery/js/categories.js?{$version}.{$build}' type='text/javascript'></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="width:1%; padding-left: 4px; padding-right: 4px;"><xsl:value-of select="PICTURE"/></th>
			<th style="padding-left: 4px; padding-right: 4px;"><xsl:value-of select="TITLE"/></th>
			<th style="padding-left: 4px; padding-right: 4px;"><xsl:value-of select="COUNT-IMAGES"/></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="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:choose>
				<xsl:when test="not(IMAGE='')">
					<td>
						<a>
							<xsl:attribute name="href">#</xsl:attribute>
							<xsl:attribute name="onclick">window.open('<xsl:value-of select="/SITEBUILDER-PAGE/VIEW-CONTENT/@ACTION"/>/Modules/Image?file=<xsl:value-of select="IMAGE/ITEM-0/FILE-NAME"/>', 'imagepreview', 'width=<xsl:value-of select="IMAGE//ITEM-0/WIDTH+17"/>, height=<xsl:value-of select="IMAGE/ITEM-0/HEIGHT+17"/>, resizable=yes, tolbar=no, status=yes, scrollbars=yes');return false;</xsl:attribute>
							<img style="border-width:0px;width:16px;height:16px" src="{$skinPath}/icons/prew.png"/>
						</a>
					</td>					
				</xsl:when>
				<xsl:otherwise>
					<td></td>
				</xsl:otherwise>
			</xsl:choose>

			<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">
							var action	= document.getElementById('viewAction');
							var form 	= document.forms['SB_WizardForm'];
							form.action = action.value+'/Modules/ImageGallery/Category/Up?id=<xsl:value-of select="ID"/>';
						
							top.sbApplyChangesObject.registerForcedSaving();
							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">
							var action	= document.getElementById('viewAction');
							var form 	= document.forms['SB_WizardForm'];
							form.action = action.value+'/Modules/ImageGallery/Category/Down?id=<xsl:value-of select="ID"/>';
						
							top.sbApplyChangesObject.registerForcedSaving();
							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">
						top.sbApplyChangesObject.registerForcedSaving();
						sbNavigationObject.go('<xsl:value-of select="/SITEBUILDER-PAGE/VIEW-CONTENT/@ACTION"/>/Modules/ImageGallery/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:template match="CATEGORIES/TOOLBAR/TOOLBAR-ITEM[1]/@ACTION">
		<xsl:attribute name="onclick">top.sbApplyChangesObject.registerForcedSaving();sbNavigationObject.go('<xsl:value-of select="."/>');</xsl:attribute>
	</xsl:template>	

</xsl:stylesheet>