﻿<?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:key name="FolderTyp" match="AjaxRequest/Resources/Files/File/FolderName" use="." />
	<xsl:variable name="DiffFolder">
		<xsl:copy-of select="AjaxRequest/Resources/Files/File/FolderName[generate-id() = generate-id(key('FolderTyp',.))]"/>
	</xsl:variable>

	<xsl:template match="/">
		<xsl:call-template name="SearchResources">
			<xsl:with-param name="Resources" select="AjaxRequest/Resources/."></xsl:with-param>
			<xsl:with-param name="PortalItemID" select="AjaxRequest/Params/PortalItemID"></xsl:with-param>
			<xsl:with-param name="PermissionID" select="AjaxRequest/PermissionID"></xsl:with-param>
			<xsl:with-param name="UserType" select="AjaxRequest/Params/UserType"></xsl:with-param>
		</xsl:call-template>


	</xsl:template>
	<xsl:template name="SearchResources">
		<xsl:param name="Resources" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="PermissionID" select="'N/A'"></xsl:param>
		<xsl:param name="UserType" select="'N/A'"></xsl:param>
		<xsl:variable name="URLProfix">
			<xsl:text></xsl:text>
		</xsl:variable>
		<div class="col-md-12">
			<xsl:for-each select="msxsl:node-set($DiffFolder)/child::node()">
				<div class="row">
					<div >
						<div class="first_header">
							<div class="leftRes">
								<i class="glyphicon glyphicon-folder-open folder_size"></i>
							</div>
							<div class="centerRes1">
								<xsl:value-of select="."/>
							</div>
							<div class="rightRes"></div>
						</div>
					</div>
					<div >
						<div class="row_header">
							<xsl:variable name="foldertype" select="."></xsl:variable>
							<xsl:for-each select="$Resources/Files/File">
								<xsl:variable name="path" select="ThumbnailPath"/>
								<xsl:variable name="LightBoxClass">
									<xsl:choose>
										<xsl:when test="Format='Vimeo'">
											popup-vimeo
										</xsl:when>
										<xsl:when test="Format='Image'">
											image-link
										</xsl:when>
										<xsl:when test="Format ='YouTube'">
											popup-youtube
										</xsl:when>
									</xsl:choose>
								</xsl:variable>
								
								
								<xsl:variable name="fnonclick">
									<xsl:choose>
										<xsl:when test="$UserType !='Client'">
											viewItemDetailVersion3('<xsl:value-of select="ItemID"></xsl:value-of>', '<xsl:value-of select="$PortalItemID"></xsl:value-of>', 'div_item_<xsl:value-of select="$PortalItemID"></xsl:value-of>_detail_container'
											, 'div_item_<xsl:value-of select="$PortalItemID"></xsl:value-of>','2.0', 'view');
										</xsl:when>
									</xsl:choose>
								</xsl:variable>
								<xsl:variable name="href_Blank">
									<xsl:choose>
										<xsl:when test="$UserType !='Client'">
											javascript:void(0);
										</xsl:when>
										<xsl:otherwise>
											<xsl:value-of select="ContentURL"/>
										</xsl:otherwise>
									</xsl:choose>
								</xsl:variable>
								<xsl:variable name="Target">
									<xsl:choose>
										<xsl:when test="$UserType ='Client'">
											blank
										</xsl:when>
										</xsl:choose>
								</xsl:variable>
								<xsl:choose>
									<xsl:when test="$foldertype=FolderName">

										<div class="row_sub_header">
											<div class="leftRes">
												<div class=" star_size ">
													<button  type="button" class="multiselect dropdown-toggle btn padinone mrgnRt" data-toggle="dropdown" title="" aria-expanded="false" style="width: auto;padding:0px;">
														<span class="onMouseOver star-default glyphicon glyphicon-star star_{Flat_Priority} " id="span_Priority_{normalize-space(ItemID)}">
														</span>
													</button>


													<ul style="padding:0;width:70px;left:0!important;left:inherit;" class=" dropdown-menu Priority " id="ddl_Priority_{normalize-space(ItemID)}" previousValue="{Flat_Priority}">
														<xsl:choose>
															<xsl:when test="Flat_Priority=1">
																<li class="active" >
																	<a href="javascript:void(0);" onclick="UpdateItemPriority_3_0('{normalize-space(ItemID)}','1'); ">
																		<label class="radio" style="padding-left: 0px;">
																			<span class="glyphicon glyphicon-star star_1" ></span>
																		</label>
																	</a>
																</li>
																<li >
																	<a href="javascript:void(0);" onclick="UpdateItemPriority_3_0('{normalize-space(ItemID)}','0'); ">
																		<label class="radio" style="padding-left: 0px;">
																			<span class="glyphicon glyphicon-star star_0" ></span>
																		</label>
																	</a>
																</li>
															</xsl:when>
															<xsl:otherwise>
																<li >
																	<a href="javascript:void(0);" onclick="UpdateItemPriority_3_0('{normalize-space(ItemID)}','1'); ">
																		<label class="radio" style="padding-left: 0px;">
																			<span class="glyphicon glyphicon-star star_1" ></span>
																		</label>
																	</a>
																</li>
																<li class="active" >
																	<a href="javascript:void(0);" onclick="UpdateItemPriority_3_0('{normalize-space(ItemID)}','0'); ">
																		<label class="radio" style="padding-left: 0px;">
																			<span class="glyphicon glyphicon-star star_0" ></span>
																		</label>
																	</a>
																</li>
															</xsl:otherwise>
														</xsl:choose>
													</ul>
												</div>

												
												<div class="img_div">
													<a href="{$href_Blank}" onclick="{$fnonclick}"  target="{$Target}" class="{$LightBoxClass}">
														<img src="{$path}" class="img-responsive {$LightBoxClass}" id="thumbnailb_{ItemID}" onerror="this.onerror=null;this.src='{$URLProfix}/images/DefaultResourceIcon.png';"/>
													</a>
												</div>

											</div>
											<div class="centerRes" id="qFileName_{ItemID}">
												<a href="{$href_Blank}" onclick="{$fnonclick}" target="{$Target}" class="{$LightBoxClass}">
													<xsl:value-of select="Item"/>
												</a>
											</div>
										</div>
									</xsl:when>
								</xsl:choose>

							</xsl:for-each>
						</div>
					</div>
					<div class=""></div>
				</div>
			</xsl:for-each>
		</div>

	</xsl:template>
</xsl:stylesheet>
