<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="PAGESET-FORM">
	<style>
		.sb-pagetitle { border-bottom: solid 1px #776655; }
	</style>
	<script type="text/javascript" src="/js/Admin/Pagesets.js?{$version}.{$build}"/>
	<script type="text/javascript" language="javascript" src="/js/Wizard/pages.js?{$version}.{$build}"/>
	
	<form name="pagesetForm" id="pagesetForm" method="post" onsubmit="return submitForm();">
		<input type="hidden" id="action" name="action" value="/Admin/Pagesets/Save"/>
		
		<xsl:apply-templates select="PANEL"/>

		<!-- input image needed for work default submit via Enter -->
		<input type="image" style="border-width: 0px; height: 0px; width: 0px;"/>
	</form>

	<table border="0" cellpadding="0" cellspacing="0" width="100%">
		<tr>
			<td align="left" style="padding-left: 5px"><xsl:call-template name="REQUIRED-FIELDS"/></td>
			<td>
				<xsl:call-template name="OK-CANCEL-BUTTONS">
					<xsl:with-param name="okAction">submitForm();</xsl:with-param>
					<xsl:with-param name="cancelAction">document.location.href="<xsl:value-of select="$baseUrl"/>/Admin/Pagesets/List";</xsl:with-param>
				</xsl:call-template>
			</td>
		</tr>
	</table>

</xsl:template>

<xsl:template match="PANEL[@NAME='details']">
	<fieldset class="sb-form-fieldset">
		<legend><xsl:value-of select="@TITLE"/></legend>
		
		<table border="0" width="100%" cellpadding="2" cellspacing="0">
			<tr>
				<td class="sb-formview-alternaterow">
					<xsl:apply-templates select="CONTROL[@NAME='pagesetCode']" mode="TITLE-LEFT">
						<xsl:with-param name="controlClass">sb-control-input-input</xsl:with-param>
						<xsl:with-param name="require">on</xsl:with-param>
						<xsl:with-param name="onChange">sbApplyChangesObject.registerChange();</xsl:with-param>
					</xsl:apply-templates>
				</td>
			</tr>
			<tr>
				<td class="sb-formview-row">
					<xsl:apply-templates select="CONTROL[@NAME='pagesetTitle']" mode="TITLE-LEFT">
						<xsl:with-param name="controlClass">sb-control-input-input</xsl:with-param>
						<xsl:with-param name="require">on</xsl:with-param>
						<xsl:with-param name="onChange">sbApplyChangesObject.registerChange();</xsl:with-param>
					</xsl:apply-templates>
				</td>
			</tr>
		</table>
		
	</fieldset>
	<br/>
</xsl:template>

<xsl:template match="PANEL[@NAME='structure']">
	<fieldset class="sb-form-fieldset">
		<legend><xsl:value-of select="@TITLE"/></legend>
		
		<table border="0" width="100%" style="height: 250px;" cellpadding="0" cellspacing="0">
			<tr>
				<td style="width: 35%; height: 100%;">
					<xsl:apply-templates select="SPECIAL-PAGES"/>
				</td>
				
				<td style="width: 15%;" align="center">
					
					<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="SPECIAL-PAGES/PAGES-TREE/@NAME"/>', '<xsl:value-of select="PAGESET-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:5px;">
								<xsl:call-template name="BUTTON">
									<xsl:with-param name="action">SbPagesSiteRemove('<xsl:value-of select="PAGESET-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 style="width: 35%; height: 100%;">
					<xsl:apply-templates select="PAGESET-STRUCTURE"/>
				</td>
				
				<td style="width: 15%;" align="center">
					<table style="width:100%;" cellpadding="0" cellspacing="0" border="0">
						<tr>
							<td style="font-weight: bold;" align="center">
								<xsl:value-of select="BUTTONS/@PAGE-POSITION-TITLE"/>
							</td>
						</tr>
						<tr>
							<td style="padding-top:10px;">
								<xsl:call-template name="BUTTON">
									<xsl:with-param name="action">SbPagesSiteMoveUp('<xsl:value-of select="PAGESET-STRUCTURE/PAGES-TREE/@NAME"/>');</xsl:with-param>
									<xsl:with-param name="title" select="BUTTONS/@UP"/>
									<xsl:with-param name="id">buttonUp</xsl:with-param>
								</xsl:call-template>
							</td>
						</tr>
						<tr>
							<td style="padding-top:5px;">
								<xsl:call-template name="BUTTON">
									<xsl:with-param name="action">SbPagesSiteMoveDown('<xsl:value-of select="PAGESET-STRUCTURE/PAGES-TREE/@NAME"/>');</xsl:with-param>
									<xsl:with-param name="title" select="BUTTONS/@DOWN"/>
									<xsl:with-param name="id">buttonDown</xsl:with-param>
								</xsl:call-template>
							</td>
						</tr>
						<tr>
							<td style="padding-top:5px;">
								<xsl:call-template name="BUTTON">
									<xsl:with-param name="action">SbPagesSiteMoveLeft('<xsl:value-of select="PAGESET-STRUCTURE/PAGES-TREE/@NAME"/>');</xsl:with-param>
									<xsl:with-param name="title" select="BUTTONS/@LEFT"/>
									<xsl:with-param name="id">buttonLeft</xsl:with-param>
								</xsl:call-template>
							</td>
						</tr>
						<tr>
							<td style="padding-top:5px;">
								<xsl:call-template name="BUTTON">
									<xsl:with-param name="action">SbPagesSiteMoveRight('<xsl:value-of select="PAGESET-STRUCTURE/PAGES-TREE/@NAME"/>');</xsl:with-param>
									<xsl:with-param name="title" select="BUTTONS/@RIGHT"/>
									<xsl:with-param name="id">buttonRight</xsl:with-param>
								</xsl:call-template>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		
		<script type="text/javascript" language="javascript">
			<xsl:comment>
				SbPagesDisableButton('buttonAdd');
				SbPagesDisableButton('buttonRemove');
				SbPagesDisableButton('buttonUp');
				SbPagesDisableButton('buttonDown');
				SbPagesDisableButton('buttonLeft');
				SbPagesDisableButton('buttonRight');
			//</xsl:comment>
		</script>
		
	</fieldset>
	<br/>
</xsl:template>

<xsl:template match="SPECIAL-PAGES">
	<xsl:call-template name="PAGES-TREE-PANEL">
		<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="PAGES-TREE/@NAME"/>');
			}
		</xsl:with-param>
	</xsl:call-template>
</xsl:template>

<xsl:template match="PAGESET-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="../SPECIAL-PAGES/PAGES-TREE/@NAME"/>', '<xsl:value-of select="../SPECIAL-PAGES/PAGES-TREE/@NAME"/>');
				sbApplyChangesObject.registerChange();
				SbPagesUpdateMainCheckBox('<xsl:value-of select="PAGES-TREE/@NAME"/>');
				SbPagesUpdateMainCheckBox('<xsl:value-of select="../PAGESET-STRUCTURE/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:with-param name="onAfterSelect">
			function(nodeId, nodeType) {
				submitFormTemporary();
			}
		</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="../SPECIAL-PAGES/PAGES-TREE/@NAME"/>', '<xsl:value-of select="../SPECIAL-PAGES/PAGES-TREE/@NAME"/>');
			
			pagesetTree = document.getElementById('pageset');
			pagesetTree.isRenamable = false;

			<xsl:if test="PAGES-TREE/@IS-CHANGED = 1">
				sbApplyChangesObject.registerChange();
			</xsl:if>					
		//</xsl:comment>
	</script>
	
</xsl:template>

<xsl:template match="PANEL[@NAME='pageInfo']">
	<fieldset class="sb-form-fieldset">
		<legend><xsl:value-of select="@TITLE"/></legend>
		
		<table border="0" width="100%" cellpadding="2" cellspacing="0">
			<tr>
				<td class="sb-formview-alternaterow">
					<xsl:apply-templates select="CONTROL[@NAME='pageTitle']" mode="TITLE-LEFT">
						<xsl:with-param name="controlClass">sb-control-input-input</xsl:with-param>
						<xsl:with-param name="require">on</xsl:with-param>
						<xsl:with-param name="onChange">sbApplyChangesObject.registerChange();</xsl:with-param>
					</xsl:apply-templates>
					
					<br/>
				</td>
			</tr>
			<tr>
				<td class="sb-formview-row">
					<xsl:apply-templates select="WYSIWYG[@NAME='pageContent']"/>
				</td>
			</tr>
		</table>
	</fieldset>
	<br/>
</xsl:template>

</xsl:stylesheet>