<?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="IMAGE-MANAGEMENT">
		<script src='/modules/ImageGallery/js/imageManagement.js?{$version}.{$build}' type='text/javascript'></script>
		
		<xsl:apply-templates select="TOOLBAR" />
		<xsl:apply-templates select="PAGED-LIST" />
	</xsl:template>

	<xsl:template match="IMAGE-MANAGEMENT/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="setImageCheckboxStatus(this.checked);"/>
			</th>
			
			<xsl:if test="../../@IS-SEQUENCED=1">
				<th style="width:1%;">&#35;</th>
			</xsl:if>
			<th style="width:1%;padding-left: 4px; padding-right: 4px;"><xsl:value-of select="PICTURE"/></th>
			<th style="padding-left: 4px; padding-right: 4px;" scope="col"><xsl:value-of select="TITLE"/></th>
			
			<th style="padding-left: 4px; padding-right: 4px;" scope="col"><xsl:value-of select="CATEGORIES"/></th>
			
			<th style="padding-left: 4px; padding-right: 4px;" scope="col"><xsl:value-of select="DIMENSION"/></th>
			<th style="padding-left: 4px; padding-right: 4px;" scope="col"><xsl:value-of select="SIZE"/></th>
			<xsl:if test="../../@IS-SEQUENCED=1">
				<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>
			</xsl:if>	
			<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="IMAGE-MANAGEMENT/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="imageId[]">
					<xsl:attribute name="value"><xsl:value-of select="ID"/></xsl:attribute>
				</input>
			</td>
			
			<xsl:if test="../../@IS-SEQUENCED=1">
				<xsl:call-template name="LIST-ROW-ITEM">
					<xsl:with-param name="title"><xsl:value-of select="POSITION"/></xsl:with-param>
				</xsl:call-template>
			</xsl:if>
			<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/FILE-NAME"/>', 'imagepreview', 'width=<xsl:value-of select="IMAGE/WIDTH+17"/>, height=<xsl:value-of select="IMAGE/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="TITLE"/></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="IMAGE/WIDTH"/>x<xsl:value-of select="IMAGE/HEIGHT"/></xsl:with-param>
			</xsl:call-template>

			<xsl:call-template name="LIST-ROW-ITEM">
				<xsl:with-param name="title"><xsl:value-of select="IMAGE/SIZE"/></xsl:with-param>
			</xsl:call-template>
		
			<xsl:if test="../../@IS-SEQUENCED=1">
				<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/Image/Up?id=<xsl:value-of select="ID"/>&amp;categoryId=<xsl:value-of select="$currentCategory"/>';
							
								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/Image/Down?id=<xsl:value-of select="ID"/>&amp;categoryId=<xsl:value-of select="$currentCategory"/>';
							
								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>
			</xsl:if>

			<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/Image/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>