﻿<?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="ResourceSyncProgress.xslt"/>
  <xsl:import href="../../GenericTemplates/StringReplace.xslt"/>
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="/">

    <xsl:variable name="ItemID" select="AjaxRequest/Params/ItemID"></xsl:variable>
    <xsl:variable name="SubPortalItemID" select="AjaxRequest/Params/SubPortalItemID"></xsl:variable>
    <xsl:variable name="FolderItemID" select="AjaxRequest/Params/FolderItemID"></xsl:variable>
    <xsl:variable name="HostName" select="AjaxRequest/HostName"></xsl:variable>
    <xsl:variable name="FileCabinet" select="AjaxRequest/FileCabinet/."></xsl:variable>
    <xsl:variable name="FolderName" select="AjaxRequest/FileCabinet/FolderName"></xsl:variable>
    <xsl:variable name="TemplateURL" select="normalize-space(AjaxRequest/TemplateURL)" />
    <xsl:variable name="Settings" select="AjaxRequest/Settings/."></xsl:variable>
    <xsl:variable name="Folders" select="$FileCabinet/Folders/."></xsl:variable>
    <xsl:variable name="RootFolder" select="$FileCabinet/FolderName"></xsl:variable>
    <xsl:variable name="Sync" select="AjaxRequest/Sync/."></xsl:variable>

    <xsl:variable name="CommunityAdmin" select="count(AjaxRequest/UserRoles/Role[RoleName = 'Community Admin'])"></xsl:variable>
    <xsl:variable name="IsActiveApi" select="AjaxRequest/ApiStatus/ApiActive/IsActive"></xsl:variable>


    <xsl:variable name="portalItemID">
      <xsl:choose>
        <xsl:when test="AjaxRequest/Params/SubPortalItemID or $SubPortalItemID!=''">
          <xsl:value-of select="$SubPortalItemID"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$ItemID"/>
        </xsl:otherwise>
      </xsl:choose>

    </xsl:variable>

    <xsl:variable name="URLProfix">
      <xsl:text></xsl:text>
    </xsl:variable>
    <xsl:variable name="FileMaskDescription">
      <xsl:text>All files (*.*)</xsl:text>
    </xsl:variable>

    <xsl:variable name="FileMaskType">
      <xsl:text>*.*</xsl:text>
    </xsl:variable>

    <div id="div_MediaList_{$ItemID}_FileList" class="col-md-12 col-sm-12 center_panel bxnone">
      <div >
        <ul>
          <li>
            <span class="folder glyphicon glyphicon-folder-open glypcolor1"></span>

            <xsl:if test="$ItemID != $FolderItemID">
              <a href="javascript:void(0);" id="BreadcrumFolder_{$ItemID}"
								   onClick="ClientPortal_LoadFileCabinetFiles_3_0( {$ItemID}, 'div_MediaList_{$ItemID}_FileContainer'
							   ,{$ItemID},{$portalItemID});">
                <xsl:text>Home</xsl:text>
              </a>
            </xsl:if>
            <xsl:for-each select="$FileCabinet/BreadCrum/Folder">
              <xsl:sort select="position()" order="descending"/>

              <xsl:if test="$ItemID != $FolderItemID">
                <span id="spnBreadcrumFolder_{FolderItemID}" ParentItemID="{ParentFolderItemID}">/</span>
              </xsl:if>
              <a href="javascript:void(0);" id="BreadcrumFolder_{FolderItemID}"
							   onClick="ClientPortal_LoadFileCabinetFiles_3_0( {$ItemID}, 'div_MediaList_{$ItemID}_FileContainer'
							   ,{FolderItemID},{$portalItemID});ExpandFolder('{FolderItemID}');">
                <xsl:value-of select="FolderName"/>
              </a>
            </xsl:for-each>
            <xsl:variable name="EscapedFolderName">
              <xsl:call-template name="replaceCharsInString">
                <xsl:with-param name="stringIn" select="$FolderName"></xsl:with-param>
                <xsl:with-param name="charsIn">
                  <xsl:text>'</xsl:text>
                </xsl:with-param>
                <xsl:with-param name="charsOut">
                  <xsl:text>\'</xsl:text>
                </xsl:with-param>
              </xsl:call-template>
            </xsl:variable>
            <span id="resourcesUpdatePanel" style="float:right;">
              <xsl:if test="$ItemID != $FolderItemID">
                <!-- <a href="#" class="dots">
                    <div class="dot"></div>
                  </a>-->
                <span class="outrcircle tooltipApi" style="margin:0px;">
                  <!--<span class="circlepoint"></span>
                  <span class="circlepoint MrgnLR5"></span>
                  <span class="circlepoint"></span>-->
                  <span class="fa fa-cloud-download glypcolor1" style="font-size:29px!important;float:right">
                  </span>
                  
                    <!--<xsl:choose>-->
                      <!--<xsl:if test="$CommunityAdmin &gt;= 1 ">-->
                        <span class="tooltiptext">
                          <xsl:for-each select="AjaxRequest/ApiStatus/ApiActive">
                          <!--<xsl:choose>-->
                            <xsl:if test="$CommunityAdmin &gt;= 1 and APISource= 'Dropbox' ">
                              <span>
                                <img src="image/DropBox.png" width="25px"  height="25px" style="margin-left:5px" onclick="windowpopup('dropbox/connect.aspx')" id="dropBoxAuthentication"></img>
                              </span>
                            </xsl:if>
                          <!--</xsl:choose>-->
                          <!--<xsl:choose>-->
                            <xsl:if test="$CommunityAdmin &gt;= 1 and APISource= 'Vimeo' ">
                              <span>
                                <img src="image/Vimeo.png" width="25px"  height="25px" style="margin-left:5px" onclick="windowpopup('integrations/vimeoConnect.aspx')" id="vimeoapi"></img>
                              </span>
                            </xsl:if>
                          <!--</xsl:choose>-->
                         </xsl:for-each>
                        </span>
                      <!--</xsl:if>-->
                      <!--<xsl:otherwise>
                        <span class="tooltiptext">
                         No Data Found<--><!--/span>-->
                      <!--</xsl:otherwise>-->
                    <!--</xsl:choose>-->

             

                </span>


                <span onclick="return deleteResourcesFile('{$FolderItemID}','deleteResourcesFolder')" data-toggle="tooltip" title="Delete Folder">
                  <span class="glyphicon glyphicon-remove-sign  glypcolor2 onMouseOver" style="font-size:25px!important;float:right">
                  </span>

                </span>
                <span onclick="OpenEditfolder('{$FolderItemID}','{$EscapedFolderName}')" data-toggle="tooltip" title="Edit Folder">
                  <span class="glyphicons glyphicons-folder-new glypcolor1 onMouseOver" style="font-size:25px!important;float:right">
                  </span>
                </span>
              </xsl:if>
              <span onclick="AddfolderPopup({$FolderItemID},{$ItemID})" data-toggle="tooltip" title="Add Folder">
                <span class="glyphicons glyphicons-folder-plus glypcolor1 onMouseOver" style="font-size:25px!important;float:right">
                </span>

              </span>
              <xsl:if test="$ItemID != $FolderItemID">
                <span onclick="return AddFileToPortal('{$FolderItemID}',{$ItemID},'{$FileMaskDescription}','{$FileMaskType}')" data-toggle="tooltip" title="Add File">
                  <span class="glyphicon glyphicon-plus-sign glypcolor1 onMouseOver" style="font-size:25px!important;">
                  </span>

                </span>
                <span onclick="return AddLink('{$FolderItemID}','{$ItemID}')" data-toggle="tooltip" title="Add Link">
                  <span class="glyphicon glyphicon-paperclip   glypcolor1 onMouseOver" style="font-size:25px!important;">
                  </span>

                </span>
              </xsl:if>

            </span>


            <xsl:if test="$CommunityAdmin &gt;= 1 and $IsActiveApi = 1 ">
              <img src="image/DropBox.png" width="25px"  height="25px" style="margin-left:5px" onclick="windowpopup('dropbox/connect.aspx')" id="dropBoxAuthentication"></img>
              <input type="hidden" value="{$FolderItemID}" id="resourcesActiveFolderID"></input>
              <input type="hidden" value="{$ItemID}" id="resourcesPortalItemID"></input>
              <div id="divResourceSyncProgress" style="display:inline">
                <xsl:call-template name="ResourceSyncProgress">
                  <xsl:with-param name="Sync" select="$Sync"></xsl:with-param>
                  <xsl:with-param name="FolderItemID" select="$FolderItemID"></xsl:with-param>
                </xsl:call-template>
              </div>
            </xsl:if>



            <!--<xsl:choose>
							<xsl:when test="$Sync/Status/PendingFiles &gt; 0">
								<div style="display:inline">
									<input id="btnDropBoxSync" type="button" value="Sync"
										   onClick="dropboxSyncInitiate({$FolderItemID}, {$Sync/Status/APIRequestID}, '');"></input>
									<span>
										<xsl:value-of select="$Sync/Status/PendingFiles"/> of <xsl:value-of select="$Sync/Status/TotalFiles"/> Pending
									</span>
								</div>
							</xsl:when>
						</xsl:choose>-->
          </li>
          <li>
            <hr/>
          </li>
          <xsl:for-each select="$Folders/Folder">


            <li id="folderDrag_{FolderItemID}"  ondragstart="dragStart(event)" ondrop="drop(event)" ondragover="allowDrop(event)" draggable="true" ItemID="{FolderItemID}" ondragenter="dragEnterFol(event);" ondragleave="dragleaveFol(event);">

              <div class="btn-group" style="padding:0;width:100%;float:left;"  draggable="false" ItemID="{FolderItemID}" ondragenter="dragEnterFol(event);" ondragleave="dragleaveFol(event);">

                <button  type="button" class="multiselect dropdown-toggle btn padinone mrgnRt" data-toggle="dropdown" title="" aria-expanded="false" style="width: auto;padding:0px;float:left;">
                  <span class="onMouseOver star-default glyphicon glyphicon-star star_{Priority}" id="span_Priority_{normalize-space(FolderItemID)}" style="line-height:41px;">
                  </span>
                </button>


                <ul style="padding:0;width:70px;left:0!important;left:inherit;" class=" dropdown-menu Priority" id="ddl_Priority_{normalize-space(FolderItemID)}" previousValue="{Priority}">
                  <xsl:choose>
                    <xsl:when test="Priority=1">
                      <li class="active" >
                        <a href="javascript:void(0);" onclick="UpdateItemPriority_3_0('{normalize-space(FolderItemID)}','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(FolderItemID)}','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(FolderItemID)}','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(FolderItemID)}','0');">
                          <label class="radio" style="padding-left: 0px;">
                            <span class="glyphicon glyphicon-star star_0" ></span>
                          </label>
                        </a>
                      </li>
                    </xsl:otherwise>
                  </xsl:choose>
                </ul>

                <xsl:if test="$portalItemID !=$ItemID">

                  <xsl:choose>
                    <xsl:when test="Authorized=1">
                      <input type="checkbox" style="float:left;margin:15px 8px 0px 0px;" id="ResCheckBox_{FolderItemID}" onchange="portalUnAuthrizedResources({$portalItemID},'ResCheckBox_{FolderItemID}','{FolderItemID}')" checked="checked"/>
                    </xsl:when>
                    <xsl:otherwise>
                      <input type="checkbox" style="float:left;margin:15px 8px 0px 0px;" id="ResCheckBox_{FolderItemID}" onchange="portalUnAuthrizedResources({$portalItemID},'ResCheckBox_{FolderItemID}','{FolderItemID}')"/>
                    </xsl:otherwise>
                  </xsl:choose>



                </xsl:if>
                <a href="javascript:void(0);"
														   onClick="ClientPortal_LoadFileCabinetFiles_3_0( {$ItemID}, 'div_MediaList_{$ItemID}_FileContainer',{FolderItemID},{$portalItemID});ExpandFolder('{FolderItemID}');" pso="position()" ItemID="{FolderItemID}" draggable="false" ondragenter="dragEnterFol(event);" ondragleave="dragleaveFol(event);">
                  <span class="folder glyphicon glyphicon-folder-close glypcolor1 glypiconbig pull-left" ItemID="{FolderItemID}"  ondragenter="dragEnterFol(event);" ondragleave="dragleaveFol(event);"></span>
                  <span class="line-height41" draggable="false" ItemID="{FolderItemID}" ondragenter="dragEnterFol(event);" ondragleave="dragleaveFol(event);">
                    <xsl:value-of select="FolderName"/>
                  </span>
                </a>

              </div>


            </li>
          </xsl:for-each>
          <!--<li>
						<span >
							<div class="form-group">
								<input style="text-align: left;" id="txt_{$FolderItemID}_FolderName" type="text" class="form-control addsbfoldr " placeholder="Add sub-folder...."
									   onkeyup="ClientPortal_CreateFolder_3_0({$FolderItemID}, 'div_MediaList_{$ItemID}_List_Folders', event, {$ItemID});"/>
							</div>
						</span>
					</li>-->
          <!--Do not show Files on Home/Root Folder-->
          <xsl:if test="$FolderItemID != $ItemID">
            <!--<li>
							<hr/>
						</li>-->
            <xsl:for-each select="$FileCabinet/File">
              <xsl:variable name="path" select="ImageAttach"></xsl:variable>
              <li id="File_{ItemID}" ondragstart="dragStart(event)" ondrag="dragging(event)" draggable="true" ItemID="{ItemID}">

                <div class="btn-group" style="padding:0;width:100%;float:left;" draggable='false' ondragstart="return false;"   ItemID="{ItemID}">

                  <button  type="button" class="multiselect dropdown-toggle btn padinone vercenter mrgnRt" data-toggle="dropdown" title="" aria-expanded="false" style="width: auto;padding:0px;" ItemID="{ItemID}">
                    <span class="onMouseOver star-default glyphicon glyphicon-star star_{Priority} vercenter" 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="{Priority}">
                    <xsl:choose>
                      <xsl:when test="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>
                  <span style="width: 2%; float: left;line-height:56px;text-align:center;margin-right:6px;">
                    <xsl:variable name="Checked">
                      <xsl:choose>
                        <xsl:when test="Authorized=1">
                          <xsl:text>checked</xsl:text>
                        </xsl:when>
                      </xsl:choose>
                    </xsl:variable>
                    <xsl:if test="$portalItemID !=$ItemID">
                      <xsl:choose>
                        <xsl:when test="Authorized=1">
                          <input type="checkbox" id="ResCheckBox_{ItemID}" onchange="portalUnAuthrizedResources({$portalItemID},'ResCheckBox_{ItemID}','{ItemID}')" checked="checked"/>
                        </xsl:when>
                        <xsl:otherwise>
                          <input type="checkbox" id="ResCheckBox_{ItemID}" onchange="portalUnAuthrizedResources({$portalItemID},'ResCheckBox_{ItemID}','{ItemID}')"/>
                        </xsl:otherwise>
                      </xsl:choose>
                    </xsl:if>
                  </span>
                  <a href="javascript:void(0)">
                    <div class="center_div_img"
											 onclick="viewItemDetailVersion3('{ItemID}', '{$ItemID}', 'div_item_{$ItemID}_detail_container'
								 , 'div_item_{$ItemID}','2.0', 'view'); ">

                      <span class="attr_img bigimg" style="width:8%;">
                        <img src="{$path}" class="img-responsive" id="thumbnailb_{ItemID}" draggable="false" onerror="this.onerror=null;this.src='{$URLProfix}/images/DefaultResourceIcon.png';"/>
                      </span>

                      <xsl:choose>
                        <xsl:when test="ContentName[text()]">
                          <span id="FileName_{ItemID}" class="whitespace vercenter lineheight34" >
                            <xsl:value-of select="ContentName"/>
                          </span>
                        </xsl:when>
                        <xsl:otherwise>
                          <span class="whitespace vercenter lineheight34" id="FileName_{ItemID}">
                            <xsl:value-of select="ContentURL"/>
                          </span>

                        </xsl:otherwise>
                      </xsl:choose>
                    </div>
                  </a>

                </div>

              </li>

            </xsl:for-each>
          </xsl:if>
        </ul>
      </div>
      <!--Do not show Add Links on Home/Root Folder-->
      <!--<xsl:if test="$FolderItemID != $ItemID">
				<div >
					<ul>
						<li>
							<button type="button"
								   onClick="document.getElementById('div_MediaList_{$ItemID}_UploadSuite').style.display='block';
							   document.getElementById('div_MediaList_{$ItemID}_FileList').style.display='none';
							   $au.imageUploaderFlash('UploadSuite_{$ItemID}').uploadPane().addFiles();" class="btn btn btn-primary pull-left">Add Files...</button>
							<input type="text" class="form-control addlink AdLink"
									   onkeyup="addResourceLink({$FolderItemID}, 'div_MediaList_{$ItemID}_FileContainer', event, {$ItemID});"
							   
								   Placeholder="Add Link ..." id="txtAddLink_{$FolderItemID}"></input>

							-->
      <!--<input type="button" value="Add a Link" onclick="AddResourceLink('Task_Popup')"/>-->
      <!--


							-->
      <!--<input type="button" value="Add Files..."
							   onClick="document.getElementById('div_MediaList_{$ItemID}_UploadSuite').style.display='block';
							   document.getElementById('div_MediaList_{$ItemID}_FileList').style.display='none';
							   $au.imageUploaderFlash('UploadSuite_{$ItemID}').uploadPane().addFiles();" ></input>-->
      <!--
						</li>
					</ul>
				</div>
			</xsl:if>-->
    </div>
    <!--<div id="div_MediaList_{$ItemID}_UploadSuite" style="height:400px;display:none;">
			<input type="hidden" id="EmbededScript_{$ItemID}_UploadSuite"
                   name="EmbededScript_{$ItemID}_UploadSuite"
                   style="display:none;"
                   value="loadFileUploadPanel('UploadSuite_{$ItemID}','div_MediaList_{$ItemID}_UploadSuite', {$ItemID}
                   , {$FolderItemID},'{$FileMaskDescription}','{$FileMaskType}', 1);"/>
		</div>-->

  </xsl:template>

  <xsl:template name="FileListing">
    <xsl:param name="FileCabinet" select="'N/A'"></xsl:param>
    <xsl:param name="ItemID" select="'N/A'"></xsl:param>
    <xsl:param name="FolderItemID" select="'N/A'"></xsl:param>
    <xsl:param name="HostName" select="'N/A'"></xsl:param>
    <xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
    <xsl:param name="Settings" select="'N/A'"></xsl:param>

    <xsl:variable name="FolderType" select="$FileCabinet/FolderType"></xsl:variable>
    <xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
    <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />

    <xsl:variable name="FileMaskDescription">
      <xsl:choose>
        <xsl:when test="$Settings/FileUpload/Folder[@name=$FolderType]">
          <xsl:value-of select="$Settings/FileUpload/Folder/@name"/>
          <xsl:text>(</xsl:text>
          <xsl:for-each select="$Settings/FileUpload/Folder[@name=$FolderType]/Type">
            <xsl:text>*.</xsl:text>
            <xsl:value-of select="."/>
            <xsl:text>;</xsl:text>
          </xsl:for-each>
          <xsl:text>)</xsl:text>
        </xsl:when>
        <xsl:when test="$Settings/DefaultSettings/FileUpload/Folder[@name=$FolderType]">
          <xsl:value-of select="$Settings/DefaultSettings/FileUpload/Folder/@name"/>
          <xsl:text>(</xsl:text>
          <xsl:for-each select="$Settings/DefaultSettings/FileUpload/Folder[@name=$FolderType]/Type">
            <xsl:text>*.</xsl:text>
            <xsl:value-of select="."/>
            <xsl:text>;</xsl:text>
          </xsl:for-each>
          <xsl:text>)</xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>All files (*.*)</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <xsl:variable name="FileMaskType">
      <xsl:choose>
        <xsl:when test="$Settings/FileUpload/Folder[@name=$FolderType]">
          <xsl:for-each select="$Settings/FileUpload/Folder[@name=$FolderType]/Type">
            <xsl:text>*.</xsl:text>
            <xsl:value-of select="."/>
            <xsl:text>;</xsl:text>
          </xsl:for-each>
        </xsl:when>
        <xsl:when test="$Settings/DefaultSettings/FileUpload/Folder[@name=$FolderType]">
          <xsl:for-each select="$Settings/DefaultSettings/FileUpload/Folder[@name=$FolderType]/Type">
            <xsl:text>*.</xsl:text>
            <xsl:value-of select="."/>
            <xsl:text>;</xsl:text>
          </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>*.*</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <div id="div_MediaList_{$ItemID}_UploadSuite" style="height:100%;display:none;">
      <input type="hidden" id="EmbededScript_{$ItemID}_UploadSuite"
                   name="EmbededScript_{$ItemID}_UploadSuite"
                   style="display:none;"
                   value="loadFileUploadPanel('UploadSuite_{$ItemID}','div_MediaList_{$ItemID}_UploadSuite', {$ItemID}
                   , {$FolderItemID},'{$FileMaskDescription}','{$FileMaskType}', 1);"/>
    </div>
    <div id="div_MediaList_{$ItemID}_FileList" class="padding5"
             style="border-left:1px solid white;height:98%;"
             onTouchStart="this.style.overflowY = 'scroll';"
             ondragenter="document.getElementById('div_MediaList_{$ItemID}_UploadSuite').style.display='block';
             document.getElementById('div_MediaList_{$ItemID}_FileList').style.display='none';">
      <div style="overflow: hidden">
        <div class="verticallyMiddle" style="float:left;">
          <div style="float:left;line-height:30px;">
            <span class="circle"></span>

          </div>
          <div style="float:left;line-height:30px;margin-left:5px;">
            <span id="spanFolderItem_{$FolderItemID}_Title" class="packageTitle">
              <xsl:value-of select="$FileCabinet/FolderName"/>
            </span>
          </div>
          <div  class="verticallyMiddle" style="float:left;height:30px;margin-left:5px;margin-top: 5px;">
            <select id="optFolderItem_{$FolderItemID}_Title"
                                onChange="folderAdminOptions(this, {$FolderItemID}, 'div_MediaList_{$ItemID}_FileList',{$ItemID});">
              <option>- Select -</option>
              <option value="1">Edit</option>
            </select>
          </div>
        </div>
        <div style="float:right;">
          <div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray"
                         style="width:100px;line-height:30px;float:right;margin-top:1px"
                         onmouseover="document.getElementById('img_AddFile') != null ? document.getElementById('img_AddFile').src=
                                         '{$TemplateURL}Web/Images/Ver_2_0/icon_add_over.png':'';"
                         onmouseout="document.getElementById('img_AddFile') != null ? document.getElementById('img_AddFile').src=
                                         '{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png':'';"
                         onClick="document.getElementById('div_MediaList_{$ItemID}_UploadSuite').style.display='block';
                         document.getElementById('div_MediaList_{$ItemID}_FileList').style.display='none';
                         $au.imageUploaderFlash('UploadSuite_{$ItemID}').uploadPane().addFiles();">
            <img id="img_AddFile"
                             src="{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png"
                             align="absmiddle" style="padding-left:8px;" class="marginRight5">
            </img>
            <span id="span_Add" class="capitalFont">Add File</span>
          </div>
        </div>
      </div>
      <div style="height:100%;"
                 onMouseOver="this.style.overflowY = 'scroll';"
                 onMouseOut="this.style.overflowY = '';">

        <xsl:for-each select="$FileCabinet/File">

          <xsl:variable name="loweredFileName">
            <xsl:value-of select="translate(FileName, $uppercase, $smallcase)"/>
          </xsl:variable>

          <xsl:variable name="ImageLink">
            <xsl:choose>
              <xsl:when test ="contains($loweredFileName, 'jpg') or contains($loweredFileName, 'jpeg')
                                          or contains($loweredFileName, 'png') or contains($loweredFileName, 'gif')
                                          or contains($loweredFileName, 'bmp')">
                <xsl:text>image-link</xsl:text>
              </xsl:when>
            </xsl:choose>
          </xsl:variable>

          <div id="divFileCabinet_{FileCabinetID}">
            <div style="width:70%; float:left;">
              <ul>
                <xsl:call-template name="FileControl">
                  <xsl:with-param name="FileName" select="FileName"></xsl:with-param>
                  <xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
                  <xsl:with-param name="ThumbnailPath" select="ThumbnailPath"></xsl:with-param>
                  <xsl:with-param name="ID" select="FileCabinetID"></xsl:with-param>
                  <xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
                </xsl:call-template>
              </ul>
            </div>
            <div class="verticallyMiddle" style="display:table-cell;height:42px;width:15%">
              <select id="opt_{FileCabinetID}_Action"
									onChange="fileCabinetAdminOptions(this
                                    , 'http://{normalize-space($HostName)}/FileCabinet/{Hash}/{FileName}'
                                    , {FileCabinetID}
                                    , '{FileName}');">
                <option value="-99">- Select -</option>
                <option value="1">Copy URL</option>
                <option value="2">Delete</option>
              </select>
            </div>
          </div>
        </xsl:for-each>
      </div>

    </div>

  </xsl:template>
  <xsl:template name="FileControl">
    <xsl:param name="FileName" select="'N/A'"></xsl:param>
    <xsl:param name="HostName" select="'N/A'"></xsl:param>
    <xsl:param name="ThumbnailPath" select="'N/A'"></xsl:param>
    <xsl:param name="ID" select="'N/A'"></xsl:param>
    <xsl:param name="WebURL" select="'N/A'"></xsl:param>
    <xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
    <xsl:param name="Title" select="'N/A'"></xsl:param>

    <xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
    <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />

    <xsl:variable name="loweredFileName">
      <xsl:value-of select="translate($FileName, $uppercase, $smallcase)"/>
    </xsl:variable>

    <xsl:variable name="ImageLink">
      <xsl:choose>
        <xsl:when test ="contains($loweredFileName, 'jpg') or contains($loweredFileName, 'jpeg')
                                          or contains($loweredFileName, 'png') or contains($loweredFileName, 'gif')
                                          or contains($loweredFileName, 'bmp')">
          <xsl:text>image-link</xsl:text>
        </xsl:when>
      </xsl:choose>
    </xsl:variable>

    <xsl:variable name="LinkTitle">
      <xsl:choose>
        <xsl:when test="$WebURL != 'N/A'">
          <xsl:value-of select="$Title"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$FileName"></xsl:value-of>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <xsl:variable name="URL">
      <xsl:choose>
        <xsl:when test="$WebURL != 'N/A'">
          <xsl:value-of select="$WebURL"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>http://</xsl:text>
          <xsl:value-of select="normalize-space($HostName)"></xsl:value-of>
          <xsl:text>/FileCabinet/</xsl:text>
          <xsl:value-of select="Hash"></xsl:value-of>
          <xsl:text>/</xsl:text>
          <xsl:value-of select="$FileName"></xsl:value-of>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <xsl:variable name="Thumbnail">
      <xsl:choose>
        <xsl:when test="$WebURL != 'N/A'">
          <xsl:value-of select="$TemplateURL"></xsl:value-of>
          <xsl:text>/Web/Images/Ver_2_0/GLBIcon.png</xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$ThumbnailPath"></xsl:value-of>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>


    <li>
      <span class="circle"></span>
      <img id="SurveyFileUpload_{$ID}_Thumbnail"
					 src="{$Thumbnail}" align="absmiddle"
					 onload="setWidthAndHeightImage(this, 50);">
      </img>

      <a class="{$ImageLink}" target="_blank"
			   href="{$URL}">
        <span id="SurveyFileUpload_{$ID}_FileName" >
          <xsl:value-of select="$LinkTitle"/>
        </span>
      </a>
    </li>
  </xsl:template>

</xsl:stylesheet>
