<?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>
			<script type="text/javascript" language="javascript" src="/wysiwyg/BlockModule.js"></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="@PROPERTIES-LINK"/>','<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%">
						<span style="margin-left:10px; color: #000000; font-family: Tahoma,Arial,Helvetica,sans-serif; font-size: 11px; font-weight:bold;">				
							<xsl:value-of select="@MODULE-NAME"/>
						</span>
					</td>
					<xsl:if test="@PROPERTIES-LINK">
					<td style="padding-right: 10px; font-family: Tahoma,Arial,Helvetica,sans-serif; font-size: 11px;">
						<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 colspan="3" id="previewHolder">
						<xsl:apply-templates match="BLOCK-MODULE-PREVIEW"/>
					</td>
				</tr>
			</table>
		</body>
	</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>