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

<xsl:variable name="skinPath"><xsl:value-of select="/SITEBUILDER-PAGE/PROPERTIES/SKIN-PATH" disable-output-escaping="yes"/></xsl:variable>
<xsl:strip-space elements="*"/>
<xsl:output method="html" indent="yes" encoding="utf-8"/>

<xsl:template match="SITEBUILDER-PAGE">
	<html>
		<body>
			<xsl:apply-templates select="VIEW-CONTENT/BLOCK-MODULE" mode="preview"/>
		</body>
	</html>
</xsl:template>

<xsl:template match="BLOCK-MODULE[@NEW-INSTANCE != 0]" mode="preview">
	<input id="newInstnaceId" value="{@INSTANCE-ID}" type="hidden"/>
</xsl:template>

<xsl:template match="BLOCK-MODULE[@NEW-INSTANCE = 0]" mode="preview">
	<head>
		<link href="/skins/style_ext.css" type="text/css" rel="stylesheet" />
		<script type="text/javascript" language="javascript" src="/wysiwyg/BlockModule.js?{$version}.{$build}"></script>
		<script type="text/javascript" language="javascript">
			window.blockModule=new BlockModule(window.parent.document.getElementById('moduleInstance_<xsl:value-of select="@INSTANCE-ID"/>'), '<xsl:value-of select="@MODULE-NAME"/>');
		</script>
	</head>
	<body style="margin:0px;" onload="window.blockModule.resizeMainFrame();">
		<input type="hidden" id="viewLink" value="{@PROPERTIES-LINK}"/>
		<input type="hidden" id="formTitle" value="{@MODULE-NAME}"/>
		<table style="margin: 0px; padding: 0px; border: 1px solid AliceBlue; width: 100%; border-collapse: collapse;" cellspacing="0" cellpadding="0">
			<tr style="height:21px; background-image: url({$skinPath}/images/toolbar_bg.gif)">
				<td style="height: 21px; width: 100%">
					<b class="sb-text" style="margin-left:10px; white-space:nowrap;">
						<xsl:value-of select="@MODULE-NAME"/>
					</b>
				</td>
				
				<xsl:apply-templates select="NAVIGATION-LIST"/>
				
				<!--
				<xsl:if test="@PROPERTIES-LINK">
				<td class="sb-text" style="padding-right: 10px;">
					<div style="cursor:pointer;text-decoration:underline;" id="props" onclick="window.blockModule.showSettingsDialog();">
						<xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/PROPERTIES"/>
					</div>
				</td>
				</xsl:if>
				-->
				<td style="width: 16px;">
					<img border="0" id="close" style="cursor:pointer;" onclick="window.blockModule.removeModule();">
						<xsl:attribute name="src">
							<xsl:value-of select="$skinPath"/>
							<xsl:text>/images/exit_icon_over.gif</xsl:text>
						</xsl:attribute>
					</img>
				</td>
			</tr>
			<tr>
				<td id="previewHolder">
					<xsl:attribute name="colspan">
						<xsl:value-of select="count(NAVIGATION-LIST/ITEM)+2"/>
					</xsl:attribute>
					<xsl:apply-templates select="BLOCK-MODULE-PREVIEW"/>
				</td>
			</tr>
		</table>
	</body>
</xsl:template>

<xsl:template match="BLOCK-MODULE/NAVIGATION-LIST/ITEM">
<td class="sb-text" style="padding-right: 10px; white-space:nowrap;">
	<div style="cursor:pointer;" name="props" onclick="window.blockModule.showSettingsDialog('{@URL}'); return false;">
		<xsl:attribute name="id">props<xsl:value-of select="position()"/></xsl:attribute>
		<xsl:value-of select="@TITLE"/>
	</div>
</td>
</xsl:template>

<xsl:template match="BLOCK-MODULE-PREVIEW">
	<iframe frameborder="0" allowtransparency="true" style="width:100%;height:100%;overflow:auto;margin:0px;padding:0px;" scrolling="no" src="{@SOURCE}" id="preview" onload="window.blockModule.disableFormsElements();window.blockModule.resizePreviewFrame();"></iframe>
</xsl:template>
	
</xsl:stylesheet>