<?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="STATUS">
		<xsl:variable name="statusLevel" select="@STATUS-LEVEL"/>
		<xsl:variable name="statusLevelUpper" select="@STATUS-LEVEL-UPPER"/>

<!--
:TODO: abelyaev 20070405: implement here
-->
	</xsl:template>

	<xsl:template match="STATUS/@STATUS-TEXT">
		<xsl:value-of select="."/>
	</xsl:template>

	<xsl:template match="STATUS" mode="admin">
		<xsl:param name="controlStyle">padding: 0 10px 10px 10px;</xsl:param>
		<xsl:variable name="statusLevel" select="@STATUS-LEVEL"/>
		<xsl:variable name="statusLevelUpper" select="@STATUS-LEVEL-UPPER"/>

		<xsl:apply-templates select="STATUS-DETAILS" mode="init"/>

		<table style="width: 100%;" cellpadding="0" cellspacing="0">
			<tr>
				<td style="{$controlStyle}">
					<table border="0" cellpadding="5" cellspacing="0" class="sb-statusbar-admin-{$statusLevel} sb-statusbar-admin" style="width: 100%; margin: 0;">
						<tr>
							<td>
								<table border="0" cellpadding="0" cellspacing="0">
									<tr valign="top">
										<td style="text-valign:middle; padding-left: 5px;">
											<img src="{$skinPath}/icons/{$statusLevel}.png" style="border-width:0px;">
												<xsl:attribute name="alt"><xsl:value-of select="LOCALE/@*[name() = $statusLevelUpper]"/></xsl:attribute>
											</img>
										</td>
										<td style="padding-left: 5px; padding-right: 5px; white-space: nowrap;">
											<xsl:if test="$statusLevel != 'success'">
												<b><xsl:value-of select="LOCALE/@*[name() = $statusLevelUpper]"/>:</b>
											</xsl:if>
										</td>
										<td width="100%" class="sb-statusbar-admin-text" style="padding-left: 5px;">
											<xsl:apply-templates select="@STATUS-TEXT"/>
											<xsl:apply-templates select="@SUB-STATUS-TEXT" mode="admin"/>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</xsl:template>

	<xsl:template match="STATUS/@SUB-STATUS-TEXT" mode="admin">
		<br/><xsl:value-of select="."/>
		<xsl:apply-templates select="../STATUS-DETAILS" mode="link"/>
	</xsl:template>

	<xsl:template match="STATUS" mode="publish">
		<xsl:variable name="statusLevel" select="@STATUS-LEVEL"/>
		<xsl:variable name="statusLevelUpper" select="@STATUS-LEVEL-UPPER"/>

		<xsl:apply-templates select="STATUS-DETAILS" mode="init"/>

		<table cellpadding="5" cellspacing="0" border="0" class="sb-publish-{$statusLevel}-block">
			<tr>
				<td>
					<img src="{$skinPath}/images/publish_{$statusLevel}.gif" border="0">
						<xsl:attribute name="alt"><xsl:value-of select="LOCALE/@*[name() = $statusLevelUpper]"/></xsl:attribute>
					</img>
				</td>
				<td width="100%">
					<span class="sb-publish-{$statusLevel}-text"><xsl:apply-templates select="@STATUS-TEXT"/></span>
					<xsl:apply-templates select="@SUB-STATUS-TEXT"/>
				</td>
			</tr>
		</table>
	</xsl:template>

	<xsl:template match="STATUS/@SUB-STATUS-TEXT">
		<br/><xsl:value-of select="."/>
		<xsl:apply-templates select="../STATUS-DETAILS" mode="link"/>
	</xsl:template>

	<xsl:template match="STATUS-DETAILS" mode="init">
		<xsl:call-template name="MODAL-FORM">
			<xsl:with-param name="formName">detailedStatusForm</xsl:with-param>
			<xsl:with-param name="formTitle" select="@TITLE"/>
			<xsl:with-param name="additionalFormStyle">width: 750px; height: 370px; display: none;</xsl:with-param>
			<xsl:with-param name="content" select="current()"/>
			<xsl:with-param name="showStatus">0</xsl:with-param>
			<xsl:with-param name="onCloseAction">sbDetailedStatusForm.hide();</xsl:with-param>
		</xsl:call-template>
		<script type="text/javascript" src="/js/detailed_status.js?{$version}.{$build}"></script>
		<script type="text/javascript" language="javascript">
			self.sbDetailedStatusForm = new SbDetailedStatusForm('detailedStatusForm');
			<xsl:apply-templates select="FORM/MESSAGE" mode="init"/>
		</script>
	</xsl:template>

	<xsl:template match="STATUS-DETAILS" mode="link">
		&#160;<a href="#" class="sb-text" onclick="sbDetailedStatusForm.show();"><xsl:value-of select="@LINK"/></a>
	</xsl:template>

	<xsl:template match="STATUS-DETAILS" mode="content">
		<table style="border-collapse: collapse;" border="0" cellpadding="5" cellspacing="0" width="10">
			<tr>
				<td>
					<xsl:apply-templates select="FORM/CONTROL[@NAME='view']" mode="TITLE-LEFT">
						<xsl:with-param name="controlClass">sb-control-input-input</xsl:with-param>
						<xsl:with-param name="titleStyle">padding-right: 5px; vertical-align: middle;</xsl:with-param>
						<xsl:with-param name="controlStyle">width: 100px;</xsl:with-param>
						<xsl:with-param name="onChange">sbDetailedStatusForm.filterMessages(this.value);</xsl:with-param>
					</xsl:apply-templates>
				</td>
			</tr>
		</table>
		<xsl:apply-templates select="FORM"/>
	</xsl:template>

	<xsl:template match="STATUS-DETAILS/FORM">
		<table style="width: 100%;" border="0" cellspacing="1">
			<tr class="sb-gridview-header" style="white-space: nowrap;" align="left">
				<th style="width: 1%; text-align: center;" class="sb-gridview-header"><xsl:value-of select="@NUMBER-COLUMN"/><div style="width:20px; height:0px;"><span></span></div></th>
				<th class="sb-gridview-header" scope="col" style="width: 1%; text-align: center; vertical-align: middle; white-space: nowrap;">
					<xsl:value-of select="@STATUS-COLUMN"/>
					<div style="width:20px; height:0px;"><span></span></div>
				</th>
				<th class="sb-gridview-header" scope="col" style="vertical-align: middle; white-space: nowrap;">
					<xsl:value-of select="@MESSAGE-COLUMN"/>
				</th>
			</tr>
		</table>
		<div style="height: 200px; overflow: auto;">
			<table style="width: 100%;" border="0" cellspacing="1">
				<xsl:apply-templates select="MESSAGE"/>
			</table>
		</div>
		<div style="width:0px; height:10px;"><span></span></div>
		<table style="cursor: pointer; width: 90px;" border="0" cellpadding="0" cellspacing="0" align="right">
			<tr>
				<td>
					<xsl:apply-templates select="CONTROL[@NAME='close']">
						<xsl:with-param name="controlStyle">width: 80%;</xsl:with-param>
						<xsl:with-param name="action">sbDetailedStatusForm.hide();</xsl:with-param>
					</xsl:apply-templates>
				</td>
			</tr>
		</table>
	</xsl:template>

	<xsl:template match="STATUS-DETAILS/FORM/MESSAGE">
		<tr id="detailedStatusFormMessage{position()}">
			<xsl:attribute name="class">
				<xsl:choose>
					<xsl:when test="position() mod 2 = 0">sb-gridtext</xsl:when>
					<xsl:otherwise>sb-gridtext-alter</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
			<td style="width: 1%; text-align: center;"><xsl:value-of select="position()"/><div style="width:20px; height:0px;"><span></span></div></td>
			<td style="text-align: center; padding-left: 4px; padding-right: 4px;">
				<img src="{$skinPath}/icons/{@STATUS-LEVEL}.png" style="border-width: 0px; width: 16px; height: 16px;"/>
			</td>
			<td style="padding-left: 4px; padding-right: 4px;">
				<xsl:value-of select="."/>
				<div style="width:20px; height:0px;"><span></span></div>
			</td>
		</tr>
	</xsl:template>

	<xsl:template match="STATUS-DETAILS/FORM/MESSAGE" mode="init">
		self.document.getElementById('detailedStatusFormMessage<xsl:value-of select="position()"/>').statusLevel = '<xsl:value-of select="@STATUS-LEVEL"/>';
	</xsl:template>

</xsl:stylesheet>