﻿<?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:template match="/">
		<xsl:call-template name="BrandOverViewContent">
			<xsl:with-param name="BrandID" select="Brand/BrandID"></xsl:with-param>
			<xsl:with-param name="SelectedBrandTabID" select="Brand/SelectedBrandTabID"></xsl:with-param>
			<xsl:with-param name="BrandProfileSectionID" select="Brand/BrandProfileSectionID"></xsl:with-param>
			<xsl:with-param name="SectionTitle" select="Brand/SectionTitle"></xsl:with-param>
			<xsl:with-param name="SectionHTML" select="Brand/SectionHTML"></xsl:with-param>
			<xsl:with-param name="SectionSummary" select="Brand/SectionSummary"></xsl:with-param>
			<xsl:with-param name="IsAuthenticated" select="Brand/IsAuthenticated"></xsl:with-param>
			<xsl:with-param name="TimeStamp" select="Brand/TimeStamp"></xsl:with-param>
			<xsl:with-param name="UserPermission" select="Brand/UserPermission"></xsl:with-param>
			<xsl:with-param name="BrandTabType" select="Brand/TabTypeID"></xsl:with-param>
			<xsl:with-param name="IsCommunityAdmin" select="Brand/IsCommunityAdmin"></xsl:with-param>
			<xsl:with-param name="BrandTabTypeID" select="Brand/BrandTabTypeID"></xsl:with-param>
		</xsl:call-template>
	</xsl:template>


	<xsl:template name="BrandOverViewContent">
		<xsl:param name="BrandID" select="'N/A'"></xsl:param>
		<xsl:param name="SelectedBrandTabID" select="'N/A'"></xsl:param>
		<xsl:param name="BrandProfileSectionID" select="'N/A'"></xsl:param>
		<xsl:param name="SectionTitle" select="'N/A'"></xsl:param>
		<xsl:param name="SectionHTML" select="'N/A'"></xsl:param>
		<xsl:param name="SectionSummary" select="'N/A'"></xsl:param>
		<xsl:param name="IsAuthenticated" select="'N/A'"></xsl:param>
		<xsl:param name="TimeStamp" select="'N/A'"></xsl:param>
		<xsl:param name="UserPermission" select="'N/A'"></xsl:param>
		<xsl:param name="BrandTabType" select="'N/A'"></xsl:param>
		<xsl:param name="IsCommunityAdmin" select="'N/A'"></xsl:param>
        <xsl:param name="BrandTabTypeID" select="'N/A'"></xsl:param>
		<xsl:choose>
			<xsl:when test ="$BrandProfileSectionID &gt; 0">
				<xsl:call-template name="BrandOverViewContent_Display">
					<xsl:with-param name="BrandID" select="$BrandID"></xsl:with-param>
					<xsl:with-param name="SelectedBrandTabID" select="$SelectedBrandTabID"></xsl:with-param>
					<xsl:with-param name="BrandProfileSectionID" select="$BrandProfileSectionID"></xsl:with-param>
					<xsl:with-param name="SectionTitle" select="$SectionTitle"></xsl:with-param>
					<xsl:with-param name="SectionHTML" select="$SectionHTML"></xsl:with-param>
					<xsl:with-param name="SectionSummary" select="$SectionSummary"></xsl:with-param>
					<xsl:with-param name="IsAuthenticated" select="$IsAuthenticated"></xsl:with-param>
					<xsl:with-param name="BrandTabType" select="$BrandTabType"></xsl:with-param>
				</xsl:call-template>

				<xsl:if test="$IsAuthenticated = 'True'">
					<xsl:call-template name="BrandOverViewContent_Edit">
						<xsl:with-param name="BrandID" select="$BrandID"></xsl:with-param>
						<xsl:with-param name="SelectedBrandTabID" select="$SelectedBrandTabID"></xsl:with-param>
						<xsl:with-param name="BrandProfileSectionID" select="$BrandProfileSectionID"></xsl:with-param>
						<xsl:with-param name="SectionTitle" select="$SectionTitle"></xsl:with-param>
						<xsl:with-param name="SectionHTML" select="$SectionHTML"></xsl:with-param>
						<xsl:with-param name="SectionSummary" select="$SectionSummary"></xsl:with-param>
						<xsl:with-param name="TimeStamp" select="$TimeStamp"></xsl:with-param>
						<xsl:with-param name="UserPermission" select="$UserPermission"></xsl:with-param>
						<xsl:with-param name="BrandTabType" select="$BrandTabType"></xsl:with-param>
						<xsl:with-param name="IsCommunityAdmin" select="$IsCommunityAdmin"></xsl:with-param>
					</xsl:call-template>
				</xsl:if>
			</xsl:when>
			<xsl:otherwise>
				<xsl:if test="$IsAuthenticated = 'True'">
					<xsl:call-template name="BrandOverViewContent_Add">
						<xsl:with-param name="BrandID" select="$BrandID"></xsl:with-param>
						<xsl:with-param name="SelectedBrandTabID" select="$SelectedBrandTabID"></xsl:with-param>
						<xsl:with-param name="BrandProfileSectionID" select="$BrandProfileSectionID"></xsl:with-param>
						<xsl:with-param name="SectionTitle" select="$SectionTitle"></xsl:with-param>
						<xsl:with-param name="SectionHTML" select="$SectionHTML"></xsl:with-param>
						<xsl:with-param name="SectionSummary" select="$SectionSummary"></xsl:with-param>
						<xsl:with-param name="TimeStamp" select="$TimeStamp"></xsl:with-param>
						<xsl:with-param name="UserPermission" select="$UserPermission"></xsl:with-param>
						<xsl:with-param name="BrandTabType" select="$BrandTabType"></xsl:with-param>
						<xsl:with-param name="IsCommunityAdmin" select="$IsCommunityAdmin"></xsl:with-param>
						<xsl:with-param name="BrandTabTypeID" select="$BrandTabTypeID"></xsl:with-param>
					</xsl:call-template>
				</xsl:if>
			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>

	<xsl:template name='BrandOverViewContent_Display'>
		<xsl:param name="BrandID" select="'N/A'"></xsl:param>
		<xsl:param name="SelectedBrandTabID" select="'N/A'"></xsl:param>
		<xsl:param name="BrandProfileSectionID" select="'N/A'"></xsl:param>
		<xsl:param name="SectionTitle" select="'N/A'"></xsl:param>
		<xsl:param name="SectionHTML" select="'N/A'"></xsl:param>
		<xsl:param name="SectionSummary" select="'N/A'"></xsl:param>
		<xsl:param name="IsAuthenticated" select="'N/A'"></xsl:param>
		<xsl:param name="BrandTabType" select="'N/A'"></xsl:param>
		<div id="divTopSection" style="display:block;">
			<div id="divSectionTitle" style="font-family: Calibri, Verdana, Arial; font-size: 14pt; font-weight: bold; color: black;">
				<xsl:value-of select ="$SectionTitle"/>
			</div>
			<xsl:if test="$IsAuthenticated = 'True' and $BrandTabType = 3">
				<div style="margin-top:10px;display:none;" id="btnEditOverviewContent">
					<input type="button" class="button" onClick='Brand_SectionEdit("divTopSection","divEditSection");' value="Edit Frame"/>
				</div>
			</xsl:if>
			<div id="divSectionMission">
				<xsl:value-of select ="$SectionHTML" disable-output-escaping ="yes"/>
			</div>
			<xsl:if test="$IsAuthenticated = 'True' and $BrandTabType != 3">
				<div style="margin-top:10px;display:none;" id="btnEditOverviewContent">
					<input type="button" class="button" onClick='Brand_SectionEdit("divTopSection","divEditSection");' value="Edit"/>
				</div>
			</xsl:if>
		</div>
	</xsl:template>

	<xsl:template name='BrandOverViewContent_Edit'>
		<xsl:param name="BrandID" select="'N/A'"></xsl:param>
		<xsl:param name="SelectedBrandTabID" select="'N/A'"></xsl:param>
		<xsl:param name="BrandProfileSectionID" select="'N/A'"></xsl:param>
		<xsl:param name="SectionTitle" select="'N/A'"></xsl:param>
		<xsl:param name="SectionHTML" select="'N/A'"></xsl:param>
		<xsl:param name="SectionSummary" select="'N/A'"></xsl:param>
		<xsl:param name="TimeStamp" select="'N/A'"></xsl:param>
		<xsl:param name="UserPermission" select="'N/A'"></xsl:param>
		<xsl:param name="BrandTabType" select="'N/A'"></xsl:param>
		<xsl:param name="IsCommunityAdmin" select="'N/A'"></xsl:param>
		<xsl:choose>
			<xsl:when test ="$UserPermission = 4 or $IsCommunityAdmin = 1">
				<div id="divEditSection" class="divEdit">
					<table class="tableMaster">
						<tr>
							<td colspan="2" style="text-align:right">
								<span onclick="CloseWindow('divEditSection'); closePopupWhiteLayerContainer();" class="labelHeader link" style="color: Black">
									[X]
								</span>
							</td>
						</tr>
						<xsl:choose>
							<xsl:when test ="$BrandTabType = 3">
								<tr>
									<td width="15%">
										<span class="labelSize10">
											Section Content:
										</span>
									</td>
									<td width="85%">
										<textarea rows="10" id="txtSectionHTML" style="width:100%; height:350px;" class="textAreaBox">
											<xsl:value-of select ="$SectionHTML"></xsl:value-of>
										</textarea>
									</td>
								</tr>
							</xsl:when>
							<xsl:otherwise>
								<tr>
									<td width="15%">
										<span class="labelSize10">
											Title:
										</span>
									</td>
									<td width="85%">
										<input type="text" name="Title" id="txtSectionTitle" style="width:100%;" class="text" maxlength="50"
											   value="{$SectionTitle}">
										</input>
									</td>
								</tr>
								<tr>
									<td width="15%">
										<span class="labelSize10">
											Section HTML Content:
										</span>
									</td>
									<td width="85%">
										<textarea rows="10" id="txtSectionHTML" style="width:100%; height:350px;" class="textAreaBox mceEditor">
											<xsl:value-of select ="$SectionHTML"></xsl:value-of>
										</textarea>
									</td>
								</tr>
								<tr>
									<td style="width:15%">
										<span class="labelSize10" >
											Section Summary:
										</span>
									</td>
									<td width="85%">
										<input type="text" id="txtOverViewTextSummary" style="width:100%;height:150px;" class="textAreaBox">
											<xsl:value-of select ="$SectionSummary"></xsl:value-of>
										</input>
									</td>
								</tr>
							</xsl:otherwise>
						</xsl:choose>
						<tr>
							<td></td>
							<td style="padding-top: 10px; padding-bottom: 10px;">
								<input type="button" value="Update" class="button" onClick='return Brand_UpdateSection(
                                                      "divBrandOverViewContent", "{normalize-space($SelectedBrandTabID)}", "{normalize-space($BrandID)}", 
                                                      "{normalize-space($BrandProfileSectionID)}", "txtSectionTitle", "txtSectionHTML", 
                                                      "Update", "txtOverViewTextSummary", "{normalize-space($UserPermission)}","{normalize-space($BrandTabType)}");'/>
							</td>
						</tr>
					</table>
				</div>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<xsl:template name='BrandOverViewContent_Add'>
		<xsl:param name="BrandID" select="'N/A'"></xsl:param>
		<xsl:param name="SelectedBrandTabID" select="'N/A'"></xsl:param>
		<xsl:param name="BrandProfileSectionID" select="'N/A'"></xsl:param>
		<xsl:param name="SectionTitle" select="'N/A'"></xsl:param>
		<xsl:param name="SectionHTML" select="'N/A'"></xsl:param>
		<xsl:param name="SectionSummary" select="'N/A'"></xsl:param>
		<xsl:param name="TimeStamp" select="'N/A'"></xsl:param>
		<xsl:param name="UserPermission" select="'N/A'"></xsl:param>
		<xsl:param name="BrandTabType" select="'N/A'"></xsl:param>
		<xsl:param name="IsCommunityAdmin" select="'N/A'"></xsl:param>
		<xsl:param name="BrandTabTypeID" select="'N/A'"></xsl:param>


		<xsl:choose>
			<xsl:when test ="$UserPermission = 4 or Brand/UserRoles/Role[RoleName = 'Brand Admin']">
				<div style="margin-top:10px;display:block;" id="btnAddOverviewContent">
					<input type="button" class="padding5 onMouseOver divBrowseGradient spanBrowseGradientTextGray"
						   onClick='Brand_SectionEdit("btnAddOverviewContent", "divAddSection");' value="Add Content"/>
				</div>
				<div id="divAddSection" class="divEdit">

					<xsl:choose>
						<xsl:when test="$BrandTabTypeID = 27">
							<table class="tableMaster" cellpadding="3" cellspacing="5">
								<tr>
									<td colspan="2" style="text-align:right">
										<span onclick="CloseWindow('divAddSection');
											  closePopupWhiteLayerContainer();" class="labelHeader link" style="color: Black">
											[X]
										</span>
									</td>
								</tr>
								<tr>
									<td width="10%">
										<span class="labelSize10">Header HTML:</span>
									</td>
									<td width="90%">
										<textarea id="txtSectionHTML" type="text"  class="mceEditor" tabindex="4" style="width: 650px;">
										</textarea>
									</td>
								</tr>
								<tr>
									<td>
										<span class="labelSize10">
											Video:
										</span>
									</td>
									<td>
										<input type="text" style="width:91%;"></input>
									</td>
								</tr>
								<tr>
									<td>
										<span class="labelSize10">
											Opt In:
										</span>
									</td>
									<td>
										<textarea style="width:91%;height:90px;"></textarea>
									</td>
								</tr>
								<tr>
									<td>
										<span class="labelSize10">Footer HTML:</span>
									</td>
									<td>
										<textarea id="txtSectionHTML2" type="text"  class="mceEditor" tabindex="4" style="width: 650px;">
										</textarea>
									</td>
								</tr>
								<tr>
									<td></td>
									<td style="padding-top: 10px; padding-bottom: 10px;">
										<input type="button" value="Save" class="button" onClick='return Brand_SaveSection(
                                                      "divBrandOverViewContent", "{normalize-space($SelectedBrandTabID)}", "{normalize-space($BrandID)}", 
                                                      "1","txtSectionTitle", "txtSectionHTML", 
                                                      "Save", "txtOverViewTextSummary", "{normalize-space($UserPermission)}", "{normalize-space($BrandTabType)}");'/>
									</td>
								</tr>
							</table>
						</xsl:when>
						
						<xsl:otherwise>
							<table style="width:99%">
								<tr>
									<td colspan="2" style="text-align:right">
										<span onclick="CloseWindow('divAddSection');
											  closePopupWhiteLayerContainer();" class="labelHeader link" style="color: Black">
											[X]
										</span>
									</td>
								</tr>
								<xsl:choose>
									<xsl:when test ="$BrandTabType = 3">
										<tr>
											<td width="15%">
												<span class="labelSize10">
													Section Content:
												</span>
											</td>
											<td width="85%">
												<textarea rows="10" id="txtSectionHTML" style="width:100%; height:350px;" class="textAreaBox">
												</textarea>
											</td>
										</tr>
									</xsl:when>
									<xsl:otherwise>
										<tr>
											<td width="15%">
												<span class="labelSize10">
													Title:
												</span>
											</td>
											<td width="85%">
												<input type="text" name="Title" id="txtSectionTitle" style="width:100%;" class="text" maxlength="50">
												</input>
											</td>
										</tr>
										<tr>
											<td width="15%">
												<span class="labelSize10">
													Section HTML Content:
												</span>
											</td>
											<td width="85%">
												<textarea rows="10" id="txtSectionHTML" style="width:100%; height:350px;" class="textAreaBox mceEditor">
												</textarea>
											</td>
										</tr>
										<tr>
											<td style="width:15%">
												<span class="labelSize10" >
													Section Summary:
												</span>
											</td>
											<td width="85%">
												<input type="text" id="txtOverViewTextSummary" style="width:100%;height:150px;" class="textAreaBox">
												</input>
											</td>
										</tr>
										<tr>
											<td></td>
											<td style="padding-top: 10px; padding-bottom: 10px;">
												<input type="button" value="Save" class="button" onClick='return Brand_SaveSection(
                                                      "divBrandOverViewContent", "{normalize-space($SelectedBrandTabID)}", "{normalize-space($BrandID)}", 
                                                      "1","txtSectionTitle", "txtSectionHTML", 
                                                      "Save", "txtOverViewTextSummary", "{normalize-space($UserPermission)}", "{normalize-space($BrandTabType)}");'/>
											</td>
										</tr>
									</xsl:otherwise>
								</xsl:choose>

							</table>
						</xsl:otherwise>
					</xsl:choose>

				</div>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

</xsl:stylesheet>
