<?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="VIEW-CONTENT">
		<script type="text/javascript" language="javascript" src="/js/Wizard/pages.js?{$version}.{$build}"/>
		<table border="0" cellpadding="10" cellspacing="0" style="height:100%; width:100%; vertical-align: top;" align="left" class="SB_Pages_Form">
			<tr>
				<td valign="top" style="width: 30%;">
					<xsl:apply-templates select="PAGESET-LIST"/>
				</td>
				<td valign="top" style="width: 25%;">
					<table cellpadding="0" cellspacing="0" border="0" style="height:100%; width:100%;">
						<tr valign="top">
							<td style="height:100%;">
								<table style="height:100%; width:100%;" cellpadding="0" cellspacing="0" border="0">
									<tr>
										<td style="height: 50%; width: 100%;" valign="top" id="{PAGESET-CONTENT/PAGES-TREE/@NAME}PanelPlace">
											<xsl:apply-templates select="PAGESET-CONTENT"/>
										</td>
									</tr>
									<tr>
										<td style="height: 50%; width: 100%;" valign="top" id="{SPECIAL-PAGES/PAGES-TREE/@NAME}PanelPlace">
											<xsl:apply-templates select="SPECIAL-PAGES"/>
										</td>
									</tr>
									<tr>
										<td style="height: 0%; width: 100%;" valign="top" id="EmptyPanelPlace"></td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</td>
				<td style="width: 10%; vertical-align: middle;">
					<table style="width:100%;" cellpadding="0" cellspacing="0" border="0">
						<tr>
							<td>
								<xsl:call-template name="BUTTON">
									<xsl:with-param name="action">SbPagesSiteAdd('<xsl:value-of select="PAGESET-CONTENT/PAGES-TREE/@NAME"/>', '<xsl:value-of select="SITE-STRUCTURE/PAGES-TREE/@NAME"/>'); SbPagesSiteAdd('<xsl:value-of select="SPECIAL-PAGES/PAGES-TREE/@NAME"/>', '<xsl:value-of select="SITE-STRUCTURE/PAGES-TREE/@NAME"/>');</xsl:with-param>
									<xsl:with-param name="title" select="BUTTONS/@ADD"/>
									<xsl:with-param name="id">buttonAdd</xsl:with-param>
								</xsl:call-template>
							</td>
						</tr>
						<tr>
							<td style="padding-top:15px;">
								<xsl:call-template name="BUTTON">
									<xsl:with-param name="action">SbPagesSiteRemove('<xsl:value-of select="SITE-STRUCTURE/PAGES-TREE/@NAME"/>');</xsl:with-param>
									<xsl:with-param name="title" select="BUTTONS/@REMOVE"/>
									<xsl:with-param name="id">buttonRemove</xsl:with-param>
								</xsl:call-template>
							</td>
						</tr>
					</table>
				</td>
				<td valign="top" style="width: 25%;">
					<xsl:apply-templates select="SITE-STRUCTURE"/>
				</td>
				<td valign="top" style="width: 10%;">
					<table style="height:100%; width:100%" cellpadding="0" cellspacing="0" border="0">
						<tr>
							<td style="width: 100%; vertical-align: top;">
								<table style="width:100%;" cellpadding="0" cellspacing="0" border="0">
									<tr>
										<td align="left" style="font-weight: bold;">
											<xsl:value-of select="SITE-STRUCTURE/BUTTONS/@TITLE"/>
										</td>
									</tr>
									<tr>
										<td style="padding-top:15px;">
											<xsl:call-template name="BUTTON">
												<xsl:with-param name="action">SbPagesSiteMoveUp('<xsl:value-of select="SITE-STRUCTURE/PAGES-TREE/@NAME"/>');</xsl:with-param>
												<xsl:with-param name="title" select="SITE-STRUCTURE/BUTTONS/@UP"/>
												<xsl:with-param name="id">buttonUp</xsl:with-param>
											</xsl:call-template>
										</td>
									</tr>
									<tr>
										<td style="padding-top:15px;">
											<xsl:call-template name="BUTTON">
												<xsl:with-param name="action">SbPagesSiteMoveDown('<xsl:value-of select="SITE-STRUCTURE/PAGES-TREE/@NAME"/>');</xsl:with-param>
												<xsl:with-param name="title" select="SITE-STRUCTURE/BUTTONS/@DOWN"/>
												<xsl:with-param name="id">buttonDown</xsl:with-param>
											</xsl:call-template>
										</td>
									</tr>
									<tr>
										<td style="padding-top:15px;">
											<xsl:call-template name="BUTTON">
												<xsl:with-param name="action">SbPagesSiteMoveLeft('<xsl:value-of select="SITE-STRUCTURE/PAGES-TREE/@NAME"/>');</xsl:with-param>
												<xsl:with-param name="title" select="SITE-STRUCTURE/BUTTONS/@LEFT"/>
												<xsl:with-param name="id">buttonLeft</xsl:with-param>
											</xsl:call-template>
										</td>
									</tr>
									<tr>
										<td style="padding-top:15px;">
											<xsl:call-template name="BUTTON">
												<xsl:with-param name="action">SbPagesSiteMoveRight('<xsl:value-of select="SITE-STRUCTURE/PAGES-TREE/@NAME"/>');</xsl:with-param>
												<xsl:with-param name="title" select="SITE-STRUCTURE/BUTTONS/@RIGHT"/>
												<xsl:with-param name="id">buttonRight</xsl:with-param>
											</xsl:call-template>
										</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td style="height: 50%; width: 100%; vertical-align: bottom;">
								<xsl:call-template name="BUTTON">
									<xsl:with-param name="action">SbPagesSiteRename('<xsl:value-of select="SITE-STRUCTURE/PAGES-TREE/@NAME"/>');</xsl:with-param>
									<xsl:with-param name="title" select="SITE-STRUCTURE/BUTTONS/@RENAME"/>
									<xsl:with-param name="id">buttonRename</xsl:with-param>
								</xsl:call-template>
							</td>
						</tr>
					</table>
