﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
	<xsl:output method="xml" indent="yes"/>

	<xsl:template name="AddRecurringTemplate">
		<xsl:param name="varItemTemplateDetailID" select="'N/A'"></xsl:param>
		<xsl:param name="TopicID" select="'N/A'"></xsl:param>
		<xsl:param name="RecurringPeriodType" select="'N/A'"></xsl:param>
		<xsl:param name="clsRecurringDetail" select="'N/A'"></xsl:param>
		<xsl:param name="clsWeeklyRecurringVisibleStyle" select="'N/A'"></xsl:param>
		<xsl:param name="RepeatEveryN" select="'N/A'"></xsl:param>
		<xsl:param name="EndAfterN" select="'N/A'"></xsl:param>
		<xsl:param name="Monday" select="'N/A'"></xsl:param>
		<xsl:param name="Tuesday" select="'N/A'"></xsl:param>
		<xsl:param name="Wednesday" select="'N/A'"></xsl:param>
		<xsl:param name="Thursday" select="'N/A'"></xsl:param>
		<xsl:param name="Friday" select="'N/A'"></xsl:param>
		<xsl:param name="Saturday" select="'N/A'"></xsl:param>
		<xsl:param name="Sunday" select="'N/A'"></xsl:param>
		<xsl:param name="clsMontlyRecurringVisibleStyle" select="'N/A'"></xsl:param>
		<xsl:param name="FirstOfMonthYN" select="'N/A'"></xsl:param>
		<xsl:param name="MiddleOfMonthYN" select="'N/A'"></xsl:param>
		<xsl:param name="LastOfMonthYN" select="'N/A'"></xsl:param>
		<xsl:param name="OneCol" select="'N/A'"></xsl:param>
		<xsl:variable name="varWidth">
			<xsl:choose>
				<xsl:when test="$OneCol ='true'">
					<xsl:text>100%</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>50%</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="ItemTemplateDetailID">
			<xsl:choose>
				<xsl:when test="$varItemTemplateDetailID='N/A'">
					<xsl:text>0</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$varItemTemplateDetailID"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<tr>
			<xsl:if test="$OneCol !='true'">
				<td style="width:90px;">
				</td>
			</xsl:if>
			<td>
				<div class="">
					<span class="glyphicon glyphicon-refresh glypcolor " style="width:25px;color: #04577E!important;padding: 0 5px 0 0;font-size:18px;font-weight: bold;
    margin-top: 10px;
    float: left;"></span>
					<xsl:choose>
						<xsl:when test="$ItemTemplateDetailID &gt;0">
							<input type="checkbox" id="chk_{$TopicID}_MakeRecurring_{$ItemTemplateDetailID}" tabindex="3" checked=""
								 onclick="showHideTableRowByClass('clsMakeRecurring','clsMakeRecurringWeekly','clsMakeRecurringMonthly',
						   'chk_{$TopicID}_MakeRecurring_{$ItemTemplateDetailID}' ,'spn_{$TopicID}_Weekly_{$ItemTemplateDetailID}');" style=" margin-left: 8px;
    float: left; margin-top: 13px;"></input>
						</xsl:when>
						<xsl:otherwise>
							<input type="checkbox" id="chk_{$TopicID}_MakeRecurring_{$ItemTemplateDetailID}" tabindex="3"
						 onclick="showHideTableRowByClass('clsMakeRecurring','clsMakeRecurringWeekly','clsMakeRecurringMonthly',
						   'chk_{$TopicID}_MakeRecurring_{$ItemTemplateDetailID}' ,'spn_{$TopicID}_Weekly_{$ItemTemplateDetailID}');" style=" margin-left: 8px;
    float: left; margin-top: 13px;"></input>
						</xsl:otherwise>
					</xsl:choose>
					<span class="publicationSummary" style="font-family: sans-serif; font-size: 13px;     padding-left: 12px;
    margin-top: 1px;float: left; padding-left: 12px;font-weight:normal;">Make Recurring </span>
				</div>
			</td>
		</tr>
		<tr class="clsMakeRecurring" style="{$clsRecurringDetail}">
			<xsl:if test="$OneCol !='true'">
				<td style="width:90px;">
				</td>
			</xsl:if>
			<td >
				<xsl:variable name="varRecurringPeriodType">
					<xsl:choose>
						<xsl:when test="$RecurringPeriodType='N/A'">
							<xsl:text>Weekly</xsl:text>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="$RecurringPeriodType"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<xsl:variable name="clsWeeklyPeriodTypeActive">
					<xsl:choose>
						<xsl:when test="$varRecurringPeriodType='Weekly'">
							<xsl:text>btn-primary</xsl:text>
						</xsl:when>
						<xsl:otherwise>
							<xsl:text></xsl:text>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<xsl:variable name="clsMontlyPeriodTypeActive">
					<xsl:choose>
						<xsl:when test="$varRecurringPeriodType='Monthly'">
							<xsl:text>btn-primary</xsl:text>
						</xsl:when>
						<xsl:otherwise>
							<xsl:text></xsl:text>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<input type="hidden" value="{$varRecurringPeriodType}" id="hdfRecurringPeriodType_{$TopicID}_{$ItemTemplateDetailID}"></input>
				<span class="publicationSummary btn btn-default {$clsWeeklyPeriodTypeActive} spn_{$TopicID}_Weekly_{$ItemTemplateDetailID}"
					  onclick="showHideTableRowTabByClass('clsMakeRecurringMonthly', 'clsMakeRecurringWeekly',
						  'spn_{$TopicID}_Weekly_{$ItemTemplateDetailID}', 'spn_{$TopicID}_Monthly_{$ItemTemplateDetailID}', 'btn-primary');
					  $('#hdfRecurringPeriodType_{$TopicID}_{$ItemTemplateDetailID}').val('Weekly');"> Weekly</span>

				<span class="publicationSummary {$clsMontlyPeriodTypeActive} btn btn-default spn_{$TopicID}_Monthly_{$ItemTemplateDetailID}"
					  onclick="showHideTableRowTabByClass('clsMakeRecurringWeekly', 'clsMakeRecurringMonthly',
						  'spn_{$TopicID}_Monthly_{$ItemTemplateDetailID}', 'spn_{$TopicID}_Weekly_{$ItemTemplateDetailID}', 'btn-primary');
					  $('#hdfRecurringPeriodType_{$TopicID}_{$ItemTemplateDetailID}').val('Monthly');">Monthly</span>
			</td>
		</tr>

		<tr class="clsMakeRecurringWeekly" style="{$clsWeeklyRecurringVisibleStyle}">
			<xsl:if test="$OneCol !='true'">
				<td>
				</td>
			</xsl:if>
			<td >
				<div style="border: 1px solid #9E9E9E !important;width: {$varWidth};  padding: 5px 5px;" >
					<table>
						<xsl:variable name="WeeklyRepeatEveryN">
							<xsl:choose>
								<xsl:when test="$RecurringPeriodType ='Weekly' and $ItemTemplateDetailID &gt;0">
									<xsl:value-of select="$RepeatEveryN"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:text></xsl:text>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>
						<xsl:variable name="WeeklyEndAfterN">
							<xsl:choose>
								<xsl:when test="$RecurringPeriodType ='Weekly' and $ItemTemplateDetailID &gt;0">
									<xsl:value-of select="$EndAfterN"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:text></xsl:text>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>

						<tr class="">
							<td style="width:90px;">
								<span class="publicationSummary" style="font-family: sans-serif;  height: 34px;   line-height: 34px;"> Repeat every </span>
							</td>
							<td>
								<input id="txt_{$TopicID}_RepeatEveryN_{$ItemTemplateDetailID}" type="text" value="{$WeeklyRepeatEveryN}"
									  style="width:50px;    display: inline;  float: left;" class="text" tabindex="3"/>
								<span class="labelGraySize10" style=" float: left;  width: 50px;  line-height: 34px;  margin-left: 6px;">week(s) </span>
							</td>
						</tr>
						<tr class="">

							<td style="width:90px;">
								<span class="publicationSummary">
									Repeat on :
								</span>
							</td>
							<td>
								<xsl:choose>
									<xsl:when test="$Monday != 0 and $RecurringPeriodType ='Weekly' and $ItemTemplateDetailID &gt;0">
										<input type="checkbox" id="txt_{$TopicID}_RepeatOnMonday_{$ItemTemplateDetailID}"  tabindex="3"
							   name="nmRepeatOnWeekly_{$ItemTemplateDetailID}" val="1" checked=""></input>M
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_RepeatOnMonday_{$ItemTemplateDetailID}"  tabindex="3"
							   name="nmRepeatOnWeekly_{$ItemTemplateDetailID}" val="1"></input>M
									</xsl:otherwise>
								</xsl:choose>

								<xsl:choose>
									<xsl:when test="$Tuesday != 0 and $RecurringPeriodType ='Weekly' and $ItemTemplateDetailID &gt;0">
										<input type="checkbox" id="txt_{$TopicID}_RepeatOnTuesday_{$ItemTemplateDetailID}"  tabindex="3"
									   name="nmRepeatOnWeekly_{$ItemTemplateDetailID}" val="2" checked=""></input>T
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_RepeatOnTuesday_{$ItemTemplateDetailID}"  tabindex="3"
									   name="nmRepeatOnWeekly_{$ItemTemplateDetailID}" val="2"></input>T
									</xsl:otherwise>
								</xsl:choose>

								<xsl:choose>
									<xsl:when test="$Wednesday != 0 and $RecurringPeriodType ='Weekly' and $ItemTemplateDetailID &gt;0">
										<input type="checkbox" id="txt_{$TopicID}_RepeatOnWednessday_{$ItemTemplateDetailID}"  tabindex="3"
									   name="nmRepeatOnWeekly_{$ItemTemplateDetailID}" val="4" checked=""></input>W
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_RepeatOnWednessday_{$ItemTemplateDetailID}"  tabindex="3"
								   name="nmRepeatOnWeekly_{$ItemTemplateDetailID}" val="4"></input>W
									</xsl:otherwise>
								</xsl:choose>

								<xsl:choose>
									<xsl:when test="$Thursday != 0 and $RecurringPeriodType ='Weekly' and $ItemTemplateDetailID &gt;0">
										<input type="checkbox" id="txt_{$TopicID}_RepeatOnThursday_{$ItemTemplateDetailID}"  tabindex="3"
								   name="nmRepeatOnWeekly_{$ItemTemplateDetailID}" val="8" checked=""></input>Th
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_RepeatOnThursday_{$ItemTemplateDetailID}"  tabindex="3"
								   name="nmRepeatOnWeekly_{$ItemTemplateDetailID}" val="8"></input>Th
									</xsl:otherwise>
								</xsl:choose>

								<xsl:choose>
									<xsl:when test="$Friday != 0 and $RecurringPeriodType ='Weekly' and $ItemTemplateDetailID &gt;0">
										<input type="checkbox" id="txt_{$TopicID}_RepeatOnFriday_{$ItemTemplateDetailID}"  tabindex="3"
									   name="nmRepeatOnWeekly_{$ItemTemplateDetailID}" val="16" checked=""></input>F
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_RepeatOnFriday_{$ItemTemplateDetailID}"  tabindex="3"
									   name="nmRepeatOnWeekly_{$ItemTemplateDetailID}" val="16"></input>F
									</xsl:otherwise>
								</xsl:choose>


								<xsl:choose>
									<xsl:when test="$Saturday != 0 and $RecurringPeriodType ='Weekly' and $ItemTemplateDetailID &gt;0">
										<input type="checkbox" id="txt_{$TopicID}_RepeatOnSaturday_{$ItemTemplateDetailID}"  tabindex="3"
								   name="nmRepeatOnWeekly_{$ItemTemplateDetailID}" val="32" checked=""></input>S
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_RepeatOnSaturday_{$ItemTemplateDetailID}"  tabindex="3"
								   name="nmRepeatOnWeekly_{$ItemTemplateDetailID}" val="32"></input>S
									</xsl:otherwise>
								</xsl:choose>

								<xsl:choose>
									<xsl:when test="$Sunday != 0 and $RecurringPeriodType ='Weekly' and $ItemTemplateDetailID &gt;0">
										<input type="checkbox" id="txt_{$TopicID}_RepeatOnSunday_{$ItemTemplateDetailID}" tabindex="3"
									   name="nmRepeatOnWeekly_{$ItemTemplateDetailID}" val="64" checked=""></input>Su
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_RepeatOnSunday_{$ItemTemplateDetailID}" tabindex="3"
									   name="nmRepeatOnWeekly_{$ItemTemplateDetailID}" val="64"></input>Su
									</xsl:otherwise>
								</xsl:choose>

							</td>
						</tr>
						<tr class="">
							<td style="width:90px;">
								<span class="publicationSummary" style="font-family: sans-serif;  height: 34px;  line-height: 34px;"> End after </span>
							</td>
							<td>
								<input id="txt_{$TopicID}_EndAfter_{$ItemTemplateDetailID}" type="text" value="{$WeeklyEndAfterN}"
										  style="width:50px;  display: inline;  float: left;" class="text"  tabindex="3"/>
								<span class="labelGraySize10" style="float: left;  width: 50px;  line-height: 34px;  margin-left: 6px;">occurences </span>
							</td>
						</tr>
					</table>
				</div>
			</td>
		</tr>
		<tr class="clsMakeRecurringMonthly" style="{$clsMontlyRecurringVisibleStyle}">
			<xsl:if test="$OneCol !='true'">
				<td >
				</td>
			</xsl:if>
			<td>



				<div style="border: 1px solid #9E9E9E !important;width: {$varWidth};  padding: 5px 5px;">
					<table>
						<xsl:variable name="MonthlyRepeatEveryN">
							<xsl:choose>
								<xsl:when test="$RecurringPeriodType ='Monthly' and $ItemTemplateDetailID &gt;0">
									<xsl:value-of select="$RepeatEveryN"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:text></xsl:text>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>
						<xsl:variable name="MonthlyEndAfterN">
							<xsl:choose>
								<xsl:when test="$RecurringPeriodType ='Monthly' and $ItemTemplateDetailID &gt;0">
									<xsl:value-of select="$EndAfterN"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:text></xsl:text>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>

						<tr class="" >
							<td style="width:90px;">
								<span class="publicationSummary" style="font-family: sans-serif; height: 34px;  line-height: 34px;"> Repeat every </span>
							</td>
							<td>
								<input id="txt_{$TopicID}_RepeatEveryN_Month_{$ItemTemplateDetailID}" type="text"
									  style="width: 50px; display: inline;  float: left;" class="text" tabindex="3" value="{$MonthlyRepeatEveryN}"/>
								<span class="labelGraySize10" style="float: left;  width: 50px;height: 34px;  line-height: 34px;   margin-left: 6px;">Month(s) </span>
							</td>
						</tr>
						<tr class="">
							<td colspan="2">
								<xsl:choose>
									<xsl:when test="$FirstOfMonthYN=1 or $FirstOfMonthYN='true'">
										<input type="checkbox" id="txt_{$TopicID}_StartOfMonth_{$ItemTemplateDetailID}"  checked="" tabindex="3"></input>Start of Month
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_StartOfMonth_{$ItemTemplateDetailID}"  tabindex="3"></input>Start of Month
									</xsl:otherwise>
								</xsl:choose>

								<xsl:choose>
									<xsl:when test="$MiddleOfMonthYN=1 or $MiddleOfMonthYN='true'">
										<input type="checkbox" id="txt_{$TopicID}_MidOfMonth_{$ItemTemplateDetailID}" checked=""   tabindex="3"></input>Mid of Month
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_MidOfMonth_{$ItemTemplateDetailID}"  tabindex="3"></input>Mid of Month
									</xsl:otherwise>
								</xsl:choose>

								<xsl:choose>
									<xsl:when test="$LastOfMonthYN=1 or $LastOfMonthYN='true'">
										<input type="checkbox" id="txt_{$TopicID}_EndOfMonth_{$ItemTemplateDetailID}"  checked="" tabindex="3"></input>End of Month
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_EndOfMonth_{$ItemTemplateDetailID}"  tabindex="3"></input>End of Month
									</xsl:otherwise>
								</xsl:choose>


							</td>
						</tr>
						<tr class="">
							<td style="width:90px;">
								<span class="publicationSummary" style=" font-family: sans-serif;  margin-left: 17px;"> Only on </span>
							</td>
							<td>

								<xsl:choose>
									<xsl:when test="$Monday != 0 and $RecurringPeriodType ='Monthly' and $ItemTemplateDetailID &gt;0">
										<input type="checkbox" id="txt_{$TopicID}_OnlyOnMonday_{$ItemTemplateDetailID}"  tabindex="3"
							   name="nmRepeatOnMonthly_{$ItemTemplateDetailID}" val="1" checked=""></input>M
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_OnlyOnMonday_{$ItemTemplateDetailID}"  tabindex="3"
								   name="nmRepeatOnMonthly_{$ItemTemplateDetailID}" val="1"></input>M
									</xsl:otherwise>
								</xsl:choose>

								<xsl:choose>
									<xsl:when test="$Tuesday != 0 and $RecurringPeriodType ='Monthly' and $ItemTemplateDetailID &gt;0">
										<input type="checkbox" id="txt_{$TopicID}_OnlyOnTuesday_{$ItemTemplateDetailID}"  tabindex="3"
									   name="nmRepeatOnMonthly_{$ItemTemplateDetailID}"  val="2" checked=""></input>T
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_OnlyOnTuesday_{$ItemTemplateDetailID}"  tabindex="3"
									   name="nmRepeatOnMonthly_{$ItemTemplateDetailID}"  val="2"></input>T
									</xsl:otherwise>
								</xsl:choose>

								<xsl:choose>
									<xsl:when test="$Wednesday != 0 and $RecurringPeriodType ='Monthly' and $ItemTemplateDetailID &gt;0">
										<input type="checkbox" id="txt_{$TopicID}_OnlyOnWednessday_{$ItemTemplateDetailID}"  tabindex="3"
									   name="nmRepeatOnMonthly_{$ItemTemplateDetailID}" val="4" checked=""></input>W
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_OnlyOnWednessday_{$ItemTemplateDetailID}"  tabindex="3"
									   name="nmRepeatOnMonthly_{$ItemTemplateDetailID}" val="4"></input>W
									</xsl:otherwise>
								</xsl:choose>

								<xsl:choose>
									<xsl:when test="$Thursday != 0 and $RecurringPeriodType ='Monthly' and $ItemTemplateDetailID &gt;0">
										<input type="checkbox" id="txt_{$TopicID}_OnlyOnThursday_{$ItemTemplateDetailID}"  tabindex="3"
								   name="nmRepeatOnMonthly_{$ItemTemplateDetailID}"  val="8" checked=""></input>Th
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_OnlyOnThursday_{$ItemTemplateDetailID}"  tabindex="3"
								   name="nmRepeatOnMonthly_{$ItemTemplateDetailID}"  val="8"></input>Th
									</xsl:otherwise>
								</xsl:choose>

								<xsl:choose>
									<xsl:when test="$Friday != 0 and $RecurringPeriodType ='Monthly' and $ItemTemplateDetailID &gt;0">
										<input type="checkbox" id="txt_{$TopicID}_OnlyOnFriday_{$ItemTemplateDetailID}"  tabindex="3"
							   name="nmRepeatOnMonthly_{$ItemTemplateDetailID}"  val="16" checked=""></input>F
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_OnlyOnFriday_{$ItemTemplateDetailID}"  tabindex="3"
							   name="nmRepeatOnMonthly_{$ItemTemplateDetailID}"  val="16"></input>F
									</xsl:otherwise>
								</xsl:choose>

								<xsl:choose>
									<xsl:when test="$Saturday != 0 and $RecurringPeriodType ='Monthly' and $ItemTemplateDetailID &gt;0">
										<input type="checkbox" id="txt_{$TopicID}_OnlyOnSaturday_{$ItemTemplateDetailID}"  tabindex="3"
										   name="nmRepeatOnMonthly_{$ItemTemplateDetailID}"  val="32" checked=""></input>S
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_OnlyOnSaturday_{$ItemTemplateDetailID}"  tabindex="3"
									   name="nmRepeatOnMonthly_{$ItemTemplateDetailID}"  val="32"></input>S
									</xsl:otherwise>
								</xsl:choose>

								<xsl:choose>
									<xsl:when test="$Sunday != 0 and $RecurringPeriodType ='Monthly' and $ItemTemplateDetailID &gt;0">
										<input type="checkbox" id="txt_{$TopicID}_OnlyOnSunday_{$ItemTemplateDetailID}" tabindex="3"
										   name="nmRepeatOnMonthly_{$ItemTemplateDetailID}"  val="64" checked=""></input>Su
									</xsl:when>
									<xsl:otherwise>
										<input type="checkbox" id="txt_{$TopicID}_OnlyOnSunday_{$ItemTemplateDetailID}" tabindex="3"
											   name="nmRepeatOnMonthly_{$ItemTemplateDetailID}"  val="64"></input>Su
									</xsl:otherwise>
								</xsl:choose>

							</td>
						</tr>
						<tr class="">
							<td style="width:90px;">
								<span class="publicationSummary"  style="font-family: sans-serif;  height: 34px;  line-height: 34px;"> End after </span>
							</td>
							<td>
								<input id="txt_{$TopicID}_EndAfter_Month_{$ItemTemplateDetailID}" type="text"
										  style="width:50px;  display: inline;  float: left;" class="text"  tabindex="3" value="{$MonthlyEndAfterN}"/>
								<span class="labelGraySize10" style="float: left;  width: auto;  line-height: 34px;  margin-left: 6px;">occurences </span>
							</td>
						</tr>
					</table>
				</div>
			</td>
		</tr>
	</xsl:template>
</xsl:stylesheet>
