<?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:variable name="blockModuleSettingsFrameId">blockModuleSettingsFrame</xsl:variable>
	<xsl:variable name="blockModuleSettingsDialogId">blockModuleSettings</xsl:variable>

	<xsl:template match="VIEW-CONTENT">		
		<xsl:apply-templates select="BLOCK-MODULE-SETTINGS" />
		<script type="text/javascript" src="/js/Wizard/panel_toogle.js?{$version}.{$build}"></script>
		<script type="text/javascript" src="/js/Wizard/modules_drag_and_drop.js?{$version}.{$build}"></script>
		<script type="text/javascript" src="/js/session.js?{$version}.{$build}"></script>
		<script type="text/javascript" language="javascript">
			<xsl:comment>
			self.sbSession = new SbSession('<xsl:value-of select="/SITEBUILDER-PAGE/PROPERTIES/SESSION/@NAME"/>', '<xsl:value-of select="/SITEBUILDER-PAGE/PROPERTIES/SESSION/@VALUE"/>');
			//</xsl:comment>
		</script>
		<table border="0" cellpadding="0" cellspacing="0" style="height: 100%;width:100%" align="center">
			<tr>
				<td style="vertical-align: top; " align="center">
					<table cellpadding="0" cellspacing="0" border="0" style="height: 100%;width:100%">
						<tr>
							<xsl:call-template name="SITE-MAP-PANEL"/>
							<xsl:call-template name="EDITOR" />
							<xsl:call-template name="MODULE-ICON-LIST-PANEL" />
						</tr>
					</table>
				</td>
			</tr>
		</table>
		
	</xsl:template>

	<xsl:template name="SITE-MAP-PANEL">
		<td valign="top">
			<table style="height:100%;" cellpadding="0" cellspacing="0">
				<tr>
					<td>
						<div id="LeftPanelDiv">
							<xsl:attribute name="style">height: 100%; display: <xsl:choose>
								<xsl:when test="SITE-MAP/@IS-OPENED='yes'">block</xsl:when>
								<xsl:otherwise>none</xsl:otherwise>
							</xsl:choose>;</xsl:attribute>
							<xsl:call-template name="SITE-MAP" />
						</div>
					</td>
                    <td style="height: 100%;" class="sb-edit-panel-hidebackground" id="LeftPanelDiv_Bar">
                        <div id="ButtonHideTree" onclick="toggleLeftPanel('{$skinPath}/images/right.gif', '{$skinPath}/images/left.gif');" align="center" style="width: 21px; height: 100%; border: 0px solid #7D7D7D; float: left; cursor: hand; cursor: pointer;">
                            <img id="LeftPanelDiv_bullet" class="sb-edit-panel-arrow" style="border-width:0px;"><xsl:attribute name="src"><xsl:value-of select="$skinPath"/>/images/<xsl:choose>
											<xsl:when test="SITE-MAP/@IS-OPENED='yes'">left</xsl:when>
											<xsl:otherwise>right</xsl:otherwise>
										</xsl:choose>.gif</xsl:attribute></img><br />
                            <img id="LeftPanelDiv_Text" style="border-width:0px;">
								<xsl:attribute name="src">/localizedimage.php?text=<xsl:choose>
											<xsl:when test="SITE-MAP/@IS-OPENED='yes'"><xsl:value-of select="/SITEBUILDER-PAGE/JS-LOCALE/HIDE-SITE-MAP" disable-output-escaping="yes"/></xsl:when>
											<xsl:otherwise><xsl:value-of select="/SITEBUILDER-PAGE/JS-LOCALE/SHOW-SITE-MAP" disable-output-escaping="yes"/></xsl:otherwise>
										</xsl:choose></xsl:attribute>
							</img>
                            <!--<img id="LeftPanelDiv_border" src="{$skinPath}/{$skinPath}/images/leftpanel_border_hide.png" style="border-width:0px;" />-->
                        </div>
                    </td>
				</tr>
			</table>
			<input type="hidden" id="LeftPanelDiv_hidden">
				<xsl:attribute name="value">
					<xsl:choose>
						<xsl:when test="SITE-MAP/@IS-OPENED='yes'">false</xsl:when>
						<xsl:otherwise>true</xsl:otherwise>
					</xsl:choose>
				</xsl:attribute>
			</input>
		</td>
	</xsl:template>

	
	<xsl:template name="SITE-MAP">
		<table style="height:100%"  class="sb-edit-panel"  width="200"  border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td valign="top">
		<table border="0" cellpadding="8" cellspacing="8" width="100%" height="95%" style="table-layout: fixed;">
		    <tr valign="top">
		        <td>
		            <b class="sb-text">
		            	<xsl:value-of select="SITE-MAP/@TITLE"/>
		            </b>
		        </td>
		    </tr>
			<xsl:call-template name="SITE-MAP-TREE" />
			<xsl:call-template name="SITE-MAP-FORM" />
		</table>
				</td>
			</tr>
		</table>
	</xsl:template>
	
	<xsl:template name="SITE-MAP-TREE">
		<script src="/js/Wizard/Edit.js?{$version}.{$build}" language="javascript"></script>
		<script type="text/javascript" language="javascript">
			<xsl:comment>
			var prevPage = '<xsl:value-of select="@PAGE"/>';
			var action = '<xsl:value-of select="@ACTION"/>';
			//</xsl:comment>
		</script>
		<tr class="sb-edit-panel-block" style="height: 100%;">
			<td class="sb-edit-panel-block-border" id="siteMapTd" valign="top" width="183">
				<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%" style="table-layout: fixed;">
					<tr><td valign="top">
						<xsl:apply-templates select="SITE-MAP/PAGES-TREE" >
							<xsl:with-param name="onSelect">onNodeSelect</xsl:with-param>
						</xsl:apply-templates>
					</td></tr>
				</table>
			</td>
		</tr>
		<script type="text/javascript" language="javascript">
			<xsl:apply-templates select="SITE-MAP/PAGES-TREE/PAGES-TREE-PAGE" mode="SBPageRegistration"/>
		</script>
	</xsl:template>
	
	<xsl:template match="PAGES-TREE-PAGE" mode="SBPageRegistration">
		registerSBPage('<xsl:value-of select="@ID"/>', '<xsl:value-of select="@JS-TITLE"/>', '<xsl:value-of select="@JS-KEYWORDS"/>', '<xsl:value-of select="@JS-DESCRIPTION"/>');
		<xsl:apply-templates select="PAGES-TREE-PAGE" mode="SBPageRegistration"/>
	</xsl:template>
	
	<xsl:template name="SITE-MAP-FORM">
	    <tr valign="top" id="PageSettingsTR" height="160px" class="sb-edit-panel-block">
	        <td class="sb-edit-panel-block-border" width="170px">
	        	<script>
					function validateForm() {
						if ( validateField('SB_Validator.notEmpty', 'pageTitle', 'EMPTY-PAGE-TITLE') ) {
							result = true;
						} else {
							result = false;
						}
						
						return result;
	        		}
	        		sbNavigationObject.registerOnSubmitFunction(validateForm);
	        	</script>
	        
	        
	            <table border="0" cellpadding="0" cellspacing="0" width="100%">
	                <tr>
	                    <td>
	                        <span class="sb-text"><xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/PAGE-TITLE"/></span><span style="color:Red; width: 10px;">*</span>
	                        <br />
	                        <input id="pageTitle" name="pageTitle" type="text" maxlength="255" class="sb-text" style="border-color:#999EA1;border-width:1px;border-style:Solid;width:90%;" onchange="pageDataChangeRegister();self.sbApplyChangesObject.registerChange();">
	                        	<xsl:attribute name="value"><xsl:value-of select="SITE-MAP/PAGE-INFO/@TITLE"/></xsl:attribute>
	                        </input>
	                       
	                    </td>
	                </tr>
	                <tr>
	                    <td>
	                        <span class="sb-text"><xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/PAGE-KEYWORDS"/></span><br />
	                        <textarea id="pageKeywords" name="pageKeywords" rows="2" cols="20" class="sb-text" style="border-color:#999EA1;border-width:1px;border-style:Solid;width:100%;" onchange="pageDataChangeRegister();self.sbApplyChangesObject.registerChange();">
	                        	<xsl:value-of select="SITE-MAP/PAGE-INFO/@KEYWORDS"/>
	                        </textarea>
	                    </td>
	                </tr>
	                <tr>
	                    <td>
	                        <span class="sb-text"><xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/PAGE-DESCRIPTION"/></span><br />
	                        <textarea id="pageDescription" name="pageDescription" rows="2" cols="20" class="sb-text" style="border-color:#999EA1;border-width:1px;border-style:Solid;width:100%;" onchange="pageDataChangeRegister();self.sbApplyChangesObject.registerChange();">
	                        	<xsl:value-of select="SITE-MAP/PAGE-INFO/@DESCRIPTION"/>
	                        </textarea>
	                    </td>
	                </tr>
	                <tr>
	                    <td>
	                        <input type="checkbox" name="pageShowInNavigation" onchange="pageDataChangeRegister();self.sbApplyChangesObject.registerChange();">
	                        	<xsl:if test="SITE-MAP/PAGE-INFO/@SHOW-IN-NAVIGATION = 1">
	                        		<xsl:attribute name="checked">checked</xsl:attribute>
	                        	</xsl:if>
	                        </input>
							<span class="sb-text"><xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/PAGE-SHOW-IN-NAVIGATION"/></span>
	                    </td>
	                </tr>
	                <tr>
	                    <td>
	                    	<br /><span style="color:Red; width: 10px;">* &#160;</span><span class="sb-text"><xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/PAGE-REQUIRE-FIELDS"/></span><br />
	                    </td>
	                </tr>
	            </table>
	            <input type="hidden" name="page" id="page" >
	            	<xsl:attribute name="value"><xsl:value-of select="SITE-MAP/PAGE-INFO/@ID"/></xsl:attribute>
	            </input>
	        </td>
	    </tr>	
	</xsl:template>

	<xsl:template name="EDITOR">
		<td  valign="top" style="width: 100%; height: 100%">
			<xsl:apply-templates select="WYSIWYG|MODULE-EDITOR"/>
		</td>
	</xsl:template>

	<xsl:template name="MODULE-ICON-LIST-PANEL">
		<xsl:if test="MODULE-ICON-LIST">
			<td valign="top" class="sb-edit-panel">
				<table style="height:100%;" cellpadding="0" cellspacing="0">
					<tr>
	                    <td style="height: 100%;" class="sb-edit-panel-showbackground" id="RightPanelDiv_Bar">
	                        <div id="ButtonHideTree" onclick="toggleRightPanel('{$skinPath}/images/right.gif', '{$skinPath}/images/left.gif');" align="center" style="width: 21px; height: 100%; border: 0px solid #7D7D7D; float: left; cursor: hand; cursor: pointer;">
	                            <img id="RightPanelDiv_bullet" class="sb-edit-panel-arrow" style="border-width:0px;"><xsl:attribute name="src"><xsl:value-of select="$skinPath"/>/images/<xsl:choose>
											<xsl:when test="MODULE-ICON-LIST/@IS-OPENED='yes'">right</xsl:when>
											<xsl:otherwise>left</xsl:otherwise>
										</xsl:choose>.gif</xsl:attribute></img><br />
	                            <img id="RightPanelDiv_Text" style="border-width:0px;">
									<xsl:attribute name="src">/localizedimage.php?text=<xsl:choose>
											<xsl:when test="MODULE-ICON-LIST/@IS-OPENED='yes'"><xsl:value-of select="/SITEBUILDER-PAGE/JS-LOCALE/HIDE-AVAILABLE-MODULES" disable-output-escaping="yes"/></xsl:when>
											<xsl:otherwise><xsl:value-of select="/SITEBUILDER-PAGE/JS-LOCALE/SHOW-AVAILABLE-MODULES" disable-output-escaping="yes"/></xsl:otherwise>
										</xsl:choose></xsl:attribute>
								</img>
	                            <!--<img id="RightPanelDiv_border" src="{$skinPath}/{$skinPath}/images/leftpanel_border_hide.png" style="border-width:0px;" />-->
	                        </div>
	                    </td>
						<td>
							<div id="RightPanelDiv">
								<xsl:attribute name="style">height: 100%; display: <xsl:choose>
									<xsl:when test="MODULE-ICON-LIST/@IS-OPENED='yes'">block</xsl:when>
									<xsl:otherwise>none</xsl:otherwise>
								</xsl:choose>;</xsl:attribute>
								<xsl:call-template name="MODULE-ICON-LIST" />
							</div>
						</td>
					</tr>
				</table>
				<input type="hidden" id="RightPanelDiv_hidden">
					<xsl:attribute name="value">
						<xsl:choose>
							<xsl:when test="MODULE-ICON-LIST/@IS-OPENED='yes'">false</xsl:when>
							<xsl:otherwise>true</xsl:otherwise>
						</xsl:choose>
					</xsl:attribute>
				</input>
			</td>
		</xsl:if>
	</xsl:template>

	<xsl:template name="MODULE-ICON-LIST">
		<table cellpadding="0" cellspacing="0" width="135" border="0" style="height:100%;">
			<tr>
				<td valign="top">
					<table style="height:100%; width:100%"  border="0">
    					<tr align="center" >
        					<td style="padding-top:10px; height:30px">
					            <b class="sb-text">
					            	<xsl:value-of select="MODULE-ICON-LIST/@TITLE"/>
					            </b><br />
            					<img src="{$skinPath}/images/line.gif" style="border-width:0px;" />
        					</td>
    					</tr>
    					<tr align="center">
        					<td valign="top" id="ModulePanel_Td">
        						<div id="ModulePanel_Div" style="display: none; overflow: auto; white-space: nowrap; user-select: none; -moz-user-select: none;">
        							<xsl:apply-templates select="MODULE-ICON-LIST/MODULE-ICON" />
        						</div>
				        	</td>
				    	</tr>
					</table>
				</td>
			</tr>
		</table>
		<script>initModulePanel();</script>	
		
	</xsl:template>

	<xsl:template match="MODULE-ICON">		
		<xsl:variable name="MODULENAME">
			<xsl:text>module_</xsl:text><xsl:value-of select="@NAME"/>
		</xsl:variable>	
			
			<span style="vertical-align:middle;" class="sb-tree-node-icon">
				<xsl:attribute name="title"><xsl:value-of select="@NAME"/></xsl:attribute> 
				<span>									
					<table border="0">
						<tr align="center">
	  						<td>
								<div>
									<xsl:attribute name="id"><xsl:value-of select="$MODULENAME"/></xsl:attribute>				
									<img border="0" width=' 32px ' height=' 32px ' >
										<xsl:attribute name="src"><xsl:value-of select="@SRC"/></xsl:attribute>
									</img>
								</div>
		    				</td>
						</tr>
						<tr align="center">
							<td >
								<span class="sb-text"><xsl:value-of select="@NAME"/></span>
	    					</td>
						</tr>
					</table>
				</span>
			</span>
	       <table border="0">
	            <tr align="center">
	                <td>
	                    <img border="0" src='{$skinPath}/images/line.gif'  width=' 65px ' height=' 1px ' /></td>
	            </tr>
	            <tr align="center">
	                <td >
	                    <span class="sb-text"></span>
	                </td>
	            </tr>
	        </table>		
		<script language="JavaScript">
			<xsl:comment>
			var module = document.getElementById('<xsl:value-of select="$MODULENAME"/>');
			makeDraggable(module, '<xsl:value-of select="@CODE"/>');
			//</xsl:comment>
		</script>
		
	</xsl:template>

	<xsl:template match="MODULE-EDITOR">
		<xsl:apply-templates select="../MODULE-TITLE" />
		<table class="sb-formtable" cellspacing="0" border="0" style="border-collapse:collapse;height: 99%; width: 100%;">
			<tr>
				<td valign="top">
					<xsl:apply-templates />
				</td>
			</tr>
		</table>
	</xsl:template>
	
	<xsl:template match="MODULE-TITLE">
		<div class="sb-edit-modulename">
			<img style="border-width:0px;" >
				<xsl:attribute name="src"><xsl:value-of select="@ICON"/></xsl:attribute>
			</img>
			<span class="sb-page-title" style="padding-left: 9px;"><xsl:value-of select="@NAME"/></span>
		</div>
	</xsl:template>
	
	<xsl:template match="BLOCK-MODULE-SETTINGS">
		<xsl:call-template name="MODAL-FORM">
			<xsl:with-param name="formName" select="$blockModuleSettingsDialogId"/>
			<xsl:with-param name="additionalFormStyle">margin:0px; padding:0px; height:520px; width:640px; display:none;</xsl:with-param>
			<xsl:with-param name="content" select="current()"/>
			<xsl:with-param name="onCloseAction">top.sbBlockModuleEditorDialogObject.hide();</xsl:with-param>
			<xsl:with-param name="showStatus">0</xsl:with-param>
		</xsl:call-template>
		<script type="text/javascript" src="/js/Wizard/BlockModuleEditorDialog.js?{$version}.{$build}"></script>
		<script type="text/javascript" language="javascript">
			<xsl:comment>
				top.sbBlockModuleEditorDialogObject = new SbBlockModuleEditorDialog('<xsl:value-of select="$blockModuleSettingsDialogId"/>', '<xsl:value-of select="$blockModuleSettingsFrameId"/>', '<xsl:value-of select="$blockModuleSettingsFrameId"/>_holder');
			//</xsl:comment>
		</script>
	</xsl:template>

	<xsl:template match="BLOCK-MODULE-SETTINGS" mode="content">
		<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
			<tr>
				<td id="{$blockModuleSettingsFrameId}_holder">
					<!--<iframe id="{$blockModuleSettingsFrameId}" frameborder="0" allowtransparency="true" style="width:627px;height:486px;overflow:hidden;margin:0px;padding:0px;" scrolling="no" src="/blank.html"></iframe>-->
				</td>
				<!--
				var blockModuleSettingsDialog = document.getElementById('blockModuleSettings');
				this.style.height = blockModuleSettingsDialog.style.height = this.contentWindow.document.body.scrollHeight + this.contentWindow.document.body.scrollTop + 25 + 'px';				
				this.style.width = blockModuleSettingsDialog.style.width = this.contentWindow.document.body.scrollWidth  + 'px';-->
			</tr>
		</table>
	</xsl:template>
	
	<xsl:template name="MODULE-MODAL-FORM">
		<xsl:call-template name="MODAL-FORM">
			<xsl:with-param name="formName">modalForm</xsl:with-param>
			<xsl:with-param name="formTitle" select="/SITEBUILDER-PAGE/LOCALE/FORM-TITLE"/>
			<xsl:with-param name="closeHint" select="@CLOSE-HINT"/>
			<xsl:with-param name="helpHint" select="/SITEBUILDER-PAGE/LOCALE/HELP-HINT"/>
			<xsl:with-param name="additionalFormStyle">width: 750px; height: 550px;</xsl:with-param>
			<xsl:with-param name="content" select="current()" />
			<xsl:with-param name="onCloseAction">sbNavigationObject.go();</xsl:with-param>
		</xsl:call-template>
	</xsl:template>

	<xsl:template name="MODULE-MODAL-FORM-OK-CANCEL-BUTTONS">
		<xsl:call-template name="OK-CANCEL-BUTTONS">
			<xsl:with-param name="okAction">wizardFormSubmit();</xsl:with-param>
			<xsl:with-param name="cancelAction">document.location.href='<xsl:value-of select="/SITEBUILDER-PAGE/APPLY-CHANGES/@VIEW-URL"/>';</xsl:with-param>
		</xsl:call-template>
	</xsl:template>
		
</xsl:stylesheet>