<!-- abelyaev@: for PAGES-TREE debugging
<div id="SbLogs" style="width:100%; height:100%; overflow:auto; vertical-align:top; border:solid 1px #000000">Logs:</div>
<script type="text/javascript" language="javascript">
	<xsl:comment>
		SbInitLogging();
	//</xsl:comment>
</script>
-->
				</td>
			</tr>
		</table>
		<script type="text/javascript" language="javascript">
			<xsl:comment>
				SbPagesDisableButton('buttonAdd');
				SbPagesDisableButton('buttonRemove');
				SbPagesDisableButton('buttonUp');
				SbPagesDisableButton('buttonDown');
				SbPagesDisableButton('buttonLeft');
				SbPagesDisableButton('buttonRight');
				SbPagesDisableButton('buttonRename');
			//</xsl:comment>
		</script>
	</xsl:template>

<xsl:template match="PAGESET-CONTENT">
	<xsl:call-template name="PAGES-TREE-PANEL">
		<xsl:with-param name="isSwitchable">true</xsl:with-param>
		<xsl:with-param name="onToggle">SbTreeOnPanelToggle('<xsl:value-of select="PAGES-TREE/@NAME"/>Panel', '<xsl:value-of select="../SPECIAL-PAGES/PAGES-TREE/@NAME"/>Panel');</xsl:with-param>
		<xsl:with-param name="onCheck">
			function() {
				SbPagesUpdateMainCheckBox('<xsl:value-of select="PAGES-TREE/@NAME"/>');
				SbUpdateAddButton('<xsl:value-of select="PAGES-TREE/@NAME"/>', '<xsl:value-of select="../SPECIAL-PAGES/PAGES-TREE/@NAME"/>');
			}
		</xsl:with-param>
	</xsl:call-template>
</xsl:template>

