<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="AUTOUPDATE-CONTENT">
		<script type="text/javascript" src="/js/Admin/Autoupdate.js?{$version}.{$build}"></script>

		<form action="{@ACTION}" method="post" id='form1'>
			<input type="hidden" name="autoupdateAction" id="autoupdateAction" value="refresh" />
			<input type="hidden" name="patchId" id="patchId" value="" />
		</form>

    	<table width="100%" cellpadding="3" border="0">
        	<tr>
            	<td class="sb-toolbarpadding"><xsl:apply-templates select="TOOLBAR"/></td>
        	</tr>
        	<tr>
            	<td><xsl:apply-templates select="PATCHES-LIST[not(@NO-UPDATES)]"/></td>
        	</tr>
         </table>
	</xsl:template>

	<xsl:template match="PATCHES-LIST">
		<xsl:variable name="avail"  select="ITEM[@AVAILABLE='yes']" />
		<xsl:variable name="uninst" select="ITEM[@INSTALLED='yes']" />

		<xsl:if test='$avail'>
			<xsl:call-template name="patchItem">
				<xsl:with-param name="item" select='$avail' />
				<xsl:with-param name="button" select="//CONTROL[@ID='INSTALL'] "/>
				<xsl:with-param name="title" select='/SITEBUILDER-PAGE/LOCALE/LAST-AVAILABLE-UPDATE' />
			</xsl:call-template>
		</xsl:if>

		<xsl:if test='$uninst'>
			<xsl:call-template name="patchItem">
				<xsl:with-param name="item" select='$uninst' />
				<!-- evil -->
				<xsl:with-param name="button" select="//CONTROL[@ID='UNINSTALL'] "/>
				<xsl:with-param name="title" select='/SITEBUILDER-PAGE/LOCALE/LAST-INSTALLED-UPDATE' />
			</xsl:call-template>
		</xsl:if>

		<xsl:if test="CONTROL[@ID='REVERT']">
			<table cellpadding="0" cellspacing="0" style="width:100%;background:#f1efef; padding-right: 4px; padding-left:10px;padding-top:8px;padding-bottom:8px; margin-top: 5px;border: 1px solid #d1d1d1">
				<tr><td style="width:100%"><xsl:value-of select='/SITEBUILDER-PAGE/LOCALE/UNINSTALL-ALL-HINT' /></td>
				<td align="right">
					<xsl:apply-templates select="CONTROL[@ID='REVERT']">
						<xsl:with-param name="style">width:100px</xsl:with-param>
					</xsl:apply-templates>
				</td></tr>
			</table>
		</xsl:if>
	</xsl:template>

	<xsl:template name="patchItem">
		<xsl:param name="item" />
		<xsl:param name="title" />
		<xsl:param name="button" />

		<fieldset class="sb-toolbar-fieldset" style="padding-left:10px">
			<legend class="sb-label-toolbar-title"><xsl:value-of select="$title" /></legend>
			<table  cellpadding="0" cellspacing="0" style="width:100%">
				<tr>
					<td style="white-space:nowrap"><xsl:value-of select='$item/NAME' /> (<xsl:value-of select='$item/SUMMARY' />)</td>
					<td style="width:100%;text-align:center"><xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/PATCH-RELEASE-DATE" />&#160;<xsl:value-of select='$item/DATE' /></td>
					<td align="right" style="padding-right: 5px">
						<xsl:apply-templates select="$button">
							<xsl:with-param name="style">width:100px</xsl:with-param>
						</xsl:apply-templates>
					</td>
				</tr>
				<tr>
					<td>
						<a id="patchDetailsLink" href="#" onclick="javascript:toggleDescription(this, '{$item/ID}')"/>
						<script type="text/javascript">$('patchDetailsLink').update(SbGetLocaleByKey('SHOW-DETAILS'));</script>
					</td>
					<td style="text-align:center">
						<xsl:value-of select="$item/STATE"/>
						<xsl:if test="$item/STATE != ''">
							<img src="{$skinPath}/images/progress.gif" alt="" style="vertical-align: top"/>
							<div id="progressController" style="display: none;"/>
							<script type="text/javascript">runProgressController();</script>
						</xsl:if>
					</td>
					<td align="center"><xsl:value-of select='$item/SIZE' /> Kb</td>
				</tr>
			</table>
			<div id='{$item/ID}' style="margin-top: 5px; padding:5px 5px 5px 5px; border: 1px solid #D0D0D0; display:none; width:640; height:350; overflow:auto;">
				<xsl:value-of select="$item/DESCRIPTION" disable-output-escaping="yes" />
			</div>
		</fieldset>
	</xsl:template>

</xsl:stylesheet>

