﻿<?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:import href="DisplayVideo.xslt"/>
	<xsl:output method="xml" indent="yes"/>

	<xsl:template match="/">
		<xsl:variable name="TemplateURL" select="normalize-space(AjaxRequest/TemplateURL)"></xsl:variable>
		<xsl:variable name="HostName" select="normalize-space(AjaxRequest/HostName)"></xsl:variable>
		<xsl:variable name="BrandCommunityID" select="normalize-space(AjaxRequest/Params/BrandCommunityID)"></xsl:variable>
		<xsl:variable name="StatusID" select="normalize-space(AjaxRequest/Params/StatusID)"></xsl:variable>
		<xsl:variable name="VideoKeyValue" select="normalize-space(AjaxRequest/VideoKeyValue)"></xsl:variable>
		<xsl:variable name="Origin" select="normalize-space(AjaxRequest/Params/Origin)"></xsl:variable>
		<xsl:variable name="VideoXML" select="AjaxRequest/Output/.."></xsl:variable>
		<xsl:variable name="BrandID" select="normalize-space($VideoXML/Output/BrandID)"></xsl:variable>

		<xsl:variable name="CountFrom">
			<xsl:choose>
				<xsl:when test="normalize-space(AjaxRequest/Params/CountFrom)">
					<xsl:value-of select="normalize-space(AjaxRequest/Params/CountFrom)"/>
				</xsl:when>
				<xsl:otherwise>1</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="$Origin = 'dragonkick'">
				<xsl:call-template name="DragonKickVideosOnBrand">
					<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
					<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
					<xsl:with-param name="BrandCommunityID" select="$BrandCommunityID"></xsl:with-param>
					<xsl:with-param name="CountFrom" select="$CountFrom"></xsl:with-param>
					<xsl:with-param name="StatusID" select="$StatusID"></xsl:with-param>
					<xsl:with-param name="VideoKeyValue" select="$VideoKeyValue"></xsl:with-param>
					<xsl:with-param name="VideoXML" select="$VideoXML"></xsl:with-param>
					<xsl:with-param name="Origin" select="$Origin"></xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<div>
					<xsl:variable name="CountData" select="count($VideoXML/Output/Item)"></xsl:variable>
					<table id="tblCommunityAdmin" class="tableMaster" cellpadding="5" cellspacing="0">
						<xsl:choose>
							<xsl:when test="count($VideoXML/Output/Item) &gt; 0">
								<tr>
									<td align="right" class="paddingTop20 paddingBottom20" style="font-weight:bold;" colspan="5">
										<div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray" style="width:120px;line-height:30px;float:right;"
											onmouseover="document.getElementById('img_AddContent').src='{$TemplateURL}Web/Images/Ver_2_0/icon_add_over.png';"
											onmouseout="document.getElementById('img_AddContent').src='{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png';"
											onclick="Portal_LoadAddCommunityContent('{$BrandCommunityID}','{$BrandID}','Video', 'divClientPortalOperations_Container');">
											<img id="img_AddContent" src="{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" style="padding-left:8px;" class="marginRight5"></img>
											<span id="span_AddContent" class="capitalFont">Add Content</span>
										</div>
									</td>
								</tr>
								<xsl:if test="count($VideoXML/Output/Item) &gt; 0">
									<tr style="padding: 20px; border-style: solid; border-width: thin; border-top-color: #000080;">
										<td width="3%" valign="top"></td>
										<td width="12%" valign="top">
											<span class="packageTitle">Community</span>
										</td>
										<td width="50%">
											<span class="packageTitle">Content</span>
										</td>
										<td width="20%">
											<span class="packageTitle">Posted By</span>
										</td>
										<td width="15%" align="right" style="padding-right: 10px;">
											<span class="packageTitle">Admin</span>
										</td>
									</tr>
								</xsl:if>
								<xsl:for-each select="$VideoXML/Output/Item">
									<xsl:variable name="RowClass">
										<xsl:choose>
											<xsl:when test="position() mod 2 = 0">
												<xsl:text>trAlternateDark</xsl:text>
											</xsl:when>
											<xsl:when test="position() mod 2 != 0">
												<xsl:text>trAlternateLight</xsl:text>
											</xsl:when>
										</xsl:choose>
									</xsl:variable>

									<tr id="tr_item_{normalize-space(ContentItemID)}" class="{$RowClass}" name="ContentRow" ItemID="{ContentItemID}">
										<td class="verticallyMiddle">

											<xsl:variable name="UpImageDisplay">
												<xsl:choose>
													<xsl:when test="position()=1">
														<xsl:text>display:none;</xsl:text>
													</xsl:when>
													<xsl:otherwise>
														<xsl:text>display:inline;</xsl:text>
													</xsl:otherwise>
												</xsl:choose>
											</xsl:variable>

											<xsl:variable name="downImageDisplay">
												<xsl:choose>
													<xsl:when test="position() &lt; $CountData">
														<xsl:text>display:inline;</xsl:text>
													</xsl:when>
													<xsl:otherwise>
														<xsl:text>display:none;</xsl:text>
													</xsl:otherwise>
												</xsl:choose>
											</xsl:variable>

											<!--<xsl:value-of  select="ContentItemID"/>
											<xsl:value-of  select="SortOrder"/>-->
											<img border="0" id="img_Video_ArrowUp_{ContentItemID}" style="{$UpImageDisplay}" class="onMouseOver" src="{$TemplateURL}Web/Images/Arrow_Up.jpg" title="Arrow_Up"
												 onclick="sortContentOrder('{ContentItemID}', '{$BrandCommunityID}', 'up', '{$CountData}');"></img>

											<img border="0" id="img_Video_ArrowDown_{ContentItemID}" style="{$downImageDisplay}" class="onMouseOver" src="{$TemplateURL}Web/Images/Arrow_Down.jpg" title="Arrow_Down"
												 onclick="sortContentOrder('{ContentItemID}', '{$BrandCommunityID}', 'down', '{$CountData}');"></img>

										</td>
										<td width="12%" valign="top">
											<xsl:if test="normalize-space(ImageAttach) != ''">
												<a class="link" target="_blank" href="Content.aspx?ID={normalize-space(ContentItemID)}">
													<img style="display:inline; margin-left: 0px; vertical-align: middle; display: none;"
														   src="{normalize-space(ImageAttach)}" onload='setWidthAndHeightImage(this,"100");'/>
												</a>
											</xsl:if>
										</td>
										<td width="50%" valign="top">
											<div class="packageTitle" style="display: inline;">
												<span class="packageTitle">
													<xsl:value-of select="ContentName"/>
												</span>
												<a class="link" target="_blank" href="Content.aspx?ID={normalize-space(ContentItemID)}" style="font-weight: normal;">
													<span class="publicationSummary"> (Open)</span>
												</a>
											</div>
											<div class="label" style="color: rgb(55, 96, 146); text-align: justify;">
												<xsl:value-of select="ContentMemo"/>
											</div>
										</td>
										<td width="20%" valign="top">
											<div class="packageTitle">
												<a href="#" style="text-decoration: underline;"
													onClick='return filterOwner("{normalize-space(OwnerID)}", "tblCommunityAdmin");'>
													<span class='packageTitle'>
														<xsl:value-of select="OwnerName"/>
													</span>
												</a>
											</div>
											<div class="packageTitle">
												<xsl:value-of select="CreatedDate"/>
											</div>
										</td>
										<td width="15%" valign="top">
											<div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray marginBottom10 textCenter" style="width:70px;line-height:25px;">
												<a href="AddCommunityContent.aspx?ID={normalize-space(ParentID)}&amp;ItemID={normalize-space(ContentItemID)}"
													style="text-decoration: none;font-family: 'PT Sans' , sans-serif;font-size: 13px;color: #4B4B4B;" target="_blank">
													<span id="span_UpdateContent" class="capitalFont onMouseOver">Update</span>
												</a>
											</div>
											<div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray textCenter" style="width:70px;line-height:25px;"
												  onclick='return deleteContent("{normalize-space(ContentItemID)}","tr_item_{normalize-space(ContentItemID)}");'>
												<span id="span_UpdateContent" class="capitalFont onMouseOver">Delete</span>
											</div>

											<div class="publicationSummary">
												Views: <xsl:value-of select="ViewCount"/>
											</div>
											<div class="publicationSummary">
												Likes: <xsl:value-of select="Like"/>% &#xa0; Dislikes: <xsl:value-of select="Dislike"/>%
											</div>
										</td>
										<td>
											<input type="hidden" id="tr_item_{normalize-space(ContentItemID)}_hiddenCommunityItemID" value="{normalize-space(ParentID)}"></input>
											<input type="hidden" id="tr_item_{normalize-space(ContentItemID)}_hiddenOwnerID" value="{normalize-space(OwnerID)}"></input>
										</td>
									</tr>
								</xsl:for-each>

								<tr>
									<td align="right" class="paddingTop20 paddingBottom20" style="font-weight:bold;" colspan="5">
										<div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray" style="width:120px;line-height:30px;float:right;"
										   onmouseover="document.getElementById('img_AddContent2').src='{$TemplateURL}Web/Images/Ver_2_0/icon_add_over.png';"
										   onmouseout="document.getElementById('img_AddContent2').src='{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png';"
										   onclick="Portal_LoadAddCommunityContent('{$BrandCommunityID}','{$BrandID}','Video', 'divClientPortalOperations_Container');">
											<img id="img_AddContent2" src="{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" style="padding-left:8px;" class="marginRight5"></img>
											<span id="span_AddContent2" class="capitalFont">Add Content</span>
										</div>
									</td>
								</tr>
							</xsl:when>
							<xsl:otherwise>
								<div id="btn_AddNewContent" align="center">
									<div class="packageTitle marginTop10 marginBottom10">There is no Content</div>
									<div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray" style="width:120px;line-height:30px;float:right;"
												onmouseover="document.getElementById('img_AddContent').src='{$TemplateURL}Web/Images/Ver_2_0/icon_add_over.png';"
												onmouseout="document.getElementById('img_AddContent').src='{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png';"
												onclick="Portal_LoadAddCommunityContent('{$BrandCommunityID}','{$BrandID}','Video', 'divClientPortalOperations_Container');">
										<img id="img_AddContent" src="{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" style="padding-left:8px;" class="marginRight5"></img>
										<span id="span_AddContent" class="capitalFont">Add Content</span>
									</div>
								</div>
							</xsl:otherwise>
						</xsl:choose>
					</table>
				</div>
			</xsl:otherwise>
		</xsl:choose>


	</xsl:template>

	<xsl:template name="DragonKickVideosOnBrand">
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<xsl:param name="HostName" select="'N/A'"></xsl:param>
		<xsl:param name="BrandCommunityID" select="'N/A'"></xsl:param>
		<xsl:param name="CountFrom" select="'N/A'"></xsl:param>
		<xsl:param name="VideoKeyValue" select="'N/A'"></xsl:param>
		<xsl:param name="StatusID" select="'N/A'"></xsl:param>
		<xsl:param name="VideoXML" select="'N/A'"></xsl:param>
		<xsl:param name="Origin" select="'N/A'"></xsl:param>

		<xsl:variable name="CountData" select="count($VideoXML/Output/Item)"></xsl:variable>
		<xsl:variable name="CountTo" select="$CountFrom + 3"></xsl:variable>

		<div id="divDragonKickVideoContent" class="dragon_DivColordBakground padding10">
			<!--<div class="welcomeContentText margin10">
				CountFrom-==<xsl:value-of select="$CountFrom"/><br/>
				CountTo-=<xsl:value-of select="$CountTo"/><br/>
				CountData-=<xsl:value-of select="$CountData"/>
			</div>-->
			<div id="dragonKickVideosHeader" class="marginTop15">
				<table cellpadding="3" cellspacing="0" class="tableMaster">
					<tr>
						<td width="2%" class="verticallyMiddle textCenter">
							<xsl:choose>
								<xsl:when test="$CountFrom &lt;= 1">
									<div>&#xa0;</div>
								</xsl:when>
								<xsl:otherwise>
									<img border="0" alt="" style="height:35px;width:20px;" title="Back" class="onMouseOver" src="{$TemplateURL}web/images/ver_2_0/dragonkick/arrow_back.png"
								 onclick="loadDragonkickVideoHeader('{$BrandCommunityID}', '{$CountFrom}', '{$StatusID}', 'back', '{$Origin}', 'divDragonKickVideoContent');"></img>
								</xsl:otherwise>
							</xsl:choose>
						</td>
						<td class="verticallyMiddle textCenter">
							<xsl:for-each select="$VideoXML/Output/Item[position() &lt;= $CountTo and position() &gt;= $CountFrom]">

								<xsl:choose>
									<xsl:when test="ImageAttach">
										<img class="onMouseOver marginLeft10" border="0" style="display:none;" onload="setWidthAndHeightImage(this, 160);" alt="" src="{ImageAttach}"
									 title="click to view video" onclick="loaddragonkickVideo('{ContentURL}', 'divDragonKickVideoDisplay', 'dragonkick', '{Format}', 'DisplayDragonKickVideo');"></img>
									</xsl:when>
									<xsl:otherwise>
										&#xa0;
									</xsl:otherwise>
								</xsl:choose>

							</xsl:for-each>
						</td>
						<td width="2%" class="verticallyMiddle textCenter">
							<xsl:choose>
								<xsl:when test="$CountData &lt;= $CountTo">
									&#xa0;
								</xsl:when>
								<xsl:otherwise>
									<img border="0" alt="" style="height:35px;width:20px;" title="Next" class="onMouseOver" src="{$TemplateURL}web/images/ver_2_0/dragonkick/arrow_next.png"
								 onclick="loadDragonkickVideoHeader('{$BrandCommunityID}', '{$CountFrom}', '{$StatusID}', 'next', '{$Origin}', 'divDragonKickVideoContent');">
									</img>
								</xsl:otherwise>
							</xsl:choose>
						</td>
					</tr>
				</table>
			</div>
			<div id="divDragonKickVideoDisplay" class="marginTop25 marginBottom20" align="center">
				<xsl:call-template name="VideoDisplay">
					<xsl:with-param name="VideoURL" select="$VideoXML/Output/Item[position() = $CountFrom]/VideoURL"></xsl:with-param>
					<xsl:with-param name="Format" select="$VideoXML/Output/Item[position() = $CountFrom]/Format"></xsl:with-param>
					<xsl:with-param name="VideoKeyValue" select="$VideoKeyValue"></xsl:with-param>
				</xsl:call-template>
			</div>
			<div align="center">
				<span style="color: #C1C1C1;">
					This site is powered by
				</span>
				<a class="publicationSummary" style="color:#C1C1C1;" href="/pro" target="_blank">LifeSpace Pro</a>
			</div>
		</div>
	</xsl:template>
</xsl:stylesheet>