<xsl:template match="SPECIAL-PAGES">
	<xsl:call-template name="PAGES-TREE-PANEL">
		<xsl:with-param name="isSwitchable">true</xsl:with-param>
		<xsl:with-param name="onToggle">SbTreeOnPanelToggle('<xsl:value-of select="PAGES-TREE/@NAME"/>Panel', '<xsl:value-of select="../PAGESET-CONTENT/PAGES-TREE/@NAME"/>Panel');</xsl:with-param>
		<xsl:with-param name="onCheck">
			function() {
				SbPagesUpdateMainCheckBox('<xsl:value-of select="PAGES-TREE/@NAME"/>');
				SbUpdateAddButton('<xsl:value-of select="../PAGESET-CONTENT/PAGES-TREE/@NAME"/>', '<xsl:value-of select="PAGES-TREE/@NAME"/>');
			}
		</xsl:with-param>
	</xsl:call-template>
</xsl:template>

<xsl:template match="SITE-STRUCTURE">
	<xsl:call-template name="PAGES-TREE-PANEL">
		<xsl:with-param name="onChange">
			function() {
				SbUpdatePagesStates('<xsl:value-of select="PAGES-TREE/@NAME"/>', '<xsl:value-of select="../PAGESET-CONTENT/PAGES-TREE/@NAME"/>', '<xsl:value-of select="../SPECIAL-PAGES/PAGES-TREE/@NAME"/>');
				top.sbApplyChangesObject.registerChange();
				SbPagesUpdateMainCheckBox('<xsl:value-of select="PAGES-TREE/@NAME"/>');
				SbPagesUpdateMainCheckBox('<xsl:value-of select="../PAGESET-CONTENT/PAGES-TREE/@NAME"/>');
				SbPagesUpdateMainCheckBox('<xsl:value-of select="../SPECIAL-PAGES/PAGES-TREE/@NAME"/>');
				SbPagesSiteButtonsUpdate('<xsl:value-of select="PAGES-TREE/@NAME"/>');
			}
		</xsl:with-param>
		<xsl:with-param name="onCheck">
			function() {
				SbPagesSiteButtonsUpdate('<xsl:value-of select="PAGES-TREE/@NAME"/>');
			}
		</xsl:with-param>
	</xsl:call-template>
	<script type="text/javascript" language="javascript">
		<xsl:comment>
			SbUpdatePagesStates('<xsl:value-of select="PAGES-TREE/@NAME"/>', '<xsl:value-of select="../PAGESET-CONTENT/PAGES-TREE/@NAME"/>', '<xsl:value-of select="../SPECIAL-PAGES/PAGES-TREE/@NAME"/>');
			sbNavigationObject.registerOnSubmitFunction(
				function () {
					sbNavigationObject.addHidden('sbSiteStructure', SbGetTreeXml('<xsl:value-of select="PAGES-TREE/@NAME"/>'));
				}
			);
		//</xsl:comment>
	</script>
</xsl:template>

<xsl:template match="PAGESET-LIST">
	<table cellpadding="0" cellspacing="0" border="0" class="PagesetsMenu">
		<tr>
			<td class="SB_Pages_Panel_PageSets_Header">
				<table cellpadding="0" cellspacing="0" border="0" style="width:100%; height:100%;">
					<tr>
						<td align="left" style="font-weight: bold;"><xsl:value-of select="@TITLE"/></td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td valign="top">
				<xsl:apply-templates select="PAGESET-ITEM"/>
			</td>
		</tr>
	</table>
</xsl:template>

<xsl:template match="PAGESET-ITEM">
	<table cellspacing="0" cellpadding="0" border="0" class="PagesetsMenuItem">
		<xsl:call-template name="PAGESET-SOURCE"/>
	</table>
</xsl:template>

<xsl:template match="PAGESET-ITEM[@SELECTED='true']">
	<table cellspacing="0" cellpadding="0" border="0" class="SB_Pages_PageSet_Selected">
		<xsl:call-template name="PAGESET-SOURCE"/>
	</table>
</xsl:template>

<xsl:template name="PAGESET-SOURCE">
	<xsl:attribute name="onclick">sbNavigationObject.setViewParam('selectedPagesetId', '<xsl:value-of select="@ID"/>'); return sbNavigationObject.go();</xsl:attribute>
	<tr>
		<td style="padding-left:10px; padding-right:5px;">
			<img src="{$skinPath}/images/pages_arrow.gif"/>
		</td>
		<td align="left" style="width: 100%;"><xsl:value-of select="@NAME"/></td>
	</tr>
</xsl:template>

</xsl:stylesheet>