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

<xsl:template match="VIEW-CONTENT">
	<style>
			.sb-formtableheader-th { background-color: #ffffff; }
			.sb-page { padding-top: 0; }
	</style>

<xsl:apply-templates select="/SITEBUILDER-PAGE/STATUS" mode="admin"/>

<script type="text/javascript" src="/js/Admin/Plans.js?{$version}.{$build}"/>

<form name="multiForm" method="POST" action="{$baseUrl}/Admin/Plan/Form" onsubmit="submitForm(); return false;">

	<!-- input image needed for work default submit via Enter -->
	<input type="image" style="border-width: 0px; height: 0px; width: 0px;"/>
	
	<input type="hidden" name="tab" value="general"/>	
	<input type="hidden" name="pageNum"   value=""/>
	<input type="hidden" name="pageSize"  value=""/>
	<input type="hidden" name="orderBy"   value=""/>
	<input type="hidden" name="orderType" value=""/>
	
	<xsl:apply-templates />
</form>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr>
		<td align="left" style="padding-left: 35px"><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.forms.multiForm.action = '<xsl:value-of select="$baseUrl"/>/Admin/Plan/Cancel';document.forms.multiForm.submit();</xsl:with-param>
			</xsl:call-template>
		</td>
	</tr>
</table>
</xsl:template>

<xsl:template match="OBJECT[@TYPE='PLAN']">
<table border="0" width="100%" cellpadding="2" cellspacing="0">
	<tr>
		<td class="sb-formview-alternaterow">
			<xsl:apply-templates select="CONTROL[@NAME='name']" mode="PLAN">
				<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">self.sbApplyChangesObject.registerChange();</xsl:with-param>
			</xsl:apply-templates>
		</td>
	</tr>
	<tr>
		<td class="sb-formview-row">
			<xsl:apply-templates select="CONTROL[@NAME='description']" mode="PLAN">
				<xsl:with-param name="controlClass">sb-control-input-input</xsl:with-param>
				<xsl:with-param name="onChange">self.sbApplyChangesObject.registerChange();</xsl:with-param>
			</xsl:apply-templates>
		</td>
	</tr>
	<tr class="sb-formview-bottomseparator">
		<td>&#160;</td>
	</tr>
	<tr>
		<td class="sb-formview-alternaterow">
			<xsl:apply-templates select="CONTROL[@NAME='maxPages']" mode="PLAN">
				<xsl:with-param name="controlClass">sb-control-input-input</xsl:with-param>
				<xsl:with-param name="checkBox">yes</xsl:with-param>
				<xsl:with-param name="onChange">self.sbApplyChangesObject.registerChange();</xsl:with-param>
			</xsl:apply-templates>
		</td>
	</tr>
	<tr>
		<td class="sb-formview-row">
			<xsl:apply-templates select="CONTROL[@NAME='maxRootPages']" mode="PLAN">
				<xsl:with-param name="controlClass">sb-control-input-input</xsl:with-param>
				<xsl:with-param name="checkBox">yes</xsl:with-param>
				<xsl:with-param name="onChange">self.sbApplyChangesObject.registerChange();</xsl:with-param>
			</xsl:apply-templates>
		</td>
	</tr>
	<tr>
		<td class="sb-formview-alternaterow">
			<xsl:apply-templates select="CONTROL[@NAME='maxSites']" mode="PLAN">
				<xsl:with-param name="controlClass">sb-control-input-input</xsl:with-param>
				<xsl:with-param name="checkBox">yes</xsl:with-param>
				<xsl:with-param name="onChange">self.sbApplyChangesObject.registerChange();</xsl:with-param>
			</xsl:apply-templates>
		</td>
	</tr>
	<tr>
		<td class="sb-formview-row">
			<xsl:apply-templates select="CONTROL[@NAME='maxUsers']" mode="PLAN">
				<xsl:with-param name="controlClass">sb-control-input-input</xsl:with-param>
				<xsl:with-param name="checkBox">yes</xsl:with-param>
				<xsl:with-param name="onChange">self.sbApplyChangesObject.registerChange();</xsl:with-param>
			</xsl:apply-templates>
		</td>
	</tr>
	<tr>
		<td class="sb-formview-alternaterow">
			<xsl:apply-templates select="CONTROL[@NAME='maxHosts']" mode="PLAN">
				<xsl:with-param name="controlClass">sb-control-input-input</xsl:with-param>
				<xsl:with-param name="checkBox">yes</xsl:with-param>
				<xsl:with-param name="onChange">self.sbApplyChangesObject.registerChange();</xsl:with-param>
			</xsl:apply-templates>
		</td>
	</tr>
	<!-- feature temporary disabled -->
	<!--tr>
		<td class="sb-formview-row">
			<xsl:apply-templates select="CONTROL[@NAME='maxPrivateTemplates']" mode="PLAN">
				<xsl:with-param name="controlClass">sb-control-input-input</xsl:with-param>
				<xsl:with-param name="checkBox">yes</xsl:with-param>
				<xsl:with-param name="onChange">self.sbApplyChangesObject.registerChange();</xsl:with-param>
			</xsl:apply-templates>
		</td>
	</tr-->
	<tr>
		<td class="sb-formview-alternaterow">

			<xsl:apply-templates select="CONTROL[@NAME='trialLifeTime']" mode="PLAN">
				<xsl:with-param name="controlClass">sb-control-input-input</xsl:with-param>
				<xsl:with-param name="checkBox">yes</xsl:with-param>
				<xsl:with-param name="onChange">self.sbApplyChangesObject.registerChange();</xsl:with-param>
			</xsl:apply-templates>
		</td>
	</tr>
</table>
</xsl:template>

<xsl:template match="CONTROL[@TYPE='INPUT']" mode="PLAN">
	<xsl:param name="titleStyle"/>
	<xsl:param name="controlStyle"/>
	<xsl:param name="controlEnvStyle"/>
	<xsl:param name="titleClass"/>
	<xsl:param name="controlClass"/>
	<xsl:param name="title"/>
	<xsl:param name="name"/>
	<xsl:param name="id"/>
	<xsl:param name="require"/>
	<xsl:param name="type"/>
	<xsl:param name="disabled"/>
	<xsl:param name="rowClass"/>
	<xsl:param name="checkBox"/>
	<xsl:param name="onChange"/>
	<xsl:param name="value" select="@VALUE"/>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<xsl:attribute name="class"><xsl:value-of select="$rowClass"/></xsl:attribute>
			
			<td>
				<xsl:attribute name="class"><xsl:value-of select="$titleClass"/></xsl:attribute>
				<xsl:attribute name="style">width:50%;<xsl:value-of select="$titleStyle"/></xsl:attribute>
				<xsl:choose>
					<xsl:when test="$title"><xsl:value-of select="$title"/></xsl:when>
					<xsl:otherwise><xsl:value-of select="@TITLE"/></xsl:otherwise>
				</xsl:choose>
				<xsl:if test="$require = 'on'">
					<span><xsl:attribute name="style">color:Red; width: 10px;<xsl:if test="$value != ''">display:none;</xsl:if></xsl:attribute><xsl:attribute name="id"><xsl:choose>
						<xsl:when test="$id"><xsl:value-of select="$id"/></xsl:when>
						<xsl:when test="@ID"><xsl:value-of select="@ID"/></xsl:when>
						<xsl:when test="$name"><xsl:value-of select="$name"/></xsl:when>
						<xsl:otherwise><xsl:value-of select="@NAME"/></xsl:otherwise>
					</xsl:choose>_asterix</xsl:attribute>&#160;*</span>
				</xsl:if>
			</td>
			<td>
				<xsl:attribute name="style"><xsl:value-of select="$controlEnvStyle"/></xsl:attribute>
				<xsl:if test="$checkBox = 'yes'">
					<input type="radio" name="radio{@NAME}" value="unlimited">
						<xsl:if test="$onChange">
							<xsl:attribute name="onchange"><xsl:value-of select="$onChange"/></xsl:attribute>
						</xsl:if>
						<xsl:choose>
							<xsl:when test="@PARENT-VALUE &gt;= 0">
								<xsl:attribute name="disabled">TRUE</xsl:attribute>
							</xsl:when>
							<xsl:otherwise>
								<xsl:if test="not(@VALUE) or @VALUE = '-1'">
									<xsl:attribute name="checked">TRUE</xsl:attribute>
								</xsl:if>
							</xsl:otherwise>
						</xsl:choose>
					</input> <xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/UNLIMITED"/> <br/>
				</xsl:if>

				<input type="radio" name="radio{@NAME}" value="limited">
					<xsl:if test="$onChange">
						<xsl:attribute name="onchange"><xsl:value-of select="$onChange"/></xsl:attribute>
					</xsl:if>
					<xsl:if test="$checkBox != 'yes'">
						<xsl:attribute name="style">visibility: hidden;</xsl:attribute>
					</xsl:if>
					<xsl:if test="@PARENT-VALUE &gt;= 0 or (@VALUE and @VALUE != '-1')"><xsl:attribute name="checked">TRUE</xsl:attribute></xsl:if>
				</input>

				<input type="hidden">
					<xsl:attribute name="id">
						<xsl:choose>
							<xsl:when test="$id">hidden<xsl:value-of select="$id"/></xsl:when>
							<xsl:otherwise>hidden<xsl:value-of select="@ID"/></xsl:otherwise>
						</xsl:choose>
					</xsl:attribute>
					<xsl:attribute name="name">
						<xsl:choose>
							<xsl:when test="$name">hidden<xsl:value-of select="$name"/></xsl:when>
							<xsl:otherwise>hidden<xsl:value-of select="@NAME"/></xsl:otherwise>
						</xsl:choose>
					</xsl:attribute>
					<xsl:attribute name="value"><xsl:value-of select="@PARENT-VALUE"/></xsl:attribute>
				</input>
				<input maxlength="250">
					<xsl:if test="$onChange">
						<xsl:attribute name="onchange"><xsl:value-of select="$onChange"/></xsl:attribute>
					</xsl:if>
					<xsl:if test="@NAME != 'name' and @NAME != 'description'">
						<xsl:attribute name="onkeyup">if(this.value!='') multiForm.radio<xsl:value-of select="@NAME" />[1].checked=true;</xsl:attribute>
						<xsl:attribute name="onchange">
							<xsl:choose>
								<xsl:when test="$onChange"><xsl:value-of select="$onChange"/>; if(this.value!='') multiForm.radio<xsl:value-of select="@NAME" />[1].checked=true;</xsl:when>
								<xsl:otherwise>if(this.value!='') multiForm.radio<xsl:value-of select="@NAME" />[1].checked=true;</xsl:otherwise>
							</xsl:choose>
						</xsl:attribute>
					</xsl:if>
					<xsl:attribute name="class"><xsl:value-of select="$controlClass"/></xsl:attribute>
					<xsl:attribute name="style"><xsl:if test="@NAME = 'trialLifeTime'">width: 60%;</xsl:if><xsl:value-of select="$controlStyle"/></xsl:attribute>
					<xsl:attribute name="type">
						<xsl:choose>
							<xsl:when test="$type"><xsl:value-of select="$type"/></xsl:when>
							<xsl:otherwise>text</xsl:otherwise>
						</xsl:choose>
					</xsl:attribute>
					<xsl:if test="$disabled"><xsl:attribute name="disabled">true</xsl:attribute></xsl:if>
					<xsl:attribute name="id">
						<xsl:choose>
							<xsl:when test="$id"><xsl:value-of select="$id"/></xsl:when>
							<xsl:otherwise><xsl:value-of select="@ID"/></xsl:otherwise>
						</xsl:choose>
					</xsl:attribute>
					<xsl:attribute name="name">
						<xsl:choose>
							<xsl:when test="$name"><xsl:value-of select="$name"/></xsl:when>
							<xsl:otherwise><xsl:value-of select="@NAME"/></xsl:otherwise>
						</xsl:choose>
					</xsl:attribute>
					<xsl:attribute name="value">
						<xsl:if test="@NAME = 'name' or @NAME = 'description'">
							<xsl:value-of select="@VALUE"/>
						</xsl:if>
						<xsl:if test="@NAME != 'name' and @NAME != 'description'">
							<xsl:choose>
								<xsl:when test="@VALUE">
									<xsl:if test="@VALUE &gt;= 0">
										<xsl:value-of select="@VALUE"/>
									</xsl:if>
								</xsl:when>
								<xsl:otherwise>
									<xsl:if test="@PARENT-VALUE &gt;= 0">
										<xsl:value-of select="@PARENT-VALUE"/>
									</xsl:if>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:if>
					</xsl:attribute>
				</input>
				<xsl:if test="@NAME = 'trialLifeTime'">
					<xsl:call-template name="LIFE-TIME">
						<xsl:with-param name="value">
							<xsl:choose>
								<xsl:when test="../CONTROL[@NAME='trialLifeTypeId']/@VALUE"><xsl:value-of select="../CONTROL[@NAME='trialLifeTypeId']/@VALUE"/></xsl:when>
								<xsl:otherwise><xsl:value-of select="../CONTROL[@NAME='trialLifeTypeId']/@PARENT-VALUE"/></xsl:otherwise>
							</xsl:choose>
						</xsl:with-param>
						<xsl:with-param name="parentValue">
							<xsl:value-of select="../CONTROL[@NAME='trialLifeTypeId']/@PARENT-VALUE"/>
						</xsl:with-param>
					</xsl:call-template>
				</xsl:if>
			</td>
		</tr>
	</table>
</xsl:template>

<xsl:template name="LIFE-TIME">
	<xsl:param name="value"></xsl:param>
	<xsl:param name="parentValue"></xsl:param>
	&#160;<select name="trialLifeTypeId" style="width: 19%;">
		<xsl:attribute name="onchange">sbApplyChangesObject.registerChange();</xsl:attribute>
		<option value="1">
			<xsl:if test="$value = 1"><xsl:attribute name="selected">true</xsl:attribute></xsl:if>
			<xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/DAYS"/>
		</option>
		<option value="2">
			<xsl:if test="$value = 2"><xsl:attribute name="selected">true</xsl:attribute></xsl:if>
			<xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/HOURS"/>
		</option>
	</select>
	<input type="hidden" name="hiddentrialLifeTypeId" id="hiddentrialLifeTypeId" value="{$parentValue}"/>
</xsl:template>

</xsl:stylesheet>