https://files.fm/u/fhazcb8kug

Submitted URL:
https://files.fm/u/fhazcb8kug
Report Finished:

The outgoing links identified from the page

LinkText
https://apps.apple.com/in/app/files-fm-cloud-storage/id1636301796 Mobile: Apple iOSNew!
https://video.failiem.lv/b/auth/openid_connectCreate video room
https://www.vuze.comVuze
https://webtorrent.io/desktop/WebTorrent

JavaScript Variables · 750 found

Global JavaScript variables loaded on the window object of a page, are variables declared outside of functions and accessible from anywhere in the code within the current scope

NameType
0object
1object
2object
3object
4object
5object
6object
onbeforetoggleobject
documentPictureInPictureobject
onscrollendobject

Console log messages · 38 found

Messages logged to the web console

TypeCategoryLog
warningother
URL
https://files.fm/webtorrent/FilesFm_P2P/filesfm_p2p.min.js?v=1719512729
Text
Invalid asm.js: Expected function name
logother
URL
https://stpd.cloud/saas/3285
Text
direct
logother
URL
https://stpd.cloud/saas/3285
Text
=============================
logother
URL
https://stpd.cloud/saas/3285
Text
adunit.code:
logother
URL
https://stpd.cloud/saas/3285
Text
adunit.path: files_320x100_sticky_anchorad_mobile
logother
URL
https://stpd.cloud/saas/3285
Text
slot.id: files_970x90_sticky_anchorad_responsive
logother
URL
https://stpd.cloud/saas/3285
Text
slot.path: files_320x100_sticky_anchorad_mobile
logother
URL
https://stpd.cloud/saas/3285
Text
=============================
logother
URL
https://stpd.cloud/saas/3285
Text
=============================
logother
URL
https://stpd.cloud/saas/3285
Text
adunit.code:
logother
URL
https://stpd.cloud/saas/3285
Text
adunit.path: files_320x100_top_mobile
logother
URL
https://stpd.cloud/saas/3285
Text
slot.id: files_320x100_top_responsive
logother
URL
https://stpd.cloud/saas/3285
Text
slot.path: files_320x100_top_mobile
logother
URL
https://stpd.cloud/saas/3285
Text
=============================
logother
URL
https://stpd.cloud/saas/3285
Text
=============================
logother
URL
https://stpd.cloud/saas/3285
Text
adunit.code:
logother
URL
https://stpd.cloud/saas/3285
Text
adunit.path: files_300x250_file_desktop_1
logother
URL
https://stpd.cloud/saas/3285
Text
slot.id: files_300x250_file_desktop_1
logother
URL
https://stpd.cloud/saas/3285
Text
slot.path: files_300x250_file_desktop_1
logother
URL
https://stpd.cloud/saas/3285
Text
=============================
logother
URL
https://stpd.cloud/saas/3285
Text
=============================
logother
URL
https://stpd.cloud/saas/3285
Text
adunit.code:
logother
URL
https://stpd.cloud/saas/3285
Text
adunit.path: files_300x250_mobile
logother
URL
https://stpd.cloud/saas/3285
Text
slot.id: files_300x250_mobile
logother
URL
https://stpd.cloud/saas/3285
Text
slot.path: files_300x250_mobile
logother
URL
https://stpd.cloud/saas/3285
Text
=============================
logother
URL
https://stpd.cloud/saas/3285
Text
=============================
logother
URL
https://stpd.cloud/saas/3285
Text
adunit.code:
logother
URL
https://stpd.cloud/saas/3285
Text
adunit.path: files_300x250_desktop_left_sticky
logother
URL
https://stpd.cloud/saas/3285
Text
slot.id: files_300x250_desktop_left_sticky
logother
URL
https://stpd.cloud/saas/3285
Text
slot.path: files_300x250_desktop_left_sticky
logother
URL
https://stpd.cloud/saas/3285
Text
=============================
warningother
URL
https://securepubads.g.doubleclick.net/pagead/managed/js/gpt/m202410100101/pubads_impl.js
Text
[GPT] Interstitial /19238985/files.fm_interstitial not requested: Unable to access local storage to determine if the frequency cap has been exceeded due to insufficient user consent. https://goo.gle/gpt-message#145
errorother
URL
https://securepubads.g.doubleclick.net/pagead/managed/js/gpt/m202410100101/pubads_impl.js
Text
[GPT] Div ID passed to googletag.display() does not match any defined slots: files_300x250_sidebar_desktop_1. https://goo.gle/gpt-message#26
errorother
URL
https://securepubads.g.doubleclick.net/pagead/managed/js/gpt/m202410100101/pubads_impl.js
Text
[GPT] Div ID passed to googletag.display() does not match any defined slots: files_300x250_sidebar_desktop_2. https://goo.gle/gpt-message#26
errorother
URL
https://securepubads.g.doubleclick.net/pagead/managed/js/gpt/m202410100101/pubads_impl.js
Text
[GPT] Div ID passed to googletag.display() does not match any defined slots: failiem_970x90_sticky_anchorad_responsive. https://goo.gle/gpt-message#26
verbosedom
URL
https://files.fm/u/fhazcb8kug
Text
[DOM] Password field is not contained in a form: (More info: https://goo.gl/9p2vKq) %o
verbosedom
URL
https://files.fm/u/fhazcb8kug
Text
[DOM] Input elements should have autocomplete attributes (suggested: "current-password"): (More info: https://goo.gl/9p2vKq) %o

HTML

The raw HTML body of the page

<html id="adaptive_html" lang="EN"><head><script type="text/javascript" async="" src="https://static.criteo.net/js/ld/publishertag.prebid.144.js"></script><style class="vjs-styles-defaults">
      .video-js {
        width: 300px;
        height: 150px;
      }

      .vjs-fluid:not(.vjs-audio-only-mode) {
        padding-top: 56.25%
      }
    </style><script type="text/javascript" async="" src="https://script.4dex.io/localstore.js"></script><script type="text/javascript" async="" src="https://www.google-analytics.com/analytics.js"></script><script type="text/javascript" async="" src="https://www.googletagmanager.com/gtag/js?id=G-H8LJ280FZW&amp;l=dataLayer&amp;cx=c"></script><script type="text/javascript" async="" src="https://www.googletagmanager.com/gtag/js?id=AW-1043031755&amp;l=dataLayer&amp;cx=c"></script><script type="text/javascript" async="" src="https://www.googletagmanager.com/gtag/js?id=UA-1970559-6&amp;l=dataLayer&amp;cx=c"></script><script type="text/javascript" async="" src="https://www.google-analytics.com/analytics.js"></script><script type="text/javascript" async="" src="https://www.googletagmanager.com/gtag/js?id=G-EFZ32Z07VR&amp;l=dataLayer&amp;cx=c"></script><script async="" src="//analytics.files.fm/matomo.js"></script><script type="text/javascript">
        var intPrevAdRefreshTST = (new Date()).getTime();
		var bolIsListViewForSpecificFile = Boolean(0);
    </script>



<meta charset="UTF-8">
<meta name="globalsign-domain-verification" content="WVoCXGP9WWz7ZO3hqGZASmZCYQ2jhO7WxIRwsepEgV">
<meta name="theme-color" content="#ffffff">
<meta name="facebook-domain-verification" content="nikti9bu56gz5oi6d126k5bloj0772">
<title>-Moments-Feb-18-2024--.mp4 | Files.fm.</title>
<meta name="keywords" content="ftp file upload, file hosting, android, file cloud, cloud storage, file sharing, failu glabāšana, bilžu hostings, bilžu apmaiņa, failu apmaiņa, failu serveris, failu koplietošana, failu rezerves kopijas, failu backup, file hosting, file sharing, file exchange, file storage, image hosting, file upload, files, file share, web file hosting, internet file storage, image upload, free upload, photo sharing, online photo gallery, photos online, data backup, online backup">
<meta property="og:title" content="mp4: -Moments-Feb-18-2024--.mp4">
<meta property="og:description" content="Visit this link to play the video: -Moments-Feb-18-2024--.mp4">
<meta name="description" content="Visit this link to play the video: -Moments-Feb-18-2024--.mp4">
<meta property="og:image" content="https://fv5-4.files.fm/thumb_video_picture.php?i=8ygca6f2cs">
<meta property="og:image:secure_url" content="https://fv5-4.files.fm/thumb_video_picture.php?i=8ygca6f2cs">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://fv5-4.files.fm/thumb_video_picture.php?i=8ygca6f2cs">
<meta property="twitter:image" content="https://fv5-4.files.fm/thumb_video_picture.php?i=8ygca6f2cs">
<meta property="og:url" content="https://files.fm/u/fhazcb8kug">
<meta property="og:type" content="website">
<meta property="og:site_name" content="Files.fm">
<meta property="fb:app_id" content="303254966461402">
<link rel="canonical" href="https://files.fm/u/fhazcb8kug">
<link rel="alternate" hreflang="x-default" href="https://files.fm/u/fhazcb8kug">
<link rel="alternate" hreflang="en" href="https://files.fm/u/fhazcb8kug">
<link rel="preconnect" href="https://www.googletagmanager.com" crossorigin="">
<link rel="preconnect" href="https://files.fm" crossorigin="">
<link rel="preconnect" href="https://www.google-analytics.com" crossorigin="">
<link rel="preconnect" href="https://www.googleadservices.com" crossorigin="">
<link rel="preconnect" href="https://googleads.g.doubleclick.net" crossorigin="">
<link rel="preconnect" href="https://stats.g.doubleclick.net" crossorigin="">
<link rel="preconnect" href="https://www.google.com" crossorigin="">
<link rel="preconnect" href="https://www.google.lv" crossorigin="">
<script>
	
    var _paq = window._paq = window._paq || [];
    
    _paq.push( [ 'trackPageView' ] );
    _paq.push( [ 'enableLinkTracking' ] );
    
    (function()
    {
        var u= '//analytics.files.fm/';
        
        _paq.push( [ 'setTrackerUrl', u + 'matomo.php' ] );
        _paq.push( [ 'setSiteId', '1' ] );
        
        var d = document;
        var g = d.createElement( 'script' );
        var s = d.getElementsByTagName( 'script' )[ 0 ];
        
        g.async = true;
        g.src = u + 'matomo.js';
        s.parentNode.insertBefore( g, s );
    } )();

</script>
<script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-1970559-10"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  
    
  gtag('js', new Date());
  
    gtag('config', 'UA-1970559-10');

    gtag('config', 'UA-1970559-6');
  
    
    gtag('config', 'AW-1043031755');
  
</script>
<script src="/js/google_conversion.js?v=4"></script>

<script async="" src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
    window.googletag = window.googletag || {cmd: []};
    googletag.cmd.push(function() {
      if(window.innerWidth > 1000) {
        googletag.defineSlot('/19238985/files_970x90_sticky_anchorad_desktop', [[970,90],[950,90],[900,90],[728,90],[970,50],[1000,90],[1000,100]], 'files_970x90_sticky_anchorad_responsive').addService(googletag.pubads());
        googletag.defineSlot('/19238985/files_300x250_sidebar_desktop_1', [[300,250]], 'files_300x250_sidebar_desktop_1').addService(googletag.pubads());
        googletag.defineSlot('/19238985/files_300x250_sidebar_desktop_2', [[300,250]], 'files_300x250_sidebar_desktop_2').addService(googletag.pubads());
        googletag.defineSlot('/19238985/files_300x250_file_desktop_1', [[300,250]], 'files_300x250_file_desktop_1').addService(googletag.pubads());
        googletag.defineSlot('/19238985/files_300x250_desktop_left_sticky', [[300,250]], 'files_300x250_desktop_left_sticky').addService(googletag.pubads());
      } else {
        googletag.defineSlot('/19238985/files_300x250_file_desktop_1', [[300,250]], 'files_300x250_file_desktop_1').addService(googletag.pubads());
		googletag.defineSlot('/19238985/files_320x100_sticky_anchorad_mobile', [[320,100],[300,100],[320,50],[300,50]], 'files_970x90_sticky_anchorad_responsive').addService(googletag.pubads());
        googletag.defineSlot('/19238985/files_320x100_top_mobile', [[320,100],[300,100],[320,50],[300,50]], 'files_320x100_top_responsive').addService(googletag.pubads());
        googletag.defineSlot('/19238985/files_300x250_mobile', [[300,250],[336,336],[336,320],[320,320],[300,300],[336,280],[320,250],[320,336]], 'files_300x250_mobile').addService(googletag.pubads());
		googletag.defineSlot('/19238985/files_300x250_desktop_left_sticky', [[300,250]], 'files_300x250_desktop_left_sticky').addService(googletag.pubads());
      }  
        var interstitialSlot = googletag.defineOutOfPageSlot('/19238985/files.fm_interstitial', googletag.enums.OutOfPageFormat.INTERSTITIAL);
        if (interstitialSlot) interstitialSlot.addService(googletag.pubads());
      
    googletag.pubads().disableInitialLoad();
    googletag.pubads().enableSingleRequest();              
    googletag.pubads().collapseEmptyDivs();
    googletag.enableServices();
    googletag.display(interstitialSlot);
    })
             
</script>
<script async="" src="https://stpd.cloud/saas/3285"></script>
<base href="https://files.fm/">
<meta name="verify-v1" content="4MHpv5CF+UNp34oMIZOxnVwoSslLpr+5GPkxFp94Wq8=">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="all" href="/css/reset.css?v=1715343650"><link rel="stylesheet" type="text/css" media="all" href="/css/global.css?v=1722490362"><link rel="stylesheet" type="text/css" media="all" href="/css/header.css?v=1728475221"><link rel="stylesheet" type="text/css" media="all" href="/css/messages/messages.css?v=1715343651"><link rel="stylesheet" type="text/css" media="all" href="/ts/chat/dist/chat.css?v=1715343647">
<script src="/js/jquery-1.12.2.min.js?v=1715343643"></script>
<script src="/js/jquery-migrate-1.3.0.js?v=1715343643"></script>
<script src="/js/JSON/cycle.js?v=1715343642"></script> <script src="/error_handler_client?v=4"></script>
<link rel="icon" type="image/png" href="/images/logo/rebranded/favicon-192x192px.png?v=2">
<link rel="icon" type="image/svg+xml" href="/images/logo/rebranded/favicon-192x192px.svg?v=2">
<script>

				var DOMAIN_NAME = 'files.fm';
				
				var HTTP_HOST = 'files.fm';
				var IS_DEV_SERVER = false;

				// capitalize first letter of domain
                DOMAIN_NAME = DOMAIN_NAME.charAt(0).toUpperCase() + DOMAIN_NAME.slice(1);

				var lang_code = 'EN';

				var DOCUMENT_IS_LOADED = false;

				var MMVD = false;
				var STDT = new Date().getTime();

				var WEB_ROOT_PATH = '';

				var FB_APP_ID = '303254966461402';

				var strTranslation_LinkCopied = 'Link copied to memory';

				var strSellFilesCurrency = 'USD';

				$(function(){

					DOCUMENT_IS_LOADED=true

                    var intScrollTop = $('html').scrollTop();
                    var intFlagHeight = $('body').hasClass('show_header_flag') ? 20 : 0;
					intScrollTop = Math.max(intScrollTop, $('body').scrollTop());
					
                    if ( intScrollTop > 0 )
                    {
                        $('body').addClass('scrolled');
                    }
                    
                    var intPrevScrollPos = intScrollTop;
                    var objHeaderElem = document.getElementById("header");
                    
                    $(window).on('scroll', function () {
                        //close side menu
                        $( '#navbar-toggler-chb' ).prop('checked', false);
                        $( '#header' ).css('z-index', '');

                        var intScrollTop = $('html').scrollTop();
                        intScrollTop = Math.max(intScrollTop, $('body').scrollTop());
                        
                        if ( intScrollTop > 0 )
                        {
                            $('body').addClass('scrolled');
                        }
                        else
                        {
                            $('body').removeClass('scrolled');
                            checkMenuItems();
                        }

                                            });

					$( document ).mousemove( function( event )
					{
						if ( ! MMVD )
						{
							if ( ( ( new Date().getTime() ) - STDT ) > 1000 )
							{
								MMVD = true;
							}
						}
					});
				});


				function changeLanguage(strLangCode, strTitle)
				{
					var strUrl = '';
					switch (strLangCode)
					{
						case 'lv':
                            strUrl = 'https://failiem.lv/u/fhazcb8kug';
                            break;
						case 'en':
                            strUrl = 'https://files.fm/u/fhazcb8kug';
                            break;
						case 'ru':
                            strUrl = 'https://ru.files.fm/u/fhazcb8kug';
                            break;
						case 'de':
                            strUrl = 'https://de.files.fm/u/fhazcb8kug';
                            break;
						case 'fi':
                            strUrl = 'https://fi.files.fm/u/fhazcb8kug';
                            break;
                        case 'es':
                            strUrl = 'https://es.files.fm/u/fhazcb8kug';
                            break;
                        case 'ko':
                            strUrl = 'https://ko.files.fm/u/fhazcb8kug';
                            break;
                        case 'uk':
                            strUrl = 'https://ua.files.fm/u/fhazcb8kug';
                            break;
					}
                    gaev('HeaderClick', 'Lang_switch', strLangCode);
					window.location = strUrl + WEB_ROOT_PATH;// + '?lng='+strLangCode;
					$('.language_dropdown .activator SPAN').each(function (){
						var img = $('IMG', this).clone();
						$(this).html(strTitle + ' ').append(img);
					});
					hidePopups();
				}


				function gaev(strCategory, strAction, strLabel, strValue) {

					if (typeof gtag != 'undefined') {
						// old ga.js
						//_gaq.push(['_trackEvent', strCategory, strAction, strLabel]);
						
						// Send the event to the gtag.js Google Analytics property
						// with tracking ID GA_MEASUREMENT_ID.
						gtag('event', 'Events', {
						  'event_category': strCategory,
						  'event_action': 	strAction,
						  'event_label': 	strLabel,
						  'value':			strValue
						});
						
						/*gtag('event', 'strEveryEventTest', {
						  'send_to': 'UA-1970559-10',
						  'event_category': 'EveryEvent',
						  'event_action': 	'TestAction',
						  'event_label': 	'TestLabel'
						});*/

					};
					
					
					if ( typeof _paq != 'undefined' )
					{
						_paq.push( [
							'trackEvent',
							strCategory ,
							strAction ,
							strLabel ,
							strValue
						] );
					}
				}
				
				function logClick(strButton)
				{
										if (typeof gtag != 'undefined')
					{
						//_gaq.push(['_trackEvent', 'ActionLine', strButton, 'List']);

						gtag('event', 'Clicks', {
						  'send_to': 'UA-1970559-10',
						  'event_category': 'ActionLine',
						  'event_action': 	strButton,
						  'event_label': 	'List'
						});
					};
									}


				function printAdwordsConversion(strIframeName) {

					var  iframe = document.createElement('iframe');
					iframe.style.width = '0px';
					iframe.style.height = '0px';
					document.body.appendChild(iframe);

					iframe.src = 'https://files.fm/server_scripts/google_adwords/'+ strIframeName +'.php';
				}

			</script>
<script>
				var IS_MOBILE = false;
			</script>

<!--[if lt IE 9]>
				<script type="text/javascript" src="./js/html5.js"></script>
				<script type="text/javascript" src="./js/css3-mediaqueries.js"></script>
			<![endif]-->
<script>  	var tb_lang = new Object();  	tb_lang["close"] = "Close";  	tb_lang["or_esc_key"] = "or press the Esc key";  </script>
<script>

				Math._round = function(number, precision)
				{
					precision = Math.abs(parseInt(precision)) || 0;
					var coefficient = Math.pow(10, precision);
					return Math.round(number*coefficient)/coefficient;
				}

				function file_size_format (filesize, intPrecision, bolShowBits=false )
				{
					if ( bolShowBits )
					{
						filesize = filesize * 8;
					}
				    
				    if (typeof(intPrecision) == 'undefined' || intPrecision==null)
				        intPrecision = 2;
				    
					if (filesize >= 1073741824)
					{
						filesize = Math._round(filesize / 1073741824, 2).toFixed(intPrecision) + '&nbsp;G';
					}
					else
					{
						if (filesize >= 1048576)
						{
							filesize = Math._round(filesize / 1048576, 2).toFixed(intPrecision) + '&nbsp;M';
						}
						else
						{
							if (filesize >= 1024)
							{
								filesize = Math._round(filesize / 1024, 0).toFixed(intPrecision) + '&nbsp;K';
							}
							else
							{
								filesize = filesize.toFixed(intPrecision) + '&nbsp;';
							};
						};
					};
					
					if ( bolShowBits )
					{
						filesize += 'bits';
					}
					else 
					{
						filesize += 'B';
					}
					
					return filesize;
				};

			</script>
<script>
    /**
     * @param strEmails - one or more emails delimited with ","
     * @param bolIsSingleEmail - is strEmails only one email
     */
    function EmailValidator(strEmails, bolIsSingleEmail)
    {
        this.state = EmailValidator.states.READY;
        this.strSuggestedEmails = "";
        this.strEmails = strEmails.trim();
        this.strNoMxEmails = "";
        this.strInputID = "";
        this.bolIsSingleEmail = bolIsSingleEmail;

        // set default invalid cb
        this.setOnInvalidCB(function(){});
        this.strErrorClass = "has-error";
    }
    
    EmailValidator.regexTest = function(email) 
    {
        var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        
        return re.test( email )
            // disallow single quotes
            && email.indexOf( "'" ) === -1;
    };
    
    //<editor-fold desc="Setters">
    /**
     * this.onValidCB and this.onInvalidCB and this.setOnSuggestionCB execution order:
     *  1. remove this.strErrorClass from this.strInputID
     *  2. show or hide modal - only for onInvalid and onValid
     *  3. run callback
     */
    EmailValidator.prototype.setOnValidCB = function (onValidCB)
    {
        this.onValidCB = applyTo(this, function ()
        {
            if (this.strModalID && $('#' + this.strModalID).css('opacity') == 0)
            {
                showModal(this.strModalID);
            }
            this.removeClassFromInput();
            onValidCB();
        });

        return this;
    };
    EmailValidator.prototype.setOnInvalidCB = function (onInvalidCB)
    {
        this.onInvalidCB = applyTo(this, function ( strInvalidEmails)
        {
            if( typeof strInvalidEmails === 'undefined' )
            {
                strInvalidEmails =  '';
            }
            
            if (this.strModalID && $('#' + this.strModalID).css('opacity') == 0)
            {
                showModal(this.strModalID);
            }
            this.addErrorClassToInput();
            onInvalidCB(strInvalidEmails);
        });

        return this;
    };
    EmailValidator.prototype.setOnSuggestionCB = function (onSuggestionCB)
    {
        this.revalidate = function ()
        {
            this.addErrorClassToInput();
            onSuggestionCB();
        };
        return this;
    };
    
    EmailValidator.prototype.setModalID = function (strModalID)
    {
        this.strModalID = strModalID;
        return this;
    };

    EmailValidator.prototype.setInputID = function (strInputID)
    {
        this.strInputID = strInputID;
        return this;
    };

    EmailValidator.prototype.setErrorClass = function (strErrorClass)
    {
        this.strErrorClass = strErrorClass;
        return this;
    };
    //</editor-fold>
    
    EmailValidator.prototype.onTooManyEmails = function () 
    {
        fError("You cannot send more than 5 emails at one time.", "", "OK", applyTo(this, this.onInvalidCB));
    };

    /**
     * adds this.strErrorClass to element with ID this.strInputID
     */
    EmailValidator.prototype.addErrorClassToInput = function ()
    {
        if (this.strInputID)
        {
            $("#" + this.strInputID).addClass(this.strErrorClass);
        }
    };

    /**
     * removes this.strErrorClass from element with ID this.strInputID
     */
    EmailValidator.prototype.removeClassFromInput = function ()
    {
        if (this.strInputID)
        {
            $("#" + this.strInputID).removeClass(this.strErrorClass);
        }
    };

    EmailValidator.prototype.run = function ()
    {
        if(this.strEmails === "") 
        {
            this.state = EmailValidator.states.INVALID;
            this.onInvalidCB();
            return;
        }
        
        // onValid, onInvalid and strEmails are necessary!
        if (!this.onValidCB || !this.onInvalidCB)
        {
            throw new Error("EmailValidator is missing essential data!");
        }
        
        var emails;

        // check if not over allowed email count
        if( !this.bolIsSingleEmail )
        {
            emails = this.strEmails.split(",");
            if( emails.length > 50 ) {
                this.state = EmailValidator.states.TOO_MANY_EMAILS;
                this.onTooManyEmails();
                return;
            }
        }
        else
        {
            emails = [ this.strEmails ];
        }

        // test emails against email regex before posting them
        for (var i in emails)
        {
            if ( emails.hasOwnProperty(i) && !EmailValidator.regexTest( emails[i].trim() ) )
            {
                this.state = EmailValidator.states.INVALID;
                this.onInvalidCB( emails[i].trim() );
                return;
            }
        }

        this.state = EmailValidator.states.RUNNING;

        $.post('/chkMail.php', {'q': this.strEmails}, applyTo(this, this.onResponse));
    };

    EmailValidator.prototype.onResponse = function (data)
    {
        var arrReturn = JSON.parse(data);

        if (arrReturn['result'] === 0)
        {
            this.state = EmailValidator.states.VALID;
            this.onValidCB(this);
        }
        else if(arrReturn['result'] === EmailValidator.states.INVALID) 
        {
            this.state = EmailValidator.states.INVALID;
            this.onInvalidCB();
        }
        else if (arrReturn['result'] === 2)
        {
            this.strSuggestedEmails = arrReturn['suggest'];

            if (arrReturn['no_mx'])
            {
                this.strNoMxEmails = arrReturn['no_mx'];
                this.state = EmailValidator.states.MISSING_MX_RECORDS;
            }
            else
            {
                this.state = EmailValidator.states.POSSIBLE_TYPO;
            }

            // this calls onSuggestionCB
            this.revalidate();
        }
        else if (arrReturn['result'] === 4)
        {
            this.state = EmailValidator.states.TOO_MANY_EMAILS;
            this.onTooManyEmails();
        }
    };

    EmailValidator.prototype.revalidate = function ()
    {
        // add typo suggestions and emails with no mx records to string
        var strMsg = '';
        if (this.strSuggestedEmails !== '')
        {
            strMsg += "Did you mean:";
            strMsg += " " + this.strSuggestedEmails + "?\n";
        }
        if (this.strNoMxEmails !== '')
        {
            if(this.bolIsSingleEmail)
            {
                strMsg += "It\u2019s possible that this e-mail address is incorrect:"            }
            else 
            {
                strMsg += "These e-mail addresses might be invalid:"            }
            
            strMsg += " " + this.strNoMxEmails + ".\n";
        }

        if(this.bolIsSingleEmail)
        {
            strMsg += "Please check the email you have entered! If it is correct, click OK.";
        }
        else 
        {
            strMsg += "Please verify that the entered e-mails are correct! If all e-mails are correct, press OK.";
        }

        this.addErrorClassToInput();

        // hide the original modal to avoid overlapping
        if (this.strModalID && $('#'+this.strModalID).css('opacity') == 1)
        {
            hideModal(this.strModalID);
        }

        fConfirm(
            strMsg,
            "Check the email address you entered",
            "OK",
            "Cancel",
            applyTo(this, function ( bolResult)
            {
                // execute onInvalid only if user declines
                if (bolResult === false)
                {
                    this.state = EmailValidator.states.INVALID;
                    this.onInvalidCB();
                }
            }),
            applyTo(this, function ()
            {
                this.state = EmailValidator.states.ACCEPTED_TYPO;
                this.onValidCB();
            }, this)
        );
    };

    EmailValidator.prototype.isSubmittable = function ()
    {
        return [EmailValidator.states.VALID, EmailValidator.states.ACCEPTED_TYPO].indexOf(this.state) !== -1;
    };

    EmailValidator.states = {
        READY: -2,              // initial state
        RUNNING: -1,            // request has started and server has not responded yet

        // => onValidCB
        VALID: 0,

        // => onInvalidCB
        INVALID: 1,

        // => revalidate => onSuggestionCB
        POSSIBLE_TYPO: 2,       // there are typos in the submitted emails
        MISSING_MX_RECORDS: 3,  // some emails have missing mx records
        TOO_MANY_EMAILS: 4,     // too many emails are submitted

        // => revalidate => onSuggestionCB (clicked OK) => onValid 
        ACCEPTED_TYPO: 5        // typo was spotted but user dismissed it
    };
    
    // the function is defined in functions.js, but because this script is included in bergafoto, lets check to make sure.
    if ( typeof applyTo !== 'function' )
    {
        /**
         * Magic function that makes vanilla JS objects usable
         *  - execute fn in the context of $this with passed parameters
         *  - you can also pass parameters to the fn that is returned, they will be added to the fn call
         * @param $this - Object scope
         * @param fn - Object method to execute
         * @param var1 - first parameter to be passed to fn
         * @returns {Function}
         */
        window.applyTo = function( $this, fn, var1 )
        {
            if ( !$this )
            {
                throw new Error( "Invalid usage of closure function, scope must be defined." );
            }
        
            if ( !fn )
            {
                throw new Error( "Invalid usage of closure function, fn must be defined." );
            }
        
            var finalArgs = [];
        
            // skip first 3 arguments (callee, $this, fn)
            for ( var i = 2; i < arguments.length; ++i )
            {
                // add to list of args
                finalArgs.push( arguments[ i ] );
            }
        
            return function ()
            {
                // add all arguments
                for ( var i = 0; i < arguments.length; ++i )
                {
                    finalArgs.push( arguments[ i ] );
                }
            
                // first arguments will be the ones passed to closure, then the ones passed to this function
                return fn.apply( $this, finalArgs );
            };
        }
    }
</script>
<link rel="stylesheet" type="text/css" media="all" href="/bootstrap/css/dropdown.css?v=1715343645"><link rel="stylesheet" type="text/css" media="all" href="/css/global_facelift.css?v=1720449903"><link rel="stylesheet" type="text/css" media="all" href="/css/inputs.css?v=1717752354"><link rel="stylesheet" type="text/css" media="all" href="/js/jquery-ui-1.12.1.custom/jquery-ui.min.css?v=1715343640"><link rel="stylesheet" type="text/css" media="all" href="/css/thickbox.css?v=1715343651"><link rel="stylesheet" type="text/css" media="all" href="/css/modal.css?v=1715343648"><link rel="stylesheet" type="text/css" media="all" href="/css/font-awesome-new/css/font-awesome.min.css?v=1715343648"><link rel="stylesheet" type="text/css" media="all" href="/css/font-awesome-pro/css/light.min.css?v=1715343650"><link rel="stylesheet" type="text/css" media="all" href="/css/font-awesome-pro/css/brands.min.css?v=1715343650"><link rel="stylesheet" type="text/css" media="all" href="/css/font-awesome-pro/css/fontawesome.min.css?v=1715343649"><link rel="stylesheet" type="text/css" media="all" href="/css/alert.css?v=1715343648">
<script src="/js/jquery.cookie.js?v=1715343634"></script>
<script src="/js/jquery-ui-1.12.1.custom/jquery-ui.js?v=1715343640"></script>
<script src="/js/global.js?v=1727422596"></script>
<script src="/js/info_tooltips.js?v=1722490360"></script>
<script src="/js/jquery-ui-1.11.4.custom/jquery-ui.min.js?v=1715343634"></script>
<script src="/js/event.js?v=1715343644"></script>
<script src="/js/functions.js?v=1715343642"></script>
<script src="/js/thickbox.js?v=1715343642"></script>
<script src="/js/modal.js?v=1715343639"></script>
<script src="/js/alert.js?v=1715343643"></script>
<link rel="stylesheet" type="text/css" media="all" href="css/list.v2/main.css?v=5091">
<link rel="stylesheet" type="text/css" media="all" href="css/list.v2/horizontal_view.css?v=23">
<link rel="stylesheet" type="text/css" media="all" href="css/list.v2/grid_view.css?v=5029">
<link rel="stylesheet" type="text/css" media="all" href="css/list.v2/list_view.css?v=5030">
<link rel="stylesheet" type="text/css" media="all" href="css/list.v2/vertical_view.css?v=21">
<link rel="stylesheet" type="text/css" media="all" href="css/bootstrap/dropdowns_custom.css?v=103">
<link rel="stylesheet" type="text/css" media="all" href="js/guillotine/css/jquery.guillotine.css">
<script type="text/javascript" src="js/jqote2/jquery.jqote2.min.js"></script>
<script type="text/javascript" src="js/timeago-en.js"></script>
<script type="text/javascript" src="js/list.v2.js?v=1104"></script>
<script type="text/javascript" src="js/long-press-event.min.js"></script>
<script type="text/javascript" src="js/jquery-lazyload/jquery.scrollstop.min.js"></script>
<script type="text/javascript" src="js/jquery-lazyload/jquery.lazyload.min.js"></script>
<script type="text/javascript" src="js/guillotine/js/jquery.guillotine.js?v=2"></script>
<script type="text/javascript" src="js/iro.js"></script><link rel="stylesheet" type="text/css" media="all" href="https://failiem.lv/u/fhazcb8kug?set_visited_cookie_and_exit=1&amp;upload_hash=fhazcb8kug"><link rel="stylesheet" type="text/css" media="all" href="/css/stripe_payment_form.css?v=1715343648">
<script src="/js/stripe_payment_form.js?v=1720712236"></script>
<script>

	var PHPSESSID = '40bdb754ce23cdfc13a344b0230a4e21f5e0785a';
	var STRIPE_PUBLIC_KEY = 'pk_live_qdaFEN4KBX40UvEYnwlKCIX8';
	var STRIPE_LOCALE = 'auto';

	var arrStripePaymentFormErrorMsg = {
		'FinishOrder' : 'An error occurred while processing the order. Please contact [email protected]!' ,
		'Processing' : 'An error occurred while processing the payment. Please try again or contact [email protected]!' ,
		'InvalidData' : 'Please enter valid payment card details!' ,
		'BankDeclined' : 'An error occurred while processing payment - your bank declined the payment. Please check if your bank account has enough funds; if your payment card is authorized to make payments on the Internet. Or contact your bank, or use another payment card.' ,
		'NotEnoughFunds' : 'Your bank account does not have enough funds. Please supplement the account or use another payment card!' ,
		'InvalidCVV' : 'Please check and enter a valid payment card CVV code!' ,
        'AlreadyPaid' : 'Thank you, payment has already been received.' ,
	};

</script> <meta http-equiv="origin-trial" content="AlK2UR5SkAlj8jjdEc9p3F3xuFYlF6LYjAML3EOqw1g26eCwWPjdmecULvBH5MVPoqKYrOfPhYVL71xAXI1IBQoAAAB8eyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiV2ViVmlld1hSZXF1ZXN0ZWRXaXRoRGVwcmVjYXRpb24iLCJleHBpcnkiOjE3NTgwNjcxOTksImlzU3ViZG9tYWluIjp0cnVlfQ=="><meta http-equiv="origin-trial" content="Amm8/NmvvQfhwCib6I7ZsmUxiSCfOxWxHayJwyU1r3gRIItzr7bNQid6O8ZYaE1GSQTa69WwhPC9flq/oYkRBwsAAACCeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiV2ViVmlld1hSZXF1ZXN0ZWRXaXRoRGVwcmVjYXRpb24iLCJleHBpcnkiOjE3NTgwNjcxOTksImlzU3ViZG9tYWluIjp0cnVlfQ=="><meta http-equiv="origin-trial" content="A9wSqI5i0iwGdf6L1CERNdmsTPgVu44ewj8QxTBYgsv1LCPUVF7YmWOvTappqB1139jAymxUW/RO8zmMqo4zlAAAAACNeyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiRmxlZGdlQmlkZGluZ0FuZEF1Y3Rpb25TZXJ2ZXIiLCJleHBpcnkiOjE3MzY4MTI4MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="A+d7vJfYtay4OUbdtRPZA3y7bKQLsxaMEPmxgfhBGqKXNrdkCQeJlUwqa6EBbSfjwFtJWTrWIioXeMW+y8bWAgQAAACTeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiRmxlZGdlQmlkZGluZ0FuZEF1Y3Rpb25TZXJ2ZXIiLCJleHBpcnkiOjE3MzY4MTI4MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><script src="https://securepubads.g.doubleclick.net/pagead/managed/js/gpt/m202410100101/pubads_impl.js" async=""></script></head>
<body class="lang_en use_vh full-width non-sticky">

<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-N9HRMM7"
            height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>


<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5ZNTW54" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>

<script>

    jQuery.fn.shake = function(interval,distance,times){
        interval = typeof interval == "undefined" ? 100 : interval;
        distance = typeof distance == "undefined" ? 10 : distance;
        times = typeof times == "undefined" ? 3 : times;
        var jTarget = $(this);
        jTarget.css('position','relative');
        for(var iter=0;iter<(times+1);iter++){
            jTarget.animate({ left: ((iter%2==0 ? distance : distance*-1))}, interval);
        }
        return jTarget.animate({ left: 0},interval);
    }

	$( window ).bind( 'load', function()
	{
        const strUrlParams = new URLSearchParams(window.location.search);
		if( strUrlParams.has('coupon') || strUrlParams.has('kupons') ) 
		{
			showCreateAccount();
            adaptFormForCoupon();
        }
	} );
</script>
<div id="container" class="filesfm ">
<noscript>
				<table class="alert_container alert_container_danger" style="display: block">
					<tr>
						<td>
							<i class="fa fa-exclamation-circle"></i>
						</td>
						<td>
							<div class="alert_main_text">
								Your browser does not support Javascript. To use this page turn on JavaScript or use another browser.							</div>
						</td>
					</tr>
				</table>
			</noscript>
<header id="header" class="">
<nav>


<div id="header_flag">
<div id="header_flag_1"></div>
<div id="header_flag_2"></div>
</div>
<!-- -->

<div class="container">
<input type="checkbox" class="navbar-toggler" id="navbar-toggler-chb">
<label id="navbar-toggler" class="only-bottom navbar-toggler-stripes user-has-not-clicked-navbar-toggler new" for="navbar-toggler-chb" onclick="if(! $('#navbar-toggler-chb').is(':checked')) { $( '#header' ).css('z-index', '100000'); } $( this ).toggleClass( 'clicked' ); navbarTogglerClicked(); gaev('HeaderClick', 'Hamburger-menu', '');" onmouseover="navbarTogglerClicked()" style="visibility: visible;">
Menu </label>
<script type="text/javascript">
                function navbarTogglerClicked()
                {
                    $( '#navbar-toggler' ).removeClass( 'user-has-not-clicked-navbar-toggler' );
                    document.cookie = 'user-has-clicked-navbar-toggler=1; max-age=' + (365*24*60*60) + ' ; path=/ ; domain=failiem.lv';
                    document.cookie = 'user-has-clicked-navbar-toggler=1; max-age=' + (365*24*60*60) + ' ; path=/ ; domain=.failiem.lv';
                    document.cookie = 'user-has-clicked-navbar-toggler=1; max-age=' + (365*24*60*60) + ' ; path=/ ; domain=files.fm';
                    document.cookie = 'user-has-clicked-navbar-toggler=1; max-age=' + (365*24*60*60) + ' ; path=/ ; domain=.files.fm';
                }
            </script>
<div class="nav-left">
<a class="navbar-brand menu-link" onclick="gaev('HeaderClick', 'Logo', '');" href="/">
<img class="logo" alt="Files.fm" src="/images/logo/rebranded/files-fm-logo-slogan.svg"> </a>
</div>
<div class="navbar" id="main-nav" style="overflow: initial;">
<ul>





<li class="nav-button showonfirstload_mid nav-upload nav-bottom" data-priority="2" data-original-order="5" style="display: list-item;">
<a class="nav-link" href="javascript:void(0);" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast'); setTimeout(()=>{$('#uploadifive-file_upload').shake();}, 50); gaev('HeaderClick', 'Upload', '');"></a>
</li>
<li class="nav-button showonfirstload_mid nav-plans nav-bottom" data-priority="2" data-original-order="6">
<a class="nav-link" href="/storage-plans" onclick="gaev('HeaderClick', 'Storage_plans_and_prices', '');">
<div class="top">Pricing</div>
<div class="bottom">Upgrade</div>
</a>
</li>
<li class="nav-button darker nav-right" data-priority="2" data-original-order="7" style="display: list-item;">
<a href="/" onclick="gaev('HeaderClick', 'Start_upload', ''); hidePopups();" class="nav-link">
Upload files </a>
</li>
<li class="nav-button darker blue showonfirstload_small nav-files nav-bottom nav-hideTop" data-priority="1" style="margin-right: 6px; display: list-item;" data-original-order="8">
<a href="/filebrowser" onclick="gaev('HeaderClick', 'My_files', 'NotLoggedIn');" class="nav-link">
My files </a>
</li>
<li class="nav-right nav-button darker showonfirstload_small nav-bottom nav-login" data-priority="0" data-original-order="9">
<div id="login">
<a href="javascript:void(0);" onclick="gaev('HeaderClick', 'Log_in', ''); showSignIn(); return false;" id="login_button" class="">
<span id="login_button_text">Log in</span>
</a>
</div>
</li>
<li class="nav-right nav-button red showonfirstload_small" data-priority="1" data-original-order="10">
<div>
<a href="javascript:void(0);" onclick="gaev('HeaderClick', 'Sign_up', ''); showCreateAccount(); return false;" id="signup">New</a>
</div>
</li>
<li class="nav-right showonfirstload_mid" id="lang_switch" data-priority="2" data-original-order="11">
<div class="header_menu_wrap">
<div class="header_menu_label">
<img id="lang_switch_icon_dark" src="/images/UI_icons/globe.svg">
<span class="currentlang">EN</span>
</div>
<div class="header_menu_drawer right">
<a class="drawer-item" href="javascript:changeLanguage('en', 'EN');">English (EN)</a>
<a class="drawer-item" href="javascript:changeLanguage('es', 'ES');">Español (ES)</a>
<a class="drawer-item" href="javascript:changeLanguage('de', 'DE');">Deutsch (DE)</a>
<a class="drawer-item" href="javascript:changeLanguage('fi', 'FI');">Suomi (FI)</a>

<a class="drawer-item" href="javascript:changeLanguage('ru', 'РУ');">Русский (РУ)</a>
<a class="drawer-item" href="javascript:changeLanguage('uk', 'UK');">Українська (UA)</a>
<a class="drawer-item" href="javascript:changeLanguage('lv', 'LV');">Latviešu (LV)</a>
</div>
</div>
</li>
</ul>
</div>
<script>
                function addAnonymousUploads()
                {
                    var addUploads = confirm('Bind previous uploads from this device to your account? You can manage or delete them.');
                    if (addUploads == true)
                    {
                        $('.add_anonym_uplaods').val('1');
                    }
                }
            </script>
<div id="mega-menu" class="collapse">
<div class="container event_ignore_click">
<ul id="nav-functional" class="has-items event_ignore_click"><li data-priority="10" class="nav-button" data-original-order="0" data-original-width="125" style="display: list-item;">
<div class="header_menu_wrap">
<div class="header_menu_label">Solutions</div>
<div class="header_menu_drawer">
<a class=" SyncShare withicon drawer-item" href="/sync-share" onclick="gaev('HeaderClick', 'Solutions-Storage', '');">
Data storage <div class="desc">Automatic sync and sharing tools</div>
</a>
<a class=" Filebox withicon drawer-item" href="/upload-form" onclick="gaev('HeaderClick', 'Solutions-Filebox', '');">
Integrate file uploads or API <div class="desc">File upload form for websites</div>
</a>
<a class="PublicProfiles withicon drawer-item" href="/public-profiles" onclick="gaev('HeaderClick', 'Solutions-Publish', '');">
Publish content <div class="desc">Create a public profile and file catalog</div>
</a>
<a class=" SportEvents withicon drawer-item" href="/events" onclick="gaev('HeaderClick', 'Solutions-SportEvents', '');">
For sports and events <div class="desc">Publishing content from events</div>
</a>
<a class=" SellFiles withicon drawer-item" href="/sell-files" onclick="gaev('HeaderClick', 'Solutions-SellFiles', '');">
Sell content <div class="desc">Sell your content publicly or privately</div>
</a>

</div>
</div>
</li><li data-priority="2" class="nav-button" data-original-order="1" style="display: list-item;" data-original-width="96">
<div class="header_menu_wrap">
<div class="header_menu_label">Apps</div>
<div class="header_menu_drawer">
<a class="drawer-item" href="https://chat.files.fm" onclick="gaev('HeaderClick', 'Apps-Chat-AI', '');" target="_blank"> AI chat.files.fm</a>
<a class="drawer-item" href="https://play.google.com/store/apps/details?id=com.files.fm" onclick="gaev('HeaderClick', 'Apps-Android', '');" target="_blank"> Mobile: Android <div class="drawer-item-new">New!</div></a>
<a class="drawer-item" href="https://apps.apple.com/in/app/files-fm-cloud-storage/id1636301796" onclick="gaev('HeaderClick', 'Apps-IOS', '');" target="_blank"> Mobile: Apple iOS <div class="drawer-item-new">New!</div></a>
<a class="drawer-item" href="/sync-share#setup" onclick="gaev('HeaderClick', 'Apps-Desktop', '');"> Sync for Windows | MacOS | Linux</a>

<a class="drawer-item" href="/webdav-info" onclick="gaev('HeaderClick', 'Apps-Webdav', '');">Network drive via Webdav</a>
</div>
</div>
</li><li data-priority="2" class="nav-button" data-original-order="2" style="display: list-item;" data-original-width="96">
<div class="header_menu_wrap">
<div class="header_menu_label">Tools</div>
<div class="header_menu_drawer">
<a class="withicon drawer-item Useroutline" target="_blank" href="/public-profiles" onclick="gaev('HeaderClick', 'Tools-My-public-profile', '');">My public profile</a>
<a class="withicon drawer-item ConvertMp4" href="?convert-to-mp4" onclick="gaev('HeaderClick', 'Tools-convert-to-mp4', '');">Convert video to mp4</a>
<a class="withicon drawer-item ConvertPDF" href="?convert-to-pdf" onclick="gaev('HeaderClick', 'Tools-convert-to-pdf', '');">Convert docs to PDF</a>
<a class="withicon drawer-item VideoCall" href="https://video.failiem.lv/b/auth/openid_connect" onclick="gaev('HeaderClick', 'Tools-Video-room', '');">Create video room</a>
</div>
</div>
</li><li class="nav-button" data-priority="2" data-original-order="3" style="display: list-item;" data-original-width="109">
<a href="/business" class="nav-link">
Business </a>
</li><li class="nav-button library-button  new" data-priority="2" data-original-order="4" style="display: list-item;" data-original-width="95">
<a href="/stream" class="nav-link">
Stream <div class="tag new">New!</div>
</a>
</li></ul>
</div>
<div class="overlay"></div>
</div>
<div id="mega-menu-close"></div>
</div>
<div id="navbar-css"></div>
</nav>
</header>
<script>

            if (!$.cookie('new_library'))
        {
            $('.library-button').addClass('new');
            $('.navbar-toggler-stripes').addClass('new');
            
        }

        $('.library-button').on('click', function () {
            if ( $(this).hasClass('new') )
            {
                document.cookie = 'new_library="1"; max-age=' + (90*24*60*60) + ' ; path=/ ; domain=failiem.lv';
                document.cookie = 'new_library="1"; max-age=' + (90*24*60*60) + ' ; path=/ ; domain=.failiem.lv';
                document.cookie = 'new_library="1"; max-age=' + (90*24*60*60) + ' ; path=/ ; domain=files.fm';
                document.cookie = 'new_library="1"; max-age=' + (90*24*60*60) + ' ; path=/ ; domain=.files.fm';

                $(this).removeClass('new');
                $('.navbar-toggler-stripes').removeClass('new');
            }
        });

        
    $('#mega-menu .other-apps LI').on('click', function () {
        if ( $('A:first-child', this).attr('href') != null && $('A:first-child', this).attr('href').indexOf('javascript:') == -1 )
        {
            window.location = $('A:first-child', this).attr('href');
        }
    });
    
    $('#mega-menu-close').on('click', function () {
        $( '#navbar-toggler-chb' ).prop('checked', false);
        $( '#header' ).css('z-index', '');
    });

    $('.header_menu_wrap').on('mouseleave', function (e)
    {
        var $elem = $(this);
        
        if (! $elem.parents('#mega-menu').length) 
        {
            if ($elem.is("#usergreeting") ){
                setTimeout(function() {
                    if(! $('#usergreeting:hover').length > 0)
                    {
                        $elem.find('.header_menu_label').removeClass('open');
                    }
                }, 500);
            }
            else
            {
                if(!$elem[ 0 ].matches(":hover"))
                {
                    $elem.find('.header_menu_label').removeClass('open');
                }
            }
        }
    });

    $('.header_menu_label').on('click', function () {
       
        var that = this;

        $(".header_menu_label").filter(function() {
            // check object in list is not current object
            if ($(this).parents('#mega-menu').length)
            {
                return false;
            }
            return this != that;
        }).removeClass('open');

        $(this).toggleClass('open');
       
        var $elem = $(this);
        
        $elem.parent().find('.header_menu_drawer').css({
            'left': '', 
            'right': ''
        });
        
        var bounding = $elem.parent().find('.header_menu_drawer')[0].getBoundingClientRect();
        var boundingParent = $elem[0].getBoundingClientRect();
        if (bounding.left < 0)
        {
            $elem.parent().find('.header_menu_drawer').css({
                'left': -boundingParent.left+5 + 'px', 
                'right': 'unset'
            });
        }
        if (bounding.right > (window.innerWidth || document.documentElement.clientWidth))
        {
            $elem.parent().find('.header_menu_drawer').css({
                'left': 'unset', 
                'right': -(window.innerWidth-boundingParent.right)+20 + 'px'
            });
        }
    });
</script>
<script src="/js/Captcha/Google/LazyGoogleReCaptchaV2.js"></script>
<script>
                objLazyGoogleReCaptchaV2.strLanguageKey = "en";
                objLazyGoogleReCaptchaV2.strSiteKey = "6LflqXQUAAAAAP2CM782IqIgjzooEt9soXTCwxX2";
            </script>
<link rel="stylesheet" type="text/css" media="all" href="/css/sign_in_form.css?v=35">
<div id="sign-in" class="modal-container" tabindex="-1" role="dialog" aria-labelledby="createaccount-header signin-header" aria-hidden="true" style="display:none">
<div class="modal-inner">

<div id="sign-in-header">
<span id="signin-header" onclick="if( !$( '#signin-modal-content' ).is( ':visible' ) ) showSignIn(); return false;">
Log in <img id="signin-header_icon_inactive" src="/images/signup_form/log_in.svg?v=2" alt="Login to upload files">
<img id="signin-header_icon_active" src="/images/signup_form/log_in_blue.svg?v=2" alt="Login to upload files">
</span>
<span id="createaccount-header" onclick="if( !$('#createaccount-modal-content').is(':visible')) showCreateAccount(); return false;">
Sign up </span>
</div>

<div id="createaccount-referral-container" style="display:none">
<span class="referrer-container">
You have been invited by&nbsp;<span id="createaccount-referral-referrer"></span>&nbsp;to create account and get 1GB </span>
<hr>
</div>
<div id="createaccount-message-container">
<table class="alert_container alert_container_danger">
<tbody><tr>
<td><i class="fa fa-exclamation-circle"></i></td>
<td><div class="alert_main_text"></div></td>
</tr>
</tbody></table>
</div>

<div id="createaccount-modal-content" class="modal-content">
<div class="info"></div>

<div class="signin-modal-content-social">
<div class="signin-modal-content-social-title">Create free account:</div>
<div class="signin-modal-content-social-buttons-container signin-modal-content-social-buttons-container-2-buttons">

<div class="standard_button google_button social_login_button" onclick="checkSocialLogin('google');">
<img src="/images/signup_form/login-google.svg?v=2" alt="Sign up with Google to upload files for free">
<span>Google</span>
</div>
<div class="standard_button ms_button social_login_button" onclick="checkSocialLogin('microsoft');">
<img src="/images/signup_form/login-microsoft.svg" alt="Sign up with Microsoft to upload files for free">
<span>Microsoft</span>
</div>
<div class="justify_el"></div>
</div>
</div>

<div class="or-delimiter">
or </div>

<div id="createaccount-simple-container">
<input id="createaccount-referral-hash" name="inviter_hash" type="hidden">
<input id="createaccount-referral-user" name="inviter_user" type="hidden">
<div id="register_coupon_code">
<div class="input-label">
<label for="register_coupon_code_input">Coupon code</label>
<input id="register_coupon_code_input" name="coupon_code" type="text">
</div>
<div class="createaccount-input-container"></div>
</div>
<div class="no-coupon-link">
<a href="" onclick="revertFormFromCoupon(); return false">I do not have a coupon code »</a>
</div>
<div class="input-label">
<label for="createaccount_name">First name</label>
<input id="createaccount_name" name="createaccount_name" type="text" autocomplete="off">
</div>
<div class="input-label">
<label for="createaccount_surname">Last name</label>
<input id="createaccount_surname" name="createaccount_surname" type="text" autocomplete="off">
</div>
<div class="input-label">
<label for="createaccount_email">E-mail</label>
<input id="createaccount_email" name="createaccount_email" type="email" autocomplete="off" onchange="createUsername(this.value);">
</div>
<div class="input-label">
<label for="createaccount_password">Password</label>
<input id="createaccount_password" name="createaccount_password" type="password" autocomplete="off">
</div>
<div class="justify_el"></div>


<div id="your_public_profile_container">
<div id="your_public_profile_label_text_before">
Your profile:
</div>
<div id="your_public_profile_label">
<span id="your_public_profile_label_text">
Your profile:
</span>
<span id="your_public_profile_label_host">
https://files.fm/ </span>
</div>
<div id="your_public_profile_field_input">
<input id="createaccount_username" name="createaccount_username" type="text" autocomplete="off" placeholder="Username" onkeyup="usernameChanged();">
</div>
</div>
<div id="createaccount_coupon_info" onclick="showSignIn()">
I already have a Files.fm account » </div>
<div id="createaccount_error_msg" class="error_msg"></div>
<div class="sign_in_captcha" id="createaccount_captcha">
<div class="google-recaptcha-v2-container" id="4CFAB007-4C44-110F-D581-FAA865AF07D3"></div> <script>
                                function loadCreateAccountCaptcha()
                                {
                                    (function () {
            var init = function (){
                // Wait for include to load
                if ( typeof(objLazyGoogleReCaptchaV2) !== "undefined" )
                {
                    objLazyGoogleReCaptchaV2.initInstance (
                        "4CFAB007-4C44-110F-D581-FAA865AF07D3",
                        captchaCreateAccountLoaded,
                        captchaCreateAccountSubmitted
                    )
                }
                else
                {
                    setTimeout(init, 50);
                }
            };
            init();
        })();
                                }
                            </script>
</div>
<div class="sign_in_submit_bn" onclick="checkCreateAccountForm();">
Sign up <img src="/images/signup_form/sign_up.svg" alt="Sign up to upload files for free">
</div>
<div id="createaccount-modal-link-container">
<a id="createaccount-modal-coupon-link" href="javascript:void(0)" onclick="adaptFormForCoupon()">
<span>Use a coupon</span>
</a>
</div>
<div id="createaccount_info">
By using this website, you agree to the terms and data processing: <a href="/terms?source=sign-up" target="_blank">Learn more »</a> </div>
<div id="createaccount_info_ico">
Registred users can store and access files for unlimited time and choose to publish them in their profile. <a href="/storage-plans" target="_blank">More info »</a> </div>

<div id="createaccount_termsandcondtotions_ico">
By signing up, you agree to our <a href="/terms" target="blank">terms of use »</a> </div>
<input id="register_from_ico" type="hidden" name="from_ico" value="0">
<input type="hidden" name="login_return_url" class="login_return_url" value="">
<input type="hidden" name="dont_redirect_after_login" class="dont_redirect_after_login" value="">
</div>

</div>


<div id="signin-modal-content" class="modal-content">
<table id="signin-modal-content-error" class="alert_container alert_container_info">
<tbody><tr>
<td>
<i class="fa fa-exclamation-circle"></i>
</td>
<td>
<div class="alert_main_text"></div>
</td>
</tr>
</tbody></table>

<div class="signin-modal-content-social">
<div class="signin-modal-content-social-title">Choose sign-in method:</div>
<div class="signin-modal-content-social-buttons-container">
<div class="standard_button fb_button social_login_button" onclick="checkSocialLogin('facebook');">
<img src="/images/signup_form/login-facebook.svg?v=2" alt="Login with Facebook to upload files for free">
<span>Facebook</span>
</div>
<div class="standard_button google_button social_login_button" onclick="checkSocialLogin('google');">
<img src="/images/signup_form/login-google.svg?v=2" alt="Login with Google to upload files for free">
<span>Google</span>
</div>
<div class="standard_button ms_button social_login_button" onclick="checkSocialLogin('microsoft');">
<img src="/images/signup_form/login-microsoft.svg" alt="Sign up with Microsoft to upload files for free">
<span>Microsoft</span>
</div>
<div class="justify_el"></div>
</div>
</div>

<div class="or-delimiter">
or </div>

<div id="signin-modal-content-simple">
<form onsubmit="checkSignInForm(); return false;" id="login_filesfm">
<div id="signin_input_container">
<div class="input-label l_coupon_code">
<label for="l_coupon_code">Coupon code</label>
<input id="l_coupon_code" name="coupon_code" type="text">
</div>
<div class="no-coupon-link">
<a href="" onclick="revertFormFromCoupon(); return false">I do not have a coupon code »</a>
</div>
<div class="input-label">
<label for="l_user">Username or e-mail</label>
<input id="l_user" name="l_user" type="text">
</div>
<div class="input-label">
<label for="l_pass">Password</label>
<input id="l_pass" name="l_pass" type="password">
</div>
<div class="justify_el"></div>
</div>
<a id="signin-modal-forgot-link" href="" onclick="showForgotPassword(); return false">
<span>Forgot password?</span>
</a>
<div id="signin_coupon_info" onclick="showCreateAccount()">
I do not have a Files.fm account » </div>
<div id="signin_error_msg" class="error_msg"></div>
<input type="submit" style="display: none;">
<div class="sign_in_submit_bn" onclick="checkSignInForm()">
Log in <img src="/images/signup_form/sign_up.svg" alt="Sign up">
</div>
</form>
<div id="signin-modal-link-container">
<a id="signin-modal-coupon-link" href="javascript:void(0)" onclick="adaptFormForCoupon()">
<span>Use a coupon</span>
</a>
</div>
<input type="hidden" name="login_return_url" class="login_return_url" value="">
<input type="hidden" name="dont_redirect_after_login" class="dont_redirect_after_login" value="">
</div>

</div>


<div id="forgotpassword-modal-content" class="modal-content">
<form onsubmit="return false;">
<div id="forgotpassword_text">
Enter your email address to reset your password. You may need to check your spam folder: </div>
<div class="input-label forgotpassword_email">
<label for="forgotpassword_email">E-mail</label>
<input id="forgotpassword_email" type="text">
</div>
<div id="forgotpassword_error_msg" class="error_msg"></div>
<div class="sign_in_submit_bn" onclick="checkForgotPasswordForm();">
Send recovery email <img src="/images/signup_form/sign_up.svg" alt="Send recovery email">
</div>
</form>
</div>


<div id="addcookieuploads-modal-content" class="modal-content">
<div id="addcookieuploads_info">
Bind previous uploads from this device to your account? You can manage or delete them. </div>
<div id="addcookieuploads_button_container">
<div class="addcookieuploads_button" id="addcookieuploads_button_no" onclick="setAddCookieUploads(false)">
No </div>
<div class="addcookieuploads_button" id="addcookieuploads_button_yes" onclick="setAddCookieUploads(true)">
Yes </div>
</div>
</div>


<div id="createaccountsuccessmessage-modal-content" class="modal-content">
<div id="createaccountsuccessmessage_info">
<div>
Thank you! Your Files.fm account is created and an e-mail with account access data is sent to you. </div>
<div>
Close this form, fill in the information about the folder and press the button "Save and send the link". </div>
</div>
<div id="createaccountsuccessmessage_button" onclick="hideModal('sign-in', true)">
Close </div>
</div>

<div id="twofactor_authcode-modal-content" class="modal-content" style="display:none">
<div id="twofactor_authcode_container">
<div id="twofactor_error_msg" class="error_msg"></div>
<div class="twofactor_code_required_message">
Please enter the two factor authentication code from your email! </div>
<input id="twofactorcode" name="twofactorcode" type="text" placeholder="Authentification code">
<div class="sign_in_submit_bn" onclick="trySignIn( $('#twofactorcode').val() )">
Log in <img src="/images/signup_form/sign_up.svg" alt="Log in">
</div>
<div id="twofactor-modal-link-container">
<a id="twofactor-modal-goback-link" href="" onclick="bolPrevFinished_checkSignInForm = true; showSignIn(); return false">
<span>Go back</span>
</a>
</div>
</div>
</div>

<div style="display: none">
<form id="login_facebook" method="get" action="/">
<input type="hidden" name="fb_login" value="">
<input type="hidden" name="add_anonym_uplaods" class="add_anonym_uplaods" value="">
<input type="hidden" name="login_return_url" class="login_return_url" value="">
<input type="hidden" name="dont_redirect_after_login" class="dont_redirect_after_login" value="">
<input type="hidden" name="inviter_user" value="">
<input type="hidden" name="inviter_hash" value="">
<input type="submit" class="standard_button" value="Log in with Facebook" style="width: 100%">
</form>
<form id="login_google" method="get" action="/">
<input type="hidden" name="google_login" value="">
<input type="hidden" name="add_anonym_uplaods" class="add_anonym_uplaods" value="">
<input type="hidden" name="login_return_url" class="login_return_url" value="">
<input type="hidden" name="dont_redirect_after_login" class="dont_redirect_after_login" value="">
<input type="hidden" name="inviter_user" value="">
<input type="hidden" name="inviter_hash" value="">
<input type="submit" class="standard_button" value="Log in with Google" style="width: 100%">
</form>
<form id="login_microsoft" method="get" action="/">
<input type="hidden" name="microsoft_login" value="">
<input type="hidden" name="add_anonym_uplaods" class="add_anonym_uplaods" value="">
<input type="hidden" name="login_return_url" class="login_return_url" value="">
<input type="hidden" name="dont_redirect_after_login" class="dont_redirect_after_login" value="">
<input type="hidden" name="inviter_user" value="">
<input type="hidden" name="inviter_hash" value="">
<input type="submit" class="standard_button" value="Login with Microsoft account" style="width: 100%">
</form>
</div>

<div id="sign-in_disable_form">
<i class="fa fa-spinner fa-spin"></i>
</div>
</div>
<div class="modal-close" id="sign-in_modal_close" data-dismiss="modal" data-close="Close"></div>
</div>
<script>

	var bolRewriteUrlHash = true;
	
    var bolSigninCaptchaRequired = Boolean();
    var bolSignupCaptchaRequired = Boolean(1);
    
    var strSinginCaptchaContainerID = 'signin_captcha';
    var strSignupCaptchaContainerID = 'createaccount_captcha';
    
    
	function showCreateAccount( bolICO )
	{
        bolHasCookieUploadsFunc();
        if( typeof bolICO === 'undefined' )
        {
            // if switching forms, get bolICO from other form
            bolICO = $( "#register_from_ico" ).val() > 0;
        }
        
        $( '#signin-header' ).removeClass( 'active' );
        $( '#createaccount-header' ).addClass( 'active' );

		$( '#signin-modal-content' ).hide();
		$( '#forgotpassword-modal-content' ).hide();
		$( '#addcookieuploads-modal-content' ).hide();
		$( '#createaccountsuccessmessage-modal-content' ).hide();

		$('#createaccount-modal-content').show();
		
		if( bolICO )
        {
            $( "#business_account_chechbox_container" ).hide();
            $( "#createaccount_info_ico" ).show();
            $( "#createaccount_termsandcondtotions_ico" ).show( );
            $( "#createaccount_termsandcondtotions" ).hide( );
            $( "#createaccount_info" ).hide();
            $( "#register_from_ico" ).val( 1 );
        }
        else
        {
            $( "#business_account_chechbox_container" ).show();
            $( "#createaccount_termsandcondtotions" ).show( );
            $( "#createaccount_termsandcondtotions_ico" ).hide( );
            $( "#createaccount_info_ico" ).hide();
            $( "#createaccount_info" ).show();
            $( "#register_from_ico" ).val( 0 );
        }

		showModal( 'sign-in' );
  
		if ( bolSignupCaptchaRequired )
            loadCreateAccountCaptcha();
		
		if ( bolRewriteUrlHash )
		{
			window.location.hash = 'sign_up';
		}
	}
	
	function setRegisterReferral( strInviter, hash, strInviteeEmail )
    {
        $( "#createaccount-referral-referrer" ).text( strInviter );
        $( "#createaccount-referral-container" ).show();
        
        if ( strInviteeEmail )
        {
            $( "#createaccount_email" )
                .val( strInviteeEmail )
                .attr( 'disabled', 'true' );
        }
    
        $("input[name='inviter_user']").val( strInviter );
        $("input[name='inviter_hash']").val( hash );
    }

	function showSignIn( bolICO )
	{
        bolHasCookieUploadsFunc();
	    if( typeof bolICO === 'undefined' )
        {
            // if switching forms, get bolICO from other form
            bolICO = $( "#register_from_ico" ).val() > 0;
        }

        $( '#signin-header' ).addClass( 'active' );
        $( '#createaccount-header' ).removeClass( 'active' );
        
	    		
		$( '#createaccount-modal-content' ).hide();
		$( '#forgotpassword-modal-content' ).hide();
		$( '#addcookieuploads-modal-content' ).hide();
		$( '#createaccountsuccessmessage-modal-content' ).hide();
        $( '#twofactor_authcode-modal-content' ).hide();
        
        if ( bolICO )
        {
            $( "#register_from_ico" ).val( 1 );
        }
        else
        {
            $( "#register_from_ico" ).val( 0 );
        }

		$( '#signin-modal-content' ).show();

		showModal( 'sign-in' );
  
		if ( bolSigninCaptchaRequired )
            loadSignInCaptcha();
		
		if ( bolRewriteUrlHash )
		{
			window.location.hash = 'log_in';
		}
	}
    
    /*** Start: Captcha callbacks ***/
    
    function captchaCreateAccountLoaded( bolSuccess )
    {
        if ( ! bolSuccess )
        {
            addError(strSignupCaptchaContainerID, "createaccount_error_msg", "An error has occurred! Please check your internet connection and try again later. If the problem does not resolve, please contact [email protected]");
        }
        else
        {
            removeError( strSignupCaptchaContainerID );
            removeAllErrors( "createaccount_error_msg" );
            $("#"+strSignupCaptchaContainerID).append('<input type="hidden" class="captcha_response" value="" />');
        }
    }
    
    function captchaCreateAccountSubmitted( strResponse )
    {
        removeError( strSignupCaptchaContainerID );
        removeAllErrors( "createaccount_error_msg" );
        $('#' + strSignupCaptchaContainerID + ' .captcha_response').val( strResponse );
    }
    
    
    function captchaSignInLoaded( bolSuccess )
    {
        if ( ! bolSuccess )
        {
            addError(strSinginCaptchaContainerID, "signin_error_msg", "An error has occurred! Please check your internet connection and try again later. If the problem does not resolve, please contact [email protected]");
        }
        else
        {
            removeError( strSinginCaptchaContainerID );
            removeAllErrors( "signin_error_msg" );
            $("#"+strSinginCaptchaContainerID).append('<input type="hidden" class="captcha_response" value="" />');
        }
    }
    function captchaSignInSubmitted( strResponse )
    {
        removeError( strSinginCaptchaContainerID );
        removeAllErrors( "signin_error_msg" );
        $('#' + strSinginCaptchaContainerID + ' .captcha_response').val( strResponse );
    }
    /*** End: Captcha callbacks ***/
    
    
	function revertFormFromCoupon()
    {
	    $( '#sign-in' ).removeClass( 'coupun_form' );
    }
    
    function adaptFormForCoupon()
    {
	    $( '#sign-in' ).addClass( 'coupun_form' );

        const strUrlParams = new URLSearchParams(window.location.search);
		if( strUrlParams.has('coupon') ) 
		{
            var strCouponCode = strUrlParams.get('coupon');
        }
        if( strUrlParams.has('kupons') ) 
		{
            var strCouponCode = strUrlParams.get('kupons')
        }

        if( typeof strCouponCode !== 'undefined' )
        {
            $('#register_coupon_code_input').val(strCouponCode)
        }
    }

	function showForgotPassword( strEmail )
	{
	    if ( typeof strEmail != 'undefined' )
	    {
			$( '#sign-in-header' ).hide();
			$( '#forgotpassword_email' ).val( strEmail );
	    }

		$( '#signin-header' ).insertBefore( $( '#createaccount-header' ) );
		
		$( '#createaccount-modal-content' ).hide();
		$( '#signin-modal-content' ).hide();
		$( '#addcookieuploads-modal-content' ).hide();
		$( '#createaccountsuccessmessage-modal-content' ).hide();

		$( '#forgotpassword-modal-content' ).show();

		showModal( 'sign-in' );

		if ( bolRewriteUrlHash )
		{
			window.location.hash = 'forgot_password';
		}
	}

	function showAddCookieUploads()
	{
		$( '#createaccount-modal-content' ).hide();
		$( '#forgotpassword-modal-content' ).hide();
		$( '#signin-modal-content' ).hide();
		$( '#createaccountsuccessmessage-modal-content' ).hide();

		$( '#addcookieuploads-modal-content' ).show();

		showModal( 'sign-in' );
	}

	function showCreateAccountSuccessMessage()
	{
		$( '#createaccount-modal-content' ).hide();
		$( '#forgotpassword-modal-content' ).hide();
		$( '#signin-modal-content' ).hide();
		$( '#addcookieuploads-modal-content' ).hide();
		
		$( '#createaccountsuccessmessage-modal-content' ).show();
		
		showModal( 'sign-in' );
	}

	var bolHasCookieUploads = false;

    function bolHasCookieUploadsFunc()
    {
        $.each(document.cookie.split(/; */), function()  {
            var splitCookie = this.split('=');
            if(splitCookie[0].slice(0, 2) == 'uf')
            {
                bolHasCookieUploads = true;
            }
        });
    }

	var bolAddCookieUploadsAnswered = false;
	var bolAddCookieUploads = false;
	var strActiveForm = '';

	function setAddCookieUploads(val) {

		bolAddCookieUploads = val;
		bolAddCookieUploadsAnswered = true;

		if (val) {
			$('#login_facebook .add_anonym_uplaods').val('1');
			$('#login_google .add_anonym_uplaods').val('1');
			$('#login_draugiem .add_anonym_uplaods').val('1');
		}

		if (strActiveForm == 'signin') {
			checkSignInForm();
			showSignIn();
		}
		else if (strActiveForm == 'createaccount') {
			checkCreateAccountForm();
			showCreateAccount();
		}
		else if (strActiveForm == 'facebook' || strActiveForm == 'google' || strActiveForm == 'draugiem') {

			checkSocialLogin(strActiveForm);
		}
	}


	var bolPrevFinished_checkCreateAccountForm = true;
	function checkCreateAccountForm(bolCouponCheckResult) {
        
        var jqCaptchaResultInput = $('#' + strSignupCaptchaContainerID + ' .captcha_response');
	    
		if ( bolCouponCheckResult === undefined )
		{
			bolCouponCheckResult = null;
		}

		if (bolPrevFinished_checkCreateAccountForm)
		{
			bolPrevFinished_checkCreateAccountForm = false;
			$('#sign-in_disable_form').show();
   
			var bolCreateBusinessAccountDataOk = true;
			if (bolCreateBusinessAccount)
			{
				bolCreateBusinessAccountDataOk = false;

				if ($('#createaccount_company_name').val().trim().length < 4 ) {

					addError('createaccount_company_name', 'createaccount_error_msg', 'Please enter a company name that is at least 4 characters long.');
				}
				else {

					removeError('createaccount_company_name');

					if ($('#createaccount_company_phone').val().trim().length < 4 ) {

						addError('createaccount_company_phone', 'createaccount_error_msg', 'The company phone number must be at least 4 digits long!');
					}
					else {

						removeError('createaccount_company_phone');

						bolCreateBusinessAccountDataOk = true;
					}
				}
			}
            
            if ( $( "#register_coupon_code" ).css("display") !== "none" && !bolCouponCheckResult )
            {
                // coupon field is visible -> so it must be filled
                if( bolCouponCheckResult === false )
                {
                    addError( 'register_coupon_code_input', 'createaccount_error_msg', 'The coupon code you entered is invalid or already used!' );
                    
                    bolPrevFinished_checkCreateAccountForm = true;
                    $('#sign-in_disable_form').hide();
                    return;
                }
                else if( !bolCouponCheckResult )
                {
                    removeError( 'register_coupon_code_input' );
                    
                    bolPrevFinished_checkCreateAccountForm = true;
                    verifyCouponCode( 'register_coupon_code_input', 'createaccount_error_msg', checkCreateAccountForm );
                    return;
                }                
            }
			
			if ( bolCreateBusinessAccountDataOk )
			{
				if ($('#createaccount_name').val().trim().length < 2 ) {

					addError('createaccount_name', 'createaccount_error_msg', 'Please enter a name that is at least 2 characters long.');

					bolPrevFinished_checkCreateAccountForm = true;
					$('#sign-in_disable_form').hide();
				}
				else {

					removeError('createaccount_name');

					if ($('#createaccount_surname').val().trim().length < 2 ) {

						addError('createaccount_surname', 'createaccount_error_msg', 'Please enter a surname that is at least 2 characters long.');

						bolPrevFinished_checkCreateAccountForm = true;
						$('#sign-in_disable_form').hide();
					}
					else {
                        function isURL(url) {
                           return url.match(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g) !== null;
                        }
                        
                        if ( isURL( $( '#createaccount_surname' ).val().trim() ) )
                        {
                            addError('createaccount_surname', 'createaccount_error_msg', 'Invalid name!');
                            
                            bolPrevFinished_checkCreateAccountForm = true;
                            $('#sign-in_disable_form').hide();
                            return;
                        }
                        else 
                        {
                            removeError( 'createaccount_surname' );
                        }
                        
                        if ( isURL( $( '#createaccount_name' ).val().trim() ) )
                        {
                            addError('createaccount_name', 'createaccount_error_msg', 'Invalid name!');
                            
                            bolPrevFinished_checkCreateAccountForm = true;
                            $('#sign-in_disable_form').hide();
                            return;
                        }
                        else
                        {
                            removeError( 'createaccount_name' );
                        }
					    
						removeError('createaccount_surname');

						if (!validateEmail($('#createaccount_email').val())) {

							addError('createaccount_email', 'createaccount_error_msg', 'Enter a valid e-mail!');

							bolPrevFinished_checkCreateAccountForm = true;
							$('#sign-in_disable_form').hide();
						}
						else {
				            new EmailValidator( $('#createaccount_email').val(), true)
                                .setOnValidCB(function(){
                                    $.ajax({
                                    type: "POST",
                                    dataType: "json",
                                    url: "./ajax/sign_in.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
                                    data: {
                                        'check_email' : true ,
                                        'email' : $('#createaccount_email').val()
                                    },
                                    success: function(data) {
                                        if (data['status'] != 'ok') {
                                            var strError = "This e-mail address is already taken!";
                                            strError += "<br/><a href='' onclick='showForgotPassword(); return false'>" + 'Forgot password' + "</a>";

                                            addHTMLError('createaccount_email', 'createaccount_error_msg', strError );

                                            bolPrevFinished_checkCreateAccountForm = true;
                                            $('#sign-in_disable_form').hide();
                                        }
                                        else {

                                            removeError('createaccount_email');

                                            if ($('#createaccount_username').val().trim().length < 4 ) {

                                                addError('createaccount_username', 'createaccount_error_msg', 'Please enter a username that is at least 4 characters long!');

                                                bolPrevFinished_checkCreateAccountForm = true;
                                                $('#sign-in_disable_form').hide();
                                            }
                                            else {

                                                if (!validateUsername($('#createaccount_username').val().trim())) {

                                                    addError('createaccount_username', 'createaccount_error_msg', 'Can only contain "a-z", "A-Z", "0-9" and "_.@-"');

                                                    bolPrevFinished_checkCreateAccountForm = true;
                                                    $('#sign-in_disable_form').hide();
                                                }
                                                else
                                                {
                                                    $.ajax({
                                                        type: "POST",
                                                        dataType: "json",
                                                        url: "./ajax/sign_in.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
                                                        data: {
                                                            'check_username' : true ,
                                                            'username' : $('#createaccount_username').val()
                                                        },
                                                        success: function(data) {
                                                            if (data['status'] != 'ok') {

                                                                addError('createaccount_username', 'createaccount_error_msg', 'This username is already taken! Please enter a different one!');

                                                                bolPrevFinished_checkCreateAccountForm = true;
                                                                $('#sign-in_disable_form').hide();
                                                            }
                                                            else {

                                                                removeError('createaccount_username');

                                                                if ($('#createaccount_password').val().trim().length < 4 ) {

                                                                    addError('createaccount_password', 'createaccount_error_msg', 'Please enter a password that is at least 4 characters long!');

                                                                    bolPrevFinished_checkCreateAccountForm = true;
                                                                    $('#sign-in_disable_form').hide();
                                                                }
                                                                else
                                                                {
                                                                    removeError('createaccount_password');
    
                                                                    var bolCaptchaOk = true;
                                                                    if ( bolSignupCaptchaRequired )
                                                                    {
                                                                        bolCaptchaOk = false;
                                                                        
                                                                        if ( jqCaptchaResultInput.length && jqCaptchaResultInput.val().length )
                                                                        {
                                                                            bolCaptchaOk = true;
                                                                            removeError( strSignupCaptchaContainerID );
                                                                        }
                                                                        else
                                                                        {
                                                                            if ( ! jqCaptchaResultInput.length )
                                                                            {
                                                                                addError( strSignupCaptchaContainerID, "createaccount_error_msg", "An error has occurred! Please check your internet connection and try again later. If the problem does not resolve, please contact [email protected]" );
                                                                            }
                                                                            else
                                                                            {
                                                                                addError( strSignupCaptchaContainerID, 'createaccount_error_msg', 'Please fill out Captcha!' );
                                                                            }
                                                                        }
                                                                    }
                                                                    
                                                                    if ( ! bolCaptchaOk )
                                                                    {
                                                                        bolPrevFinished_checkCreateAccountForm = true;
                                                                        $( '#sign-in_disable_form' ).hide();
                                                                    }
                                                                    else
                                                                    {
                                                                        removeError( 'createaccount_password' );
                                                                        removeError( strSignupCaptchaContainerID );
        
                                                                        removeAllErrors( 'createaccount_error_msg' );
        
        
                                                                        if ( bolHasCookieUploads == true && bolAddCookieUploadsAnswered == false )
                                                                        {
            
                                                                            strActiveForm = 'createaccount';
                                                                            showAddCookieUploads();
            
                                                                            bolPrevFinished_checkCreateAccountForm = true;
                                                                            $( '#sign-in_disable_form' ).hide();
                                                                        }
                                                                        else
                                                                        {
                                                                            var postData = {
                                                                                'create_account': true,
                                                                                'username': $( '#createaccount_username' ).val(),
                                                                                'email': $( '#createaccount_email' ).val(),
                                                                                'password': $( '#createaccount_password' ).val(),
                                                                                'add_cookie_uploads': bolAddCookieUploads,
                                                                                'first_name': $( '#createaccount_name' ).val(),
                                                                                'surname': $( '#createaccount_surname' ).val(),
                                                                                'create_business_account': bolCreateBusinessAccount,
                                                                                'company_name': $( '#createaccount_company_name' ).val(),
                                                                                'company_phone': $( '#createaccount_company_phone' ).val(),
                                                                                'company_country': $( '#createaccount_company_country' ).val(),
                                                                                'from_ico': $( "#register_from_ico" ).val() ,
                                                                                'recaptcha_response': (jqCaptchaResultInput.length ? jqCaptchaResultInput.val() : '')
                                                                            };

                                                                            // add referral fields if the container is visible
                                                                            if ( $( "#createaccount-referral-container" ).css( "display" ) !== "none" )
                                                                            {
                                                                                postData[ 'inviter_hash' ] = $( "#createaccount-referral-hash" ).val();
                                                                                postData[ 'inviter_user' ] = $( "#createaccount-referral-user" ).val();
                                                                            }
                                                                            
                                                                            if ( $( "#register_coupon_code" ).css( "display" ) !== "none" )
                                                                            {
                                                                                postData.coupon_code = $( "#register_coupon_code_input" ).val().trim();
                                                                            }

                                                                                                                                                        
                                                                            var bolDontRedirectAfterLogin = true;
                                                                            
                                                                            if ( $( '.dont_redirect_after_login' ).val() == '' )
                                                                            {
                                                                            	bolDontRedirectAfterLogin = false;
                                                                            }
                                                                            
                                                                            var strCustomLoginReturnUrl = $( '.login_return_url' ).val();

                                                                            
                                                                            if ( ! bolDontRedirectAfterLogin && strCustomLoginReturnUrl == '' )
                                                                            {
                                                                            	postData.show_onboarding_survey = true;
                                                                            }
                                                                            else 
                                                                            {
                                                                            	postData.show_onboarding_survey = false;
                                                                            }
                                                                            
            
                                                                            $.ajax( {
                                                                                type: "POST",
                                                                                dataType: "json",
                                                                                url: "./ajax/sign_in.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
                                                                                data: postData,
                                                                                success: function ( data )
                                                                                {
                                                                                    if ( data[ 'status' ] == 'ok' )
                                                                                    {
                        																                        																
                                                                                        if ( ! bolDontRedirectAfterLogin )
                                                                                        {
                                                                                            if ( data[ 'custom_login_return_url' ] != 'undefined' )
                                                                                            {
                                                                                                strCustomLoginReturnUrl = data[ 'custom_login_return_url' ];
                                                                                            }

                                                                                            if ( strCustomLoginReturnUrl != '' )
                                                                                            {

                                                                                                if (
                                                                                                    ( "/" + strCustomLoginReturnUrl ).search( 'filebrowser' ) == -1 &&
                                                                                                    ( "/" + strCustomLoginReturnUrl ).search( window.location.pathname ) != -1 &&
                                                                                                    strCustomLoginReturnUrl != 'sync-share?create_cloud_files_user' &&
                                                                                                    strCustomLoginReturnUrl != 'library-info?after_login' &&
                                                                                                    strCustomLoginReturnUrl != 'video?after-signup' &&
                                                                                                    ( "/" + strCustomLoginReturnUrl ).search( 'lifetime-storage' ) == -1 &&
                                                                                                    ( "/" + strCustomLoginReturnUrl ).search( 'save-youtube-video' ) == -1
                                                                                                )
                                                                                                {
                                                                                                    if ( location.hash == '#sign_up' )
                                                                                                    {
                                                                                                        location.hash = '';
                                                                                                    }
                                    
                                                                                                    if ( strCustomLoginReturnUrl == 'storage-plans#subscribe' )
                                                                                                    {
                                                                                                        location.hash = 'subscribe';
                                                                                                    }
                                    
                                                                                                    location.reload();
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    window.location = "https://files.fm/" + strCustomLoginReturnUrl;
                                                                                                }
                                
                                                                                            }
                                                                                            else
                                                                                            {
                                
                                                                                                window.location = "/account";
                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
        
                                                                                            showCreateAccountSuccessMessage();
                            
                                                                                            bolPrevFinished_checkCreateAccountForm = true;
                                                                                            $( '#sign-in_disable_form' ).hide();
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                        
                                                                                        addError( 'createaccount_error_msg', 'createaccount_error_msg', 'There was an error, contact the Files.fm team!' );
                        
                                                                                        bolPrevFinished_checkCreateAccountForm = true;
                                                                                        $( '#sign-in_disable_form' ).hide();
                                                                                    }
                                                                                },
                                                                                error: function ( data )
                                                                                {
                    
                                                                                    addError( 'createaccount_error_msg', 'createaccount_error_msg', 'An error occurred. Please try again or contact [email protected]!' );
                    
                                                                                    bolPrevFinished_checkCreateAccountForm = true;
                                                                                    $( '#sign-in_disable_form' ).hide();
                                                                                }
                                                                            } );
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        } ,
                                                        error: function(data) {

                                                            addError('createaccount_error_msg', 'createaccount_error_msg', 'An error occurred. Please try again or contact [email protected]!');

                                                            bolPrevFinished_checkCreateAccountForm = true;
                                                            $('#sign-in_disable_form').hide();
                                                        }
                                                    });
                                                }
                                            }
                                        }
                                    } ,
                                    error: function(data) {

                                        addError('createaccount_error_msg', 'createaccount_error_msg', 'An error occurred. Please try again or contact [email protected]!');

                                        bolPrevFinished_checkCreateAccountForm = true;
                                        $('#sign-in_disable_form').hide();
                                    }
                                })
                                }).setOnInvalidCB(function() {
                                    bolPrevFinished_checkCreateAccountForm = true;
                                    $('#sign-in_disable_form').hide();
                                    addError('createaccount_email', 'createaccount_error_msg', 'Enter a valid e-mail!');
                                }).setModalID("sign-in").run();
						}
					}
				}
			}
			else
			{
				bolPrevFinished_checkCreateAccountForm = true;
				$('#sign-in_disable_form').hide();
			}
		}
	}

	function getSigninReturnRedirectUrl()
    {
        if ($('.login_return_url').val() != '') {

            if ($('.dont_redirect_after_login').val() == '') {
                if (
                    ("/"+$('.login_return_url').val()).search(window.location.pathname) != -1 &&
                    $('.login_return_url').val() != 'sync-share?create_cloud_files_user' && 
                    $('.login_return_url').val() == 'storage-plans#subscribe' 
                )
                {
                    return '#subscribe';
                }
                else if ($('.login_return_url').val() == 'my-profile' )
                {
                    return $( '#l_user' ).val();
                }
                else {
                    return $('.login_return_url').val();
                }
            }
        }

        
	    return false;
    }
     
    function verifyCouponCode( strCouponInputID, strErrorID, fnCallback, bolResult )
    {
    	if ( bolResult === undefined )
		{
    		bolResult = null;
		}

        var strCouponInputSelector = "#" + strCouponInputID;
        
        var onError = function ()
        {
            addError( strCouponInputID, strErrorID, 'Invalid coupon code!' );
            
            bolPrevFinished_checkCreateAccountForm = true;
            $( '#sign-in_disable_form' ).hide();
        };
        
        if ( bolResult === false )
        {
            onError();
            return false
        }
        else if ( bolResult === true )
        {
            return true;
        }
        
        if ( $( strCouponInputSelector ).css( "display" ) !== "none" )
        {
            // coupon field is visible -> so it must be filled
            if ( $( strCouponInputSelector ).val().trim().length === 0 )
            {
                onError();
                return false
            }
            else
            {
                if ( !bolResult )
                {
                    removeError( strCouponInputID );
                    
                    $.ajax( {
                        type: "POST",
                        dataType: "json",
                        url: "./ajax/sign_in.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
                        global: false,
                        data: {
                            'check_coupon': true,
                            'coupon_code': $( strCouponInputSelector ).val().trim()
                        },
                        success: function ( data )
                        {
                            fnCallback( typeof data[ 'status' ] !== "undefined" && data[ 'status' ] === 'ok' );
                        },
                        error: function ( )
                        {
                            fnCallback( false );
                        }
                    } );
                    return false;
                }
                else
                {
                    return true;
                }
            }
        }
        else
        {
            return true;
        }
    }

	var bolPrevFinished_checkSignInForm = true;

    function trySignIn( strTwoFactorAuthCode )
    {
        if ( typeof strTwoFactorAuthCode === "undefined" )
        {
            strTwoFactorAuthCode = "";
        }

        var jqCaptchaResultInput = $( '#' + strSinginCaptchaContainerID + ' .captcha_response' );

        removeAllErrors( 'signin_error_msg' );
       
        var strReturnUrl = getSigninReturnRedirectUrl();

        var objPostData = {
            'signin': true,
            'username': $( '#l_user' ).val(),
            'password': $( '#l_pass' ).val(),
            'remember_me': $( '#remember_me' ).prop( 'checked' ),
            'from_ico': $( '#register_from_ico' ).val(),
            'add_cookie_uploads': bolAddCookieUploads,
            'recaptcha_response': ( jqCaptchaResultInput.length ? jqCaptchaResultInput.val() : '' )
        };

        if ( strTwoFactorAuthCode )
        {
            objPostData[ 'two_factor_auth_code' ] = strTwoFactorAuthCode;
        }

        if ( strReturnUrl )
        {
            objPostData[ 'override_return_url' ] = strReturnUrl;
        }

        if ( $( "#l_coupon_code" ).css( "display" ) !== "none" )
        {
            objPostData.coupon_code = $( "#l_coupon_code" ).val().trim();
        }

        
        $.ajax( {
            type: "POST",
            dataType: "json",
            url: "./ajax/sign_in.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
            crossDomain: true,
            data: objPostData,
            success: function ( data )
            {
                var strAdditionalMessage = "";
                
                if ( typeof data[ 'login_attempts_left' ] !== 'undefined' )
                {
                    var strPartOne = +data[ 'login_attempts_left' ] === 1 ? ' You have ' : ' You have ';
                    var strPartTwo = +data[ 'login_attempts_left' ] === 1 ? ' login attempt left before your account is automatically blocked.' : ' more login attempts before your account is automatically blocked.';

                    strAdditionalMessage = strPartOne + data[ 'login_attempts_left' ] + strPartTwo;
                }
                
                if ( ( data[ 'status' ] === 'ok' || data[ 'status' ] === 'missing_account_data' ) && typeof data[ 'redirect_to' ] !== 'undefined' )
                {
                    
                    if ( data[ 'redirect_to' ].substring( 0, 17 ) == '/lifetime-storage' )
                    {
                        data[ 'redirect_to' ] += '?after_login';
                    }

                    if ( data[ 'redirect_to' ].substring( 0, 6 ) == '/token' )
                    {
                        data[ 'redirect_to' ] = '/token';
                    }

                    window.location = data[ 'redirect_to' ];
                }
                else if ( data[ 'status' ] === 'invalid_auth_code' )
                {
                    $( '#twofactor_error_msg' ).text( 'The entered code is invalid! Please try again!' + strAdditionalMessage ).show();
                    bolPrevFinished_checkSignInForm = true;
                    $( '#sign-in_disable_form' ).hide();
                }
                else
                {
                    var $errorCont;
                    if( strTwoFactorAuthCode )
                    {
                        $errorCont = $( '#twofactor_error_msg' );
                    }
                    else
                    {
                        $errorCont = $( '#signin_error_msg' );
                    }
                    
                    if ( typeof data[ "message" ] === "undefined" )
                    {
                       $errorCont.text( 'Incorrect username or password! Access can be restored via your email address.' + strAdditionalMessage );
                       console.log( 'SIGNIN ERROR CODE : 1' );
                    }
                    else
                    {
                        $errorCont.text( data[ "message" ] + strAdditionalMessage );
                    }
                    $errorCont.show();

                    bolPrevFinished_checkSignInForm = true;
                    $( '#sign-in_disable_form' ).hide();
                }
            },
            error: function ( data )
            {

                $( '#signin_error_msg' ).text( 'An error occurred. Please try again or contact [email protected]!' );
                $( '#signin_error_msg' ).show();

                bolPrevFinished_checkSignInForm = true;
                $( '#sign-in_disable_form' ).hide();
            }
        } );
    }

    function show2FAPrompt()
    {
        $( '#createaccount-modal-content' ).hide();
        $( '#forgotpassword-modal-content' ).hide();
        $( '#addcookieuploads-modal-content' ).hide();
        $( '#createaccountsuccessmessage-modal-content' ).hide();
        $( '#signin-modal-content' ).hide();

        $( '#twofactor_authcode-modal-content' ).show();
    }
    
	function checkSignInForm(bolCouponCheckResult) {

		if ( bolCouponCheckResult === undefined )
		{
			bolCouponCheckResult = null;
		}
        
        var jqCaptchaResultInput = $('#' + strSinginCaptchaContainerID + ' .captcha_response');
        
		if (bolPrevFinished_checkSignInForm) {

			bolPrevFinished_checkSignInForm = false;
            $('#sign-in_disable_form').show();
            
            if ( $( "#l_coupon_code" ).css("display") !== "none" )
            {
                if ( bolCouponCheckResult )
                {
                    $( "#signin_error_msg" ).hide();
                }
                else if ( bolCouponCheckResult === null )
                {
                    bolPrevFinished_checkSignInForm = true;
                    return verifyCouponCode( "l_coupon_code", "signin_error_msg", checkSignInForm, bolCouponCheckResult );
                }
                else
                {
                    $( "#signin_error_msg" )
                        .text( "The coupon code you entered is invalid or already used!" )
                        .show();
                    bolPrevFinished_checkSignInForm = true;
                    $( '#sign-in_disable_form' ).hide();
                    return false;
                }
            }
                
			bolError = false;

			if ($('#l_user').val() == '' ) {

				$('#l_user').addClass( 'has_error' );
				bolError = true;
			}
			else {
				$('#l_user').removeClass( 'has_error' );
			}

			if ($('#l_pass').val() == '' ) {
				$('#l_pass').addClass( 'has_error' );
				bolError = true;
			}
			else {
				$('#l_pass').removeClass( 'has_error' );
			}
            
            
            if ( bolSigninCaptchaRequired )
            {
                if ( jqCaptchaResultInput.length === 0 )
                {
                    bolError = true;
    
                    addError(strSinginCaptchaContainerID, "signin_error_msg", "An error has occurred! Please check your internet connection and try again later. If the problem does not resolve, please contact [email protected]");
                }
                else if ( jqCaptchaResultInput.val().length === 0 )
                {
                    bolError = true;
    
                    addError(strSinginCaptchaContainerID, "signin_error_msg", "Please fill in the captcha field!");
                }
                else
                {
                    removeError( strSinginCaptchaContainerID );
                }
            }

			if (!bolError) {

				$.ajax({
					type: "POST",
					dataType: "json",
					url: "./ajax/sign_in.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
                    crossDomain: true,
                    data: {
						'check_signin' : true ,
						'username' : $('#l_user').val() ,
						'password' : $('#l_pass').val()
					},
					success: function(data) {
                        if ( data[ 'status' ] === 'ok' )
                        {
                            if ( bolHasCookieUploads == true && bolAddCookieUploadsAnswered == false && data[ 'show_add_cookie_uploads' ] == true )
                            {
                                strActiveForm = 'signin';
                                showAddCookieUploads();

                                bolPrevFinished_checkSignInForm = true;
                                $( '#sign-in_disable_form' ).hide();
                            }
                            else
                            {
                                trySignIn();
                            }
                        }
                        else if ( data[ 'status' ] === 'requires_auth_code' )
                        {
                            $( '#sign-in_disable_form' ).hide();
                            bolPrevFinished_checkSignInForm = true;
                            
                            show2FAPrompt();
                        }
                        else
                        {
                            var strMessage = 'Incorrect username or password! Access can be restored via your email address.';

                            if ( typeof data[ 'message' ] !== "undefined" )
                            {
                                strMessage = data[ 'message' ];
                            } 
                            else if ( typeof data[ 'login_attempts_left' ] !== 'undefined' ) 
                            {
                                var strPartOne = +data['login_attempts_left'] === 1 ? ' You have ' : ' You have ';
                                var strPartTwo = +data['login_attempts_left'] === 1 ? ' login attempt left before your account is automatically blocked.' : ' more login attempts before your account is automatically blocked.';
                                
                                strMessage += strPartOne + data[ 'login_attempts_left' ]  + strPartTwo;
                            }
                            else
                            {
                                console.log( 'SIGNIN ERROR CODE : 2' );
                            }

                            $( '#signin_error_msg' ).text( strMessage );
							$('#signin_error_msg').show();

							bolPrevFinished_checkSignInForm = true;
							$('#sign-in_disable_form').hide();
						}
					} ,
					error: function(data) {

						$('#signin_error_msg').text('An error occurred. Please try again or contact [email protected]!');
						$('#signin_error_msg').show();

						bolPrevFinished_checkSignInForm = true;
						$('#sign-in_disable_form').hide();
					}
				});
			}
			else {

				bolPrevFinished_checkSignInForm = true;
				$('#sign-in_disable_form').hide();
			}
		}
	}


	function checkForgotPasswordForm() {

		if (!validateEmail($('#forgotpassword_email').val())) {

			addError('forgotpassword_email', 'forgotpassword_error_msg', 'Enter a valid e-mail!');
		}
		else {

			removeError('forgotpassword_email');

			$.ajax({
				type: "POST",
				dataType: "json",
				url: "./ajax/sign_in.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
				data: {
					'recover_password' : true ,
					'email' : $('#forgotpassword_email').val()
				},
				success: function(data) {
					if (data['status'] == 'ok') {

						removeAllErrors('forgotpassword_error_msg');

						$('#forgotpassword_error_msg').addClass('ok_msg_active');
						$('#forgotpassword_error_msg').text('If an account with this email exists, then the password reset link was sent to the email provided.');
						$('#forgotpassword_error_msg').show();
					}
					else {

						addError('forgotpassword_email', 'forgotpassword_error_msg', 'This e-mail is not registered.');
					}
				}
			});
		}
	}

	function checkSocialLogin(strType) {
	
		if ( strType == 'facebook' )
		{
			fError( 'Facebook has changed something, so unfortunately logging in with Facebook is not available at the moment. To get in, reset the password to your e-mail (with which you used Facebook) <a href="/?a#forgot_password">by clicking here</a> . In the future, we recommend using your email or Google account so that you are not dependent on Facebook. We plan to disable this method.' );
			return;
		}

		if (bolHasCookieUploads == true && bolAddCookieUploadsAnswered == false) {

			strActiveForm = strType;
			showAddCookieUploads();
		}
		else {

			if ($('.dont_redirect_after_login').val() == 'true')
			{
				$('#sendfiles').submit();
				$('.add_anonym_uplaods').val('true');
			}

			if (strType == 'facebook') {

				$('#login_facebook').submit();
			}
			else if (strType == 'google') {

				$('#login_google').submit();
			}
			else if (strType == 'draugiem') {

				$('#login_draugiem').submit();
			}
			else if (strType == 'microsoft') {

				$('#login_microsoft').submit();
			}

		}
	}


	function validateEmail(email) {
		var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
		var result = re.test(email);
		return result;
	}

	function validateUsername(username) {

		var re = /^[a-zA-Z0-9_\.@\-]+$/;
		var result = re.test(username);
		return result;
	}
    
    function addHTMLError(strDomId, strErrorMsgId, strErrorMsgText) {
        $('#' + strDomId).addClass( 'has_error' );
        $('#' + strErrorMsgId).html(strErrorMsgText);
        $('#' + strErrorMsgId).show();
    }

	function addError(strDomId, strErrorMsgId, strErrorMsgText) {
		$('#' + strDomId).addClass( 'has_error' );
		$('#' + strErrorMsgId).text(strErrorMsgText);
		$('#' + strErrorMsgId).show();
	}

	function removeError(strInputId) {
		$('#' + strInputId).removeClass( 'has_error' );
	}

	function removeAllErrors(strErrorMsgId) {
		$('#' + strErrorMsgId).text('');
		$('#' + strErrorMsgId).hide();
	}

	var isUsernameChanged = false;
	function usernameChanged()
	{
		isUsernameChanged = true;
	}

	function createUsername(strEmail)
	{
		if( !isUsernameChanged && strEmail != '' && validateEmail(strEmail))
		{
			var arrEmail = strEmail.split("@");

			var strUsername = arrEmail[0];
			while (strUsername.length < 4)
			{
				strUsername += '1';
			}


			$.ajax(
			{
				type: "POST",
				dataType: "json",
				url: "./ajax/sign_in.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
				data:
				{
					'get_username' : true ,
					'username' : strUsername
				},
				success: function(data)
				{
					if (data['status'] == 'ok' && data['username'])
					{
						$('#createaccount_username').val(data['username']);
					}
				}
			});
		}
	}

	var bolCreateBusinessAccount = false;
	function toggleCreateBusinessAccount()
	{
		if (bolCreateBusinessAccount)
		{
			bolCreateBusinessAccount = false;
			$('#create_business_account_container').hide();
		}
		else
		{
			bolCreateBusinessAccount = true;
			$('#create_business_account_container').show();
		}
	}


    
    </script> <script type="text/javascript" src="js/prebid-ads.js"></script>
<script type="text/javascript">
        if( window.canRunAds === undefined )
        {
            fError( "An ad blocking plugin has been detected in your browser. There is a possibility that the page is displayed incorrectly. Please disable the plugin and refresh the page!" );
            document.cookie="adblock_warning_shown; max-age=86400";
        }
    </script>
<div id="content">
<script type="text/javascript">

	var objWebTorrentDownloadForm;
	
	$( function()
	{
		objWebTorrentDownloadForm = new WebTorrentDownloadForm( '40bdb754ce23cdfc13a344b0230a4e21f5e0785a' );
	} );

</script>
<link rel="stylesheet" type="text/css" media="all" href="/css/webtorrent_download_form.css?v=1715343651">
<script src="/webtorrent/FilesFm_P2P/filesfm_p2p.min.js?v=1719512729"></script>
<script src="/js/webtorrent_download_form.js?v=1715343639"></script>
<script src="/js/p2p-graph/p2p-graph.js?v=1715343639"></script>
<section id="webtorrent_download_form" class="modal-container" tabindex="-1" role="dialog" aria-labelledby="modal-label" aria-hidden="true">
<div class="modal-inner">
<div class="modal-content">

<div id="webtorrent_download_form__header_main">
Peer-Powered Download </div>
<div id="webtorrent_download_form__close_btn" onclick="$('#webtorrent_download_form_modal_close').click()">
<i class="fal fa-times-circle"></i>
</div>

<div id="webtorrent_download_form__top_content">
<div id="webtorrent_download_form__main_content__wt_download">
<div class="webtorrent_download_form__main_content__wt_download__status" id="webtorrent_download_form__main_content__wt_download__status__in_progress">
<span id="webtorrent_download_form__main_content__wt_download__status__in_progress__label">
<b>Keep this browser tab active in foreground</b>. Finish in </span>
<span id="webtorrent_download_form__main_content__wt_download__status__in_progress__value"></span>
</div>
<div id="webtorrent_download_form__main_content__wt_download__progress" class="progress-bar">
<div id="webtorrent_download_form__main_content__wt_download__progress__bar_outer" class="progress-bar-outer"><div id="webtorrent_download_form__main_content__wt_download__progress__bar_inner" class="progress-bar-inner"></div></div>
<div id="webtorrent_download_form__main_content__wt_download__progress__bar_text" class="progress-bar-text"></div>
</div>



<div class="webtorrent_download_form__main_content__wt_download__status" id="webtorrent_download_form__main_content__wt_download__status__download_error">
<i class="fa fa-exclamation-circle"></i>
ERROR while downloading. REFRESH or try another download method! </div>
</div>
<div class="webtorrent_download_form__sharing_stats_cont">
<div class="webtorrent_download_form__sharing_info__stats my_tooltip" my_title="Download">
<i class="fal fa-arrow-down"></i>
<span class="webtorrent_download_form__sharing_size" id="webtorrent_download_form__sharing_size__download"></span><br>
<span class="webtorrent_download_form__sharing_speed" id="webtorrent_download_form__sharing_speed__download"></span>
</div>
<div class="webtorrent_download_form__download_all_button"></div>
<div class="webtorrent_download_form__sharing_info__stats my_tooltip" my_title="Upload">
<i class="fal fa-arrow-up"></i>
<span class="webtorrent_download_form__sharing_size" id="webtorrent_download_form__sharing_size__upload"></span><br>
<span class="webtorrent_download_form__sharing_speed" id="webtorrent_download_form__sharing_speed__upload"></span>
</div>
</div>
</div>
<div id="webtorrent_download_form__desktop_clients_line">
<a id="webtorrent_download_form__torrent_file_url" href="javascript:void()" target="_blank" class="my_tooltip" my_title="Download">.torrent</a>
<span class="webtorrent_download_form__desktop_clients_text">
You can use <a href="https://www.vuze.com" target="_blank">Vuze</a> or other <a href="https://webtorrent.io/desktop/" target="_blank">WebTorrent</a> desktop clients to download and seed </span>
</div>
<div id="webtorrent_download_form__top_alerts_container">
<table id="webtorrent_download_form__alert_container__wait" class="alert_container alert_container_info">
<tbody><tr>
<td>
<i class="fa fa-spinner fa-spin"></i>
</td>
<td>
<div class="alert_main_text"></div>
</td>
</tr>
</tbody></table>
<table id="webtorrent_download_form__alert_container__error" class="alert_container alert_container_danger">
<tbody><tr>
<td>
<i class="fa fa-exclamation-circle"></i>
</td>
<td>
<div class="alert_main_text"></div>
</td>
</tr>
</tbody></table>
<table id="webtorrent_download_form__alert_container__ok" class="alert_container alert_container_success">
<tbody><tr>
<td>
<i class="fa fa-check-circle"></i>
</td>
<td>
<div class="alert_main_text"></div>
</td>
</tr>
</tbody></table>
</div>
<div id="webtorrent_download_form__main_content">
<div id="webtorrent_download_form__world_image"></div>
<div id="webtorrent_download_form__p2p_graph"></div>
</div>
<div id="webtorrent_download_form__bottom_content">
<div>
"Save as" window will pop up for each file, when download finishes. This window must be in foreground. You can set your browser to allow download of multiple files: Settings &gt; Advanced &gt; Ask where to save each file before downloading. Doesn’t work? <a href="/contacts" target="_blank">Let us know</a> </div>
<div id="webtorrent_download_form__file_links" style="width: 100%; height: 1px; overflow: hidden;">
</div>
</div>
</div>
</div>
<div id="webtorrent_download_form_modal_close" class="modal-close" data-dismiss="modal" data-close="Close">X</div>
</section><link rel="stylesheet" type="text/css" media="all" href="/css/elements/upload_access_switch.css?v=114">
<script type="text/javascript">

	var bolUploadAccessSwitch_closeAllSelect_Binded = false;
	var bolSessionUser_IsStorageSubscriber = false;
	var bolSessionUser_HasLifetimeStorage = false;

	function UploadAccessSwitch( objParentElement, objUploadAccessSwitchSettings )
	{
		this.objParentElement = objParentElement;
		this.bolAccessTypeChanged = false;


		this.strItemType = 'upload';

		if ( typeof objUploadAccessSwitchSettings.item_type != 'undefined' && objUploadAccessSwitchSettings.item_type == 'file' )
		{
			this.strItemType = objUploadAccessSwitchSettings.item_type;
		}
		
		
		this.strUploadHash = objUploadAccessSwitchSettings.upload_hash;
		this.strFileHash = objUploadAccessSwitchSettings.file_hash;
		this.strParentAccessType = objUploadAccessSwitchSettings.parent_access_type;

		
		this.bolOwnerLoggedIn;

		if ( typeof objUploadAccessSwitchSettings.owner_logged_in == 'undefined' )
		{
			this.bolOwnerLoggedIn = 1;
		}
		else
		{
			this.bolOwnerLoggedIn = objUploadAccessSwitchSettings.owner_logged_in;
		}

		this.strAccessType;
		this.strUploadPassword = '';

		if ( objUploadAccessSwitchSettings.access_type == 'PRIVATE' )
		{
			this.strAccessType = 'private';
		}
		else if ( this.strItemType == 'upload' && objUploadAccessSwitchSettings.password != null && objUploadAccessSwitchSettings.password != '' )
		{
			this.strAccessType = 'password';
			this.strUploadPassword = objUploadAccessSwitchSettings.password;
		}
		else if ( this.strItemType == 'upload' && objUploadAccessSwitchSettings.is_public == 1 )
		{
			this.strAccessType = 'public';
		}
		else
		{
			this.strAccessType = 'link';
		}

		
		if ( objUploadAccessSwitchSettings.access_type != 'PRIVATE' && typeof objUploadAccessSwitchSettings.from_eparaksts != 'undefined' && objUploadAccessSwitchSettings.from_eparaksts )
		{
			this.strAccessType = 'link-can-edit';
			$( '.copy_button_wrapper_popup' ).addClass('no-dropdown');
		}
		else
		{
			$( '.copy_button_wrapper_popup' ).removeClass('no-dropdown');
		}

		if ( objUploadAccessSwitchSettings.access_type == 'link-can-upload' )
		{
			this.strAccessType = 'link-can-upload';
		}

		this.strUploadAccessSwitchType = 'default';

		if ( typeof objUploadAccessSwitchSettings.upload_access_switch_type != 'undefined' )
		{
			this.strUploadAccessSwitchType = objUploadAccessSwitchSettings.upload_access_switch_type;
		}

		this.strEmbedPlace = objUploadAccessSwitchSettings.embed_place;

		
		
		var _this = this;
		
		
		this.init = function()
		{
			var objTypeCopyWrap = $( '#copy_button_drawer_popup' );
			objTypeCopyWrap.html('');
			$( '.copy_button_wrapper_popup' ).removeClass('copy_input_value_to_clipboard_no_tooltip');
			
			var strHtml = '';

			var objTypeSelectWrap = $( '<div></div>' ).attr( {
        						'class' : 'styled-select upload-access-switch-select' ,
        					} )
			var objTypeSelect = $( '<select></select>' ).attr( {
                    				'class' : 'upload-access-switch_type-select' ,
                    				'disabled' : ( this.strUploadAccessSwitchType == 'default' && ! this.bolOwnerLoggedIn ? true : false )
                    			} );

			objTypeSelect.append(
				$( '<option></option>' ).text( '&nbsp;' )
			);
			if ( this.bolOwnerLoggedIn )
			{
				objTypeSelect.append(
    					$( '<option></option>' ).attr( {
    						'value' : 'private' ,
    						'desc' : 'Only you or users invited by email can access.' ,
    						'selected' : ( this.strAccessType == 'private' ? true : false )
    					} )
    					.text( 'Only with private permission' )
    				);
			}
			
			if ( this.strUploadAccessSwitchType == 'default' )
			{ 
    			objTypeSelect.append(
						$( '<option></option>' ).attr( {
							'value' : 'link' ,
							'desc' : 'View and download access' ,
							'selected' : ( this.strAccessType == 'link' ? true : false )
						} )
						.text( 'Anyone with a link' )
					);

				strHtml = 	'<div id="drawer_copy_button_view" class="share-input copy_input_value_to_clipboard_no_tooltip checked" onclick="updateSharePopupLink(1)">' +
								'<span>Copy view link</span>' +
								'<span class="desc_popup">Can be viewed and downloaded</span>' +
							'</div>';
			}
			else if ( this.strUploadAccessSwitchType == 'sharing_form' )
			{
    			objTypeSelect.append(
    					$( '<option></option>' ).attr( {
    						'value' : 'link-can-view' ,
    						'desc' : 'View and download.' ,
    						'selected' : ( this.strAccessType == 'link' ? true : false ) ,
    						'class' : 'upload-access-switch_type-select_option_link-can-view'
    					} )
    					.text( 'via link to access content' )
    				);
					
				if ( !( objUploadAccessSwitchSettings.access_type != 'PRIVATE' && typeof objUploadAccessSwitchSettings.from_eparaksts != 'undefined' && objUploadAccessSwitchSettings.from_eparaksts ) )
				{
					strHtml = 	'<div id="drawer_copy_button_view" class="share-input copy_input_value_to_clipboard_no_tooltip checked" onclick="updateSharePopupLink(1)">' +
								'<span>Copy view link</span>' +
								'<span class="desc_popup">Can be viewed and downloaded</span>' +
							'</div>';
							objTypeCopyWrap.append(strHtml);
				}

    			objTypeSelect.append(
    					$( '<option></option>' ).attr( {
    						'value' : 'link-can-edit' ,
    						'desc' : 'Link to add, edit or delete content.' ,
    						'selected' : ( this.strAccessType == 'link-can-edit' ? true : false ) ,
    					} )
    					.text( 'Get a link to edit content' )
    				);

					strHtml = 	'<div id="drawer_copy_button_edit" class="share-input copy_input_value_to_clipboard_no_tooltip" onclick="updateSharePopupLink(2)">' +
									'<span>Copy edit link</span>' +
									'<span class="desc_popup">Can add, edit content, e-sign and delete</span>' +
								'</div>';
								objTypeCopyWrap.append(strHtml);

    			if ( this.strItemType == 'upload' )
    			{
        			objTypeSelect.append(
        					$( '<option></option>' ).attr( {
        						'value' : 'link-can-upload' ,
        						'desc' : 'Visitors can add files, but can’t delete or edit existing.' ,
        						'selected' : ( this.strAccessType == 'link-can-upload' ? true : false ) ,
        					} )
        					.text( 'Get Link to add content' )
        				);

					if ( !( objUploadAccessSwitchSettings.access_type != 'PRIVATE' && typeof objUploadAccessSwitchSettings.from_eparaksts != 'undefined' && objUploadAccessSwitchSettings.from_eparaksts ) )
					{
						strHtml = 	'<div id="drawer_copy_button_upload" class="share-input copy_input_value_to_clipboard_no_tooltip" onclick="updateSharePopupLink(3)">' +
										'<span>Copy add link</span>' +
										'<span class="desc_popup">You can add files, but not delete or edit existing files</span>' +
									'</div>';
									objTypeCopyWrap.append(strHtml);
					}
    			}
			}
			else if ( this.strUploadAccessSwitchType == 'modal_gallery' )
			{
    			objTypeSelect.append(
    					$( '<option></option>' ).attr( {
    						'value' : 'link-can-view' ,
    						'desc' : 'View and download.' ,
    						'selected' : ( this.strAccessType == 'link' ? true : false ) ,
    						'class' : 'upload-access-switch_type-select_option_link-can-view'
    					} )
    					.text( 'via link to access content' )
    				);

    			objTypeSelect.append(
    					$( '<option></option>' ).attr( {
    						'value' : 'link-can-edit' ,
    						'desc' : 'Link to add, edit or delete content.' ,
    						'selected' : ( this.strAccessType == 'link-can-edit' ? true : false ) ,
    					} )
    					.text( 'Get a link to edit content' )
    				);

    			if ( this.strItemType == 'upload' )
    			{
        			objTypeSelect.append(
        					$( '<option></option>' ).attr( {
        						'value' : 'link-can-upload' ,
        						'desc' : 'Visitors can add files, but can’t delete or edit existing.' ,
        						'selected' : ( this.strAccessType == 'link-can-upload' ? true : false ) ,
        					} )
        					.text( 'Get Link to add content' )
        				);
    			}
			}

			if ( this.strItemType == 'upload' && this.bolOwnerLoggedIn )
			{
				objTypeSelect.append(
    					$( '<option></option>' ).attr( {
    						'value' : 'password' ,
    						'desc' : 'Visitors must enter a password to access' ,
    						'selected' : ( this.strAccessType == 'password' ? true : false )
    					} )
    					.text( 'Set password' )
    				);
			
				objTypeSelect.append(
    					$( '<option></option>' ).attr( {
    						'value' : 'public' ,
    						'desc' : 'Visible to anyone on your profile and via search.' ,
    						'selected' : ( this.strAccessType == 'public' ? true : false )
    					} )
    					.text( 'Posted on my profile page' )
    				);
			}

			objTypeSelectWrap.append( objTypeSelect );

			$('.url_wrapper ').removeClass('switch');
			
			if ( this.strUploadAccessSwitchType == 'sharing_form' )
			{
				strHtml = 	'<div id="upload-access-switch_type-toggle_wrapper">'+
							'<input type="checkbox" class="upload-access-switch_type-toggle"'+
							( this.strAccessType == 'private' ? ' ' : 'checked ' )+
							//'disabled="'+( this.strUploadAccessSwitchType == 'default' && ! this.bolOwnerLoggedIn ? true : false )+'"'+
							'id="upload-access-switch_type-toggle">'+
							'<label for="upload-access-switch_type-toggle"></label>'+
							'<div>Private</div>'+
							'<div>Link</div>'+
							'</div>';


				if (this.strItemType == 'upload' )
				{
					$('.url_wrapper ').addClass('switch');
					strHtml += '<div id="upload-access-switch-password-download-wrap">'+
									'<div class="upload-access-switch_password-wrapper ' + (this.strAccessType == 'password' ? 'has_password' : '') + '">'+
										'<label onclick="$(this).parent().addClass(\'open\'); $(this).parent().find(\'input\').focus()"> ' + (this.strAccessType == 'password' ? 'Password:' : 'Set password') + '</label>'+
										'<input onclick="$(this).parent().addClass(\'open\')" type="text" class="upload-access-switch_password" value="'+this.strUploadPassword+'"></input>'+
										'<input onclick="$(this).parent().addClass(\'open\')" type="password" class="upload-access-switch_password_placeholder" value="111111"></input>'+
										'<div class="upload-access-switch_password-save-btn">Save</div>'+
									'</div>';
					
					if (typeof objUploadAccessSwitchSettings.hide_download_buttons !== 'undefined' && ! (! bolSessionUser_IsStorageSubscriber && ! bolSessionUser_HasLifetimeStorage) )
					{
						strHtml +=	'<div class="upload-access-switch-hide-download">' +
										'<label for="upload-access-switch_hide-download-toggle">Hide download buttons:</label>' +
										'<input type="checkbox" class="upload-access-switch_hide-download-toggle" '+ (objUploadAccessSwitchSettings.hide_download_buttons == '1' ? 'checked' : '') +' id="upload-access-switch_hide-download-toggle">' +
										'<label for="upload-access-switch_hide-download-toggle"></label>' +
										'<label>'+(objUploadAccessSwitchSettings.hide_download_buttons == '1' ? 'Yes' : 'No')+'</label>'+
									'</div>';	
					}
					
					strHtml += '</div>';
				}

				$( this.objParentElement ).html(

					$( '<div></div>' ).attr( {
						'class' : 'upload-access-switch ' + (typeof objUploadAccessSwitchSettings.propagate_settings !== 'undefined' && objUploadAccessSwitchSettings.propagate_settings == 2 ? 'disabled' : '') ,
						'data-selected-access-type' : this.strAccessType 
					} )
					.append(
						$( '<div></div>' ).attr( {
							'class' : 'upload-access-switch_type-wrapper' 
						} )
						.append(
							$( '<label></label>' ).text( ( this.strUploadAccessSwitchType == 'sharing_form' ? 'Access rights:' : 'Access:' ) )
						)
						.append(
							$( '<label></label>' ).attr( {
							'class' : 'upload-access-switch_type-wrapper-desc' 
							} ).text(( this.strAccessType == 'private' ? 'Only with private permission' : 'Anyone with a link' ))
						)
					)
					.append( strHtml )

					
					
				);
			}
			else
			{
				$( this.objParentElement ).html(

					$( '<div></div>' ).attr( {
						'class' : 'upload-access-switch' ,
						'data-selected-access-type' : this.strAccessType 
					} )
					.append(
						$( '<div></div>' ).attr( {
							'class' : 'upload-access-switch_type-wrapper' 
						} )
						.append(
							$( '<label></label>' ).text( ( this.strUploadAccessSwitchType == 'sharing_form' ? 'Link and Access rights:' : 'Access:' ) )
						)
						.append( objTypeSelectWrap )
					)
					.append(
						$( '<div></div>' ).attr( {
							'class' : 'upload-access-switch_password-wrapper'
						} )
						.append(
							$( '<label></label>' ).text( 'Password:' )
						)
						.append(
							$( '<input/>' ).attr( {
								'class' : 'upload-access-switch_password' ,
								'type' : 'text' ,
								'title' : 'Enter a password' ,
								'value' : this.strUploadPassword
							} )
						)
						.append(
							$( '<div></div>' ).attr( {
								'class' : 'upload-access-switch_password-save-btn'
							} ).text( 'Save' )
						)
					)
					.append(
						$( '<div></div>' ).attr( {
							'class' : 'upload-access-switch_loading-mask'
						} )
						.append(
							$( '<i></i>' ).attr( {
								'class' : 'fal fa-spinner fa-spin'
							} )
						)
					)
				);
			}
		


			checkTooltips();
			
			var x, i, j, selElmnt, a, b, c, d, e;
			/*look for any elements with the class "styled-select":*/
			x = document.getElementsByClassName("upload-access-switch-select");
			
			for (i = 0; i < x.length; i++) 
			{
				if (x[i].getElementsByClassName("select-selected").length < 1) 
				{
					selElmnt = x[i].getElementsByTagName("select")[0];
					/*for each element, create a new DIV that will act as the selected item:*/
					a = document.createElement("DIV");
					a.setAttribute("class", "select-selected");
					a.innerHTML = selElmnt.options[selElmnt.selectedIndex].innerHTML;
					x[i].appendChild(a);
					/*for each element, create a new DIV that will contain the option list:*/
					b = document.createElement("DIV");
					b.setAttribute("class", "select-items select-hide");
					for (j = 1; j < selElmnt.length; j++) {
						/*for each option in the original select element,
						create a new DIV that will act as an option item:*/
						c = document.createElement("DIV");
						d = document.createElement("DIV");
						if(selElmnt.options[j].value == selElmnt.value)
						{
							c.setAttribute("class", "checked");
						}
						e = document.createElement("DIV");
						e.setAttribute("class", "value");
						d.setAttribute("class", "desc");
						//c.innerHTML = selElmnt.options[j].innerHTML;
						e.innerHTML = selElmnt.options[j].innerHTML;
						d.innerHTML = selElmnt.options[j].getAttribute('desc');
						c.appendChild(e);
						c.appendChild(d);
						if ( !!selElmnt.id && !!selElmnt.options[j].value )
						{
							c.setAttribute( 'id', selElmnt.id + '_' + selElmnt.options[j].value );
						}
						c.addEventListener("click", function(e) {
							/*when an item is clicked, update the original select box,
							and the selected item:*/
							var y, i, k, s, sjq, h, clicked;
							clicked = this;
							s = this.parentNode.parentNode.getElementsByTagName("select")[0];
							sjq = $(s);
							$(clicked).parents().children().removeClass('checked');
							$(clicked).addClass('checked');

									
							h = this.parentNode.previousSibling;
							for (i = 0; i < s.length; i++) {
								if (s.options[i].innerHTML == this.getElementsByClassName("value")[0].innerHTML) {
									s.selectedIndex = i;
									h.innerHTML = this.getElementsByClassName("value")[0].innerHTML;
									y = this.parentNode.getElementsByClassName("same-as-selected");
									for (k = 0; k < y.length; k++) {
										y[k].removeAttribute("class");
									}
									this.setAttribute("class", "same-as-selected checked");
									sjq.trigger("change");
									break;
								}
							}
							h.click();
						});
						b.appendChild(c);
					}
					x[i].appendChild(b);
					a.addEventListener("click", function(e) {
						/*when the select box is clicked, close any other select boxes,
						and open/close the current select box:*/
						e.stopPropagation();
						closeAllSelect(this);
						this.nextSibling.classList.toggle("select-hide");
						this.classList.toggle("select-arrow-active");
						this.parentElement.classList.toggle("blue-border");
						if (this.parentElement.previousElementSibling)
						{
							this.parentElement.previousElementSibling.classList.toggle("blue-span");
						}
						
					});
				}
			}
			function closeAllSelect(elmnt) {
				/*a function that will close all select boxes in the document,
				except the current select box:*/
				var x, y, i, arrNo = [];
				x = document.getElementsByClassName("select-items");
				y = document.getElementsByClassName("select-selected");
				for (i = 0; i < y.length; i++) {
					if (elmnt == y[i]) {
						arrNo.push(i)
					} else {
						y[i].classList.remove("select-arrow-active");
					}
				}
				for (i = 0; i < x.length; i++) {
					if (arrNo.indexOf(i)) {
						x[i].classList.add("select-hide");
						x[i].parentElement.classList.remove("blue-border");
						if (x[i].parentElement.previousElementSibling)
						{
							x[i].parentElement.previousElementSibling.classList.remove("blue-span");
						}
					}
				}
			}
			/*if the user clicks anywhere outside the select box,
			then close all select boxes:*/
			if ( ! bolUploadAccessSwitch_closeAllSelect_Binded )
			{
				document.addEventListener("click", closeAllSelect);
				bolUploadAccessSwitch_closeAllSelect_Binded = true;
			}

			if ( ! this.bolOwnerLoggedIn )
			{
				if ( this.strUploadAccessSwitchType == 'sharing_form' )
				{
					// do nothing
				}
				else
				{
        			$( this.objParentElement ).on( 'click', function( event )
        			{
        				showCreateAccount();
        			} );
				}
			}
			else
			{
    			$( this.objParentElement ).find( '.upload-access-switch_type-select' ).on( 'change', function()
    			{
    				_this.changeAccessType( $( this ).val() );
    			} );
    
				$( this.objParentElement ).find( '.upload-access-switch_password' ).on( 'blur', function()
    			{
					if($( this ).val().trim() != '' ) {
						$(this).parent().delay(500).queue(function(next) {
							$(this).removeClass('open');
							$( '.upload-access-switch_password-save-btn' ).html('Save');
							$( '.upload-access-switch_password-save-btn' ).removeClass("green");
							next();
						});
					}
					else
					{
						$( this ).parent().removeClass('has_password').removeClass('open');
						$( '.upload-access-switch_password-save-btn' ).html('Save');
						$( '.upload-access-switch_password-save-btn' ).removeClass("green");
					}
				} );

    			$( this.objParentElement ).find( '.upload-access-switch_password' ).on( 'change', function()
    			{
					$(this).parent().addClass('has_password');
    				_this.changeAccessType( 'password' );
    			} );

				$( this.objParentElement ).find( '#upload-access-switch_type-toggle' ).on( 'change', function()
    			{
					if ($(this).is(':checked'))
					{
						_this.changeAccessType( 'link' );
					}
					else
					{
						_this.changeAccessType( 'private' );
					}
    				
    			} );

				$( this.objParentElement ).find( '.upload-access-switch_hide-download-toggle' ).on( 'change', function()
    			{

					if ($(this).is(':checked'))
					{
						_this.changeHideDownloadButtons( 1 );
						$(this).next().next().html('Yes');
					}
					else
					{
						_this.changeHideDownloadButtons( 0 );
						$(this).next().next().html('No');
					}
    			} );
				

				$( this.objParentElement ).find( '.upload-access-switch_password' ).on( 'input', function()
    			{
					$( '.upload-access-switch_password-save-btn' ).html('Save');
            		$( '.upload-access-switch_password-save-btn' ).removeClass("green");
    			} );
			}
		}

		this.init();

		this.changeHideDownloadButtons = function( intHideDownloadButtons )
		{
			this.showLoadingMask();

			var strAjax_Url = '';
            var objAjax_Data = null;

            if ( this.strItemType == 'upload' )
            {
            	strAjax_Url = '/ajax/upload_info.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a';
            	
            	objAjax_Data = {
                    'set_upload_hide_download_buttons': true ,
					'upload_hash' : this.strUploadHash ,
					'hide_download_buttons' : intHideDownloadButtons
                };
            }
            
            			
            $.ajax(
            {
                type: "POST",
                dataType: "json",
                url: strAjax_Url ,
                data: objAjax_Data ,
                success: function( data )
                {
                    if ( data['status'] == 'ok' )
                    {
                    	if ( _this.strItemType == 'upload' && ( _this.strEmbedPlace == 'filebrowser' || _this.strEmbedPlace == 'list' ) )
            			{
                        	location.reload();
            			}

            			_this.hideLoadingMask();
                    }
                    else
                    {
                        _this.afterErrorOn_changeAcceccType();
                    }
                } ,
                error: function()
                {
                    _this.afterErrorOn_changeAcceccType();
                }
            } );
		}
		

		this.changeAccessType = function( strNewAccessType )
		{
			$( this.objParentElement ).find( '.upload-access-switch' ).attr( 'data-selected-access-type', strNewAccessType );

			
			if ( strNewAccessType == 'password' && $( this.objParentElement ).find( '.upload-access-switch_password' ).val().trim() == '' )
			{
				if ( this.strUploadAccessSwitchType == 'sharing_form' )
				{
					this.changeAccessType( 'link' );
					$( this.objParentElement ).find( '.upload-access-switch_password' ).parent().removeClass('has_password').removeClass('open');
					$( '.upload-access-switch_password-save-btn' ).html('Save');
					$( '.upload-access-switch_password-save-btn' ).removeClass("green");
				}
				return;
			}

			if (
					strNewAccessType == 'link-can-view'
					|| strNewAccessType == 'link-can-edit'
					|| strNewAccessType == 'link-can-upload'
				)
			{
				strNewAccessType = 'link';
			}
   
			
			this.showLoadingMask();


			var strAjax_Url = '';
            var objAjax_Data = null;

            if ( this.strItemType == 'upload' )
            {
            	strAjax_Url = '/ajax/upload_info.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a';
            	
            	objAjax_Data = {
                    'set_upload_access_type' : true ,
					'upload_hash' : this.strUploadHash ,
					'upload_access_type' : strNewAccessType ,
					'upload_password' : $( this.objParentElement ).find( '.upload-access-switch_password' ).val()
                };
            }
            else if ( this.strItemType == 'file' )
            {
            	strAjax_Url = '/ajax/file_info.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a';
            	
            	objAjax_Data = {
                    'set_file_access_type' : true ,
					'file_hash' : this.strFileHash ,
					'file_access_type' : strNewAccessType 
                };
            }
            
            			
            $.ajax(
            {
                type: "POST",
                dataType: "json",
                url: strAjax_Url ,
                data: objAjax_Data ,
                success: function( data )
                {
                    if ( data['status'] == 'ok' )
                    {
                    	_this.strAccessType = strNewAccessType;
                    	_this.bolAccessTypeChanged = true;

                    	if ( _this.strItemType == 'upload' )
                    	{
                			if ( strNewAccessType != 'password' )
                			{
                				$( _this.objParentElement ).find( '.upload-access-switch_password' ).val( '' );
								$( _this.objParentElement ).find( '.upload-access-switch_password-wrapper' ).find('label').eq(0).html('Set password');
								$( _this.objParentElement ).find( '.upload-access-switch_password' ).parent().removeClass('has_password').removeClass('open');
                			}
							else 
							{
								$( '.upload-access-switch_password-save-btn' ).html('Saved!');
            					$( '.upload-access-switch_password-save-btn' ).addClass("green");
								$( _this.objParentElement ).find( '.upload-access-switch_password-wrapper' ).find('label').eq(0).html('Password:');
							}
    
                			if ( strNewAccessType == 'link' )
                			{
                    			$( '#upload_button__publish' ).show();
                    			$( '#upload_button__unpublish' ).hide();
                			}
                			else if ( strNewAccessType == 'public' )
                			{
                    			$( '#upload_button__publish' ).hide();
                    			$( '#upload_button__unpublish' ).show();
                			}
                			else 
                			{
                    			$( '#upload_button__publish' ).hide();
                    			$( '#upload_button__unpublish' ).hide();
                			}
    
                			if ( _this.strEmbedPlace == 'filebrowser' )
                			{
    							gaev( 'filebrowser-folder-info', 'access', strNewAccessType );
                			}
                    	}

                    	if ( _this.strEmbedPlace == 'filebrowser' || _this.strEmbedPlace == 'list' )
            			{
                        	location.reload();
            			}

            			_this.hideLoadingMask();
            			
                    }
                    else
                    {
                        _this.afterErrorOn_changeAcceccType();
                    }
                } ,
                error: function()
                {
                    _this.afterErrorOn_changeAcceccType();
                }
            } );
		}

		this.afterErrorOn_changeAcceccType = function( strErrorMsg )
		{
			if ( this.strAccessType == 'link' && this.strUploadAccessSwitchType == 'sharing_form' )
			{
				this.strAccessType = 'link-can-view';
			}
    					
			$( this.objParentElement ).find( '.upload-access-switch' ).attr( 'data-selected-access-type', this.strAccessType );
			$( this.objParentElement ).find( '.upload-access-switch_type-select option[value="' + this.strAccessType + '"]' ).attr( 'selected', 'selected' );

			$( this.objParentElement ).find( '.upload-access-switch_type-select' ).trigger( 'change' );

			if ( typeof strErrorMsg == 'undefined' )
			{
				strErrorMsg = 'An error occurred. Try again!';
			}
			
			fError( strErrorMsg );

			this.hideLoadingMask();
		}

		this.showLoadingMask = function()
		{
			$( this.objParentElement ).find( '.upload-access-switch_loading-mask' ).show();
		}

		this.hideLoadingMask = function()
		{
			$( this.objParentElement ).find( '.upload-access-switch_loading-mask' ).hide();
		}
	}

</script>
<script src="/js/download_selected_files/download_selected_files.js?v=1725995709"></script>
<script type="text/javascript">
	
	var objDownloadSelectedFiles;
	
	$( function()
	{
		objDownloadSelectedFiles = new downloadSelectedFiles(
			{
				'Warning-DontUseIOS' : 'Apple mobile devices do not support this option. Download each file individually or all files in a ZIP archive, or use a different device. On iOS, files are stored in Files > Downloads folder.<br/><br/> You are using the iOS operating system, the limitations of which prevent you from using this feature. It works on MacOS, Windows or Android operating systems. On iOS files are stored in the Files > Downloads.' ,
				'Warning-SelectFiles' : 'Please select at least one file.' ,
			}
		);
	} );

</script> <script type="text/javascript" src="/js/file.report.functions.js.php"></script>
<div id="list_waiting_overly_for_printing_order" style="display: none;position: absolute; top: 0; left:0; width: 100%; height: 100%; background: rgba(43, 61, 82, 0.9); z-index: 10000001; padding-top: 20%; text-align: center;">
<i class="fa fa-spinner fa-spin fa-fw" style="color: white; font-size: 50px;"></i>
</div>
<script type="text/javascript">

    if ( window.location.hash == '#order'|| window.location.hash.substr( 0, 10 ) == '#eparaksts' )
    {
        $( '#list_waiting_overly_for_printing_order' ).show();
    }

</script>
<div id="center" class="list_page_container show_ads">

<script type="text/x-jqote-template" id="file_context_menu_drawer_template"><![CDATA[
<div id="file_context_menu_drawer" class="dropdown-menu">	
	<div class="copy_button_wrapper" >				
		<div class="copy_button_drawer">
			<*= ! this.item_view_link ? '<!--':''*>
			<div class="drawer_copy_button" data-item-hash="<*= this.file_hash *>" data-clipboard-text="<*= this.item_view_link *>">
				<span>Copy link to view</span>
				<span class="desc">View and download rights</span>
			</div>
			<*= ! this.item_view_link ? '-->':''*>
		
			<*= ! this.item_edit_link ? '<!--':''*>
			<div class="drawer_edit_button" data-item-hash="<*= this.file_hash *>" data-clipboard-text="<*= this.item_edit_link *>">
				<span>Copy edit link</span>
				<span class="desc">Can add, edit content, e-sign and delete</span>
			</div>
			<*= ! this.item_edit_link ? '-->':''*>
		</div>
	</div>
</div>
]]>
</script>

<script type="text/x-jqote-template" id="upload_context_menu_drawer_template"><![CDATA[
<div id="upload_context_menu_drawer" class="dropdown-menu">					
	<div class="copy_button_drawer">
		<*= ! this.item_view_link ? '<!--':''*>
		<div class="drawer_copy_button" data-item-hash="<*= this.upload_hash *>" data-clipboard-text="<*= this.item_view_link *>">
			<span>Copy link to view</span>
			<span class="desc">View and download rights</span>
		</div>
		<*= ! this.item_view_link ? '-->':''*>
	
		<*= ! this.item_edit_link ? '<!--':''*>
		<div class="drawer_edit_button" data-item-hash="<*= this.upload_hash *>" data-clipboard-text="<*= this.item_edit_link *>">
			<span>Copy edit link</span>
			<span class="desc">Can add, edit content, e-sign and delete</span>
		</div>
		<*= ! this.item_edit_link ? '-->':''*>
		
		<*= ! this.item_add_link ? '<!--':''*>
		<div class="drawer_edit_button" data-item-hash="<*= this.upload_hash *>" data-clipboard-text="<*= this.item_add_link *>">
			<span>Copy add link</span>
			<span class="desc">You can add files, but not delete or edit existing files</span>					
		</div>
		<*= ! this.item_add_link ? '-->':''*>
	</div>
</div>
]]>
</script>

<script type="text/x-jqote-template" id="file_context_menu_template"><![CDATA[
<ul id="file_context_menu" class="dropdown-menu">

    <li role="presentation" class="item-name">
        <div class="context-img"><img style="width: 18px; height: unset" src="/images/file_types_v2/<*= this.file_icon *>"/></div>
        <span class="title">
            <*= this.name *>
        </span>
        <div id="file_context_menu_close"> <i class="fal fa-times"></i></div>
    </li>

    
    <li role="presentation" class="divider" style="margin-top: 0"></li>
    
	<div class="button-wrap">
    <!-- View -->
    
	    <!-- Download -->
    <*= ! this.can_download ? '<!--':''*>
    <li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:void(0)" onclick="downloadFile( '<*= this.file_hash *>' )"><div class="context-img"><img src="/images/UI_icons/download.svg"/></div>Download</a></li>
    <*= ! this.can_download ? '-->':''*>
        
    
	    <!-- Open in web view -->
    <*= this.panel_id != 'shared-with-me' ? '<li role="presentation"><a role="menuitem" tabindex="-1" href="/f/' + this.file_hash + '" target="_blank"><div class="context-img"><img src="/images/UI_icons/external.svg"/></div>Open direct link</a></li>' : '' *>
        
        <!-- Copy link -->
    <*= this.panel_id != 'shared-with-me' ? '<li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:void(0)" onclick="copyToClipboard(\'https://files.fm/f/' + this.file_hash + '\')"><div class="context-img"><img src="/images/UI_icons/link.svg"/></div>Copy link</a></li>' : '' *>
        
        <!-- Embed -->
    <li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:void(0)" onclick="$( '#list_item_embed_button_for_file_<*= this.file_hash *>' ).click();"><div class="context-img"><img src="/images/UI_icons/code.svg"/></div>Embed content</a></li>
    
	<li role="presentation" class="divider"></li>

	
    
	
    
	<!-- Sell file-->
    <*= ! this.can_sell_file ? '<!--':''*>
	<li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:void(0)" onclick="showSetPriceFormModal('<*= this.file_hash *>')"><div class="context-img"><img src="/images/UI_icons/euro.svg"/></div>Sell file</a></li>
    <*= ! this.can_sell_file ? '-->':''*>

	<!-- Buy file-->
    <*= ! this.can_buy_file ? '<!--':''*>
	<li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:void(0)" onclick="showBuyFileFormModal('<*= this.file_hash *>')"><div class="context-img"><img src="/images/UI_icons/cart.svg"/></div>Buy</a></li>
    <*= ! this.can_buy_file ? '-->':''*>

	<!-- Order prints-->
    <*= ! this.can_order_prints ? '<!--':''*>
	<li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:void(0)" onclick="showPrintingOrderModal('<*= this.file_hash *>', 'ListActionLineDropdown');"><div class="context-img"><img src="/images/UI_icons/print.svg"/></div>Order prints</a></li>
    <*= ! this.can_order_prints ? '-->':''*>

	<!-- Order products -->
    <*= ! this.can_order_producs ? '<!--':''*>
	<li role="presentation"><a role="menuitem" tabindex="-1" href="/c/<*= this.upload_hash *>?h=<*= this.file_hash *>" target="_blank"><div class="context-img"><img src="/images/UI_icons/cup.svg"/></div>View products</a></li>
    <*= ! this.can_order_producs ? '-->':''*>

	<!-- Slideshow-->
    <*= ! this.can_open_slideshow ? '<!--':''*>
    <li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:void(0)" onclick="showSlideshow( '<*= this.file_hash *>' )"><div class="context-img"><img src="/images/UI_icons/play.svg"/></div>Slideshow</a></li>
    <*= ! this.can_open_slideshow ? '-->':''*>


	<!-- Report-->
	<*= ! this.can_be_reported ? '<!--':''*>
	<li role="presentation" class="divider"></li>
	<*= ! this.can_be_reported ? '-->':''*>

	<*= ! this.can_be_reported ? '<!--':(! this.has_reported ? '<!--':'')*>
	<li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:void(0)" onclick="showCancelFileReportModal(this, '<*= this.file_hash *>');"><div class="context-img"><img src="/images/UI_icons/alert.svg"/></div>Cancel a problem report</a></li>
    <*= ! this.can_be_reported ? '-->':(! this.has_reported ? '-->':'')*>

    <*= ! this.can_be_reported ? '<!--':( this.has_reported ? '<!--':'')*>
	<li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:void(0)" onclick="showFileReportModal(this, '<*= this.file_hash *>');"><div class="context-img"><img src="/images/UI_icons/alert.svg"/></div>Report a problem</a></li>
    <*= ! this.can_be_reported ? '-->':( this.has_reported ? '-->':'')*>
    </div>
</ul>
]]>
</script>
<link rel="stylesheet" type="text/css" media="all" href="/css/upload_copy_form.css?v=101">
<script type="text/javascript" src="/js/upload_copy_form.js?v=109"></script>
<script type="text/javascript">

	var objUploadCopyForm = null;
	var PHPSESSID = '40bdb754ce23cdfc13a344b0230a4e21f5e0785a';
	
	$( function()
	{
		objUploadCopyForm = new UploadCopyForm(
			false ,
			false ,
			'40bdb754ce23cdfc13a344b0230a4e21f5e0785a' ,
			{
				'Error-General' : 'Sorry, an error occurred while processing data. Please try again!' ,
				'Error-FileSizeLimitExceeded' : 'Some of the files you selected for copying exceeds the file size limit for your account.' ,
				'Error-UploadSizeLimitExceeded' : 'The total file size exceeds the folder size limit for your account.' ,
				'Error-CircularMove' : 'Copying a folder to one of its child folders or itself is not possible! Pick another folder.' ,
				'Error-HttpDownloadNotAllowed' : 'Some of the selected files are not allowed to be downloaded.' ,
				'ConfirmText-CloseForm' : 'Are you sure you want to close the form and stop copying files?' ,
				'YES' : 'Yes' ,
				'NO' : 'No' ,
				'Header' : 'Files are being copied' ,
				'SubHeader-1' : 'Do not close this window while files are being copied.' ,
				'Copied' : 'Copied' ,
				'Header-Share' : 'File saving in your account' ,
				'SubHeader-1-Share' : 'Do not close this window while files are being uploaded' ,
				'Copied-Share' : 'Saved' ,
			} ,
		);
	} );

</script>
<section id="upload-copy-form" class="modal-container" tabindex="-1" role="dialog" aria-labelledby="modal-label" aria-hidden="true">
<div class="modal-inner">
<div id="upload-copy-form__close-top-button" onclick="objUploadCopyForm.confirmClose()"><i class="fal fa-times"></i></div>
<div class="modal-content">
<div id="upload-copy-form_header-main"></div>
<div id="upload-copy-form_header-info"></div>
<div id="upload-copy-form_main-content">
<div id="upload-copy-form_stats-top">
<span id="upload-copy-form_stats_text"></span>
<span id="upload-copy-form_stats_finished-count">-</span>
<span>from</span>
<span id="upload-copy-form_stats_total-count">-</span>
</div>
<div id="upload-copy-form_progress-bar">
<div id="upload-copy-form_progress-bar_text">-%</div>
<div id="upload-copy-form_progress-bar_outer">
<div id="upload-copy-form_progress-bar_inner"></div>
</div>
</div>
<div id="upload-copy-form_stats-bottom">
<span id="upload-copy-form_stats_finished-size">-</span>
<span id="upload-copy-form_stats_total-size">-</span>
</div>
<div id="upload-copy-form_finished-info">
<div id="upload-copy-form_finished-info_text">
Copy complete </div>
<div id="upload-copy-form_finished-info_button" onclick="hideModal('upload-copy-form')">
OK </div>
</div>

<div id="upload-copy-form_main-content_loading-mask">
<i class="fa fa-spinner fa-spin"></i>
</div>

</div>
</div>
</div>
<div id="upload-copy-form_modal-close" class="modal-close modal-close-dont-close" data-dismiss="modal" data-close="Close" onclick="objUploadCopyForm.confirmClose()"></div>
</section>
<link rel="stylesheet" type="text/css" media="all" href="/js/bxslider/jquery.bxslider.min.css?v=1715343640"><link rel="stylesheet" type="text/css" media="all" href="/css/modal_gallery.v2.css?v=1728559333"><link rel="stylesheet" type="text/css" media="all" href="/css/global_facelift.css?v=1720449903"><link rel="stylesheet" type="text/css" media="all" href="/css/audio_player.css?v=1715343651"><link rel="stylesheet" type="text/css" media="all" href="/js/filesfm_videojs/videojs_8.3.0/video-js.css?v=1715343635"><link rel="stylesheet" type="text/css" media="all" href="/js/filesfm_videojs/css/filesfm_videojs.css?v=1717493775"><link rel="stylesheet" type="text/css" media="all" href="/js/filesfm_videojs/plugins/videojs-quality-selector_1.3.1/quality-selector.css?v=1715343635"><link rel="stylesheet" type="text/css" media="all" href="/js/highlight/styles/atom-one-dark.min.css?v=1715343642">
<script src="/js/jquery.tagsinput.js?v=1715343639"></script>
<script src="/js/jquery.fitvids.js?v=1715343639"></script>
<script src="/js/bxslider/jquery.bxslider.js?v=1715343640"></script>
<script src="/js/autosize.min.js?v=1715343635"></script>
<script src="/js/audio_player.js?v=1715343635"></script>
<script src="/js/functions.js?v=1715343642"></script>
<script src="/js/dropdown.button.js?v=1715343643"></script>
<script src="/js/panzoom/panzoom.min.js?v=1715343639"></script>
<script src="/js/exif-js/exif.js?v=1728656961"></script>
<script src="/js/filesfm_videojs/videojs_8.3.0/video.min.js?v=1715343635"></script>
<script src="/js/filesfm_videojs/filesfm_videojs.js?v=1715343635"></script>
<script src="/js/filesfm_videojs/plugins/videojs-quality-selector_1.3.1/silvermine-videojs-quality-selector.min.js?v=1715343635"></script>
<script src="/js/edit_image_popup.js?v=1715343639"></script>
<script src="/js/highlight/highlight.min.js?v=1715343642"></script>
<div id="gallery2" style="display: none;" class=" ">
<div id="gallery2__bg"></div>
<div id="gallery2__content-wrapper">
<div id="gallery2__header_mobile">
<span class="gallery2__header__img-count">&nbsp;</span>
<span class="gallery2__header__file_name_value"></span>
<span class="gallery2__header__close" onclick="if($( '#gallery2__content' ).hasClass( 'gallery__sidebar__info-visible' ) &amp;&amp; $( '#gallery2__content' ).hasClass( 'gallery__sidebar-visible' ) ){showGalleryInfo(); $(window).trigger('resize');} else {closeGallery(strCurrentFileHash);}"></span>
</div>
<div id="gallery2__header">
<div id="gallery2__header__inner" class="clearfix">
<div class="gallery2__header__icon-group" id="gallery2__header__left">
<span class="gallery2__header__img-count">&nbsp;</span>
<span class="gallery2__header__file_name_value"></span>
</div>
<div id="gallery2__header__mid">
<div id="gallery2__header__mid_content">
<span id="gallery2__buyproducts" class="gallery2__header_middle_button gallery2__button__buy-products">
<a href="javascript:void(0);">
<span class="text">Buy prints</span>
</a>
</span>
<span id="gallery2__sign_main" class="gallery2__header_middle_button" style="display: none;">
<a href="javascript:void(0);">
<span>eSign</span>
</a>
</span>
<span id="gallery2__download_space"></span>
<span id="gallery2__buyfile" style="display:none" class="gallery2__header_middle_button ">
<a href="javascript:void(0);">
<span class="text">Buy</span>
<span class="dash"> - </span>
<span class="price"></span>
</a>
</span>
<span id="gallery2__buyall" style="" class="gallery2__header_middle_button ">
<a href="javascript:void(0);">
<span class="text">Buy all</span>
<span class="dash"> - </span>
<span class="price"></span>
</a>
</span>
<span id="gallery2__share" class="gallery2__header_middle_button">
<a href="javascript:void(0);" id="gallery2__share_button">
<span>Share link</span>
</a>
</span>
<span id="gallery2__header__right_more" class="gallery2__header_middle_button" onclick="if(!bolGallerySidebarVisible || $(window).width() > 500){$(this).toggleClass('open')}else{showGalleryInfo(); $(window).trigger('resize');} galleryLoadFileInfo(true);">More</span>
<div id="gallery2__header__mobile_menu">
<span id="gallery2__edit" class="gallery2__header_middle_button gallery2__edit" style="display: none;">
<a href="javascript:void(0);" id="gallery2__edit_button">
<span>Edit</span>
</a>
</span>
<span id="gallery2__edit_in_google" class="gallery2__header_middle_button gallery2__edit_in_google">
<a href="javascript:void(0);" id="gallery2__edit_in_google_button">
<span>Edit in Google</span>
</a>
</span>
<span id="gallery2__sign" class="gallery2__header_middle_button" style="display: none;">
<a href="javascript:void(0);">
<span>eSign</span>
</a>
</span>
<a id="gallery2__item_info_cover_middle" class="gallery2__header_middle_button bottom_menu" onclick="setAsThumb(arrIDs[ getItemIndex ( strCurrentFileHash ) ], strUploadHash);" href="javascript:void(0)">
Set as cover image </a>
<a id="gallery2__sidebar__info-price_middle" class="gallery2__header_middle_button bottom_menu" href="javascript:void(0)"></a>
<a id="gallery2__sidebar__info-rename_middle" onclick=" if( bolIsOwner )
                                                                                    {
                                                                                        $('#gallery2__header__right_more').toggleClass('open');
                                                                                        showGalleryInfo();
                                                                                        $(window).trigger('resize');
                                                                                        $('#file_name_edit_wrapper textarea').focus();
                                                                                        $('#file_name_edit_wrapper textarea').addClass('pulse');
                                                                                    }" class="not_owner_hide gallery2__header_middle_button bottom_menu" href="javascript:void(0)">Rename</a>
<a href="javascript:void(0);" id="gallery2__sidebar__info_embed_button_middle" class="gallery2__header_middle_button bottom_menu">
Embed links <div class="tag pro">Pro</div>
</a>
<a id="gallery2__item_info_delete_middle" class="gallery2__header_middle_button bottom_menu" href="javascript:void(0)">
Delete </a>
<a id="gallery2__item_info_replace_middle" class="gallery2__header_middle_button bottom_menu" href="javascript:void(0)">
Replace file</a>

<div class="gallery2__header__mobile_menu_seperator"></div>
<a id="gallery2__info_more" class="gallery2__header_middle_button bottom_menu" href="javascript:void(0)" onclick="showGalleryInfo(); $(window).trigger('resize'); $('#gallery2__header__right_more').removeClass('open')">
Info </a>
<a id="gallery2__slideshow_middle" class="gallery2__header_middle_button bottom_menu" onclick="enterSlideshow()" href="javascript:void(0)" style="display: none;">
Slideshow </a>
<div id="gallery2__comments_button_middle" class="gallery2__header_middle_button" onclick="if(!bolGallerySidebarVisible) {showGalleryInfo();} showGalleryMessages(); $(window).trigger('resize'); $('#gallery2__header__right_more').removeClass('open')">Add comment</div>
<span id="gallery2__buy-products" class="gallery2__header_middle_button gallery2__button__buy-products">
<a href="javascript:void(0);">
<span class="text">Buy prints</span>
</a>
</span>
<div id="gallery2__report_button_middle" class="gallery2__report_button gallery2__header_middle_button" onclick="$('#gallery2__header__right_more').removeClass('open')">
<span class="not-reported">Report a problem</span>
<span class="reported">Cancel a problem report</span>
</div>
<div id="gallery2_item_info_share_middle" class="gallery2_item_info_share">
<div class="gallery2_input-container">
<input type="text" id="gallery_share_popup_url_middle" onclick="this.setSelectionRange(0, this.value.length); gaev( 'filebrowser-file-info', 'share-link', '' );  $( '#copy_button_middle' ).addClass( 'copied' ).delay( 4000 ).queue( function( next ){$( this ).removeClass( 'copied' );next();} );" class="gallery2_share-input copy_input_value_to_clipboard my_tooltip" data-clipboard-text="" my_title="You can send the link to other users for access to these files. File owner can change access rights.">
</div>
<div id="copy_button_middle" class="copy_button">
<div class="copy_text">
<div class="hover mobile">Copy</div>
<div class="copied">Copied</div>
</div>
</div>
</div>
</div>
<div id="gallery2__header__mobile_menu_close_before"></div>
<span id="gallery2__info_middle" class="gallery2__info gallery2__header_middle_button" onclick="showGalleryInfo(); $(window).trigger('resize'); $('#gallery2__header__right_more').removeClass('open')">Info</span>
</div>
</div>
<div class="gallery2__header__icon-group gallery2__header__right" id="gallery2__header__right">
<span id="gallery2__close" class="gallery2__close" onclick="closeGallery(strCurrentFileHash);"></span>
</div>
</div>
</div>
<div id="gallery2__header_slideshow">
<span class="gallery2__header_slideshow_resume" onclick="nextSlide(); resumeSlideshow()">Play</span>
<span class="gallery2__header_slideshow_pause" onclick="pauseSlideshow()">Pause</span>
<span class="gallery2__header__close" onclick="exitSlideshow()"></span>
</div>
<div id="gallery2__content" class="gallery__image__is-image clearfix">
<div id="gallery2__content__sidebar">
<div id="gallery2__sidebar__info__comments">
<div id="gallery2__info_button" onclick="hideGalleryMessages(); $(window).trigger('resize');">
Information </div>
<div id="gallery2__comments_button" onclick="showGalleryMessages(); $(window).trigger('resize');">
Add a comment </div>
<div id="gallery2__sidebar-close" onclick="hideSidebar();"></div>
</div>
<div id="gallery2__content__sidebar__inner" class="gallery2__content__sidebar__inner__flex">
<div id="gallery2__sidebar__info">
<div class="gallery2__sidebar__content">
<div id="file-info">File info:</div>
<div id="gallery2_file_info">
<div id="gallery2_item_info_bottom_section">
<div class="gallery2_item_info_padded">
<div id="gallery2_info_head">
<div class="info_head">
<div class="thumbnail-wrapper">
</div>
<div id="gallery2__sidebar__info-name" class="not_owner_hide">
<div id="file_name_edit_wrapper">
<div class="error_msg">An error occurred. Please try again!</div>
<textarea class="gallery2__sidebar__info-value gallery2__sidebar__file_name_value" rows="1"></textarea>
<div class="editable_field_save_button">
Save </div>
<div class="edit_wrapper_edit_button"><div class="edit_wrapper_edit_button_icon"></div></div>
</div>
</div>
<h1 id="gallery2__sidebar__info-name-uneditable" style="word-wrap: break-word;" class="not_owner_show">
<span class="gallery2__sidebar__file_name_value"></span>
</h1>
</div>
<label class="block-label" for="gallery2__sidebar__file_description_value" style="margin-top: 30px;">Description</label>
<div id="gallery2__sidebar__info-description" class="not_owner_hide">
<div id="file_description_edit_wrapper">
<div class="error_msg">An error occurred. Please try again!</div>
<textarea id="gallery2__sidebar__file_description_value" class="gallery2__sidebar__info-value not_owner_hide gallery2__sidebar__file_description_value" placeholder="Add file description"></textarea>
<div class="editable_field_save_button">
Save </div>
<div class="edit_wrapper_edit_button not_owner_hide"><div class="edit_wrapper_edit_button_icon"></div></div>
</div>
</div>
<div class="not_owner_show">
<span class="gallery2__sidebar__file_description_value"></span>
</div>
<div id="gallery2__sidebar__info-set-custom-thumbnail"></div>
</div>
</div>
<div class="gallery2_item_info_padded share">
<label class="block-label" for="upload-access-switch_type-select" style="margin-bottom: 10px;">Access</label>
<div id="gallery2_item_info_share-wrapper">
<div id="gallery_upload-access-switch"></div>
</div>
<div id="gallery2_item_info_share" class="gallery2_item_info_share">
<div class="gallery2_input-container">
<input type="text" id="gallery_share_popup_url" onclick="this.setSelectionRange(0, this.value.length); gaev( 'filebrowser-file-info', 'share-link', '' ); $( '#copy_button_left' ).addClass( 'copied' ).delay( 4000 ).queue( function( next ){$( this ).removeClass( 'copied' );next();}" class="gallery2_share-input gallery_share_popup_url copy_input_value_to_clipboard my_tooltip" data-clipboard-text="" my_title="You can send the link to other users for access to these files. File owner can change access rights.">
</div>
<div id="copy_button_left" class="copy_button">
<div class="copy_text">
<div class="hover">Copy</div>
<div class="copied">Copied</div>
</div>
</div>
</div>
</div>
<div class="gallery2_item_info_padded signatures">
<div id="gallery2__left_info__signers-list-container">
<div class="file-signing-eparaksts-form_file-list_file-item_signatures-info_is-signed_header">
Signed by:
</div>
<div id="gallery2__left_info__signers-list">
</div>
</div>
</div>
<div class="header-owner">
<div class="header-owner_title block-label">User </div>
<div class="header-owner_image-wrapper"></div>
<div class="header-owner_name"></div>
</div>
<table id="gallery2_file_details_table_ai" class="zebra_table gallery2_item_info_padded">
<tbody>
<tr id="gallery2__sidebar__info-content_analyze-buttons" class="gallery2__sidebar__info-metadata gallery2__sidebar__exif_tags-top-separator">
<td colspan="2">
<div class="gallery2__sidebar__info-one_line_buttons">
<div>
<div class="gallery2__sidebar__info-dropdown_button google_cloud-vision" onclick="objectsLabelsDetection( this ); gaev( 'modal-gallery-objects_labels_detection', 'any-user-clicked', '' );">
<span class="gallery2__sidebar__info-dropdown_text">
Find objects PRO </span>
<span class="gallery2__sidebar__info-dropdown_icon"></span>
</div>
<div class="gallery2__sidebar__info-dropdown_button yolo-object_detection" onclick="objectDetection( this ); gaev( 'modal-gallery-yolo_objects_labels_detection', 'any-user-clicked', '' );">
<span class="gallery2__sidebar__info-dropdown_text">
Find objects </span>
<span class="gallery2__sidebar__info-dropdown_icon"></span>
</div>
</div>
<div>
<div class="gallery2__sidebar__info-dropdown_button google_cloud_vision-ocr" onclick="ocrAnalyze( this, 'googlecv' ); gaev( 'modal-gallery-ocr-buttons', 'googlecv-model', '' );">
<span class="gallery2__sidebar__info-dropdown_text">
Find text PRO </span>
<span class="gallery2__sidebar__info-dropdown_icon"></span>
</div>
<div class="gallery2__sidebar__info-dropdown_button easyocr-text_recognition" onclick="ocrAnalyze( this, 'easyocr' ); gaev( 'modal-gallery-ocr-buttons', 'easyocr-model', '' );">
<span class="gallery2__sidebar__info-dropdown_text">
Find Text </span>
<span class="gallery2__sidebar__info-dropdown_icon"></span>
</div>
</div>
</div>
</td>
</tr>
<tr id="gallery2__sidebar__info-easyocr_text" class="gallery2__sidebar__info-metadata">
<td colspan="2" class="metadata-title_above_content">
<div>
Basic printed text recognition: </div>
<div class="gallery2__sidebar__info-value"></div>
</td>
</tr>
<tr id="gallery2__sidebar__info-google_cv_text" class="gallery2__sidebar__info-metadata">
<td colspan="2" class="metadata-title_above_content">
<div>
PRO OCR text found in image: </div>
<div class="gallery2__sidebar__info-value"></div>
</td>
</tr>
<tr id="gallery2__sidebar__info-google_cloud-speech_to_text-button" class="gallery2__sidebar__info-metadata gallery2__sidebar__exif_tags-top-separator">
<td colspan="2">
<div class="gallery2__sidebar__info-one_line_buttons">
<div class="gallery2__sidebar__info-dropdown_button" onclick="speechToText( this ); gaev( 'modal-gallery-speech-to-text', 'any-user-clicked', '' );" style="width: max-content;">
<span class="gallery2__sidebar__info-dropdown_text">
Recognize speech </span>
<span class="gallery2__sidebar__info-dropdown_icon"></span>
</div>
</div>
</td>
</tr>
<tr id="gallery2__sidebar__info-google_cloud-speech_to_text-text" class="gallery2__sidebar__info-metadata">
<td colspan="2" class="metadata-title_above_content">
<div>
Transcription </div>
<div class="gallery2__sidebar__info-value"></div>
</td>
</tr>
</tbody>
</table>
<table id="gallery2_file_details_table_tags" class="zebra_table gallery2_item_info_padded">
<tbody>
<tr id="gallery2__sidebar__info-metadata-tags" class="gallery2__sidebar__info-metadata gallery2__sidebar__exif_tags-top-separator">
<td colspan="2">
Tags </td>
</tr>
</tbody>
</table>
<ul class="fa-ul" id="gallery2__sidebar__info-data">
<li id="gallery2__sidebar__info-tags">
<div id="gallery_file_tags_container" class="file_tags_container ">
<input class="file_tags_input" style="display:none" data-tagsinput-init="true" id="tags17289306443090"><div id="tags17289306443090_tagsinput" class="tagsinput" style="width: 100%; min-height: auto; height: auto;"><div id="tags17289306443090_addTag" class="add_tag_button"></div><div class="tags_clear"></div></div>
<div class="file_tags_error">An error occurred. Please try again!</div>
</div>
</li>
</ul>
<div id="gallery2__sidebar__info-object_tags" class="gallery2__sidebar__info-metadata gallery2__sidebar__info-image_annotation">
<div class="title">
Objects </div>
<div class="tags"></div>
</div>
<div id="gallery2__sidebar__info-label_tags" class="gallery2__sidebar__info-metadata gallery2__sidebar__info-image_annotation">
<div class="title">
Labels </div>
<div class="tags"></div>
</div>
<label class="block-label" id="gallery2_file_details_table_label" style="padding-left: 20px;">Meta data</label>
<table id="gallery2_file_details_table" class="zebra_table gallery2_item_info_padded">
<tbody>
<tr id="gallery2__sidebar__info-mainexif">
<td colspan="2" class="gallery2__sidebar__info-value">
<div class="exif-grid">
<div class="Model my_tooltip" my_title="Device"><span></span></div>
<div class="ISO my_tooltip" my_title="ISO controls the camera’s sensitivity to light. Lower values produce clearer images in bright conditions, while higher values are ideal for low light but may introduce grain."><span></span></div>
<div class="LensModel my_tooltip" my_title="Lens model specifies the type and characteristics of the lens being used, which greatly influences image quality, depth of field, and perspective in photography"><span></span></div>
<div class="FocalLength my_tooltip" my_title="Focal length determines the camera’s field of view and zoom level; shorter lengths capture wider scenes, while longer lengths zoom in for close-up details."><span></span></div>
<div class="ApertureValue my_tooltip" my_title="Aperture value controls the amount of light entering the camera and affects depth of field, influencing how much of the image is in focus!">f/<span></span></div>
<div class="ExposureTime my_tooltip" my_title="Exposure time or shutter speed - determines how long the camera’s sensor is exposed to light, affecting the brightness of the image and the ability to freeze motion or create motion blur."><span></span></div>
<div class="size my_tooltip" my_title="Resolution refers to the amount of detail an image can capture, measured in pixels. Higher resolution allows for larger prints and greater cropping flexibility without losing image quality."><span></span></div>
<div class="mp my_tooltip" my_title="Megapixels indicate the approximate total number of pixels in an image in millions (length * width) for a quick estimate of its size."><span></span></div>
</div>
</td>
</tr>
<tr id="gallery2__sidebar__info-date-created">
<td>
Created:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-moddate">
<td>
Modified:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-date">
<td>
Uploaded:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-date-delete">
<td style="color:#C96F6F">
Will be deleted:
</td>
<td class="gallery2__sidebar__info-value" style="color:#C96F6F">
</td>
</tr>
<tr id="gallery2__sidebar__info-size">
<td>
Size:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-dimensions">
<td>
Resolution:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-views">
<td>
Views:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-downloads">
<td>
Downloads:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-comments">
<td>
Comments:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-title" class="gallery2__sidebar__info-metadata">
<td>
Title:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-subject" class="gallery2__sidebar__info-metadata">
<td>
Subject:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-content_type" class="gallery2__sidebar__info-metadata">
<td>
Content type:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-category" class="gallery2__sidebar__info-metadata">
<td>
Category:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-categories" class="gallery2__sidebar__info-metadata">
<td>
Categories:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-keywords" class="gallery2__sidebar__info-metadata">
<td>
Keywords:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-creator" class="gallery2__sidebar__info-metadata">
<td>
Author:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-publisher" class="gallery2__sidebar__info-metadata">
<td>
Publisher:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-contributor" class="gallery2__sidebar__info-metadata">
<td>
Contributor:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-copyrights" class="gallery2__sidebar__info-metadata">
<td>
Copyrights:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-license_type" class="gallery2__sidebar__info-metadata">
<td>
License type:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-license_details" class="gallery2__sidebar__info-metadata">
<td>
License details:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-language" class="gallery2__sidebar__info-metadata">
<td>
Language:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-location" class="gallery2__sidebar__info-metadata">
<td>
Location:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-location_lat" class="gallery2__sidebar__info-metadata">
<td>
GPS Lat:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-location_long" class="gallery2__sidebar__info-metadata">
<td>
GPS Long:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-references" class="gallery2__sidebar__info-metadata">
<td>
References:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-relates_to" class="gallery2__sidebar__info-metadata">
<td>
Relates to:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-format" class="gallery2__sidebar__info-metadata">
<td>
Format:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-device" class="gallery2__sidebar__info-metadata">
<td>
Device:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-source" class="gallery2__sidebar__info-metadata">
<td>
Source:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-metadata-duration" class="gallery2__sidebar__info-metadata">
<td>
Length:
</td>
<td class="gallery2__sidebar__info-value">
</td>
</tr>
<tr id="gallery2__sidebar__info-exif_tags-button" class="gallery2__sidebar__info-metadata">
<td class="gallery2__sidebar__info-exif_tags-dropdown" onclick="$( '#gallery2__sidebar__info-exif_tags-button' ).hide(); $('.gallery2__sidebar__info-exif_tags').show();">
<span class="gallery2__sidebar__info-dropdown_text">
Show Exif info </span>
<span class="gallery2__sidebar__info-dropdown_icon"></span>
</td>
</tr>
</tbody>
</table>
</div>
</div> 
</div>
</div>
<div id="gallery2__sidebar__banner">
<div id="files_300x250_file_desktop_1" data-google-query-id="CNLziMjAjokDFZReQQIdny4gaw" style="display: none;">
<script>
                                    if ( typeof googletag != 'undefined' && typeof googletag.cmd != 'undefined' )
                                    {
                                        googletag.cmd.push(function () {
                                            googletag.display('files_300x250_file_desktop_1');
                                        });
                                    }
                                </script>
<div id="google_ads_iframe_/19238985/files_300x250_file_desktop_1_0__container__" style="border: 0pt none; width: 300px; height: 0px;"></div></div>
</div>
</div>
<script>
                            var CHAT_DATA = {
                                userId: null,
                                phpSessid: '40bdb754ce23cdfc13a344b0230a4e21f5e0785a',
                                fullChat: false,
                                apiUrl: "https://files.fm/api/chat/",
                                mainUrl: "https://files.fm/",
                                avatarCache: Date.now(),
                                isOrg: false,
                                translations: {"CHATFM_SEND-BUTTON":"Send","CHATFM_MEMBERS":"Members","CHATFM_TYPE-NEW-MESSAGE":"Write a message","CHATFM_NEW-CONVERSATION-BUTTON":"New conversation","CHATFM_START-NEW-CONVERSATION-BUTTON":"Start a new conversation","CHATFM_GROUP-CHAT-TITLE":"Create a new conversation:","CHATFM_GROUP-CHAT-INPUT":"Type a conversation name","CHATFM_GROUP-CHAT-SELECT":"Select members:","CHATFM_GROUP-CHAT-ACTION-ALL":"Select all","CHATFM_GROUP-CHAT-ACTION-NONE":"Clear","CHATFM_GROUP-CHAT-CREATE-BUTTON":"Create","CHATFM_SELECT-CONVERSATION":"Select conversation or","CHATFM_EMPTY-CHANNELS":"You currently do not have any conversation","CHATFM_CANCEL-BUTTON":"Cancel","CHATFM_REPORT-TITLE":"Report message?","CHATFM_REPORT-BUTTON":"Report","CHATFM_DELETE-TITLE":"Delete message?","CHATFM_DELETE-BUTTON":"Delete","CHATFM_MESSAGE-DELETED":"Message deleted","CHATFM_NEW-ACCOUNT-TITLE":"Create an account to write a message.","CHATFM_SIGN-UP":"Sign up","CHATFM_LOG-IN":"Log in","CHATFM_ERROR":"Something went wrong. Please reload the page and try again.","CHATFM_MESSAGES-LOAD-MORE":"Load more","CHATFM_SYSTEM-MESSAGES":"System messages","CHATFM_SYSTEM-MESSAGE":"System message","CHATFM_NOT_VALID_EMAIL":"Not valid email!","CHATFM_ALREADY_ADDED_TO_WAITINGLIST":"Invitation sent!","CHATFM_ADDED_TO_WAITINGLIST":"Invitation sent!","CHATFM_ALREADY_ADDED_TO_CHANNEL":"Already added!","CHATFM_ADDED_TO_CHANNEL":"Successfully added!","CHATFM_NOT_FROM_ORG":"This email is not registered in the organisation!","CHATFM_ADD_MEMBER_TITLE":"Invite a new member via email to chat","CHATFM_ADD_MEMBER_INPUT":"Email","CHATFM_ADD_MEMBER_BUTTON":"Add","CHATFM_REQUEST_ACCESS_ALREADY_MEMBER":"User is already in this conversation!","CHATFM_REQUEST_ACCESS_NOT_POSSIBLE":"Unable to send request!","CHATFM_REQUEST_ACCESS_SENT":"Request sent!","CHATFM_REQUEST_ACCESS_TITLE":"You don\\'t have access to this conversation.","CHATFM_REQUEST_ACCESS_BUTTON_SEND":"Send access request","CHATFM_REQUEST_ACCESS_BUTTON_BACK":"Back to conversations","CHATFM_YES-BUTTON":"Yes","CHATFM_NO-BUTTON":"No","CHATFM_WAITINGLIST-TITLE":"Waiting list","CHATFM_WAITINGLIST-EMPTY":"Waiting list is empty","CHATFM_WAITINGLIST-DELETE-TITLE":"Cancel invite?","CHATFM_MENTION_DESCRIPTION":"Write @ symbol to send email to user","CHATFM_MEMBER-DELETE-TITLE":"Remove member?","CHATFM_EDIT-NAME-UPDATED":"Successfully updated!","CHATFM_EDIT-NAME-TITLE":"Edit name","CHATFM_EDIT-NAME-INPUT":"Type a conversation name","CHATFM_EDIT-NAME-BUTTON":"Save","CHATFM_CHANNEL-ERROR-BACK-BUTTON":"Back to conversations","CHATFM_CHANNEL-ERROR-NO-ACCESS":"You don\\'t have access to this conversation.","CHATFM_CONTACT-MESSAGE":"To contact Files.fm support, go to the section %link% and send a message.","CHATFM_CONTACT-TITLE":"Contacts"},
                                showMessagesHeader: false,
                                allowAddNewMember: false,
                                allowSendAccessRequest: false,
                                initChannelId: null,
                                initChannelStatus: null,
                                initChannelType: null,
                                initChannelName: null,
                                showWaitinglist: false
                            };
                        </script>
<div id="gallery2__comments" class="gallery2__comments">
<a href="javascript:void(0)" onclick="hideGalleryMessages(); $(window).trigger('resize');" id="gallery2__comments_button_close" class="my_tooltip" my_title="Back to information">
<i class="fas fa-chevron-left"></i>
</a>
<div id="chatfm-app-wrapper">
<div id="chatfm-app" class="chatfm-app"><div class="chatfm"><div class="chatfm__loading"><div class="chatfm-spinner"></div></div></div></div>
</div>
</div>
</div>
<div id="gallery2__content__viewport">
<div id="gallery2__image-wrapper">
<div id="gallery2__swipe-wrapper"><i class="fa fa-spinner fa-spin gallery2__load-spinner"></i></div>
<div id="gallery2__controls_middle">
<div class="gallery2__controls_middle">
<div id="gallery_select_middle" onclick="checkToggleItem(event, $('#item_' + strCurrentFileHash))" class="my_tooltip" my_title="Select to save"><div class="gallery2__controls_middle_icon"></div></div>
<div id="gallery_vote_middle" class="gallery_vote gallery2__header__icon my_tooltip" onclick="voteForFile(strCurrentFileHash)" my_title="Mark as Like">
<div class="gallery2__controls_middle_icon"><span class="vote_count"></span></div>
</div>
<div id="gallery_comments_middle" onclick="if(!bolGallerySidebarVisible) {showGalleryInfo();} showGalleryMessages(); $(window).trigger('resize');" class="my_tooltip" my_title="Add a comment"><div class="gallery2__controls_middle_icon"></div></div>
<div id="gallery_edit_image_middle" class="edit_image gallery2__edit my_tooltip" my_title="Edit image" style="display: none;"><div class="gallery2__controls_middle_icon"></div></div>
</div>
<div class="gallery2__controls_middle">
<div id="gallery2__header__zoom" onclick="openPanZoomImage()" class="my_tooltip" my_title="Zoom image preview"><div class="gallery2__controls_middle_icon"></div></div>
<div id="gallery2__header__view-original" onclick="showOrginal(strCurrentFileHash)" class="my_tooltip" my_title="Open original image in full quality"><div class="gallery2__controls_middle_icon"></div></div>
<div id="gallery2__header__fullscreen" onclick="galleryToggleFullScreen(document.body)" class="my_tooltip" my_title="Switch to fullscreen"><div class="gallery2__controls_middle_icon"></div></div>
<div id="gallery2__header__slideshow" onclick="enterSlideshow()" class="my_tooltip" my_title="Slideshow" style="display: none;"><div class="gallery2__controls_middle_icon"></div></div>
</div>
</div>
<div id="gallery2__controls_doc_sign">
<span id="gallery2__controls_doc_sign_button">
<a href="javascript:void(0);">
<span>eSign</span>
</a>
</span>
</div>
<div id="gallery2__controls_left">
<a href="javascript:void(0);" id="gallery2__controls__prev" onclick="galleryOpenPrevItem()"></a>
</div>
<div id="gallery2__controls_right">
<a href="javascript:void(0);" id="gallery2__controls__next" onclick="galleryOpenNextItem()"></a>
</div>
</div>
<div id="gallery2__thumb-strip__hide_container" style="display: none;">
<a href="javascript:void(0)" id="gallery2__thumb-strip__hide" onclick="toggleThumbs();"></a>
</div>
<div id="gallery2__thumb-strip">
<div id="gallery2__thumb-strip__buttons">
<a href="javascript:void(0)" id="gallery2__thumb-strip__prev" onclick="
                            var intMovementPx = parseInt($('#gallery2__image-wrapper').width()) / 2;
                            if (parseInt($('#gallery2__thumb-strip__inner').css('left')) + intMovementPx > 0) 
                            {
                                $('#gallery2__thumb-strip__inner').css({'left': 0});
                            } 
                            else 
                            {
                                $('#gallery2__thumb-strip__inner').css({'left': parseInt($('#gallery2__thumb-strip__inner').css('left')) + intMovementPx});
                            }; 
                            galleryLazyloadRecalc();">
</a>
<a href="javascript:void(0)" id="gallery2__thumb-strip__next" onclick="
                            var intMovementPx = parseInt($('#gallery2__image-wrapper').width()) / 2;
                            if (parseInt($('#gallery2__image-wrapper').width()) - parseInt($('#gallery2__thumb-strip__inner').width()) > parseInt($('#gallery2__thumb-strip__inner').css('left')) - intMovementPx) 
                            {
                                $('#gallery2__thumb-strip__inner').css({'left': parseInt($('#gallery2__image-wrapper').width()) - parseInt($('#gallery2__thumb-strip__inner').width())})
                            } 
                            else 
                            {
                                $('#gallery2__thumb-strip__inner').css({'left': parseInt($('#gallery2__thumb-strip__inner').css('left')) - intMovementPx})
                            };
                            galleryLazyloadRecalc();">
</a>
</div>
<div id="gallery2__thumb-strip__inner" style="width: 0; left: 0;"></div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
    
    var bolStartAudioOnOpen = false;    
    var bolHashtagViewUseSemicolon = false;
	
	var bolGalleryIsVisible = false;
    var bolGallerySidebarVisible = false;
    var bolGalleryCommentsVisible = false;

	var intPreloadImagesCount = 1;
	var intPreloadThumbnailsCount = 2;
    
    var bolUseAsyncFileInfoDataLoad = false;
    var intPreloadFileInfoDataCount = 1;
	
    var strLinkToView = 'https://files.fm/u/fhazcb8kug';
    var strGalleryCloseHashtag = '';
	
    var intCurrentFileIndex = null;
    var strCurrentFileHash = null;
    var strCurrentFileName = null;
    
    var intNextIndex = null;
    var intPreviousIndex = null;
    
    var intThumbWidth = 110;
    
    var jqThumbViewport = null;
    var jqThumbContainer = null;

    var jqMainSlider = null;
    
    var objVideoIsLoading = {};

    var resVideoCheckInterval = null;

    var bolHaveToRedrawGallery = false;
    
    
    var bolIsOwner = Boolean();
    var bolCanEdit = Boolean(); 
    var bolCanDelete = Boolean(); 
    
    var bolCloseGalleryIfHashRemoved = false;
    
    var objMainShareParams = null;

    var arrMOVsWithH264Hashes = [];

    var strFolderName = null;
    
    var bolIsiOSDevice = window.navigator.userAgent.match(/(iPod|iPhone|iPad)/) && window.navigator.userAgent.match(/AppleWebKit/);
    
    var bolIsListViewForSpecificFile = Boolean(0);
    
    var objEmbedPlayerFileEventCallback = {};
    
    var strActiveCommentsEntityHash = "";

    var bolPopupOnlyGallery = false;
    
    var bolOpenGalleryCommentsBlock = false;

            var strSlideshowInterval = null;
        var strSlideshowUserActive = null;
        var bolActivateSlideshowOnOpen = false;
    
    var strPublicProfileHref = '';
    if ( typeof strUploadUserNameHref != 'undefined' && strUploadUserNameHref != '' )
    {
        strPublicProfileHref =  '/' + strUploadUserNameHref;
    }
    else if ( typeof PublicProfile != 'undefined' && typeof PublicProfile.strProfileName != 'undefined' )
    {
        strPublicProfileHref = '/' + PublicProfile.strProfileName;
    }

    function browserSupportsCanvas() {
        var elem = document.createElement('canvas');
        return !!(elem.getContext && elem.getContext('2d'));
    }

    window.addEventListener('message', function(data)
    {
        if ( data.data === "info" )
        {
            showGalleryInfo();
        }
    }, false);

        objMainShareParams = {"show_type_select":false,"type":"all_files","can_share":false,"all_files":{"view_url":"https:\/\/files.fm\/u\/fhazcb8kug","edit_url":"","upload_url":"","facebook":{"name":"-Moments-Feb-18-2024--.mp4","picture_url":"https:\/\/files.fm\/images\/files.fm_300.png","description":"https:\/\/files.fm\/u\/fhazcb8kug","link":"https:\/\/files.fm\/u\/fhazcb8kug","return_link":"https:\/\/files.fm\/u\/fhazcb8kug?after_fb_share"},"twitter":{"text":"files.fm: -Moments-Feb-18-2024--.mp4","link":"https:\/\/files.fm\/u\/fhazcb8kug"},"share_email":{"upload_hash":"fhazcb8kug","file_view_hash":""},"item_info":{"upload_hash":"fhazcb8kug","item_name":"-Moments-Feb-18-2024--.mp4"}}};
    
    
        strFolderName = "-Moments-Feb-18-2024--.mp4";
        
    var bolUseEmbedPlayer = WEBRTC_SUPPORT && (window.navigator.userAgent.indexOf("Edge") == -1);
    var viewItemIsDeleted = 0;

    var bolGalleryInitalizedState = null;
    function galleryInitalize()
    {
    	bolGalleryInitalizedState = 0;
    	
    	if( viewItemIsDeleted )
    	{
    				return;
    			}
    	
    	if ( bolIsListViewForSpecificFile )
        {
            $( '#gallery2' ).addClass( 'list_for_specific_file' );
        }

        $('body').append('<div id="gallery_panzoomdiv" style="overflow:hidden;height:100%;width:100%;position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 999999999; background: #666666; display: none;" height="100%" width="100%"></div>')

        window.oncontextmenu = function( event )
        {
            if (
                    $( event.target ).parents( '.gallery2__item' ).length
                    || $( event.target ).parents( '#gallery2__thumb-strip' ).length
                )
            {
                // Disabling the context menu for thumbnails
                event.preventDefault();
                event.stopPropagation();
                return false;
            }
        }

        $('.edit_wrapper_edit_button').click(function() {
            $(this).parent().find("textarea").focus();
        });

        $('#file_description_edit_wrapper textarea').on("keyup change", function(e) {
            autoGrow( this, '32px' );
            if ( bolIsOwner )
            {
                updateFileDescription();
            }
        });

        $('#file_name_edit_wrapper textarea').on("keyup", function(e) {
            $('#file_name_edit_wrapper textarea').removeClass('pulse');
            autoGrow( this, '32px' );
        });
        $('#file_name_edit_wrapper textarea').on("change", function(e) {
            $('#file_name_edit_wrapper textarea').removeClass('pulse');
            autoGrow( this, '32px' );
            if ( bolIsOwner )
            {
                updateFileName();
            }
        });
        
        $('#file_name_edit_wrapper textarea').keypress(function(event) {
            if (event.keyCode == 13) {
                event.preventDefault();
            }
        });

        $('#file_name_edit_wrapper textarea').on("focus", function(e) {
            var strFullName = $('#file_name_edit_wrapper textarea').val();
            var strExtension = '.' + arrExtensions[ intCurrentFileIndex ];
            var intIndex = strFullName.lastIndexOf(strExtension);
            strFullName = strFullName.slice(0, intIndex) + strFullName.slice(intIndex).replace(strExtension, '');

            $('#file_name_edit_wrapper textarea').val(strFullName);
        } )

        $('#file_name_edit_wrapper textarea').on("focusout", function(e) {
            $('#file_name_edit_wrapper textarea').removeClass('pulse');
        	$('#file_name_edit_wrapper textarea').val( $('#file_name_edit_wrapper textarea').val() + '.' + arrExtensions[ intCurrentFileIndex ] );
        } )


        $('#file_description_edit_wrapper textarea').on("focus", function(e) {

            $( "#file_description_edit_wrapper" ).removeClass("no-description");
        } )

        $('#file_description_edit_wrapper textarea').on("focusout", function(e) {
            if ( $('#file_description_edit_wrapper textarea').val() == '' )
            {
            	$( "#file_description_edit_wrapper" ).addClass("no-description");
            }
            else
            {
            	$( "#file_description_edit_wrapper" ).removeClass("no-description");
            }
        } )

        if ( bolIsOwner )
        {
            $('#gallery2__header__setprice').show();
        }

		if ( ! bolHideShareButtons )
		{
	        $('#gallery2__share').show();
		}
        
		if (arrHashes.length == 1)
		{
			hideThumbs();
            $('#gallery2__slideshow_middle, #gallery2__slideshow, #gallery2__header__slideshow').hide();
		}
		
		$('#gallery_file_tags_container .file_tags_input').tagsInput(
		{
			'autocomplete_url': './ajax/file_tag.php?autocomplete&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a' ,
			'autocomplete': { selectFirst:false, autoFill:false},
			'height' : 'auto',
			'width' : '100%',
            'interactive' : bolIsOwner || ( window.location.href.indexOf( "filebrowser" ) !== -1 && 0 ),
			'defaultText' : 'Add tags',
			'onAddTag' : function(strTagName) 
			{
				$('#gallery_file_tags_container .file_tags_error').hide();
				
				$.ajax({
					type: "POST",
					dataType: "json",
					url: "./ajax/file_tag.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
					data: 
					{
						'add_file_tag': true ,
						'file_hash' : strCurrentFileHash ,
						'tag_name': strTagName
					} ,
					success: function(data)
					{
						if (data['status'] == 'ok')
						{
							var intItemIndex = getItemIndex(strCurrentFileHash);
							arrTags[intItemIndex] += ';' + strTagName;
							// update tags in filebrowser
                            $('#sidebar_file_tags_container .file_tags_input').importTags(typeof arrTags[intItemIndex] === "undefined" ? "" : arrTags[intItemIndex]);
						}
						else
						{
							$('#gallery_file_tags_container .file_tags_error').show();
						}
					} ,
					error: function()
					{
						$('#gallery_file_tags_container .file_tags_error').show();
					}
				});
			} ,
			'onRemoveTag' : function(strTagName)
			{
				$('#gallery_file_tags_container .file_tags_error').hide();

				$.ajax({
					type: "POST",
					dataType: "json",
					url: "./ajax/file_tag.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
					data: 
					{
						'delete_file_tag': true ,
						'file_hash' : strCurrentFileHash ,
						'tag_name': strTagName
					} ,
					success: function(data)
					{
						if (data['status'] == 'ok')
						{
							var intItemIndex = getItemIndex(strCurrentFileHash);
							arrTags[intItemIndex] = arrTags[intItemIndex].replace(strTagName, '');
							// update tags in filebrowser
                            $('#sidebar_file_tags_container .file_tags_input').importTags(typeof arrTags[intItemIndex] === "undefined" ? "" : arrTags[intItemIndex]);
						}
						else
						{
							$('#gallery_file_tags_container .file_tags_error').show();
						}
					} ,
					error: function()
					{
						$('#gallery_file_tags_container .file_tags_error').show();
					}
				});
			} ,
            'onSearchTag' : function(strTagName)
            {
                if ( typeof strUploadUserNameHref != 'undefined' && strUploadUserNameHref != '' )
                {
                    window.open('/' + strUploadUserNameHref + '#search='+  strTagName, '_self');
                }
                else if ( typeof PublicProfile != 'undefined' && typeof PublicProfile.strProfileName != 'undefined' )
                {
                    window.open('/' + PublicProfile.strProfileName + '#search='+  strTagName, '_self');
                }
            } ,
			'delimiter' : [';'] ,
			'removeWithBackspace' : false ,
			'minChars' : 1 ,
			'maxChars' : 245 ,
			'placeholderColor' : '#666666'
		});


        $('#gallery_file_tags_container .file_tags_input')

        if (( typeof strUploadUserNameHref != 'undefined' && strUploadUserNameHref != '' ) ||
            ( typeof PublicProfile != 'undefined' && typeof PublicProfile.strProfileName != 'undefined' ))
        {
            $('#gallery_file_tags_container .tagsinput').addClass('searchable');
        }
        else
        {
            $('#gallery_file_tags_container .tagsinput').removeClass('searchable');
        }

		function getFileShareParams()
        {
            if ( objMainShareParams )
            {
                var intItemIndex = getItemIndex( strCurrentFileHash );
    
                var objFileShareParams = {};
                for ( idx in objMainShareParams )
                {
                    objFileShareParams[ idx ] = objMainShareParams[ idx ];
                }
    
                if ( typeof( arrFileShareLinks ) != 'undefined' && typeof( arrFileShareLinks[ intItemIndex ] ) != 'undefined' )
                {
                    objFileShareParams[ 'view_url' ] = 'https://files.fm' + arrFileShareLinks[ intItemIndex ];
                }
                else
                {
                    objFileShareParams[ 'view_url' ] += '#/view/' + arrHashes[ intItemIndex ];
                }
    
                objFileShareParams[ 'can_share' ] = bolIsOwner;
                
                objFileShareParams[ 'show_type_select' ] = false;
                objFileShareParams[ 'type' ] = 'one_file';
                
                var strFileShareParams_PictureUrl = '';
                if ( arrFileTypes[ intItemIndex ] == 'image' )
                {
                    strFileShareParams_PictureUrl = 'https://files.fm/thumb_show.php?i=' + arrHashes[ intItemIndex ] + '&view&v=1&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a';
                }
    
                var strFileViewLink = 'https://files.fm/f/' + strCurrentFileHash;

                var strFileEditLink = '';
                
                if ( bolCanDelete && typeof arrFileDeleteKeys != 'undefined' && arrFileDeleteKeys[ intItemIndex ] != '' )
                {
                	strFileEditLink = strFileViewLink + '?fk=' + arrFileDeleteKeys[ intItemIndex ];
                }

                var intVersion = 0;
                if ( typeof( arrFileVersion ) != 'undefined' && typeof( arrFileVersion[ intItemIndex ] ) != 'undefined' && arrFileVersion[ intItemIndex ] > 0 )
                {
                    intVersion = arrFileVersion[ intItemIndex ];
                }
    
                objFileShareParams[ 'one_file' ] = {
                    'view_url': strFileViewLink,
                    'edit_url': strFileEditLink,
                    'facebook': {
                        'name': strFileViewLink,
                        'picture_url': strFileShareParams_PictureUrl,
                        'description': strFileViewLink,
                        'link': strFileViewLink,
                        'return_link': objFileShareParams[ 'all_files' ][ 'facebook' ][ 'return_link' ]
                    },
                    'twitter': {
                        'text': DOMAIN_NAME + ': ',
                        'link': strFileViewLink
                    },
                    'share_email': {
                        'upload_hash': '',
                        'file_view_hash': strCurrentFileHash
                    },
                    'embed_player': {
                        'file_view_hash': null
                    },
                    'item_info': {
                    	'file_view_hash': strCurrentFileHash,
                    	'upload_hash': objFileShareParams[ 'all_files' ][ 'share_email' ][ 'upload_hash' ],
                    	'file_name': arrDisplayNames[ intItemIndex ],
                        'item_name': arrDisplayNames[ intItemIndex ],
                        'extension': arrExtensions[ intItemIndex ],
                        'file_version': intVersion,
                        'owner_logged_in': bolIsOwner,
                        'access_type': ( typeof arrFileAccessTypes != 'undefined' ? arrFileAccessTypes[ intItemIndex ] : '' ),
                        'parent_access_type': arrAccessType[ intItemIndex ]
                    }
                };
    
                if (
                        arrFeeDownloadPrice[ intItemIndex ] == null && 
                        ! currentFolderHasFeeDownload( intItemIndex ) &&
                        arrAllowDownload[ intItemIndex ] && 
                        ( arrAccessType[ intItemIndex ] == 'LINK' || arrAccessType[ intItemIndex ] == 'PUBLIC' ) && 
                        arrUploadPassword[ intItemIndex ] == '' && 
                        arrAllowPublicDownload[ intItemIndex ]
                    )
                {
                    objFileShareParams[ 'one_file' ][ 'embed_player' ] = {
                        'file_view_hash': strCurrentFileHash,
                        'file_extension': arrExtensions[ intItemIndex ],
                        'is_video': arrIsVideo[ intItemIndex ]
                    }
                }
    
                return objFileShareParams;
            }
            
            return null;
        }
        
        window.galleryGetFileShareParams = getFileShareParams;
    
        $( document ).on( 'click', '#gallery2__share', function ( e )
        {
            var objFileShareParams = getFileShareParams();
            if ( objFileShareParams !== null )
            {
                showSharePopup( e, objFileShareParams );
            }
        } );

        $( document ).on( 'click', '#gallery2__sign, #gallery2__sign_main, #gallery2__controls_doc_sign_button, #gallery2__left_info-button_sign', function ( e )
        {
        	if ( bolCanEdit )
        	{
	        	objEparakstsFileSigningForm.showForm( [ strCurrentFileHash ] );
        	}
	        else 
	        {
	        	fError( 'This link is for viewing the document only. To sign, please ask the file owner to send a link to edit the file - from the e-signature form.', 'Warning!' );
	        }
        } );

        
        
        $( document ).on( 'click', '.gallery2__edit', function ( e )
        {
            if ( canOpenFileInEditor( 'edit', arrExtensions[ intCurrentFileIndex ] ) )
            {
                                                        showCreateAccount();
                            }
            else
            {
                showImageEditorIframe( strCurrentFileHash, true,  );
            }
        } );

        $( document ).on( 'click', '.gallery2__edit_in_google', function ()
        {
            if (
                    [ 'doc','docx','xls','xlsx','ppt','pptx' ].includes( arrExtensions[ intCurrentFileIndex ] )
                    && true                )
            {
                                    
                    showCreateAccount();
                            }
        } );

                    $( document ).on( 'click', '.gallery2__button__buy-products', function ( e )
            {
                window.open( '/c/' + strUploadHash + '?h=' + strCurrentFileHash, '_blank' );
            } );
            $( document ).on( 'click', '.print_or_buy_popup__products', function ( e )
            {
                window.open( '/c/' + strUploadHash + '?h=' + strCurrentFileHash, '_blank' );
            } );
        
        $( document ).on( 'contextmenu', 'video', function ( e )
        {
        	e.preventDefault();
        } );
        
    
        $( document ).on( 'click', '#gallery2__sidebar__info_embed_button, #gallery2__sidebar__info_embed_button_middle', function ( e )
        {
            var objFileShareParams = getFileShareParams();
            
            if ( objFileShareParams !== null )
            {
                window.FileEmbedPopup.showPopup( e, objFileShareParams );
            }
        } );

        $( document ).on( 'click', '#copy_button_middle, #copy_button_left', function ( e )
        {
            var el = document.createElement( 'textarea' );
            el.value = $(this).prev().find( 'input' ).val();
            document.body.appendChild( el );
            el.select();
            document.execCommand( 'copy' );
            document.body.removeChild( el );

            $(this).addClass( 'copied' ).delay( 4000 ).queue( function( next )
            {
                $( this ).removeClass( 'copied' );
                next();
            } );
        } );
    
    
        $(window).resize(function() {

			if (!bolGalleryIsVisible)
			{
				bolHaveToRedrawGallery = true;
			}
			else
			{
    	    	recalculateGalleryForBanner(true);
			}
		});

                    $(window).mousemove(function() {
                if($('#gallery2__content-wrapper').hasClass( 'gallery__slideshow' )){
                    $('#gallery2__content-wrapper').addClass( 'gallery__slideshow_user_active' );
                    clearTimeout(strSlideshowUserActive);
                    strSlideshowUserActive = setTimeout(removeActiveClass, 1000);
                }
            });
        
		// Check video network state, if loading longer than 1+1 intervals, show thumbnail generation message
		var bolHasVideo = false;
		for ( idx in arrFileTypes)
		{
			if ( arrFileTypes[idx] == 'video' )
			{
				bolHasVideo = true;
			}
		}

		if (bolHasVideo)
		{
			if ( resVideoCheckInterval != null)
			{
				clearInterval(resVideoCheckInterval);
				resVideoCheckInterval = null;
			}
			
			resVideoCheckInterval = setInterval(function () {
				for ( idx in arrFileTypes)
				{
					if ( arrFileTypes[idx] == 'video' )
					{
						var domVideo = document.getElementById('video_' + arrHashes[idx]);
                        
						if ( domVideo )
						{
						    // iOS safari workaround - "play" gets fired when the play button is clicked => set video as loading
                            if(bolIsiOSDevice)
                            {
                                domVideo.addEventListener('play', function ()
                                {
                                    objVideoIsLoading[idx] = true;
                                });
                            }
                            
							var bolIsLoading = bolIsiOSDevice ? objVideoIsLoading[idx] : false;
                                    // iOS safari workaround: video has stopped loading when its duration attribute is > 0
                                    if (domVideo.duration > 0 && bolIsiOSDevice) 
                                    {
                                        bolIsLoading = false;
                                    }
                                    // If network connection active (2=NETWORK_LOADING) - this is broken in iOS safari
                                    else if (domVideo.networkState == 2)	
									{
										bolIsLoading = true;
									}									

							if ( bolIsLoading )
							{
								if (objVideoIsLoading[idx] == true)
								{
									$('#video_thumb_gen_'+ arrHashes[idx]).css({'visibility':'visible'});
								}
								objVideoIsLoading[idx] = true;
							}
							else if ( objVideoIsLoading[idx] )
							{
								objVideoIsLoading[idx] = false;
								$('.video_thumb_gen').css({'visibility':'hidden'});
							}
						}
					}
				}
			}, 3000);
		}

        // Close in item main element click
        $( '#gallery2' ).on( 'bx_slider_click', '.bx-viewport', function( e, domElement ){
            if ( $(domElement).hasClass('gallery2__item') )
            {
                closeGallery(strCurrentFileHash);
            }
        });

		bolGalleryInitalizedState = 1;
    }

    $(function (){
    	if ( bolGalleryInitalizedState === null )
    	{
    		galleryInitalize();
		}
	});

    $(document).on( "fullscreenchange", function () {
        adjustContentWidth( true );
    } );
    
	$(document).on("keydown", function(evt) {
        if (evt.altKey || evt.ctrlKey || evt.metaKey || $(evt.target).is(":input"))
        { 
            return; 
        }
        
        if ( ! bolGalleryIsVisible )
        {
        	return;	
		}
		
		if( 0)
        {
            return;
        }
        
        var key = evt.keyCode;
    
        if (key == 37 )
        {
            galleryOpenPrevItem();
        }
        else if (key == 39)
        {
        	galleryOpenNextItem();
		}
        else if (key == 27)
        {
        	closeGallery(strCurrentFileHash);
        }
    });
    
    function autoGrow( element, strMinHeight )
    {
        if( typeof strMinHeight === "undefined" )
        {
            strMinHeight = '32px';
        }
        
        element.style.height = strMinHeight;
        element.style.height = element.scrollHeight + "px";
        element.style.height = element.scrollHeight + 5 + "px";
    }
	
    function galleryCalculateOffset(el) {
	    var rect = el.getBoundingClientRect(),
	    scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,
	    scrollTop = window.pageYOffset || document.documentElement.scrollTop;
	    return { top: rect.top + scrollTop, left: rect.left + scrollLeft }
	}
    
	window.getImageCountText = function() {
        return ( parseInt( intCurrentFileIndex ) + 1 ) + '/' + arrIDs.length;
    };

    function checkThumbStripArrows()
    {
        if ( parseInt( $('#gallery2__thumb-strip__inner').width() ) >  parseInt( $('#gallery2__thumb-strip').width() ) )
        {
            $('#gallery2__thumb-strip__buttons').show();
        }
        else
        {
            $('#gallery2__thumb-strip__buttons').hide();
        }
    }

    var bolHideShareButtons = false;
	var bolGalleryIsShowingItem = false;
    var clickedItemHash = null;
    function showGalleryItem( strHash )
    {
        if (arrHashes.length == 1)
		{
    		hideThumbs();
            $('#gallery2__slideshow_middle, #gallery2__slideshow, #gallery2__header__slideshow').hide();
		}
        else
        {
            showThumbs();
            $('#gallery2__slideshow_middle, #gallery2__slideshow, #gallery2__header__slideshow').show();
        }

		
        clickedItemHash = strHash;
		if ( bolGalleryIsShowingItem )
		{
			return;
		}
		bolGalleryIsShowingItem = true;

        var bolSimpleDownloadAllowed = false;

    	strCurrentFileHash = strHash;

        intCurrentFileIndex = getItemIndex ( strHash );
        strCurrentFileName = arrDisplayNames[intCurrentFileIndex];

        preloadImage( intCurrentFileIndex );
        preloadFileInfoData( intCurrentFileIndex );

		if ( ! bolGalleryIsVisible )
		{
			showGallery();
		}

		stopActiveContent();


		checkBeforeContentChange ();

        jqMainSlider.goToSlide( intCurrentFileIndex );
        checkAfterContentChange();

        if ($('#share_popup').is(":visible"))
        {
            hideSharePopup();
        }

        if ( typeof window.FileEmbedPopup !== 'undefined' )
        {
            window.FileEmbedPopup.hidePopup();
        }

        if ( arrFileTypes[intCurrentFileIndex] == 'image' && arrFeeDownloadPrice[intCurrentFileIndex] == null && ! currentFolderHasFeeDownload( intCurrentFileIndex ) )
        {
            $('#gallery2__header__view-original').show();
        }
        else
        {
            $('#gallery2__header__view-original').hide();
        }

        $('.gallery2__header__img-count').text( window.getImageCountText() );


		if (arrAllowDownload[intCurrentFileIndex] && ( typeof(bolHideDownloadButtons) === 'undefined' || ! bolHideDownloadButtons ) && ( typeof(arrHideDownloadButtons) === 'undefined' || ! arrHideDownloadButtons[intCurrentFileIndex] ))
		{
            bolSimpleDownloadAllowed = true;
			$('.gallery2__save_button').show();
			$('#gallery2__sidebar__info_embed_button, #gallery2__sidebar__info_embed_button_middle').show();
			$('#gallery2__share').show();
		}
		else
		{
            bolSimpleDownloadAllowed = false;
			$('.gallery2__save_button').hide();
			$('#gallery2__sidebar__info_embed_button, #gallery2__sidebar__info_embed_button_middle').hide();
			$('#gallery2__share').hide();
		}


        if ( !arrFileAttributes[ intCurrentFileIndex ][ 'readOnly' ] && bolCanDelete )
        {
            $('#gallery2__item_info_delete, #gallery2__item_info_delete_middle').css('display', 'flex');
        }
        else
        {
            $('#gallery2__item_info_delete, #gallery2__item_info_delete_middle').hide();
        }

        if( canSetAsThumb( strHash ) )
        {
            $('#gallery2__item_info_cover, #gallery2__item_info_cover_middle').show();
        }
        else
        {
            $('#gallery2__item_info_cover, #gallery2__item_info_cover_middle').hide();
        }
        


        $( '#gallery2__left_info__signers-list-container' ).hide();

        
        if (
            	bolCanEdit 
            	&& 
            	( 
                	typeof arrFileIsLockedByOtherUser == 'undefined' 
                	|| ! arrFileIsLockedByOtherUser[ intCurrentFileIndex ]
            	) 
        	)
        {
            $( '#gallery2__left_info-button_sign' ).show();
            $('#gallery2__sign').css('display', 'flex');

            if (
				arrExtensions[intCurrentFileIndex] == 'edoc'
				|| arrExtensions[intCurrentFileIndex] == 'pdf'
				|| arrExtensions[intCurrentFileIndex] == 'doc'
				|| arrExtensions[intCurrentFileIndex] == 'docx'
				|| arrExtensions[intCurrentFileIndex] == 'txt'
				|| arrExtensions[intCurrentFileIndex] == 'asice'
			)
		    {
                $('#gallery2__sign_main').css('display', 'flex');
                $('#gallery2__controls_doc_sign').addClass('document');
            }
            else
            {
                
                $('#gallery2__sign_main').hide();
                $('#gallery2__controls_doc_sign').removeClass('document');
            }
        }
        else
        {
            $( '#gallery2__left_info-button_sign' ).hide();
            $( '#gallery2__sign' ).hide();
            $('#gallery2__sign_main').hide();
            $('#gallery2__controls_doc_sign').removeClass('document');
        }

                
        

        $( '#gallery_edit_image_middle' ).hide();
        if ( bolCanEdit )
        {
            if ( canOpenFileInEditor( 'edit', arrExtensions[ intCurrentFileIndex ] ) )
            {
                $( '#gallery2__item_info_edit' )
                    .removeClass( 'edit_image' )
                    .text( 'Edit file' );
				
				$( '#gallery2__header__mid #gallery2__edit' )
                    .removeClass( 'edit_image' )
                    .find( '#gallery2__edit_button span' )
                        .text( 'Edit' );
                
                $( '.gallery2__edit' ).show();
            }
            else if ( canOpenImageInEditor( arrExtensions[ intCurrentFileIndex ] ) )
            {
                $( '#gallery2__item_info_edit' )
                    .addClass( 'edit_image' )
                    .text( 'Edit image' );

                $( '#gallery2__header__mid #gallery2__edit' )
                    .addClass( 'edit_image' )
                    .find( '#gallery2__edit_button span' )
                        .text( 'Edit image' );

                $( '.gallery2__edit' ).show();
                $( '#gallery_edit_image_middle' ).show();
            }
            else 
            {
                $( '.gallery2__edit' ).hide();
            }

            if (
                    [ 'doc','docx','xls','xlsx','ppt','pptx' ].includes( arrExtensions[ intCurrentFileIndex ] )
                    && true                )
            {
                $( '.gallery2__edit_in_google' ).show();
            }
            else
            {
                $( '.gallery2__edit_in_google' ).hide();
            }
        }
        else
        {
            $( '.gallery2__edit' ).hide();
            $( '.gallery2__edit_in_google' ).hide();
        }


        $( '#gallery2__item_info_replace_middle' ).hide();
                
        
        $( '.gallery2__button__buy-products' ).hide();
		        if ( canOrderProductGeneral( strCurrentFileHash ) || arrFileHasProductSelling[ intCurrentFileIndex ] == 1 )
        {
            $( '.gallery2__button__buy-products' ).show();
            if( arrFileHasProductSelling[ intCurrentFileIndex ] != 1 )
            {
                $( '#gallery2__buyproducts' ).hide();
            }
        }
                

        if( window.location.href.indexOf("filebrowser") === -1 && typeof arrReports != 'undefined' && typeof arrStatuses != 'undefined' && ! [3, 4].includes(arrStatuses[ intCurrentFileIndex ]) &&
            ( 
                typeof arrFileIsLockedByOtherUser == 'undefined' 
                || ! arrFileIsLockedByOtherUser[ intCurrentFileIndex ]
            )
        ) 
        {
            $( '.gallery2__report_button' ).show();
    
            if (arrReports[ intCurrentFileIndex ] == 0)
            {
                $( '.gallery2__report_button' ).click(function() {
                    showFileReportModal(this, strCurrentFileHash);
                });
            }
            else 
            {
                $( '.gallery2__report_button' ).click(function() {
                    showCancelFileReportModal(this, strCurrentFileHash);
                });
            }
            
        }
        else
        {
            $( '.gallery2__report_button' ).hide();
        }

        if (
                arrFileTypes[ intCurrentFileIndex ] === 'document'
                && 
                (
                    arrExtensions[ intCurrentFileIndex ] === 'pdf' 
                    || arrExtensions[ intCurrentFileIndex ] === 'odt' 
                    || arrExtensions[ intCurrentFileIndex ] === 'ods' 
                    || arrExtensions[ intCurrentFileIndex ] === 'odp'  
                    || isFileConvertable( 'pdf', intCurrentFileIndex )
                ) 
                && arrFeeDownloadPrice[ intCurrentFileIndex ] == null 
                && ! currentFolderHasFeeDownload( intCurrentFileIndex )
                && arrAllowDownload[ intCurrentFileIndex ] 
            )
        {
            $( "#gallery2__controls_left" ).css( {
                'margin-top': '32px',
                'height': 'calc(100% - 50px)'
            } );
            
            $( "#gallery2__controls_right" ).css( {
                'right': '15px',
                'margin-top': '32px',    
                'height': 'calc(100% - 50px)'
            } );
        }
        else
        {
            $( "#gallery2__controls_right" ).css( {
                'right': '0',
                'margin-top': '32px',
                'height': 'calc(100% - 50px)'
                
            } );
    
            $( "#gallery2__controls_left" ).css( {
                'margin-top': '32px',
                'height': 'calc(100% - 50px)'
            } );
        }

        if ( arrFileTypes[ intCurrentFileIndex ] !== 'image' )
        {
            $('#gallery2__controls_middle').removeClass('image');
            $('#gallery2__controls_zoom').css('display', 'none');
            $('#gallery2__content-wrapper').removeClass( 'gallery__only_image' );
            $('#gallery2__content-wrapper').removeClass( 'gallery__is_image' );
        }
        else
        {
            $('#gallery2__controls_middle').addClass('image');
            $('#gallery2__controls_zoom').css('display', 'block');
            $('#gallery2__content-wrapper').addClass( 'gallery__is_image' );
        }
        
        if ( arrFileTypes[ intCurrentFileIndex ] !== 'audio' )
        {
            $('#gallery2__header__fullscreen').show();
        }
        else
        {
            $('#gallery2__header__fullscreen').hide();
        }

        $('.gallery2__video_filename-download .gallery2__save_button').show();
        
        
        if (bolIsOwner)
        {
            $("#gallery2__buyfile").attr("onclick", "showSetPriceFormModal(strCurrentFileHash)");

                            $("#gallery2__buyall").attr("onclick", "showSetPriceFormModal(strUploadHash, 'folder')");
                        
            $(".print_or_buy_popup__buyfile").attr("onclick", "showSetPriceFormModal(strCurrentFileHash)");
        }
        else 
        {
            $("#gallery2__buyfile").attr("onclick", "showBuyFileFormModal(strCurrentFileHash)");
            
                            $("#gallery2__buyall").attr("onclick", "showBuyFileFormModal(strUploadHash, 'folder')");
            
            $(".print_or_buy_popup__buyfile").attr("onclick", "showBuyFileFormModal(strCurrentFileHash)");
        }

		// spec for public profile -> fee file count can be dynamic, assume it is > 0
        		
			if ( arrFeeDownloadPrice[ intCurrentFileIndex ] != null )
			{
				$( '.gallery2__buy_button' ).css( 'display', 'flex' );
                $( '.gallery2__save_button' ).hide();
                
                if ( bolIsOwner )
                {
                    $( '#gallery2__buyfile' ).show();
                    $( '#gallery2__buyall' ).hide();
                    $( '#gallery2__buyfile span.text' ).html('Change price');
                    $( '#gallery2__buyfile span.price' ).html(arrFeeDownloadPrice[ intCurrentFileIndex ] + ' $');
                    $( '#gallery2__buyall span.price' ).html('');
                    $( '.print_or_buy_popup__buyfile' ).show();
                    $( '.print_or_buy_popup__buyfile span.text' ).html('Change price');
                    $( '.print_or_buy_popup__buyfile span.price' ).html(arrFeeDownloadPrice[ intCurrentFileIndex ] + ' $');
                }
                else 
                {
                    $( '#gallery2__buyfile' ).hide();
                    $( '#gallery2__buyall' ).hide();
                    $( '.print_or_buy_popup__buyfile' ).hide();
                }
			}
			else if ( currentFolderHasFeeDownload( intCurrentFileIndex ) )
			{
    			$( '.gallery2__buy_button' ).hide();
    			$( '.gallery2__save_button' ).hide();
                if ( bolIsOwner )
                {
                    $( '#gallery2__buyfile span.text' ).html('Sell file');
                    $( '#gallery2__buyfile span.price' ).html('');
                    $( '#gallery2__buyfile' ).hide();
                    $( '#gallery2__buyall' ).hide();
                    
                    $( '.print_or_buy_popup__buyfile span.text' ).html('Sell file');
                    $( '.print_or_buy_popup__buyfile span.price' ).html('');
                    $( '.print_or_buy_popup__buyfile' ).hide();
                }
                else 
                {
                    $( '#gallery2__buyall' ).show();
                    $( '#gallery2__buyall span.price' ).html('0' + ' $');
                
                    $( '#gallery2__buyfile' ).hide();
                  
                    $( '.print_or_buy_popup__buyfile' ).hide();
                }
			}
			else 
    		{
    			$( '.gallery2__buy_button' ).hide();
    			$( '.gallery2__save_button' ).show();
    
                if ( typeof bolHideDownloadButtons != 'undefined' && bolHideDownloadButtons )
                {
                    $( '.gallery2__save_button' ).hide();
                }
    
                if ( bolIsOwner )
                {
                    $( '#gallery2__buyfile span.text' ).html('Sell file');
                    $( '#gallery2__buyfile span.price' ).html('');
                    $( '#gallery2__buyfile' ).hide();
                    $( '#gallery2__buyall' ).hide();
                    $( '.print_or_buy_popup__buyfile span.text' ).html('Sell file');
                    $( '.print_or_buy_popup__buyfile span.price' ).html('');
                    $( '.print_or_buy_popup__buyfile' ).hide();
                }
                else 
                {
                    $( '#gallery2__buyfile' ).hide();
                    $( '#gallery2__buyall' ).hide();
                    $( '.print_or_buy_popup__buyfile' ).hide();

                    if (    !(arrFeeDownloadPrice[ intCurrentFileIndex ]==null && 
                            ! currentFolderHasFeeDownload( intCurrentFileIndex ) &&
                            arrAllowDownload[ intCurrentFileIndex ] && 
                            ( typeof(bolHideDownloadButtons) === 'undefined' || ! bolHideDownloadButtons ) && 
                            ( typeof(arrHideDownloadButtons) === 'undefined' || ! arrHideDownloadButtons[ intCurrentFileIndex ] )))
                    {
                        $( '#gallery2__item_info_save' ).hide();
                        $( '.gallery2__save_button' ).hide();
                    }
                }
    		}
    		
				
		if (
				(arrExtensions[intCurrentFileIndex] == 'png' || arrExtensions[intCurrentFileIndex] == 'jpg' || arrExtensions[intCurrentFileIndex] == 'jpge')
				&& arrFeeDownloadPrice[intCurrentFileIndex] == null
				&& ! currentFolderHasFeeDownload( intCurrentFileIndex )
				&& bolSimpleDownloadAllowed
			)
		{
			$('#gallery2__item_info_order').show();
			$('#gallery2__order').css({display: 'flex'});

                        
                        if ( arrFileHasProductSelling[ intCurrentFileIndex ] == 1 )
            {
                $('#gallery2__order').hide();
                $('#gallery2__item_info_order').hide();
            }
            		}
		else
		{
			$('#gallery2__item_info_order').hide();
			$('#gallery2__order').hide();
		}

		if (intCurrentFileIndex == 0)
		{
			$('#gallery2__controls_left').hide();
		}
		else 
		{
			$('#gallery2__controls_left').show();
		}

		if (intCurrentFileIndex == arrIDs.length - 1)
		{
			$('#gallery2__controls_right').hide();
		}
		else 
		{
			$('#gallery2__controls_right').show();
		}

        if( arrFileTypes[intCurrentFileIndex] == 'audio' && $(window).width() <= 600 )
        {
            $('#gallery2__controls_left').hide();
            $('#gallery2__controls_right').hide();
        }

		
                bolHideShareButtons = false;
        $( '#gallery2__share' ).show();
        $( '#item_info_share' ).show();
        $( '#gallery2__sidebar__info_embed_button, #gallery2__sidebar__info_embed_button_middle' ).css( 'display', 'flex' );

        var strAccessType = '';

        if (typeof strAccessType != 'undefined')
        {
            strAccessType = arrAccessType[ intCurrentFileIndex ];
        }
        else 
        {
            strAccessType = 'LINK';
        }

        if(strAccessType != '') 
        {
            if (bolIsOwner)
            {
                $( '#gallery_upload-access-switch' ).show();
                $( '#gallery2_item_info_share-wrapper' ).show();
                var intItemIndex = getItemIndex( strCurrentFileHash );
                var strFileAccessType = ( typeof arrFileAccessTypes != 'undefined' ? arrFileAccessTypes[ intItemIndex ] : '' )
                var strUploadAccessType = ( typeof arrAccessType != 'undefined' ? arrAccessType[ intItemIndex ] : '' )
                
                if ( strFileAccessType == '' || strFileAccessType == null )
                {
                    strFileAccessType = strUploadAccessType;
                }
                
                if ( strFileAccessType == 'PRIVATE' && strUploadAccessType == 'LINK' )
                {
                    strFileAccessType = 'LINK';
                }

                var objGalleryUploadAccessSwitch = new UploadAccessSwitch(
                    $( '#gallery_upload-access-switch' ) ,
                    {
                        item_type : 'file' ,
                        file_hash : strCurrentFileHash ,
                        owner_logged_in : bolIsOwner ,
                        access_type : strFileAccessType ,
                        parent_access_type : strUploadAccessType,
                        upload_access_switch_type : 'modal_gallery'
                    }
                );
            }
            else 
            {
                $( '#gallery_upload-access-switch' ).hide();
                $( '#gallery2_item_info_share-wrapper' ).hide();
            }
        }
        else 
        {
            $( '#gallery_upload-access-switch' ).hide();
            $( '#gallery2_item_info_share-wrapper' ).hide();
        }

        
        $( document ).on( 'change', '#gallery2_file_info .upload-access-switch_type-select', function()
        {
            var strAccessSwitchType = $( this ).val();

            
            if ( strAccessSwitchType == 'link-can-view' )
            {
                updateSharePopupLink( 1 );
            }
            else if ( strAccessSwitchType == 'link-can-edit' )
            {
                updateSharePopupLink( 2 );
            }
            else if ( strAccessSwitchType == 'link-can-upload' )
            {
                updateSharePopupLink( 3 );
            }
        } );

        function updateSharePopupLink(intSelected)
        {
            
            var objFileShareParams = galleryGetFileShareParams();

            if ( intSelected == 2 && objFileShareParams[ 'one_file' ][ 'edit_url' ] != '' )
            {
                $( '#gallery_share_popup_url' ).val( objFileShareParams[ 'one_file' ][ 'edit_url' ] );
                $( '#gallery_share_popup_url' ).attr( 'data-clipboard-text', objFileShareParams[ 'one_file' ][ 'edit_url' ] );
            }
            else if( intSelected == 3 && objFileShareParams[ 'one_file' ][ 'upload_url' ] )
            {
                $( '#gallery_share_popup_url' ).val( objFileShareParams[ 'one_file' ][ 'upload_url' ] );
                $( '#gallery_share_popup_url' ).attr( 'data-clipboard-text', objFileShareParams[ 'one_file' ][ 'upload_url' ] );
            }
            else
            {
                $( '#gallery_share_popup_url' ).val( objFileShareParams[ 'one_file' ][ 'view_url' ] );
                $( '#gallery_share_popup_url' ).attr( 'data-clipboard-text', objFileShareParams[ 'one_file' ][ 'view_url' ] );
            }
        }

        
        checkThumbStripArrows();

        galleryUpdateVoteCount();

                    //add checkboxes to thumb strip and update middle menu
            galleryUpdateFileSelection();
        
        galleryLoadFileInfo();
        $( '#gallery2__comments-list__loadmore' ).remove();
        galleryLoadFileComments();

        setTimeout('gallerySelectThumb('+ intCurrentFileIndex +')', 100);
                 
        var bolLogViews = 0;

        // bolOwnerIsStorageSubscriber - comes from public.php, this overrides bolLogViews
        if( typeof bolOwnerIsStorageSubscriber !== 'undefined' ) {
            bolLogViews |= bolOwnerIsStorageSubscriber;
        }
        
        var bolLogFileView = true;

        if ( bolLogFileView )
            $.post('./fileView.php', {'h': strCurrentFileHash, 'p': bolLogViews});

		// Google Analytics
        if ( typeof _gaq != 'undefined' )
        {
            _gaq.push( [ '_trackPageview', window.location.href ] );
        }
    
        var jqGalleryContainer = $('#gallery2');
        
        if ( bolSimpleDownloadAllowed )
        {
            jqGalleryContainer.addClass( 'simple_download_allowed' );
        }
        else
        {
            jqGalleryContainer.removeClass( 'simple_download_allowed' );
        }
        
		bolGalleryIsShowingItem = false;
        if( bolStartAudioOnOpen )
        {
            $( "#audio_" + strCurrentFileHash ).trigger( 'play' );
            bolStartAudioOnOpen = false;
        }


        // Build main download button
        var intItemIndex = getItemIndexByHashOrName( strCurrentFileHash );
        var bolSimpleDownloadAllowed = canDownload( strCurrentFileHash );
        
        $( '#gallery-main-download-button' ).remove();
        
        if ( bolSimpleDownloadAllowed ) {

            var objDownloadButton = new DropdownButton ();

            if ( bolSimpleDownloadAllowed ) {
                objDownloadButton.addButton('gallery-download-simple-split-button', 'Download original file', 'Download original', '<img src="/images/UI_icons/white/download.svg" /> ', function (){
                    gaev('split-download-button-engagement', 'header-download-simple-click', 'Split button simple download click');
                    modalGalleryDownloadFileBtn( strCurrentFileHash )
                })
            }
            
            if ( isFileConvertable( 'pdf', intItemIndex ) )
            {
                objDownloadButton.addButton(
                    'gallery-download-simple-split-button' ,
                    'Download this file as PDF' ,
                    'Download as PDF' ,
                    '<img src="/images/UI_icons/white/download.svg" /> ' ,
                    function ()
                    {
                    	gaev( 'split-download-button-engagement', 'header-download-pdf-click', 'Split button pdf download click' );
	                    modalGalleryDownloadFileBtn( strCurrentFileHash, 'pdf' )
                } );
            }
            else if ( isFileConvertable( 'mp4', intItemIndex ) )
            {
                objDownloadButton.addButton(
                    'gallery-download-simple-split-button' ,
                    'Download as MP4' ,
                    'Download as MP4' ,
                    '<img src="/images/UI_icons/white/download.svg" /> ' ,
                    function ()
                    {
                    	gaev( 'split-download-button-engagement', 'header-download-mp4-click', 'Split button mp4 download click' );
	                    modalGalleryDownloadFileBtn( strCurrentFileHash, 'mp4' )
                } );
            }
            else if ( isFileConvertable( 'jpg', intItemIndex ) )
            {
                objDownloadButton.addButton(
                    'gallery-download-simple-split-button' ,
                    'Download smaller JPG' ,
                    'Download smaller JPG' ,
                    '<img src="/images/UI_icons/white/download.svg" /> ' ,
                    function ()
                    {
                    	gaev( 'split-download-button-engagement', 'header-download-jpg-click', 'Split button jpg download click' );
	                    modalGalleryDownloadFileBtn( strCurrentFileHash, 'jpg' )
                } );
            }
            else if ( arrFileTypes[ intItemIndex ] == 'video' && arrExtensions[ intItemIndex ] == 'mp4' && typeof arrBigThumbPath != 'undefined' && arrBigThumbPath[ intItemIndex ] == 1 )
            {
                objDownloadButton.addButton(
                    'gallery-download-simple-split-button' ,
                    'Download optimized MP4' ,
                    'Download optimized MP4' ,
                    '<img src="/images/UI_icons/white/download.svg" /> ' ,
                    function ()
                    {
                    	gaev( 'split-download-button-engagement', 'header-download-mp4-click', 'Split button mp4 download click' );
	                    modalGalleryDownloadFileBtn( strCurrentFileHash, 'mp4' )
                } );
            }

                            if ( bolSimpleDownloadAllowed && typeof(listDownloadSelectedFiles) === 'function' && ! bolIsiOSDevice )
                {
                    objDownloadButton.addButton('gallery-download-simple-split-button gallery-download-simple-select-button', 'Download all selected', 'Download all selected', '<img src="/images/UI_icons/white/download.svg" /> ', function (){
                        gaev('split-download-button-engagement', 'header-download-selected-click', 'Split button selected download click');
                        listDownloadSelectedFiles()
                    })
                }
            
            if ( bolSimpleDownloadAllowed && ! bolIsOwner && typeof objUploadCopyForm != 'undefined' && typeof strUploadHash != 'undefined' ) {
                objDownloadButton.addButton(
                    'gallery-download-myfiles-split-button', 
                    'Save to my account', 
                    'Save to my account', 
                    null, 
                    function (){
                    gaev('split-download-button-engagement', 'header-download-myfiles-click', 'Split button myfiles download click');
                    modalGalleryDownloadFileBtn( strCurrentFileHash, 'my-files' );
                    },
                    'Recommended!'
                )
            }
            
            var jqDownloadButton = objDownloadButton.build( 'gallery-download-split-button', 'gallery-main-download-button', 'Download' );

            $( '#gallery2__header__mid_content #gallery2__download_space' ).before( jqDownloadButton );

                            objSelectedFiles = getSelectedFiles();
                if ( typeof objSelectedFiles && objSelectedFiles.length != 0 )
                {
                    $( '.gallery-download-simple-select-button' ).show();
                }
                        
        }


        if ( ! objMainShareParams )
        {
            $('#gallery2__share').hide();
            $('#gallery2_item_info_share-wrapper').hide();
            $('#gallery2__sidebar__info_embed_button, #gallery2__sidebar__info_embed_button_middle').hide();
        }

        $( '#gallery2_info_head .thumbnail-wrapper' ).html( '' );
        $( '#gallery2_info_head .thumbnail-wrapper' ).removeClass("two-actions");
        $( '#gallery2_info_head .thumbnail-wrapper' ).removeClass("one-action");
        var strThumbnailActions = '';
        if( bolIsOwner && arrFileTypes[intCurrentFileIndex] != 'image' )
		{
            if ( arrThumbnails[intItemIndex] )
            {
                var strThumbPath = arrThumbnails[intItemIndex];
                
                strThumbHTML = '<img src="'+strThumbPath+'"/>';

            }
            else if ( typeof( arrIconSvg ) !== 'undefined' && arrIconSvg[intItemIndex] )
            {
                strThumbHTML = '<img src="/images/file_types_v2/'+arrIconSvg[ intItemIndex ]+'" />';
            }
            else
            {
                strThumbHTML = '<img src="/images/file_types_v2/default.svg" />';
            }

            $( '#gallery2_info_head .thumbnail-wrapper' ).html( '' );
            $( '#gallery2_info_head .thumbnail-wrapper' ).append(strThumbHTML);
            $( '#gallery2_info_head .thumbnail-wrapper' ).append('<div class="thumbnail-actions"></div>');

			
    		if ( arrFileAttributes[ intItemIndex ][ 'hasCustomThumb' ] )
    		{
                strThumbnailActions = 
                    '<a href="javascript:void(0)" onclick="modalGallery_changeFileThumbnail( \'' +  arrHashes[ intItemIndex ] + '\', ' + intItemIndex + ' )">' +
                        '<div class="thumbnail-actions-edit" title="Change file image"></div>' +
                    '</a>' +
                    '<a href="javascript:void(0)" onclick="modalGallery_removeFileThumbnail( \'' +  arrHashes[ intItemIndex ] + '\', ' + intItemIndex + ' )">' +
                        '<div class="thumbnail-actions-delete" title="Delete file image"></div>' +
                    '</a>';
                    
                $( '#gallery2_info_head .thumbnail-actions' ).append(strThumbnailActions);
                $( '#gallery2_info_head .thumbnail-wrapper' ).addClass("two-actions");

    		}
    		else
    		{
                strThumbnailActions = 
                    '<a href="javascript:void(0)" onclick="modalGallery_changeFileThumbnail( \'' +  arrHashes[ intItemIndex ] + '\', ' + intItemIndex + ' )">' +
                        '<div class="thumbnail-actions-edit" title="Set file preview image"></div>' +
                    '</a>';
                    
                $( '#gallery2_info_head .thumbnail-actions' ).append(strThumbnailActions);
                $( '#gallery2_info_head .thumbnail-wrapper' ).addClass("one-action");
    		}
		}
        else 
        {
            if ( typeof( arrIconSvg ) !== 'undefined' && arrIconSvg[intItemIndex] )
            {
                strThumbHTML = '<img src="/images/file_types_v2/'+arrIconSvg[ intItemIndex ]+'" />';
            }
            else
            {
                strThumbHTML = '<img src="/images/file_types_v2/default.svg" />';
            }

            $( '#gallery2_info_head .thumbnail-wrapper' ).html( '' );
            $( '#gallery2_info_head .thumbnail-wrapper' ).append(strThumbHTML);

        }

        var strName = arrDisplayNames[intItemIndex];
		if (strName == '')
		{
			strName = arrNames[intItemIndex];
		}
        
        $( ".gallery2__header__file_name_value" ).html( strName );

        if( bolIsOwner )
        {
            $(".not_owner_show").hide();
            $(".not_owner_hide").show();
        }
        else
        {
            $(".not_owner_show").show();
            $(".not_owner_hide").hide();
        }

                    if(bolActivateSlideshowOnOpen && arrHashes.length > 1)
            {
                enterSlideshow();
                bolActivateSlideshowOnOpen = false;
            }

            if(typeof(strSlideshowInterval) !== 'undefined' && strSlideshowInterval !== null)
            {
                if(arrFileTypes[intCurrentFileIndex] == 'video' && typeof(objVideoPlayers[intCurrentFileIndex]) !== 'undefined' )
                {
                    clearInterval(strSlideshowInterval);
                    strSlideshowInterval = 'reset';
                    objVideoPlayers[intCurrentFileIndex].objPlayer.loop(false);
                    objVideoPlayers[intCurrentFileIndex].objPlayer.play();
                }
                else if (arrFileTypes[intCurrentFileIndex] == 'audio' && typeof(objAudioPlayer) !== 'undefined')
                {
                    clearInterval(strSlideshowInterval);
                    strSlideshowInterval = 'reset';
                    objAudioPlayer._isSlideshowOn = true;
                    objAudioPlayer.play();
                }
            }
                
        if ( bolOpenGalleryCommentsBlock )
        {
            setTimeout( function()
            {
                if ( ! bolGallerySidebarVisible )
                {
                    showGalleryInfo();
                }
                
                showGalleryMessages();
                
                $( window ).trigger( 'resize' );
            }, 300 );
        }

        // check mobile footer visible elements and hide info button if overflow
        var visibleElemCount = 0;
        var visibleBtns = $( '#gallery2__header__mid_content span.gallery2__header_middle_button:visible' );
        visibleElemCount = visibleBtns.length;

        var bolSimpleDownloadAllowed = canDownload( strCurrentFileHash );

        if ( bolSimpleDownloadAllowed )
        {
            visibleElemCount += 1;
        }

        if ( visibleElemCount > 4 )
        {
            $( '#gallery2__info_middle' ).addClass( 'mobile-hide' );
            $(' #gallery2__info_more' ).addClass( 'mobile-show' );
        }
	}
	window.showGalleryItem = showGalleryItem;
	
	function stopActiveContent()
	{
		// Stop video
		var jqAllVideos = $("video");
		if (jqAllVideos.length>0)
		{
			jqAllVideos.each(function () {
				this.pause();
			});
		}
		// Stop audio
		var jqAllAudios = $("audio");
		if (jqAllAudios.length>0)
		{
			jqAllAudios.each(function () {
				this.pause();
			});
		}
	}
	
    function GalleryDeleteFile(strFileH, strFileName)
    {
        fConfirm( 'Do you really want to delete this file?</br><b>"' + strFileName + '"</b>', 'Delete', 'Yes, delete!', 'Cancel', function(r){
            if( r == true )
            {                
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: "./ajax/delete_file.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
                    data: {
                        'delete_user_file' : true ,
                        'f'             : strFileH ,
                        'source'		: 'filebrowser'
                    },
                    success: function( data ){
                        if( data['status'] == 'ok' )
                        {
                            if(bolGalleryIsVisible && intNextIndex != null && !isNaN( intNextIndex ))
                            {
                                galleryOpenNextItem();
                            }
                            else if (intPreviousIndex != null && !isNaN( intPreviousIndex ))
                            {
                                galleryOpenPrevItem();
                            }
                            fSuccess( "File \""+ strFileName +"\" has been <b>deleted</b>!", "" );
                            location.reload();
                        }
                        else
                        {
                            if( typeof data[ 'file_read_only' ] !== 'undefined' && data[ 'file_read_only' ] ) 
                            {
                                fError( "The file cannot be deleted because it is shared!", "Info" );
                            }
                            else if ( typeof data[ 'file_is_locked' ] !== 'undefined' && data[ 'file_is_locked' ] ) 
                            {
                                fError( "This file cannot be deleted because it is locked.", "Info" );
                            }
                            else
                            {
                                fError( "There was an error, the file was not deleted", "Info" );
                            }
                        }
                    }
                });
            }
        });
        return false;
    }

    function GalleryDeleteFileAnon(strKey, strFileH, strFileName)
    {
        fConfirm( 'Do you really want to delete this file?</br><b>"' + strFileName + '"</b>', 'Delete', 'Yes, delete!', 'Cancel', function(r){
			if( r == true )
			{
				$.ajax({
					type: "POST",
					dataType: "json",
					url: "./ajax/delete_file.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
					data: {
						'delete_file': true,
						'fk'			 : strKey,
						'f'			 : strFileH ,
						'source'	 : 'list'
					},
					success: function( data ){
                        if( data['status'] == 'ok' )
                        {
                            if(bolGalleryIsVisible && intNextIndex != null && !isNaN( intNextIndex ))
                            {
                                galleryOpenNextItem();
                            }
                            else if (intPreviousIndex != null && !isNaN( intPreviousIndex ))
                            {
                                galleryOpenPrevItem();
                            }
                            fSuccess( "File \""+ strFileName +"\" has been <b>deleted</b>!", "" );
                            location.reload();
                        }
						else
						{
						    if( typeof data[ 'file_read_only' ] !== 'undefined' && data[ 'file_read_only' ] ) 
                            {
                                fError( "The file cannot be deleted because it is shared!", "Info" );
                            }
						    else if ( typeof data[ 'file_is_locked' ] !== 'undefined' && data[ 'file_is_locked' ] ) 
                            {
                                fError( "This file cannot be deleted because it is locked.", "Info" );
                            }
                            else
                            {
                                fError( "There was an error, the file was not deleted", "Info" );
                            }
						}
					}
				});
			}
		});
		return false;
    }

    function checkGalleryArrows()
    {
        if( $( window ).width() < 550 )
        {
            if( arrFileTypes[intCurrentFileIndex] == 'audio' || arrFileTypes[intCurrentFileIndex] == 'video' || arrFileTypes[intCurrentFileIndex] == 'document' )
            {
                $( '#gallery2__controls_left, #gallery2__controls_right' ).show();
                $( '#gallery2__controls_left a, #gallery2__controls_right a' ).css({
                    'top': 'initial',
                    'bottom': '0px'
                });
            }
            else
            {
                $( '#gallery2__controls_left, #gallery2__controls_right' ).hide();
            }
        }
        else
        {
            $( '#gallery2__controls_left a, #gallery2__controls_right a' ).removeAttr( 'style' );
            $( '#gallery2__controls_left, #gallery2__controls_right' ).show();
        }
    }
	
	function galleryLoadFileInfo(bolUpdateInfo)
	{
        if ( typeof(bolUpdateInfo) === 'undefined' && $(window).width() > 500 && ! bolGallerySidebarVisible )
        {
            return;	
        }

		var intItemIndex = getItemIndex ( strCurrentFileHash );

        
        if ( bolUseAsyncFileInfoDataLoad )
        {
            if ( ! arrIsFileInfoDataPreloaded[ intItemIndex ] )
            {
                $( '#gallery2__sidebar__info' ).hide();
                setTimeout( function() { galleryLoadFileInfo( bolUpdateInfo ) }, 1000 );
                return;
            }
            else
            {
                $( '#gallery2__sidebar__info' ).show();
            }
        }
        

        var strPublicProfileHref = '';
        if ( typeof strUploadUserNameHref != 'undefined' && strUploadUserNameHref != '' )
        {
            strPublicProfileHref =  '/' + strUploadUserNameHref;
        }
        else if ( typeof PublicProfile != 'undefined' && typeof PublicProfile.strProfileName != 'undefined' )
        {
            strPublicProfileHref = '/' + PublicProfile.strProfileName;
        }


        if ( typeof strUploadUserNameLink != 'undefined' )
		{
            $( '#gallery2__sidebar__info-owner-user .gallery2__sidebar__info-value' ).html( strUploadUserNameLink );
			$( '#gallery2__sidebar__info .header-owner_name' ).html( strUploadUserNameLink );
            if( typeof strUploadUserID != 'undefined' && strUploadUserID != '' && typeof strUploadUserLastProfileEditTimestamp != 'undefined')
            {
                $( '#gallery2__sidebar__info .header-owner .header-owner_image-wrapper' ).html( '<a class="header-owner_image" style="background-image: url( \'/avatars/thumb.php?i='+ strUploadUserID +'_'+ strUploadUserLastProfileEditTimestamp +'.jpg\' );"></a>' );
            }
            else 
            {
                $( '#gallery2__sidebar__info .header-owner .header-owner_image-wrapper' ).html( '<div class="header-owner_image"><img src="/images/list/unknown-owner.svg"></div>' );
            }
		}
		else if ( typeof PublicProfile != 'undefined' && typeof PublicProfile.strProfileName != 'undefined' )
		{
			$( '#gallery2__sidebar__info-owner-user .gallery2__sidebar__info-value' ).html( '<a href="/' + PublicProfile.strProfileName + '" target="_blank">' + PublicProfile.strProfileName + '</a>' );
			$( '#gallery2__sidebar__info .header-owner_name' ).html( '<a href="/' + PublicProfile.strProfileName + '" target="_blank">' + PublicProfile.strProfileName + '</a>' );
            if( typeof strUploadUserID  != 'undefined' && strUploadUserID != '' && typeof strUploadUserLastProfileEditTimestamp != 'undefined')
            {
                $( '#gallery2__sidebar__info .header-owner .header-owner_image-wrapper' ).html( '<a class="header-owner_image" style="background-image: url( \'/avatars/thumb.php?i='+ strUploadUserID +'_'+ strUploadUserLastProfileEditTimestamp +'.jpg\' );"></a>' );
            }
            else if( typeof PublicProfile.strAvatarPath  != 'undefined' && PublicProfile.strAvatarPath != '')
            {
                $( '#gallery2__sidebar__info .header-owner .header-owner_image-wrapper' ).html( '<a class="header-owner_image" style="background-image: url( \''+PublicProfile.strAvatarPath+'\' );"></a>' );
            }
            else
            {
                $( '#gallery2__sidebar__info .header-owner .header-owner_image-wrapper' ).html( '<div class="header-owner_image"><img src="/images/list/unknown-owner.svg"></div>' );
            }
		}
		else 
		{
			$( '#gallery2__sidebar__info-owner-user' ).hide();
			$( '#gallery2__sidebar__info .header-owner' ).hide();
		}

		$('#gallery2__sidebar__info-size .gallery2__sidebar__info-value').html(arrSizes[intItemIndex]);


        if ( typeof arrDatesCreated != 'undefined' )
        {
            $( '#gallery2__sidebar__info-date .gallery2__sidebar__info-value' ).html( arrDatesCreated[ intItemIndex ] );
        }
        else
        {
            $( '#gallery2__sidebar__info-date .gallery2__sidebar__info-value' ).html( arrDates[ intItemIndex ] );
        }

        if ( typeof arrFileDateCreated != 'undefined' && arrFileDateCreated[ intItemIndex ] != '' )
        {
            $( '#gallery2__sidebar__info-date-created .gallery2__sidebar__info-value' ).html( arrFileDateCreated[ intItemIndex ] );
        }
        else if ( typeof arrDatesCreated != 'undefined' )
        {
            $( '#gallery2__sidebar__info-date-created .gallery2__sidebar__info-value' ).html( arrDatesCreated[ intItemIndex ] );
        }
        else
        {
            $( '#gallery2__sidebar__info-date-created .gallery2__sidebar__info-value' ).html( arrDates[ intItemIndex ] );
        }

        if ( typeof arrDatesModified != 'undefined' )
        {
            $( '#gallery2__sidebar__info-moddate .gallery2__sidebar__info-value' ).html( arrDatesModified[ intItemIndex ] );
        }
        else
        {
            $( '#gallery2__sidebar__info-moddate .gallery2__sidebar__info-value' ).html( arrDates[ intItemIndex ] );
        }


		$('#gallery2__sidebar__info-views .gallery2__sidebar__info-value').html(arrViews[intItemIndex]);
		$('#gallery2__sidebar__info-downloads .gallery2__sidebar__info-value').html(arrDownloads[intItemIndex]);
		$('#gallery2__sidebar__info-comments .gallery2__sidebar__info-value').html(arrCommentCounts[intItemIndex]);

        $( '#gallery2__sidebar__info-dimensions' ).hide();
        if ( typeof arrWidths != 'undefined' && typeof arrHeights != 'undefined' && typeof arrWidths[intItemIndex] != 'undefined' && typeof arrHeights[intItemIndex] != 'undefined' && arrWidths[intItemIndex] != '' && arrHeights[intItemIndex] != '' && arrWidths[intItemIndex] != 'undefined' && arrHeights[intItemIndex] != 'undefined' )
        {
            if(arrFileTypes[ intItemIndex ] == 'video')
            {
                var strResolutionLabel = getResolutionLabel( arrWidths[ intItemIndex ], arrHeights[ intItemIndex ] );

                $('#gallery2__sidebar__info-dimensions .gallery2__sidebar__info-value').html(strResolutionLabel + arrWidths[intItemIndex] + ' x ' + arrHeights[intItemIndex] + ', ' + Math.round((arrWidths[intItemIndex]*arrHeights[intItemIndex]/1000000) * 100) / 100+ 'MP');
            }
            else
            {
                $('#gallery2__sidebar__info-dimensions .gallery2__sidebar__info-value').html(arrWidths[intItemIndex] + ' x ' + arrHeights[intItemIndex] + ', ' + Math.round((arrWidths[intItemIndex]*arrHeights[intItemIndex]/1000000) * 100) / 100+ 'MP');
            }
            $( '#gallery2__sidebar__info-dimensions' ).show();
        }
		
		$( '#gallery2_file_details_table_ai' ).hide();
        $( '#gallery2_file_details_table_label' ).css('margin-top', '');
		$( '.gallery2__sidebar__info-metadata' ).hide();
        $( '.gallery2__sidebar__info-exif_tags' ).remove();
        $( '.gallery2__sidebar__info-one_line_buttons .disabled' )
            .removeClass( 'disabled' );
        $( '#gallery2__sidebar__info-metadata-tags' ).addClass( 'gallery2__sidebar__exif_tags-top-separator' );

        $( '.gallery2__sidebar__info-dropdown_button.easyocr-text_recognition' )
            .html(
                '<span class="gallery2__sidebar__info-dropdown_text">' +
                    'Find Text' +
                '</span>' +
                '<span class="gallery2__sidebar__info-dropdown_icon"></span>'
            );
            
        $( '.gallery2__sidebar__info-dropdown_button.google_cloud_vision-ocr' )
            .html(
                '<span class="gallery2__sidebar__info-dropdown_text">' +
                    'Find text PRO' +
                '</span>' +
                '<span class="gallery2__sidebar__info-dropdown_icon"></span>'
            );

        $( '.gallery2__sidebar__info-dropdown_button.yolo-object_detection' )
            .html(
                '<span class="gallery2__sidebar__info-dropdown_text">' +
                    'Find objects' +
                '</span>' +
                '<span class="gallery2__sidebar__info-dropdown_icon"></span>'
            );

        $('#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value .exif-grid div span').html('');
        $('#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value .exif-grid div').hide();
        $('#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value').hide();
		if ( typeof arrFileTitle != 'undefined' )
		{
    		$( '#gallery2__sidebar__info-metadata-title .gallery2__sidebar__info-value' ).html( arrFileTitle[ intItemIndex ] );
    		if ( arrFileTitle[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-title' ).show();
		}
		
		if ( typeof arrFileSubject != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-subject .gallery2__sidebar__info-value' ).html( arrFileSubject[ intItemIndex ] );
            if ( arrFileSubject[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-subject' ).show();
		}
		
		if ( typeof arrFileContentType != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-content_type .gallery2__sidebar__info-value' ).html( arrFileContentType[ intItemIndex ] );
            if ( arrFileContentType[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-content_type' ).show();
		}
		
		if ( typeof arrFileCategory != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-category .gallery2__sidebar__info-value' ).html('');

            if (strPublicProfileHref != '')
            {
                $( '#gallery2__sidebar__info-metadata-category .gallery2__sidebar__info-value' ).append('<a href="' + strPublicProfileHref + '#search='+  arrFileCategory[ intItemIndex ] +'" target="_self">' +  arrFileCategory[ intItemIndex ] + '</a>');
            }
            else
            {
                $( '#gallery2__sidebar__info-metadata-category .gallery2__sidebar__info-value' ).html( arrFileCategory[ intItemIndex ] );
            }
            
            if ( arrFileCategory[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-category' ).show();
		}
		
		if ( typeof arrFileCategories != 'undefined' )
		{           
            var arrCategories = arrFileCategories[ intItemIndex ].split(',')
            $( '#gallery2__sidebar__info-metadata-categories .gallery2__sidebar__info-value' ).html('');

            if (strPublicProfileHref != '')
            {
                arrCategories.forEach(function(elem, idx, array) {
                    if (idx != array.length - 1)
                    { 
                        $( '#gallery2__sidebar__info-metadata-categories .gallery2__sidebar__info-value' ).append('<a href="' + strPublicProfileHref + '#search='+ elem +'" target="_self">' + elem + ',</a> ');
                    }
                    else
                    {
                        $( '#gallery2__sidebar__info-metadata-categories .gallery2__sidebar__info-value' ).append('<a href="' + strPublicProfileHref + '#search='+ elem +'" target="_self">' + elem + '</a>');
                    }
                });
            }
            else
            {
                $( '#gallery2__sidebar__info-metadata-categories .gallery2__sidebar__info-value' ).html( arrFileCategories[ intItemIndex ] );
            }
            if ( arrFileCategories[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-categories' ).show();
		}
		
		if ( typeof arrFileKeywords != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-keywords .gallery2__sidebar__info-value' ).html( arrFileKeywords[ intItemIndex ] );
            if ( arrFileKeywords[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-keywords' ).show();
		}
		
		if ( typeof arrFileCreator != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-creator .gallery2__sidebar__info-value' ).html( arrFileCreator[ intItemIndex ] );
            if ( arrFileCreator[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-creator' ).show();
		}
		
		if ( typeof arrFilePublisher != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-publisher .gallery2__sidebar__info-value' ).html( arrFilePublisher[ intItemIndex ] );
            if ( arrFilePublisher[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-publisher' ).show();
		}
		
		if ( typeof arrFileContributor != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-contributor .gallery2__sidebar__info-value' ).html( arrFileContributor[ intItemIndex ] );
            if ( arrFileContributor[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-contributor' ).show();
		}
		
		if ( typeof arrFileCopyrights != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-copyrights .gallery2__sidebar__info-value' ).html( arrFileCopyrights[ intItemIndex ] );
            if ( arrFileCopyrights[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-copyrights' ).show();
		}
		
		if ( typeof arrFileLicenseType != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-license_type .gallery2__sidebar__info-value' ).html( arrFileLicenseType[ intItemIndex ] );
            if ( arrFileLicenseType[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-license_type' ).show();
		}
		
		if ( typeof arrFileLicenseDetails != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-license_details .gallery2__sidebar__info-value' ).html( arrFileLicenseDetails[ intItemIndex ] );
            if ( arrFileLicenseDetails[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-license_details' ).show();
		}
		
		if ( typeof arrFileLanguage != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-language .gallery2__sidebar__info-value' ).html( arrFileLanguage[ intItemIndex ] );
            if ( arrFileLanguage[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-language' ).show();
		}
		
		if ( typeof arrFileLocation != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-location .gallery2__sidebar__info-value' ).html( arrFileLocation[ intItemIndex ] );
            if ( arrFileLocation[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-location' ).show();
		}
		
        if ( typeof arrFileLocationLat !== 'undefined' && typeof arrFileLocationLong !== 'undefined' )
        {
            let strGpsLat = gpsDecimalToDMS( arrFileLocationLat[ intItemIndex ], true );
            let strGpsLong = gpsDecimalToDMS( arrFileLocationLong[ intItemIndex ], false );

            $( '#gallery2__sidebar__info-metadata-location_lat .gallery2__sidebar__info-value' )
                .html( '<a href="https://www.google.com/maps/place/' + encodeURIComponent( strGpsLat.replace( /\s/g, '' ) ) + '+' + encodeURIComponent( strGpsLong.replace( /\s/g, '' ) ) + '" target="_blank">' + strGpsLat + '</a>' );
            $( '#gallery2__sidebar__info-metadata-location_long .gallery2__sidebar__info-value' )
                .html( '<a href="https://www.google.com/maps/place/' + encodeURIComponent( strGpsLat.replace( /\s/g, '' ) ) + '+' + encodeURIComponent( strGpsLong.replace( /\s/g, '' ) ) + '" target="_blank">' + strGpsLong + '</a>' );

            if ( strGpsLat !== '' && strGpsLong !== '' )
            {
                $( '#gallery2__sidebar__info-metadata-location_lat' ).show();
                $( '#gallery2__sidebar__info-metadata-location_long' ).show();
            }
        }
		
		if ( typeof arrFileReferences != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-references .gallery2__sidebar__info-value' ).html( arrFileReferences[ intItemIndex ] );
            if ( arrFileReferences[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-references' ).show();
		}
		
		if ( typeof arrFileRelatesTo != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-relates_to .gallery2__sidebar__info-value' ).html( arrFileRelatesTo[ intItemIndex ] );
            if ( arrFileRelatesTo[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-relates_to' ).show();
		}
		
		if ( typeof arrFileFormat != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-format .gallery2__sidebar__info-value' ).html( arrFileFormat[ intItemIndex ] );
            if ( arrFileFormat[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-format' ).show();
		}
		
		if ( typeof arrFileDevice != 'undefined' )
		{
            $( '#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value .exif-grid .Model span' ).html( arrFileDevice[ intItemIndex ] );
            $( '#gallery2__sidebar__info-metadata-device .gallery2__sidebar__info-value' ).html( arrFileDevice[ intItemIndex ] );
            if ( arrFileDevice[ intItemIndex ] != '' )
            {
                $( '#gallery2__sidebar__info-metadata-device' ).show();
                $( '#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value .exif-grid .Model' ).show();
            }
		}
		
		if ( typeof arrFileSource != 'undefined' )
		{
            $( '#gallery2__sidebar__info-metadata-source .gallery2__sidebar__info-value' ).html( arrFileSource[ intItemIndex ] );
            if ( arrFileSource[ intItemIndex ] != '' ) $( '#gallery2__sidebar__info-metadata-source' ).show();
		}

        if ( typeof arrFileTypes != 'undefined' )
        {
            if ( arrFileTypes[ intItemIndex ] == 'image' )
            {
                $( '#gallery2__sidebar__info-exif_tags-button' ).show();

                if ( typeof arrExtensions != 'undefined' && [ 'jpg', 'jpeg', 'png' ].includes( arrExtensions[ intItemIndex ] ) )
                {
                    if (
                            bolIsOwner
                            || (
                                    typeof( bolIsAnonymousUpload ) == 'boolean'
                                    && bolIsAnonymousUpload
                                )
                        )
                    {
                        $( '#gallery2__sidebar__info-content_analyze-buttons' ).show();
                        $( '#gallery2_file_details_table_ai' ).show();
                        $( '#gallery2_file_details_table_label' ).css('margin-top', '25px');
                        
                        $( '#gallery2__sidebar__info-metadata-tags' ).removeClass( 'gallery2__sidebar__exif_tags-top-separator' );
                    }

                    if ( !bolIsOwner )
                    {
                        $( '.gallery2__sidebar__info-dropdown_button.easyocr-text_recognition' ).hide();
                        $( '.gallery2__sidebar__info-dropdown_button.yolo-object_detection' ).hide();
                    }

                }
            }
        }

		if ( typeof arrDuration != 'undefined' &&  typeof arrDuration[ intItemIndex ] != 'undefined' && arrDuration[ intItemIndex ] != '' )
		{
            var strDuration = arrDuration[ intItemIndex ];

            if( strDuration < 600 )
            {
                strDuration = new Date(strDuration * 1000).toISOString().slice(15, 19);
            }
            else if( strDuration < 3600 )
            {
                strDuration = new Date(strDuration * 1000).toISOString().slice(14, 19);
            }
            else
            {
                strDuration = new Date(strDuration * 1000).toISOString().slice(11, 19);
            }
            
            $( '#gallery2__sidebar__info-metadata-duration .gallery2__sidebar__info-value' ).html( strDuration );
            if ( arrDuration[ intItemIndex ] != ''&& arrDuration[ intItemIndex ] != '0' ) $( '#gallery2__sidebar__info-metadata-duration' ).show();
		}

        if ( typeof arrFileGoogleCVText != 'undefined' && typeof arrFileGoogleCVText[ intItemIndex ] != 'undefined' )
        {
            $( '#gallery2__sidebar__info-google_cv_text .gallery2__sidebar__info-value' ).text( arrFileGoogleCVText[ intItemIndex ] );
            if ( arrFileGoogleCVText[ intItemIndex ] != '' && bolIsOwner )
            {
                $( '#gallery2__sidebar__info-google_cv_text' ).show();
                $( '.gallery2__sidebar__info-dropdown_button.google_cloud_vision-ocr' )
                    .addClass( 'disabled' );
            }
        }

        if ( typeof arrFileEasyOCRText != 'undefined' && typeof arrFileEasyOCRText[ intItemIndex ] != 'undefined' )
        {
            $( '#gallery2__sidebar__info-easyocr_text .gallery2__sidebar__info-value' ).text( arrFileEasyOCRText[ intItemIndex ] );
            if ( arrFileEasyOCRText[ intItemIndex ] != '' && bolIsOwner )
            {
                $( '#gallery2__sidebar__info-easyocr_text' ).show();
                $( '.gallery2__sidebar__info-dropdown_button.easyocr-text_recognition' )
                    .addClass( 'disabled' );
            }
        }


        if ( bolIsOwner && arrFileTypes[ intCurrentFileIndex ] == 'audio' )
        {
            $( '#gallery2__sidebar__info-google_cloud-speech_to_text-button .gallery2__sidebar__info-dropdown_button' )
                .html(
                    '<span class="gallery2__sidebar__info-dropdown_text">' +
                        'Recognize speech' +
                    '</span>' +
                    '<span class="gallery2__sidebar__info-dropdown_icon"></span>'
                )
                .removeClass( 'disabled' );;
            

            $( '#gallery2__sidebar__info-google_cloud-speech_to_text-button' )
                .show();

                $( '#gallery2__sidebar__info-metadata-tags' ).removeClass( 'gallery2__sidebar__exif_tags-top-separator' );
                    
        }

        if ( bolIsOwner && typeof arrFileAudioTranscription != 'undefined' && typeof arrFileAudioTranscription[ intItemIndex ] != 'undefined' )
        {
            $( '#gallery2__sidebar__info-google_cloud-speech_to_text-text .gallery2__sidebar__info-value' ).text( arrFileAudioTranscription[ intItemIndex ] );
            if ( arrFileAudioTranscription[ intItemIndex ] != '' )
            {
                $( '#gallery2__sidebar__info-google_cloud-speech_to_text-text' ).show();
                $( '#gallery2__sidebar__info-google_cloud-speech_to_text-button .gallery2__sidebar__info-dropdown_button' )
                    .addClass( 'disabled' );
            }
        }


        if (
                arrFileTypes[ intCurrentFileIndex ] == 'image'
                && (
                        bolIsOwner
                        || (
                                typeof( bolIsAnonymousUpload ) == 'boolean'
                                && bolIsAnonymousUpload
                            )
                    )
            )
        {
            $( '.gallery2__sidebar__info-dropdown_button.google_cloud-vision' )
                .html(
                    '<span class="gallery2__sidebar__info-dropdown_text">' +
                        'Find objects PRO' +
                    '</span>' +
                    '<span class="gallery2__sidebar__info-dropdown_icon"></span>'
                )
                .removeClass( 'disabled' );
        }


        var jqObjectTagsElem = $( '#gallery2__sidebar__info-object_tags .tags' );
        jqObjectTagsElem.empty();
        if (
                typeof arrObjectTags != 'undefined'
                && typeof arrObjectTags[ intItemIndex ] != 'undefined'
                && arrObjectTags[ intItemIndex ] != ''
            )
        {
            let arrTagsSplitted = arrObjectTags[ intItemIndex ].split( ';' );

            $.each( arrTagsSplitted, ( i, tag ) => {
                jqObjectTagsElem.append( '<span class="tag">' + tag + '</span>' );
            } );

            $( '#gallery2__sidebar__info-object_tags' ).show();
            $( '.gallery2__sidebar__info-dropdown_button.google_cloud-vision' ).addClass( 'disabled' );
        }


        if (
                typeof arrYoloObjectTags != 'undefined'
                && typeof arrYoloObjectTags[ intItemIndex ] != 'undefined'
                && arrYoloObjectTags[ intItemIndex ] != ''
            )
        {
            let arrExistingTags = jqObjectTagsElem.find( '.tag' ).map( function() {
                return $( this ).text();
            } ).get();

            let arrTagsSplitted = arrYoloObjectTags[ intItemIndex ].split( ';' );

            let arrTagsToBeAdded = arrTagsSplitted.filter( tag => ! arrExistingTags.includes( tag ) );

            $.each( arrTagsToBeAdded, ( i, tag ) => {
                jqObjectTagsElem.append( '<span class="tag">' + tag + '</span>' );
            } );

            $( '#gallery2__sidebar__info-object_tags' ).show();
            $( '.gallery2__sidebar__info-dropdown_button.yolo-object_detection' ).addClass( 'disabled' );
        }


        if (
                typeof arrLabelTags != 'undefined'
                && typeof arrLabelTags[ intItemIndex ] != 'undefined'
                && arrLabelTags[ intItemIndex ] != ''
            )
        {
            let jqTagsElem = $( '#gallery2__sidebar__info-label_tags .tags' );

            jqTagsElem.empty();

            let arrTagsSplitted = arrLabelTags[ intItemIndex ].split( ';' );

            $.each( arrTagsSplitted, ( i, tag ) => {
                jqTagsElem.append( '<span class="tag">' + tag + '</span>' );
            } );

            $( '#gallery2__sidebar__info-label_tags' ).show();
            $( '.gallery2__sidebar__info-dropdown_button.google_cloud-vision' ).addClass( 'disabled' );
        }


        $('.gallery2_share-input').val('https://files.fm/f/' + strCurrentFileHash  );

		if ( typeof arrDatesDelete == 'undefined' || arrDatesDelete[intItemIndex] == '' )
		{
			$('#gallery2__sidebar__info-date-delete').hide();
		}
		else
		{
			$('#gallery2__sidebar__info-date-delete .gallery2__sidebar__info-value').html( ( typeof arrDatesDelete != 'undefined' ? arrDatesDelete[intItemIndex] : '' ) );
			$('#gallery2__sidebar__info-date-delete').show();
		}
		
		var strName = arrDisplayNames[intItemIndex];
		if (strName == '')
		{
			strName = arrNames[intItemIndex];
		}

		var $name = $('#gallery2__sidebar__info-name .gallery2__sidebar__info-value');
        
        $name.val( strName );
        
        if( bolIsOwner )
        {
            autoGrow( $name.get( 0 ), '32px' );
            
            $(".not_owner_show").hide();
            $(".not_owner_hide").show();
        }
        else
        {
            $(".not_owner_show").show();
            $(".not_owner_hide").hide();
            
            $( ".gallery2__sidebar__file_name_value" ).html( strName );
            $( ".gallery2__header__file_name_value" ).html( strName );
        }

                
        var $desc = $('#gallery2__sidebar__info-description .gallery2__sidebar__info-value');

        var strDescriptionForInput = arrDescriptions[ intItemIndex ].replaceAll('&#10;', String.fromCharCode(13, 10));
        var strDescriptionForHtml = arrDescriptions[ intItemIndex ].replaceAll('&#10;', '<br/>');
        
        $desc.val( strDescriptionForInput );
        var strDescription = strDescriptionForInput;
        
        if ( strDescription == '' || typeof strDescription == 'undefined' )
        {
            strDescription = '';
            $desc.html( strDescription );
        }
        else
        {
            $( ".gallery2__sidebar__file_description_value" ).html( strDescription );
        }
        
        if( bolIsOwner )
        {
            autoGrow( $desc.get( 0 ), '32px' );
            
            $(".not_owner_show").hide();
            $(".not_owner_hide").show();

            if ( strDescription == '' )
            {
            	$( "#file_description_edit_wrapper" ).addClass("no-description");
            }
            else
            {
            	$( "#file_description_edit_wrapper" ).removeClass("no-description");
            }
        }
        else
        {
            
            $("#file_description_edit_wrapper").click(function () {
                if( window.location.href.indexOf("filebrowser") === -1 )
                {
                    showSignIn();
                }
            });
            
            $( ".gallery2__sidebar__file_description_value" ).html( strDescriptionForHtml );

            if ( strDescription == '' )
            {
            	$( "#gallery2__sidebar__info-description" ).hide();
            	$( ".gallery2__sidebar__file_description_value, label[for='gallery2__sidebar__file_description_value']" ).hide();
            	$( ".gallery2__sidebar__file_description_value" ).css('padding-bottom', '');
            }
            else
            {
            	$( "#gallery2__sidebar__info-description" ).show();
            	$( ".gallery2__sidebar__file_description_value, label[for='gallery2__sidebar__file_description_value']" ).show();
            	$( ".gallery2__sidebar__file_description_value" ).css('padding-bottom', '5px');
            }

            $(".not_owner_show").show();
            $(".not_owner_hide").hide();
        }
        
        
		// regenerate tagsInput in filebrowser
		if(window.location.href.indexOf( "filebrowser" ) !== -1 )
        {
        	// user can browse folders without reloading filebrowser, recheck if user owns file has to be done for each file
            $('#gallery_file_tags_container .file_tags_input').html('');
            $('#gallery_file_tags_container .file_tags_input').removeAttr('data-tagsinput-init');
            $('#gallery_file_tags_container .file_tags_input').removeAttr('id');
            $('#gallery_file_tags_container .tagsinput').remove();

            $('#gallery_file_tags_container .file_tags_input').tagsInput(
            {
                'autocomplete_url': './ajax/file_tag.php?autocomplete&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a' ,
                'autocomplete': { selectFirst:false, autoFill:false},
                'height' : 'auto',
                'width' : '100%',
                'interactive' : bolIsOwner || ( window.location.href.indexOf( "filebrowser" ) !== -1 && 0 ),
                'defaultText' : 'Add tags',
                'onAddTag' : function(strTagName) 
                {
                    $('#gallery_file_tags_container .file_tags_error').hide();
                    
                    $.ajax({
                        type: "POST",
                        dataType: "json",
                        url: "./ajax/file_tag.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
                        data: 
                        {
                            'add_file_tag': true ,
                            'file_hash' : strCurrentFileHash ,
                            'tag_name': strTagName
                        } ,
                        success: function(data)
                        {
                            if (data['status'] == 'ok')
                            {
                                var intItemIndex = getItemIndex(strCurrentFileHash);
                                arrTags[intItemIndex] += ';' + strTagName;
                                // update tags in filebrowser
                                $('#sidebar_file_tags_container .file_tags_input').importTags(typeof arrTags[intItemIndex] === "undefined" ? "" : arrTags[intItemIndex]);
                            }
                            else
                            {
                                $('#gallery_file_tags_container .file_tags_error').show();
                            }
                        } ,
                        error: function()
                        {
                            $('#gallery_file_tags_container .file_tags_error').show();
                        }
                    });
                } ,
                'onRemoveTag' : function(strTagName)
                {
                    $('#gallery_file_tags_container .file_tags_error').hide();

                    $.ajax({
                        type: "POST",
                        dataType: "json",
                        url: "./ajax/file_tag.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
                        data: 
                        {
                            'delete_file_tag': true ,
                            'file_hash' : strCurrentFileHash ,
                            'tag_name': strTagName
                        } ,
                        success: function(data)
                        {
                            if (data['status'] == 'ok')
                            {
                                var intItemIndex = getItemIndex(strCurrentFileHash);
                                arrTags[intItemIndex] = arrTags[intItemIndex].replace(strTagName, '');
	                            // update tags in filebrowser
                                $('#sidebar_file_tags_container .file_tags_input').importTags(typeof arrTags[intItemIndex] === "undefined" ? "" : arrTags[intItemIndex]);
                            }
                            else
                            {
                                $('#gallery_file_tags_container .file_tags_error').show();
                            }
                        } ,
                        error: function()
                        {
                            $('#gallery_file_tags_container .file_tags_error').show();
                        }
                    });
                } ,
                'onSearchTag' : function(strTagName)
                {
                    if (strPublicProfileHref != '')
                    {
                        window.open(strPublicProfileHref + '#search='+  strTagName, '_self');
                    }
                    
                } ,
                'delimiter' : [';'] ,
                'removeWithBackspace' : false ,
                'minChars' : 1 ,
                'maxChars' : 245 ,
                'placeholderColor' : '#666666'
            });
        }

        if (strPublicProfileHref != '')
        {
            $('#gallery_file_tags_container .tagsinput').addClass('searchable');
        }
        else
        {
            $('#gallery_file_tags_container .tagsinput').removeClass('searchable');
        }

		$('#gallery_file_tags_container .file_tags_input').importTags(typeof arrTags[intItemIndex] === "undefined" ? "" : arrTags[intItemIndex]);

		if ( ( arrTags[ intItemIndex ] == '' || typeof arrTags[intItemIndex] === "undefined" ) && ! bolIsOwner )
		{
			$( '#gallery2__sidebar__info-tags' ).hide();
			$( '#gallery2__sidebar__info-metadata-tags' ).hide();
            $( '#gallery2_file_details_table_tags, #gallery2__sidebar__info-data' ).hide();
            
		}
		else
		{
			$( '#gallery2__sidebar__info-tags' ).show();
			$( '#gallery2__sidebar__info-metadata-tags' ).show();
            $( '#gallery2_file_details_table_tags, #gallery2__sidebar__info-data' ).show();
		}


		if( bolIsOwner && arrFileTypes[intCurrentFileIndex] != 'image' )
		{
			$( '#gallery2__sidebar__info-set-custom-thumbnail' ).html( '' );
			
    		if ( arrFileAttributes[ intItemIndex ][ 'hasCustomThumb' ] )
    		{
    			$( '#gallery2__sidebar__info-set-custom-thumbnail' ).append( '<div class="gallery2__sidebar__info-button no-background" onclick="modalGallery_changeFileThumbnail( \'' +  arrHashes[ intItemIndex ] + '\', ' + intItemIndex + ' )"><i class="fal fa-image"></i> Change file image</div>' );
    			$( '#gallery2__sidebar__info-set-custom-thumbnail' ).append( '<div class="gallery2__sidebar__info-button no-background" onclick="modalGallery_removeFileThumbnail( \'' +  arrHashes[ intItemIndex ] + '\', ' + intItemIndex + ' )"><i class="fal fa-times"></i> Delete file image</div>' );
    		}
    		else
    		{
    			$( '#gallery2__sidebar__info-set-custom-thumbnail' ).append( '<div class="gallery2__sidebar__info-button no-background" onclick="modalGallery_changeFileThumbnail( \'' +  arrHashes[ intItemIndex ] + '\', ' + intItemIndex + ' )"><i class="fal fa-image"></i> Set file preview image</div>' );
    		}

			$( '#gallery2__sidebar__info-set-custom-thumbnail' ).show();
		}
		else
		{
			$( '#gallery2__sidebar__info-set-custom-thumbnail' ).hide();
		}

        
        if( bolIsOwner )
        {
            $( "#gallery2__item_info_delete, #gallery2__item_info_delete_middle" ).on( 'click', function()
            {
                GalleryDeleteFile(arrHashes[ intItemIndex ], strName );
            });
        }
        else if( bolCanDelete && typeof arrFileDeleteKeys != 'undefined' && arrFileDeleteKeys[ intCurrentFileIndex ] != '' )
        {
            $( "#gallery2__item_info_delete, #gallery2__item_info_delete_middle" ).on( 'click', function()
            {
                GalleryDeleteFileAnon( arrFileDeleteKeys[ intCurrentFileIndex ], arrHashes[ intCurrentFileIndex ], strName );
            });
        }
       

		$( '#gallery2__sidebar__info-price, #gallery2__sidebar__info-price_middle' ).html( '' );
		$( '#gallery2__sidebar__info-price, #gallery2__sidebar__info-price_middle' ).hide();
		$( '#gallery2__item_info_save' ).hide();
		
		if ( arrFeeDownloadPrice[ intCurrentFileIndex ] != null )
		{
			if ( bolIsOwner )
			{
				$("#gallery2__sidebar__info-price, #gallery2__sidebar__info-price_middle").attr("onclick", "showSetPriceFormModal(strCurrentFileHash)")
                $("#gallery2__sidebar__info-price, #gallery2__sidebar__info-price_middle").append("Change price")
                $( '#gallery2__item_info_save' ).show();
                $('#gallery2__buyfile span.text').html('Change price');
                $('.print_or_buy_popup__buyfile span.text').html('Change price');
                $( '#gallery2__sidebar__info-price, #gallery2__sidebar__info-price_middle' ).append( ' (' + arrFeeDownloadPrice[ intCurrentFileIndex ] + ' $)' );
            }
			else
			{
				$("#gallery2__sidebar__info-price, #gallery2__sidebar__info-price_middle").attr("onclick", "showBuyFileFormModal(strCurrentFileHash)")
                $("#gallery2__sidebar__info-price, #gallery2__sidebar__info-price_middle").append("<span class='text'>Buy</span>")
                $('#gallery2__buyfile span.text').html('Buy');
                $('.print_or_buy_popup__buyfile span.text').html('Buy');
                $( '#gallery2__item_info_save' ).hide();
                $( '#gallery2__sidebar__info-price, #gallery2__sidebar__info-price_middle' ).append( '<span class="price">' + arrFeeDownloadPrice[ intCurrentFileIndex ] + ' $</span>' );
			}
			
			$( '#gallery2__sidebar__info-price, #gallery2__sidebar__info-price_middle' ).show();
		}
		else
		{
            if ( bolIsOwner )
            {
                $("#gallery2__sidebar__info-price, #gallery2__sidebar__info-price_middle").attr("onclick", "showSetPriceFormModal(strCurrentFileHash)")
                $("#gallery2__sidebar__info-price, #gallery2__sidebar__info-price_middle").append("Sell")	
                $('#gallery2__buyfile span.text').html('Sell');
                $('.print_or_buy_popup__buyfile span.text').html('Sell');
                $( '#gallery2__sidebar__info-price, #gallery2__sidebar__info-price_middle' ).show();
                $( '#gallery2__item_info_save' ).show();
            }
            else 
            {
                if (    arrFeeDownloadPrice[ intItemIndex ]==null && 
                		! currentFolderHasFeeDownload( intItemIndex ) &&
                        arrAllowDownload[ intItemIndex ] && 
                        ( typeof(bolHideDownloadButtons) === 'undefined' || ! bolHideDownloadButtons ) && 
                        ( typeof(arrHideDownloadButtons) === 'undefined' || ! arrHideDownloadButtons[ intItemIndex ] ))
                {
                    $( '#gallery2__item_info_save' ).show();
                    $( '.gallery2__save_button' ).show();
                }
                else
                {
                    $( '#gallery2__item_info_save' ).hide();
                    $( '.gallery2__save_button' ).hide();

                }
            }
		}		
		
		autosize.update($('#file_description_edit_wrapper textarea'));
		autosize.update($('#file_name_edit_wrapper textarea'));
        
        bolGalleryCommentsVisible = true;
        galleryLoadFileComments();

        if (! bolGallerySidebarVisible )
		{
            bolGalleryCommentsVisible = false;
		}

        if ( $( '#main_image_' + strCurrentFileHash ).length )
        {
            loadExifTags();
        }
	}

    function galleryLoadFileComments()
    {
        if (!bolGalleryCommentsVisible || strActiveCommentsEntityHash == strCurrentFileHash)
        {
            return;
        }
    
        // Check if global variable is available
        if (typeof window.ChatFM === 'undefined')
        {
            setTimeout(function() {
                galleryLoadFileComments()
            }, 100)
            return
        }
        
        strActiveCommentsEntityHash = strCurrentFileHash;
    
        ChatFM.resetChat();
        ChatFM.setNewEntityChat(strCurrentFileHash, "1");
    }

    function galleryUpdateVoteCount()
    {
		var intItemIndex = getItemIndex ( strCurrentFileHash );
		
		$('.gallery_vote .vote_count').text( arrVoteCounts[intItemIndex] );
		var strVoteIcon = null;
		if ( arrHasVoted[intItemIndex] )
		{
            strVoteIcon = '/images/gallery/heart_red.svg';
			$('.gallery_vote').addClass('has_voted');
		}
		else
		{
            strVoteIcon = '/images/gallery/heart_hollow.svg';
			$('.gallery_vote').removeClass('has_voted');	
		}
		
		if( typeof objAudioPlayer !== "undefined" && objAudioPlayer !== null )
        {
            objAudioPlayer.afterVote();
        }

        var jqImage = $('#main_image_' + strCurrentFileHash);
	}

    function galleryUpdateFileSelection()
    {
                    var objSelectedFiles = getSelectedFiles();
               

        $('#gallery2__thumb-strip__inner a').removeClass('selected');
        $('#gallery_select_middle').removeClass('selected');
        objSelectedFiles.forEach((strHash) => {
            $('#gallery2__thumb-strip__inner a[file_hash="' + strHash + '"]').addClass('selected');

            if(strHash == strCurrentFileHash)
            {
                $('#gallery_select_middle').addClass('selected')
            }
        });
        
	}


	function galleryChangeLocation ( strLocation, bolAuto )
    {
        
        if ( window.location.hash === strLocation )
        {
            setTimeout( "galleryCheckLocation ();", 50 );
        }
        else
        {
            var bolChangeLocation = true;
            
            
            if ( bolChangeLocation )
            {
                if ( window.location.hash.indexOf( ';/action/send_message' ) != -1 )
                {
                    bolOpenGalleryCommentsBlock = true;
                }
                
                if(window.location.hash.indexOf('#') != -1)
                {
                    window.location.replace(('' + window.location).split('#')[0] + strLocation)
                }
                else
                {
                    window.location.replace(('' + window.location) + '#' + strLocation)
                }

                if(typeof(bolAuto) === 'undefined' && typeof(strSlideshowInterval) !== 'undefined' && strSlideshowInterval !== null)
                {
                    var domVideo = document.getElementById('video_' + arrHashes[intCurrentFileIndex]);

                    clearInterval(strSlideshowInterval);
                    strSlideshowInterval = null;
                    if (!strSlideshowInterval)
                    {
                        strSlideshowInterval = setInterval(nextSlide, 4000);
                    }
                }
            }
        }
            }

    var bolCheckLocationRunning = false;
    function galleryCheckLocation ()
    {
        if ( bolCheckLocationRunning )
            return;

        bolCheckLocationRunning = true;

    	var intFileIndex = null;


        if (window.location.hash.indexOf(';/view/') != -1)
        {
            bolHashtagViewUseSemicolon = true;
        }
        else
        {
            bolHashtagViewUseSemicolon = false;
        }

        var intIndexOfView = window.location.hash.indexOf('/view/');
        if (intIndexOfView != -1)
        {
            var strViewLink = window.location.hash.slice(intIndexOfView, window.location.hash.length);
            var intIndexOfFileNameEnd = strViewLink.indexOf(';');
            if ( intIndexOfFileNameEnd == -1 )
            {
                intIndexOfFileNameEnd = strViewLink.length;
            }
            var strItemHashOrName = strViewLink.slice(6, intIndexOfFileNameEnd);
            intFileIndex = getItemIndexByHashOrName ( strItemHashOrName );
        }
        else
        {
            if( strCurrentFileHash && ! bolIsListViewForSpecificFile  ) closeGallery(strCurrentFileHash);
            if(bolGalleryOpened)
            {
	            // if user goes backwards in history, add the entry of /u/ page again
                bolPushWhenOpen = true; 
            }
        }



		if (window.location.hash.indexOf(';zoom') == -1)
		{
            $('#gallery_panzoomdiv').css('display', 'none');
        }

		if ( typeof intFileIndex !== "undefined" && intFileIndex !== null )
		{
			$('#gallery2').show();
			if ( strCurrentFileHash !== arrHashes[ intFileIndex ]  )
            {
                setTimeout( "showGalleryItem( '" + arrHashes[ intFileIndex ] + "')", 0 );
            }
		}
        else
        {
            if ( bolGalleryIsVisible && bolCloseGalleryIfHashRemoved )
            {
                closeGallery(strCurrentFileHash);
            }
        }

        bolCheckLocationRunning = false;
	}

    var galleryCheckHashtag = galleryCheckLocation;

    if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
    {
        var mql = window.matchMedia("(orientation: portrait)");
        // If there are matches, we're in portrait
        // Add a media query change listener
        mql.addListener(function(m) {
            if(m.matches) {
                // Changed to portrait
                $('#gallery2__content-wrapper').removeClass( 'gallery__only_image' );
            }
            else {
                // Changed to landscape
                $('#gallery2__content-wrapper').addClass( 'gallery__only_image' );
            }
            setTimeout( function() {
                var evt = document.createEvent('UIEvents');
                evt.initUIEvent('resize', true, false,window,0);
                window.dispatchEvent(evt);
            }, 300 );
        });
    }

    $(window).bind('hashchange', galleryCheckLocation);
        
    function galleryDestroyMainSlider ()
    {
    	if ( jqMainSlider )
    	{
    		jqMainSlider.destroySlider();	
    		jqMainSlider = null;
		}
	}
    
    function galleryReinitalize ()
    {
    	galleryDestroyMainSlider ();
    	$( '#gallery2__swipe-wrapper .gallery2__item' ).remove();
    	$( '#gallery2__thumb-strip__inner' ).html('');
        $('#gallery2__controls_doc_sign').removeClass('document');

        $( '#gallery2__info_middle' ).removeClass( 'mobile-hide' );
        $(' #gallery2__info_more' ).removeClass( 'mobile-show' );

        if ( bolIsOwner )
        {
            $('#gallery2__header__setprice').show();
            $('#gallery2__sign').show();
            $('#gallery2__sign_main').show();
            $('.gallery2__edit').show();
        }
        else
        {
            $('#gallery2__header__setprice').hide();
            $('#gallery2__sign').hide();
            $('#gallery2__sign_main').hide();
            $('.gallery2__edit').hide();
        }
        
        if ( bolUseAsyncFileInfoDataLoad )
        {
            arrFileTitle = [];
            arrFileSubject = [];
            arrFileContentType = [];
            arrFileCategory = [];
            arrFileCategories = [];
            arrFileKeywords = [];
            arrFileCreator = [];
            arrFilePublisher = [];
            arrFileContributor = [];
            arrFileCopyrights = [];
            arrFileLicenseType = [];
            arrFileLicenseDetails = [];
            arrFileLanguage = [];
            arrFileLocation = [];
            arrFileLocationLat = [];
            arrFileLocationLong = [];
            arrFileReferences = [];
            arrFileRelatesTo = [];
            arrFileFormat = [];
            arrFileDevice = [];
            arrFileSource = [];
            arrTags = [];
            arrObjectTags = [];
            arrYoloObjectTags = [];
            arrLabelTags = [];
            arrFileGoogleCVText = [];
            arrFileEasyOCRText = [];
            arrFileAudioTranscription = [];
            arrIsFileInfoDataPreloaded = [];
            }
	}

    var objVideoPlayers = {};
    
    function initVideoPlayer (intFileIndex)
    {
        var logoHref = "https://files.fm";
        var logoImgUrL = logoHref;
    
                logoImgUrL += "/images/logo/white/filesfm_logo_full.svg";
                
        var player = new FilesFm_VideoJS( "video_" + arrHashes[ intFileIndex ], {
            autoplay: false,
            posterHref: 'https://' + arrFileHost[ intFileIndex ]  + '/thumb_video_picture.php?i=' + arrHashes[intFileIndex] + '&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a' ,
        } );

        objVideoPlayers[intFileIndex] = player;

        player.objPlayer.on( 'ready', function() {
            var domVideo = $( '#' + player.strContainerId + ' video' )[ 0 ];
            var objQualitySelector = player.objPlayer.controlBar.qualitySelector;
            var objPlaybackRateMenuButton = player.objPlayer.controlBar.playbackRateMenuButton;


            // Add title to PlaybackRateMenuButton
            $( objPlaybackRateMenuButton.menu.el() )
                .prepend( '<div class="vjs-menu-title bx_allow_events">Speed</div>' );

            // Close QualitySelector and PlaybackRateMenuButton when any of CenterButtons is clicked.
            // Event 'touchend' is specifically for touchscreens.
            // Mouse click is implemented in VideoJS by default.
            player.objPlayer.getChild( 'CenterButtons' ).children().forEach( button => {
                $( button.el() ).on( 'touchend', () => {
                    objQualitySelector.unpressButton();
                    objPlaybackRateMenuButton.unpressButton();
                } );
            } );


            // Do not make further changes to QualitySelector
            //     if there is no source of the original video.
            if ( player.objPlayer.currentSources().length != 2 )
            {
                return;
            }


            function onMetadataLoaded()
            {
                domVideo.removeEventListener( 'loadedmetadata', onMetadataLoaded );

                // If preview and original video resolutions are the same, remove QualitySelector
                if (
                        typeof arrWidths != 'undefined'
                        && typeof arrHeights != 'undefined'
                        && arrWidths[ intFileIndex ] == domVideo.videoWidth
                        && arrHeights[ intFileIndex ] == domVideo.videoHeight
                    )
                {
                    objQualitySelector.el().remove();
                    return;
                }

                styleQualitySelector( player, intFileIndex );

                $( objPlaybackRateMenuButton.el() ).addClass( 'vjs-quality-selector-available' );
                $( objQualitySelector.menu.el() ).find( '*' ).addClass( 'bx_allow_events' );


                
                    var jqQualitySelectorList = $( objQualitySelector.menu.contentEl() );
                    var jqOriginalQualityBTN = $( objQualitySelector.items[ 1 ].el() );

                    jqOriginalQualityBTN.remove();

                    // Create plain copy of element (to prevent any event listeners and other stuff)
                    jqOriginalQualityBTN = $( jqOriginalQualityBTN[ 0 ].outerHTML );

                    jqQualitySelectorList.append( jqOriginalQualityBTN );

                    jqOriginalQualityBTN.on( 'click touchend', function() {
                        player.objPlayer.pause();

                        
                            showCreateAccount();

                                            } );

                            }

            if ( domVideo.readyState == 0 )
            {
                domVideo.addEventListener( 'loadedmetadata', onMetadataLoaded );
            }
            else
            {
                onMetadataLoaded();
            }
        } );

        player.objPlayer.on( 'qualityRequested', function( event, newSource ) {
            $( event.target )
                .find( '.vjs-control-bar .vjs-quality-selector .vjs-quality-selector-value' )
                .text( newSource.resolutionLabel );
        } );

        player.objPlayer.on("ended", (event) => {
            if ( bolGalleryIsVisible )
            {
                var intNextSlideIndex = intNextIndex;

                if(intNextIndex == null || isNaN( intNextIndex ) && arrHashes[0] != null)
                {
                    intNextSlideIndex = getItemIndex ( arrHashes[0] );
                }

                if ( intNextSlideIndex != null && !isNaN( intNextSlideIndex ) )
                {
                    if (strSlideshowInterval === 'reset')
                    {
                        objVideoPlayers[intCurrentFileIndex].objPlayer.loop(true);
                        galleryChangeLocation ( getItemLink ( arrHashes[intNextSlideIndex] ) );
                    }
                }
            }
        });
        
        fitVideoPlayer( $( "#video_" + arrHashes[ intFileIndex ] ) );
    
        $( "#video_" + arrHashes[ intFileIndex ] ).find( "*" ).addClass( "bx_allow_events" );

        $( "#video_" + arrHashes[ intFileIndex ] ).addClass( 'ffm_video_fallback' );

        $( "#video_" + arrHashes[ intFileIndex ] + ' .vjs-loading-spinner .vjs-control-text' ).text( 'Wait for the mp4 video preview to be created for playback in the browser. This takes time, depending on the length of the video. If the video does not start, refresh the page or download the original.' );

        // let's not resize the player anymore
        player.setFluid( false );
    }

    function styleQualitySelector( player, intFileIndex )
    {
        var strDefaultQualityLabel = 'HD';

        var domVideo = $( '#' + player.strContainerId + ' video' )[ 0 ];
        var objQualitySelector = player.objPlayer.controlBar.qualitySelector;

        $( objQualitySelector.menu.el() )
            .prepend( '<div class="vjs-menu-title">Quality</div>' );


        // PREVIEW QUALITY BUTTON
        var jqPreviewQualityText = $( objQualitySelector.items[ 0 ].el() ).find( '.vjs-menu-item-text' );
        jqPreviewQualityText.html( '<div>Preview</div>' );

        var intPreviewWidth = domVideo.videoWidth;
        var intPreviewHeight = domVideo.videoHeight;

        if (
                typeof intPreviewWidth == 'number'
                && typeof intPreviewHeight == 'number'
                && intPreviewWidth > 0
                && intPreviewHeight > 0
            )
        {
            var strPreviewResolutionLabel = getResolutionLabel( intPreviewWidth, intPreviewHeight, true );
            if ( strPreviewResolutionLabel === '' )
            {
                strPreviewResolutionLabel = 'SD ';
            }

            jqPreviewQualityText.append(
                '<div>' +
                    strPreviewResolutionLabel + intPreviewWidth + 'x' + intPreviewHeight +
                '</div>'
            );
            
            $( objQualitySelector.el() ).prepend( '<div class="vjs-quality-selector-value">' + strPreviewResolutionLabel + '</div>' );

            player.objPlayer.currentSources()[ 0 ].resolutionLabel = strPreviewResolutionLabel;
        }
        else
        {
            $( objQualitySelector.el() ).prepend( '<div class="vjs-quality-selector-value">' + strDefaultQualityLabel + '</div>' );

            player.objPlayer.currentSources()[ 0 ].resolutionLabel = strDefaultQualityLabel;
        }

        // ORIGINAL QUALITY BUTTON
        var jqOriginalQualityText = $( objQualitySelector.items[ 1 ].el() ).find( '.vjs-menu-item-text' );
        jqOriginalQualityText.html(
            '<div>' +
                'Original ' +
                '<span class="pro_flag">PRO</span>' +
            '</div>'
        );

        if (
                typeof arrWidths != 'undefined'
                && typeof arrHeights != 'undefined'
                && arrWidths[ intFileIndex ] != ''
                && arrHeights[ intFileIndex ] != ''
            )
        {
            var strOriginalResolutionLabel = getResolutionLabel( arrWidths[ intFileIndex ], arrHeights[ intFileIndex ], true );
            if ( strOriginalResolutionLabel === '' )
            {
                strOriginalResolutionLabel = 'SD ';
            }

            jqOriginalQualityText.append(
                '<div>' +
                    strOriginalResolutionLabel + arrWidths[ intFileIndex ] + 'x' + arrHeights[ intFileIndex ] +
                '</div>'
            );

            player.objPlayer.currentSources()[ 1 ].resolutionLabel = strOriginalResolutionLabel;
        }
        else
        {
            player.objPlayer.currentSources()[ 1 ].resolutionLabel = strDefaultQualityLabel;
        }
    }

    function getVideoSize($video) 
    {
        $video = $($video);
        
        var $viewPort = $video.closest( ".gallery2__video_container" );
    
        var viewportHeight = $viewPort.height() - 100;
        var viewportWidth = $viewPort.width();
        
        var minHeight = 240;
    
        var videoHeight = $video.get( 0 ).offsetHeight;
        var videoWidth = $video.get( 0 ).offsetWidth;
    
        var widthToHeight = $video.attr( 'data-wth' );
    
        if ( typeof widthToHeight === "undefined" || !widthToHeight )
        {
            widthToHeight = Math.floor( videoWidth / videoHeight * 100 ) / 100;
            $video.attr( 'data-wth', widthToHeight );
        }
        
        if( widthToHeight == 0 )
        {
            widthToHeight = 1;
        }
    
        var maxHeight = viewportHeight;
    
        if ( maxHeight * widthToHeight >= viewportWidth )
        {
            maxHeight = Math.round( viewportWidth / widthToHeight );
        }
        
        if( maxHeight > viewportHeight )
        {
            maxHeight = viewportHeight;
        }
    
        if ( maxHeight < minHeight )
        {
            maxHeight = minHeight;
        }
        
        var w = Math.floor( widthToHeight * maxHeight );
        
        return {
            height: maxHeight + 'px',
            width: !isNaN(w) ? (w + "px") : "0px"
        };
    }
    
    function fitVideoPlayer( $video )
    {
        $video = $($video);
        
        var size = getVideoSize( $video );

        $video.css( {
            paddingTop: size.height,
            width: size.width,
            height: 0
        } );
        
        $video.find( "video" ).css( 'width', '100%' );
    }

    function fitEmbedPlayer( $video )
    {
        $video = $( $video );
        var size = getVideoSize( $video );

        if ( size.width !== "0px" )
        {
            $video.closest( ".gallery2__video_container__embed_palyer" ).css( {
                'maxWidth': size.width
            } );
    
            $video.closest( ".filesfm__embed_player__container" ).css( {
                height: "100%"
            } );
        }
    
        $video.find( "video" ).css( 'width', '100%' );
    }
    
    var bolGalleryIsOpening = false;
    var arrThumbWidth = [];
    function showGallery()
    {
    	if ( bolGalleryIsOpening )
    	{
    		return;
		}

		bolGalleryIsOpening = true;

        $( 'html' ).css( 'overflow', 'hidden' );
        $( '#gallery2' ).show();

        $('#tawkchat-iframe-container').hide();

        if( $( '#gallery2__swipe-wrapper .gallery2__item' ).length == 0 )
        {
            if (jqThumbContainer == null)
            {
                jqThumbContainer = $('#gallery2__thumb-strip__inner');

                var intAllThumbCount = $( 'A', jqThumbContainer ).length;
            }
            var intThumbsW = 0;

            var arrItems = [];
            var arrThumbs = [];
            for( idx in arrIDs )
            {
            	// Removed jQuery from content composing
				var strItemHTML = '<span class="gallery2__item" id="gallery2__item-' + idx + '"></span>';
				
                strAddress = '';
                
                var strThumbHTML = '';
                var strClass = null;
                if ( arrThumbnails[idx] )
                {
                    var strThumbPath = arrThumbnails[idx];
                    
                    strThumbHTML = '<img src="/images/gallery-image-icon.png" data-original="'+strThumbPath+'" id="thumb_strip_img_'+arrHashes[idx]+'" class="lazyload-image-gallery" />';
                }
                else if ( typeof( arrIconSvg ) !== 'undefined' && arrIconSvg[idx] )
                {
                    strThumbHTML = '<span class="gallery2__item__thumbnail '+ arrExtensions[ idx ].toLowerCase() +' thumb-svg-icon"><img src="/images/file_types_v2/'+arrIconSvg[ idx ]+'" data-original="/images/file_types_v2/'+arrIconSvg[ idx ]+'" style="max-width: 35px" /><span class="gallery2__item__thumbnail-ext">'+ arrExtensions[ idx ].toUpperCase() +'</span></span>';
                }
                else if ( arrIconClass[idx] )
                {
                    strThumbHTML = '<span class="gallery2__item__thumbnail '+ arrExtensions[ idx ].toLowerCase() +'"><i class="' + arrIconClass[idx] + '"></i><span class="gallery2__item__thumbnail-ext">'+ arrExtensions[ idx ].toUpperCase() +'</span></span>';
                    strClass = 'doc-icon';
                }
                else
                {
                    strThumbHTML = '<span class="gallery2__item__thumbnail '+ arrExtensions[ idx ].toLowerCase() +'"><i class="fal fa-file"></i><span class="gallery2__item__thumbnail-ext">'+ arrExtensions[ idx ].toUpperCase() +'</span></span>';
                    strClass = 'doc-icon';
                }
                
                var strThumbItemHTML = '<a href="javascript:void(0)" class="thumb_' + arrHashes[idx] + ''+ (strClass ? ' '+strClass : '') +'" file_hash="'+arrHashes[idx]+'" onclick="galleryChangeLocation ( getItemLink ( \''+arrHashes[idx]+'\' ) )" ';
                if( !arrThumbnails[idx] )
                {
                    strThumbItemHTML += 'style="min-width:65px;"';
                }
                strThumbItemHTML += '><!--<div class="thumb-loader">Loading</div>--><div class="thumb-wrapper">'+ strThumbHTML +'</div><div class="checkbox"></div></a>';
                
                arrItems.push(strItemHTML);
                arrThumbs.push(strThumbItemHTML);
            }
            
            $( '#gallery2__swipe-wrapper' )[0].innerHTML = arrItems.join('');
            jqThumbContainer[0].innerHTML = arrThumbs.join('');
            
            arrItems = null;
            arrThumbs = null;
        }

                    //add checkboxes to thumb strip and update middle menu
            galleryUpdateFileSelection();
        

        
		
		if (jqThumbContainer == null)
		{
			jqThumbContainer = $('#gallery2__thumb-strip__inner');
		}
		
		if (jqThumbViewport == null)
		{
			jqThumbViewport = $('#gallery2__thumb-strip');
		}

        if( jqMainSlider == null )
        {
            recalculateGalleryForBanner();
            var bolTouchEnabled = true;

                            if(arrIDs.length == 1)
                {
                    bolTouchEnabled = false;
                }
                        
            jqMainSlider = $( '#gallery2__swipe-wrapper' ).bxSlider({
                slideSelector: 'span.gallery2__item',
                infiniteLoop: false,
                hideControlOnEnd: true,
                preventDefaultSwipeX: true,
                video: true,
                pager: false,
                controls: false,
                slideWidth: 9999,
                useCSS: true,
                speed: 0,
                animationSpeed: 0,
                touchEnabled: bolTouchEnabled ,
                onSlideBefore: function( $slide, oldIDx, newIDx ){

                    galleryChangeLocation ( getItemLink ( arrHashes[newIDx] ) );

                    if( !$slide.hasClass( 'content_ready' ) )
                    {
                        loadSlideContent( $slide, newIDx );
                    }
                },
                onSlideAfter: function( $slide, oldIDx, newIDx ){
                    var slidePrevIDx = parseInt( newIDx ) - 1;
                    var slideNextIDx = parseInt( newIDx ) + 1;

                    if( slidePrevIDx >= 0 )
                    {
                        $slidePrev = $( '#gallery2__item-' + slidePrevIDx );

                        if( $slidePrev.length > 0 && !$slidePrev.hasClass( 'content_ready' ) )
                        {
                            loadSlideContent( $slidePrev, slidePrevIDx );
                        }
                    }

                    if( slideNextIDx < jqMainSlider.getSlideCount() )
                    {
                        $slideNext = $( '#gallery2__item-' + slideNextIDx );

                        if( $slideNext.length > 0 && !$slideNext.hasClass( 'content_ready' ) )
                        {
                            loadSlideContent( $slideNext, slideNextIDx );
                        }
                    }
    
                    if ( $slide.find( ".gallery2__item__audio-wrapper" ).length )
                    {
                        objAudioPlayer.appendTo( $slide.find( ".gallery2__item__audio-wrapper" ) );
                        objAudioPlayer.setCurrentTrackByHash( arrHashes[ newIDx ] );
                    }
                }
            });

            var obj = document.getElementById('gallery2__swipe-wrapper');
            obj.addEventListener('touchmove', function(event) {
                if(event.targetTouches.length > 1)
                {
                    $( '#gallery2__swipe-wrapper' ).attr('data-multi-touch', true)
                }
                else
                {
                    $( '#gallery2__swipe-wrapper' ).attr('data-multi-touch', false)
                }
            }, false);
            
        }
        else if (bolHaveToRedrawGallery)
        {
        	recalculateGalleryForBanner(true);
        	bolHaveToRedrawGallery = false;
        }
        
        // At the beginning we need fixed size for lazyload to work
        $( 'img.lazyload-image-gallery', jqThumbContainer).css( {'width': 'auto', 'height':'73px'} ).addClass('image-not-loaded');

        $(function(){

            var intAllThumbCount = $( 'A', jqThumbContainer ).length;

            // After preload image is loaded - set auto size for original images.
            $( 'img.lazyload-image-gallery', jqThumbContainer ).on( 'load', function (){

                var intW = this.naturalWidth;
                if ( intW < intThumbWidth )
                    intW = intThumbWidth;
                arrThumbWidth.push( intW );
                var intLoadedThumbCount = 0;
                var intLoadedThumbWidthSum = 0;
                for ( var i = 0; i<arrThumbWidth.length; i++ )
                {
                    intLoadedThumbCount++;
                    intLoadedThumbWidthSum += arrThumbWidth[i];
                }

                var intAllThumbCount = $( 'A', jqThumbContainer ).length;

                this.className = this.className + ' image-loaded';
            } );

            $( document ).on( 'click', function( e )
            {
                var jqTarget = $( e.target );
                
                if (
                    jqTarget.parents( '#gallery2__header__mobile_menu' ).size()==0 && 
                    jqTarget.attr( 'id' )!='gallery2__header__mobile_menu' && 
                    jqTarget.parents( '#gallery2__header__right_more' ).size()==0 && 
                    jqTarget.attr( 'id' )!='gallery2__header__right_more' 
                )
                {
                    $( '#gallery2__header__right_more' ).removeClass('open');
                }
                if (
                    jqTarget.parents( '#gallery-main-download-button' ).size()==0 && 
                    jqTarget.attr( 'id' )!='gallery-main-download-button'
                )
                {
                    $( '#gallery-main-download-button' ).removeClass('open');
                }
            });

            $( '#gallery2__header__mobile_menu > .gallery2__header_middle_button:not(#gallery2__sidebar__info_embed_button_middle)' )
                .on( 'click', function ()
                {
                    $( '#gallery2__header__right_more' ).removeClass('open');
                } );
        });

		$( 'img.lazyload-image-gallery' ).lazyload({
			container: jqThumbViewport,
			skip_invisible: true,
			event: 'scroll touchmove thumb-scroll',
			threshold: parseInt(intPreloadThumbnailsCount * intThumbWidth)
		});
		
		bolGalleryIsVisible = true;

        $( function() {
            if(typeof(bolOpenPopupInGallery) !== 'undefined' && bolOpenPopupInGallery)
            {
                if( intPopupType == 2) 
                {
                    objPopupForm.showForm();
                    bolPopupOnlyGallery = true;
                }
                else
                {
                    setTimeout(function() {
                        objPopupForm.showForm();
                        bolPopupOnlyGallery = true;
                    }, 2000);
                }
            }
        } );

		setTimeout("$('#info_tooltip_global').hide();", 100);

		        if ( objMainShareParams )
            $('#gallery2__share').show();
                
		bolGalleryIsOpening = false;

        var bolIsMobile = navigator.userAgent.match( '/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/i' )
        if ( !bolIsMobile && $( window ).width() >= 1400 && !bolGallerySidebarVisible )
        {
            showGalleryInfo();
        }
    }

    
    function galleryLazyloadRecalc()
    {
		// Optimization for lazy load to work faster on large set of images.
		// Trigger lazy load recalc event for 5 images before loaded images and 5 after.
		var arrPreElements = [];
		var arrPostElements = [];
		var bolPassedLoadedImages = false; 
		$('img.lazyload-image-gallery').each (function (){
			var jqImage = $(this);
			if ( jqImage.hasClass('image-loaded') )
			{
				bolPassedLoadedImages = true;
			}
			if ( bolPassedLoadedImages == false )
			{
				arrPreElements.unshift( jqImage );
				if (arrPreElements.length == intPreloadThumbnailsCount)
				{
					delete arrPreElements[intPreloadThumbnailsCount-1];
				}
			}
			else
			{
				if (arrPostElements.length < intPreloadThumbnailsCount)
				{
					arrPostElements.push( jqImage );
				}
			}
		});

        jqThumbViewport.trigger('scroll');
		
	}

	function openPanZoomImage ()
    {
        if ( arrFileTypes[intCurrentFileIndex] !== 'image' )
            return;

        var strImageURL = 'https://'+ arrFileHost[ intCurrentFileIndex ]  +'/thumb_show.php?i=' + arrHashes[intCurrentFileIndex] + '&view&v=1&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a';
        if (arrFeeDownloadPrice[intCurrentFileIndex] > 0 || currentFolderHasFeeDownload( intCurrentFileIndex ) )
        {
            strImageURL += '&wm=103';
        }

        if ( typeof( arrFileVersion ) != 'undefined' && typeof( arrFileVersion[ intCurrentFileIndex ] ) != 'undefined' && arrFileVersion[ intCurrentFileIndex ] > 0 )
        {
            strImageURL += '&version=' + arrFileVersion[ intCurrentFileIndex ];
        }

        var srNewPanZoomLink = getItemLink ( strCurrentFileHash );

       
        if( !window.location.hash.includes(';zoom') )
        {
            if ( window.location.hash.length > 0 )
            {
                srNewPanZoomLink += ';zoom';
            }
            else
            {
                srNewPanZoomLink += '#;zoom';
            }
        }
        galleryChangeLocation ( srNewPanZoomLink );

        var strHtml = '<img id="gallery_panzoomdiv_content" src="' + strImageURL + '" onload="initPanZoomImage(this)" />';

        strHtml += '<div id="gallery_panzoomdiv_info" style="position: absolute; top: 0px; left: 0px; font-size: 12px; color: #fff; padding: 10px;"></div>';


        var resCloseTimeout = null;
        $('#gallery_panzoomdiv')
            .html( strHtml )
            .css('display', 'block')
            .on('mouseup', function (e){
                resCloseTimeout = setTimeout( function (){
                    $('#gallery_panzoomdiv').css('display', 'none');
                }, 50);
            })
            .on('mousemove', function (e){
                if ( resCloseTimeout )
                {
                    clearTimeout( resCloseTimeout );
                    resCloseTimeout = null;
                }
            });

        $('#gallery_panzoomdiv_close').on('click', function () {
            $('#gallery_panzoomdiv').css('display', 'none');
        });
    }

    function initPanZoomImage (dom)
    {
        var intBodyHeight = $('body').outerHeight();

        var panzoom_instance = panzoom(dom, {
            transformOrigin: {x: 0.5, y: 0.5},
            maxZoom: 8,
            minZoom: 0.25,
            onTouch: function(e) {
                return false;
            }
        });
        var container_width = $('#gallery_panzoomdiv').width();
        var container_height = $('#gallery_panzoomdiv').height();
        var width = $('#gallery_panzoomdiv_content').width();
        var height = $('#gallery_panzoomdiv_content').height();

        panzoom_instance.moveTo((width - container_width)/-2, (height - container_height)/-2);

        var jqHead = $( 'head' );
        jqHead.find( 'meta[name=viewport]' ).remove();
        jqHead.prepend( '<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0" />' );
    }

    var arrIframeTimers = [];
    var objAudioPlayer = null;

    function getBackgroundSize(elem) {
        var objElemComputedStyle = getComputedStyle(elem),
        objImage = new Image(),
        strElemSrc = objElemComputedStyle.backgroundImage.replace(/url\((['"])?(.*?)\1\)/gi, '$2'),
        intElemWidth = parseInt(objElemComputedStyle.width.replace('px', ''), 10),
        intElemHeight = parseInt(objElemComputedStyle.height.replace('px', ''), 10);
        objImage.src = strElemSrc;
        
        var intBackgroundWidth, intBackgroundHeight;
        var intRatioWidth = objImage.width / intElemWidth;
        var intRatioHeight = objImage.height / intElemHeight;

        if (intRatioWidth > intRatioHeight)
        {
            intBackgroundHeight = objImage.height / intRatioWidth;
            intBackgroundWidth = intElemWidth;
        }
        else
        {
            intBackgroundWidth = objImage.width / intRatioHeight;
            intBackgroundHeight = intElemHeight;
        }
        return {
            width: intBackgroundWidth,
            height: intBackgroundHeight
        };
    }

    function loadSlideContent( $jqSlideElem, intFileIndex )
    {
		var strHttpCacheKey = '';
		if ( typeof(arrHttpCacheKeys) != 'undefined' && typeof(arrHttpCacheKeys[intFileIndex]) != 'undefined' )
		{
			strHttpCacheKey = '' + arrHttpCacheKeys[intFileIndex];
		}

        if ( arrFileAttributes && arrFileAttributes[ intFileIndex ] && arrFileAttributes[ intFileIndex ][ 'readOnly' ] )
        {
            $( '#gallery2__header__mid_content' ).hide();
        }
        else
        {
            $( '#gallery2__header__mid_content' ).show();
        }

        
    	var strFileType = arrFileTypes[intFileIndex];
    	
    	var bolIsFileConvertableToPdf = isFileConvertable( 'pdf', intFileIndex );

    	if ( bolIsFileConvertableToPdf )
    	{
    		strFileType = 'pdf_converted';
    	}
    	
        
        switch( strFileType )
        {
            default:
                var bolSimpleDownloadAllowed = false;
                if ( arrAllowDownload[ intFileIndex ]
                    && arrFeeDownloadPrice[ intFileIndex ] == null
                    && ! currentFolderHasFeeDownload( intFileIndex )
                    && ( typeof(bolHideDownloadButtons) === 'undefined' || ! bolHideDownloadButtons ) && ( typeof(arrHideDownloadButtons) === 'undefined' || ! arrHideDownloadButtons[ intFileIndex ] )
                ) {
                    bolSimpleDownloadAllowed = true;
                }

                var jqThumb;

                if ( arrFileAttributes[ intFileIndex ][ 'hasCustomThumb' ] )
                {
                	jqThumbInner = $( "<div>" )
                    .css({
                        'background-image': 'url("/thumb.php?i=' + arrHashes[ intFileIndex ] + '&v=1")',
                        'height': function() 
                        {
                        }
                    })
                    .addClass( 'gallery2__item__custom_thumb' );

                    if ( arrFeeDownloadPrice[intFileIndex] > 0 )
                    {
                        if (bolIsOwner)
                        {
                            jqThumbInner.attr( 'onclick', 'showSetPriceFormModal(strCurrentFileHash)' );
                        }
                        else 
                        {
                            jqThumbInner.attr( 'onclick', 'showBuyFileFormModal(strCurrentFileHash)' );
                        }
                    	jqThumbInner.addClass( 'bx_allow_events' );
                    	jqThumbInner.addClass( 'has_price' );
                    }

                    jqThumb = jqThumbInner;
                }

                $jqSlideElem.append( '<span class="gallery2__vertical-helper"></span><span class="gallery2__item__doc-wrapper' + ( arrFileAttributes[ intFileIndex ][ 'hasCustomThumb' ] ? ' has_custom_thumb' : '' ) + '"></span>' );
                $( '.gallery2__item__doc-wrapper', $jqSlideElem ).append( jqThumb );

                var strIconHtml = '<i class="fa-5x fa ' + arrIconClass[ intFileIndex ] + '"></i>';
                if ( typeof( arrIconSvg ) !== 'undefined' && arrIconSvg[ intFileIndex ] )
                {
                    strIconHtml = '<img src="/images/file_types_v2/'+arrIconSvg[ intFileIndex ]+'" class="ext-icon" />';
                }
                jqThumbIcon = $( '<span class="gallery2__item__doc-icon ' + arrExtensions[ intFileIndex ].toLowerCase() + '">' + strIconHtml + '</span>' );
                $( '.gallery2__item__doc-wrapper', $jqSlideElem ).append( jqThumbIcon );
                $('.gallery2__item__doc-wrapper', $jqSlideElem).append('<div class="gallery2__item__information-wrapper"><p class="gallery2__item__doc-filename">' + arrDisplayNames[intFileIndex] + '</p></div>');
                

                $( '.gallery2__item__doc-wrapper', $jqSlideElem ).append( '<p class="gallery2__item__doc-nopreview"></p>' );

                $( '.gallery2__item__doc-wrapper', $jqSlideElem ).append(jqButtonContainer);
                break;

            case 'image':
                    var strImageURL = 'https://' + arrFileHost[ intFileIndex ] + '/thumb_show.php?i=' + arrHashes[intFileIndex] + '&view&v=1&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a';
                    if (arrFeeDownloadPrice[intFileIndex] > 0 || currentFolderHasFeeDownload( intFileIndex ) )
                    {
                        strImageURL += '&wm=103';
                    }

                    if ( typeof( arrFileVersion ) != 'undefined' && typeof( arrFileVersion[ intFileIndex ] ) != 'undefined' && arrFileVersion[ intFileIndex ] > 0 )
                    {
                        strImageURL += '&version=' + arrFileVersion[ intFileIndex ];
                    }

					var strHtml = '' +
						'<span class="gallery2__vertical-helper"></span>' +
						'<i class="fa fa-spinner fa-spin gallery2__load-spinner" id="main_image_load-spinner_'+ arrHashes[intFileIndex] +'"></i>' +
                        '<img class="gallery2__item__img gallery2__item__base-width-on bx_allow_events ' + ((arrWidths[intFileIndex] >= 1500 || arrHeights[intFileIndex] >= 1500 ) ? 'stretch_image' : '') + '" src="" alt="" id="main_image_'+ arrHashes[intFileIndex] +'" />' +
                        '<div class="print_or_buy_popup">' +
                            '<div class="print_or_buy_popup_close bx_allow_events" onclick="$(\'.print_or_buy_popup\').hide();"></div>' +
                            '<div class="print_or_buy_popup_desc">You can buy this file or print-on-demand products:</div>' +
                            '<span class="print_or_buy_popup__buyfile print_or_buy_popup_button" style="display:none"  onclick="showSetPriceFormModal(strCurrentFileHash)">' +
                                '<a href="javascript:void(0);">' +
                                ' <span class="text">Buy</span>' +
                                    '<span class="price"></span>' +
                                '</a>' +
                            '</span>' +
                            '<span class="print_or_buy_popup__products print_or_buy_popup_button">' +
                                '<a href="javascript:void(0);">' +
                                    '<span class="text">View products</span>' +
                                '</a>' +
                            '</span>' +
                        '</div>' +
                        '</div>';
                     $jqSlideElem.append( strHtml );

                     var bolImageLoaded = false;
                     var strImageFileHash = arrHashes[intFileIndex];
                     $( 'img', $jqSlideElem ).attr( 'src', strImageURL ).on( 'load', function(){
                        bolImageLoaded = true;
                        $( this ).css( 'opacity', '1' );
                        $('#main_image_load-spinner_'+ strImageFileHash).hide();

                        $(this).attr( 'data-image-loaded', true );
                        
                        var intImageWidth =  $( 'img', $jqSlideElem ).width();
                        if(intImageWidth>=$('#gallery2__image-wrapper').width())
                        {
                            intImageWidth=intImageWidth-20;
                        }
                        $('img', $jqSlideElem).siblings('.gallery2__item__desc-wrapper, .gallery2__item__information-wrapper').width( intImageWidth );
                        if ( arrHashes[intFileIndex] == strCurrentFileHash )
                        {
                            loadExifTags();
                        }
                     }).on('click', function (){
                        if($( this ).hasClass( "bx_allow_events" ))
                        {
                            if ( arrFeeDownloadPrice[intFileIndex] > 0 )
                            {
                                                                    if ( arrFileHasProductSelling[ intCurrentFileIndex ] == 1 )
                                    {
                                        $( this ).siblings(".print_or_buy_popup").toggle();
                                    }
                                    else
                                    {
                                        if (bolIsOwner)
                                        {
                                            showSetPriceFormModal(strCurrentFileHash);
                                        }
                                        else 
                                        {
                                            showBuyFileFormModal(strCurrentFileHash);
                                        }
                                    }
                                                            }
                            else 
                            {
                                                                if ( arrFileHasProductSelling[ intCurrentFileIndex ] == 1 )
                                {
                                    window.open( '/c/' + strUploadHash + '?h=' + strCurrentFileHash, '_blank' );
                                }
                                                            }
                        }
                        else
                        {
                            $('#gallery2__content-wrapper').toggleClass( 'gallery__only_image' );
                        }
                     });

                     setTimeout("var domImg=document.getElementById('main_image_"+ arrHashes[intFileIndex] +"');  if ( ! domImg.complete ) { $( domImg ).css( 'opacity', '0.6' );}", 300);

                break;

            case 'document':
            case 'code':
            case 'pdf_converted':
            	var jqThumb;

                if ( arrFileAttributes[ intFileIndex ][ 'hasCustomThumb' ] )
                {
                    jqThumb = $( "<div>" ).css( 'background-image', 'url("/thumb.php?i=' + arrHashes[ intFileIndex ] + '&v=1")' ).addClass( 'gallery2__item__custom_thumb gallery2__item__base-width-on' );

                    if ( arrFeeDownloadPrice[intFileIndex] > 0 )
                    {
                        if (bolIsOwner)
                        {
                            jqThumb.attr( 'onclick', 'showSetPriceFormModal(strCurrentFileHash)' );
                        }
                        else 
                        {
                            jqThumb.attr( 'onclick', 'showBuyFileFormModal(strCurrentFileHash)' );
                        }
                    	jqThumb.addClass( 'bx_allow_events' );
                    	jqThumb.addClass( 'has_price' );
                    }
                }
                else
                {
                    jqThumb = $( '<i />' ).addClass( 'fa-5x fa ' + arrIconClass[intFileIndex] );
                    if ( typeof( arrIconSvg ) !== 'undefined' && arrIconSvg[ intFileIndex ] )
                    {
                        jqThumb = $( '<img />' ).attr('src', '/images/file_types_v2/' + arrIconSvg[ intFileIndex ]).addClass( 'gallery2__item__base-width-on ext-icon' );
                    }
                }

                var bolSimpleDownloadAllowed = false;
                if ( arrAllowDownload[ intFileIndex ]
                    && arrFeeDownloadPrice[ intFileIndex ] == null
                    && ! currentFolderHasFeeDownload( intFileIndex )
                    && ( typeof(bolHideDownloadButtons) === 'undefined' || ! bolHideDownloadButtons ) && ( typeof(arrHideDownloadButtons) === 'undefined' || ! arrHideDownloadButtons[ intFileIndex ] )) {

                    bolSimpleDownloadAllowed = true;
                }
                $jqSlideElem.append( '<span class="gallery2__vertical-helper"></span><span class="gallery2__item__doc-wrapper' + ( arrFileAttributes[ intFileIndex ][ 'hasCustomThumb' ] ? ' has_custom_thumb' : '' ) + '"></span>' );
                $( '.gallery2__item__doc-wrapper', $jqSlideElem ).append( jqThumb );
                if (!arrFileAttributes[ intFileIndex ][ 'hasCustomThumb' ]) 
                {
                    $('.gallery2__item__doc-wrapper', $jqSlideElem).append('<div class="gallery2__item__information-wrapper"><p class="gallery2__item__doc-filename">' + arrDisplayNames[intFileIndex] + '</p></div>');
                }
    
                var jqButtonContainer = $('<div />').css({'white-space': 'normal'});
                jqButtonContainer.append('<div class="gallery2__item__desc-wrapper"><p class="gallery2__item__desc-wrapper-text">' + arrDescriptions[intFileIndex] + '</p></div>');
                
                if ( arrExtensions[ intFileIndex ] == 'pdf' || bolIsFileConvertableToPdf )
                {
                    var bolForbidDirectDownload = false;
                    
                	if ( typeof( arrForbidDirectDownload ) != 'undefined' && arrForbidDirectDownload[ intFileIndex ] == true )
                	{
                		bolForbidDirectDownload = true;
                	}
                	

                    if (
                            arrFeeDownloadPrice[ intFileIndex ] == null
                            && ! currentFolderHasFeeDownload( intFileIndex )
                            && arrAllowDownload[ intFileIndex ] 
                            && browserSupportsCanvas() 
                            && ! bolForbidDirectDownload 
                            && arrSizesInBytes[ intFileIndex ] < 104857600                        )
                    {
                        ( function()
                        {
                            $( this ).attr( 'disabled', 'disabled' );
            
                            var $jqSlideElem = $( this ).closest( ".gallery2__item" );
                            var intFileIndex = $jqSlideElem.attr( 'id' ).split( "-" ).slice( -1 )[ 0 ];
            
                            $jqSlideElem.prepend(
                                '<div class="gallery2__item__iframe-wrapper" id="gallery2__item__iframe-wrapper__' + intFileIndex + '">' +
	                                '<div class="gallery2__item__iframe-loading">' +
    		                            '<span class="gallery2__vertical-helper"></span>' +
    		                            '<div class="gallery2__item__iframe-loading__wrapper">' +
	            		                    '<i class="fa fa-spinner fa-spin gallery2__item__iframe-loading__icon"></i>' +
    	                            		'<span class="gallery2__item__iframe-loading__text">Wait while the preview is being created.<br/> This will take longer for large files. Download to view the original.</span>' +
	                            		'</div>' +
                    	            '</div>' +
                        	        '<iframe src=""></iframe>' +
                                '</div>'
                            );

                            var strPdfSrc;

                            if ( bolIsFileConvertableToPdf ) 
                            {
                                var strDateModified = ( typeof arrDatesModified != 'undefined' ? arrDatesModified[ intFileIndex ] : ( typeof arrModDate != 'undefined' ? arrModDate[ intFileIndex ] : '' ) );
                            	strPdfSrc = 'https://' + arrFileHost[ intFileIndex ] + '/api/file/get_thumb_pdf.php?i=' + arrHashes[ intFileIndex ] + '&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a&dm=' + strDateModified + '&v=102&n=' + arrDisplayNames[ intFileIndex ] + '.pdf';
                            }
                            else 
                            {
                            	strPdfSrc = 'https://' + arrFileHost[ intFileIndex ] + '/down.php?pdf=1&truemimetype=1&i=' + arrHashes[ intFileIndex ] + '&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a&n=' + arrDisplayNames[ intFileIndex ];
                            }
                            
                            // There is an issue if user on mobile Chrome requests desktop version, User-Agent becomes similar
                            let strChromeDesktopRegex = /^Mozilla\/5\.0\s+\(.*\)\s+AppleWebKit\/\d+\.\d+\s+\(KHTML,\s+like\s+Gecko\)\s+Chrome\/\d+\.\d+\.\d+\.\d+\s+Safari\/\d+\.\d+$/;
                            if ( strChromeDesktopRegex.test( navigator.userAgent ) && arrExtensions[ intFileIndex ] === 'pdf' )
                            {
                                var strDocumentIframeSource = encodeURI( strPdfSrc ) + '&view';
                            }
                            else
                            {
                                var strDocumentIframeSource = '/js/pdfjs-v4/web/viewer.html#' + encodeURI( strPdfSrc );
                            }
                            
                        	$.ajax(
                        	{
                                type: "GET",
                                url: strPdfSrc,
                                success: function()
                                {
                                    $( 'iframe', $jqSlideElem )
                                        .attr( 'src', strDocumentIframeSource )
                                        .addClass( 'gallery2__item__base-width-on' )
                                        .css(
                                        {
                                            'height': function()
                                            {
                                                return '100%';
                                            }
                                        } )
                                    .on( 'load', function ()
                                    {
                                        if ( ! bolSimpleDownloadAllowed )
                                        {
                                            $( this ).contents().find( '#print' ).hide();
                                            $( this ).contents().find( '#download' ).hide();
                                        }
                                    } );
                            	} ,
                            	error: function(data)
                            	{
                            		var stErrorText = 'Sorry, we were unable to create file preview. Please try again by refreshing the page or contact [email protected]. You can download the file to view it.';
                            		
                                	if ( data.status == 405 )
                                	{
                                		stErrorText = 'There is no preview available for this file. Download the file to view it.';
                                	}

                                	$( 'iframe', $jqSlideElem ).replaceWith(
                                    	'<div class="gallery2__item__msg_has_no_preview">' + 
	                                    	'<span class="gallery2__vertical-helper"></span>' +
    	                                	'<div>' + stErrorText + '</div>' +
	                                	'</div>'
                                	);

                                	$( '.gallery2__item__msg_has_no_preview' )
                                        .addClass( 'gallery2__item__base-width-on' )
                                        .css(
                                        {
                                            'height': function()
                                            {
                                                return '100%';
                                            }
                                        } );

                                    $( '.gallery2__item__iframe-loading', $jqSlideElem ).hide();
                            	}
                            } );
                        } ).apply( $jqSlideElem );
                    }
                }
                else if (
                            [ 'txt', 'csv' ].indexOf( arrExtensions[ intFileIndex ] ) !== -1
                            && arrFeeDownloadPrice[ intFileIndex ] == null
                            && ! currentFolderHasFeeDownload( intFileIndex )
                            && arrAllowDownload[ intFileIndex ]
                        )
                {
                    var fnLoadIframe = function ()
                    {
                        $( this ).attr( 'disabled', 'disabled' );
        
                        var $jqSlideElem = $( this ).closest( ".gallery2__item" );
                        var intFileIndex = $jqSlideElem.attr( 'id' ).split( "-" ).slice( -1 )[ 0 ];
        
                        $jqSlideElem.prepend( '<div class="gallery2__item__iframe-wrapper" id="gallery2__item__iframe-wrapper__' + intFileIndex + '"><div class="gallery2__item__iframe-loading"><span class="gallery2__vertical-helper"></span><i class="fa fa-spinner fa-spin"></i></div><iframe src="" class="modal_gallery_simple_iframe"></iframe><div class="gallery2__item__information-wrapper"><p class="gallery2__item__doc-filename">' + arrDisplayNames[ intFileIndex ] + '</p></div><div class="gallery2__item__desc-wrapper"><p class="gallery2__item__desc-wrapper-text">' + arrDescriptions[intFileIndex] + '</p></div></div>' );
        
                        arrIframeTimers[ intFileIndex ] = setTimeout( function ()
                        {
                            $( '#gallery2__item__iframe-wrapper__' + intFileIndex ).hide();
                        }, 30000 );

                       
                        $( 'iframe', $jqSlideElem )
                            .attr( 'src', 'https://' + arrFileHost[ intFileIndex ] + '/down.php?i=' + arrHashes[ intFileIndex ] + '&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a&plain_text&view&pv=1' )
                            .attr( 'onload', 'clearTimeout( arrIframeTimers[ ' + intFileIndex + ' ] );' )
                            .css({
                                'height': function(){
                                    return '100%';
                                },
                                "background": "white"
                            })
                            .addClass( 'gallery2__item__base-width-on' )
                    };
                    
                    fnLoadIframe.apply( $jqSlideElem );
                }
                // Highlighting code syntax
                else if (
                            [ 'asp','asm','c','h','cc','m','cpp','css','html','java','jsp','js','json','php','pl','py','rb','script','sh','vb','xml','ini' ].indexOf( arrExtensions[ intFileIndex ] ) !== -1
                            // Excluded extensions that highlight.js is not able to recognize and highlight properly
                            && [ 'asp', 'asm', 'm', 'script' ].indexOf( arrExtensions[ intFileIndex ] ) === -1
                            && arrFeeDownloadPrice[ intFileIndex ] == null
                            && ! currentFolderHasFeeDownload( intFileIndex )
                            && arrAllowDownload[ intFileIndex ]
                        )
                {
                    var fnLoadCode = function ()
                    {
                        $( this ).attr( 'disabled', 'disabled' );

                        var $jqSlideElem = $( this ).closest( ".gallery2__item" );
                        var intFileIndex = $jqSlideElem.attr( 'id' ).split( "-" ).slice( -1 )[ 0 ];

                        $jqSlideElem.prepend(
                            '<div class="gallery2__item__code-wrapper" id="gallery2__item__code-wrapper__' + intFileIndex + '">' +
                                '<div class="gallery2__item__code-loading">' +
                                    '<span class="gallery2__vertical-helper"></span>' +
                                    '<i class="fa fa-spinner fa-spin"></i>' +
                                '</div>' +
                                '<div class="modal_gallery_code_container" style="display: none;">' +
                                    '<pre>' +
                                        '<code></code>' +
                                    '</pre>' +
                                '</div>' +
                                '<div class="gallery2__item__information-wrapper">' +
                                    '<p class="gallery2__item__doc-filename">' +
                                        arrDisplayNames[ intFileIndex ] +
                                    '</p>' +
                                '</div>' +
                                '<div class="gallery2__item__desc-wrapper">' +
                                    '<p class="gallery2__item__desc-wrapper-text">' +
                                        arrDescriptions[ intFileIndex ] +
                                    '</p>' +
                                '</div>' +
                            '</div>'
                        );

                        $.ajax( {
                            type: 'GET',
                            url: 'https://' + arrFileHost[ intFileIndex ] + '/down.php?i=' + arrHashes[ intFileIndex ] + '&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a&code_highlighter&plain_text&view&pv=1',
                            success: function ( data ) {
                                var jqCodeContainer = $( '.modal_gallery_code_container', $jqSlideElem );
                                var jqCodeHighlightElem = $( 'pre code', jqCodeContainer );

                                jqCodeHighlightElem
                                    .text( data )
                                    .addClass( 'gallery2__item__base-width-on' );

                                // Forcing helper classname for highlight.js to properly detect syntax
                                let strHljsCodeClass;
                                switch ( arrExtensions[ intFileIndex ] )
                                {
                                    case 'js':
                                        strHljsCodeClass = 'language-javascript';
                                        break;

                                    case 'html':
                                        strHljsCodeClass = 'language-xml';
                                        break;

                                    case 'cc':
                                    case 'c':
                                    case 'h':
                                        strHljsCodeClass = 'language-cpp';
                                        break;

                                    case 'jsp':
                                        strHljsCodeClass = 'language-java';
                                        break;

                                    case 'pl':
                                        strHljsCodeClass = 'language-perl';
                                        break;

                                    case 'py':
                                        strHljsCodeClass = 'language-python';
                                        break;

                                    case 'rb':
                                        strHljsCodeClass = 'language-ruby';
                                        break;

                                    case 'sh':
                                        strHljsCodeClass = 'language-bash';
                                        break;

                                    case 'vb':
                                        strHljsCodeClass = 'language-vbnet';
                                        break;

                                    case 'php':
                                    case 'cpp':
                                    case 'css':
                                    case 'java':
                                    case 'json':
                                    case 'xml':
                                    case 'ini':
                                        strHljsCodeClass = 'language-' + arrExtensions[ intFileIndex ];
                                        break;
                                }

                                /*
                                    If new extension has been added to FILE_TYPE_CODE, highlight.js won't fail,
                                    it will try to determine to which file type the syntax looks most likely
                                    (out of available types in compiled highlight.min.js script)
                                */
                                if ( typeof( strHljsCodeClass ) !== 'undefined' )
                                {
                                    jqCodeHighlightElem.addClass( strHljsCodeClass );
                                }

                                hljs.highlightElement( jqCodeHighlightElem[ 0 ] );

                                if ( ! false )
                                {
                                    jqCodeHighlightElem.addClass( 'bx_allow_events' );
                                    $( '*', jqCodeHighlightElem ).addClass( 'bx_allow_events' );
                                }

                                jqCodeContainer.show();
                            },
                            error: function () {
                                $( '#gallery2__item__code-wrapper__' + intFileIndex ).hide();
                            },
                        } );
                    };

                    fnLoadCode.apply( $jqSlideElem );
                }
                else
                {
                    if (
                            arrFeeDownloadPrice[ intFileIndex ] == null 
                            && ! currentFolderHasFeeDownload( intFileIndex )
                            && arrSizesInBytes[ intFileIndex ] < 50 * 1024 * 1024 
                            && arrUploadPassword[ intFileIndex ] == '' 
                            && arrAccessType[ intFileIndex ] == 'LINK' 
                        )
                    {
                        var fnLoadIframe = function ()
                        {
                            $( this ).attr( 'disabled', 'disabled' );
            
                            var $jqSlideElem = $( this ).closest( ".gallery2__item" );
                            var intFileIndex = $jqSlideElem.attr( 'id' ).split( "-" ).slice( -1 )[ 0 ];
            
                            $jqSlideElem.prepend(
                                '<div class="gallery2__item__iframe-wrapper" id="gallery2__item__iframe-wrapper__' + intFileIndex + '">' + 
                                '<div class="gallery2__item__iframe-loading">' +
                                '<span class="gallery2__vertical-helper"></span>' + 
                                '<i class="fa fa-spinner fa-spin"></i>' + 
                                '</div>' + 
                                '<iframe src=""></iframe>' + 
                                '</div>'
                            );

                            arrIframeTimers[ intFileIndex ] = setTimeout( function ()
                            {
                                $( '#gallery2__item__iframe-wrapper__' + intFileIndex ).hide();
                            }, 30000 );


                            if ( arrExtensions[intFileIndex] == "dwg" || arrExtensions[intFileIndex] == "dxf" )
                            {
                                $.ajax( {
                                    type: "GET",
                                    url: "/api/embed_urls.php",
                                    data: {
                                        'i': arrHashes[ intFileIndex ]
                                    },
                                    success: function ( data )
                                    {
                                        data = JSON.parse( data );

                                        $( 'iframe', $jqSlideElem )
                                        .attr( 'src', 'https://sharecad.org/cadframe/load?url='+data[ 'path_access_url' ] )
                                        .attr( 'onload', 'clearTimeout( arrIframeTimers[ ' + intFileIndex + ' ] );' );
                                    }
                                } );
                            }
                            else if ( arrExtensions[intFileIndex] == "rtf" || arrSizesInBytes[ intFileIndex ] > 10 * 1024 * 1024 )
                            {
                                $( 'iframe', $jqSlideElem )
                                .attr( 'src', 'https://docs.google.com/viewerng/viewer?embedded=true&url=https://api.files.fm/down.php?i=' + arrHashes[ intFileIndex ] + '&gpv=1' )
                                .attr( 'onload', 'clearTimeout( arrIframeTimers[ ' + intFileIndex + ' ] );' );
                            }
                            else
                            {
                                $( 'iframe', $jqSlideElem )
                                .attr( 'src', 'https://view.officeapps.live.com/op/embed.aspx?src=https://api.files.fm/down.php?i=' + arrHashes[ intFileIndex ] + '&gpv=1' )
                                .attr( 'onload', 'clearTimeout( arrIframeTimers[ ' + intFileIndex + ' ] );' );
                            }

                            $( 'iframe', $jqSlideElem )
                            .css({
                                'height': function(){
                                    return '100%';
                                }
                            })
                            .addClass( 'gallery2__item__base-width-on' )
                    
                        };
                        
                        var jqPreviewButton = $( '<a />' ).attr( {
                            'href': 'javascript:void(0);',
                            'title': 'View',
                            'class': 'gallery2__item__doc-wrapper__download_button gallery2__save_button gallery2__item__doc-wrapper__download_button gallery2__preview_button'
                        } ).html( 'Preview this file' )
                            .click( function() {
                              
                                if ( arrExtensions[intFileIndex] == "dwg" || arrExtensions[intFileIndex] == "dxf" )
                                {
                                                                            showSignIn();
                                                                    }
                                else
                                {
                                    fnLoadIframe.apply( $jqSlideElem );
                                    var jqDownloadButton = $( '<a />' ).attr( {
                                        'href': 'javascript:void(0);',
                                        'onclick': 'modalGalleryDownloadFileBtn( "' + arrHashes[ intFileIndex ] + '" )',
                                        'title': 'Download',
                                        'class': 'gallery2__item__doc-wrapper__download_button gallery2__save_button'
                                    } ).html( 'Download original file' );

                                    $( '.gallery2__item__information-wrapper', $jqSlideElem ).append( jqDownloadButton );
                                }
                            } )
        
                        $( '.gallery2__item__information-wrapper', $jqSlideElem ).append( jqPreviewButton );
                    }
                }
                
                $(".gallery2__item__custom_thumb" ).each(function() 
                {
                    var objBackground = getBackgroundSize(this);    
                    if(objBackground.width>=$('#gallery2__image-wrapper').width())
                    {
                        objBackground.width=objBackground.width-20; 
                    }
                    $(this).siblings('.gallery2__item__desc-wrapper, .gallery2__item__information-wrapper').width( objBackground.width );
                    $(this).parent().siblings('.gallery2__item__desc-wrapper, .gallery2__item__information-wrapper').width( objBackground.width );
                }); 
                $("img").each(function() 
                {
                    var intImageWidth = $(this).width();
                    if(intImageWidth>=$('#gallery2__image-wrapper').width())
                    {
                        intImageWidth=intImageWidth-20; 
                    }
                    $(this).siblings('.gallery2__item__desc-wrapper, .gallery2__item__information-wrapper').width( intImageWidth );
                });      
                $("iframe", ".gallery2__item__iframe-wrapper" ).each(function() 
                {
                    var intIframeWidth = $(this).width();
                    if(intIframeWidth>=$('#gallery2__image-wrapper').width())
                    {
                        intIframeWidth=intIframeWidth-20;   
                    }
                    $(this).siblings('.gallery2__item__desc-wrapper, .gallery2__item__information-wrapper').width( intIframeWidth );
                });
                $( '.modal_gallery_code_container', '.gallery2__item__code-wrapper' ).each( function ()
                {
                    let intCodeContainerWidth = $( this ).width();
                    if( intCodeContainerWidth >= $( '#gallery2__image-wrapper' ).width() )
                    {
                        intCodeContainerWidth = intCodeContainerWidth - 20;
                    }
                    $( this ).siblings( '.gallery2__item__desc-wrapper, .gallery2__item__information-wrapper' ).width( intCodeContainerWidth );
                } );
                break;
    
            case 'video':
                var bolThisVideoUseEmbedPlayer = false;
        
                var strHtml = '';
                strHtml += '<span class="gallery2__vertical-helper"></span>';
                strHtml += '<div class="gallery2__video_container">';

                if ( useEmbedPlayer( intFileIndex ) )
                {
                    bolThisVideoUseEmbedPlayer = true;
                }
        
                strHtml += "<div class='gallery2__video_wrapper //'>";
    
                if ( !arrFileAttributes[ intFileIndex ][ 'canDownload' ] && ( arrFileAttributes[ intFileIndex ][ 'isForSale' ] || currentFolderHasFeeDownload( intFileIndex ) ) && !arrFileAttributes[ intFileIndex ][ 'hasPreviewVideo' ] )
                {
                    $jqSlideElem.append( '<span class="gallery2__vertical-helper">' );
                    $jqSlideElem.append( '<img src="/thumb_video_picture.php?i=' + arrHashes[ intFileIndex ] + '&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a">' );

                    var objVideoPlayBuyButton = $( '<span class="gallery2__video-play-button bx_allow_events">' );
                    
                    if ( bolIsOwner )
                    {
                        objVideoPlayBuyButton.attr( 'onclick', 'showSetPriceFormModal( strCurrentFileHash )' );
                    }
                    else if ( currentFolderHasFeeDownload( intFileIndex ) )
                    {
                        if ( typeof arrParentHashes != 'undefined' )
                        {
                            objVideoPlayBuyButton.attr( 'onclick', 'showBuyFileFormModal( arrParentHashes[ getItemIndex ( strCurrentFileHash ) ], "folder" )' );
                        }
                        else if ( typeof strUploadHash != 'undefined' )
                        {
                            objVideoPlayBuyButton.attr( 'onclick', 'showBuyFileFormModal( strUploadHash, "folder" )' );
                        }
                    }
                    else
                    {
                        objVideoPlayBuyButton.attr( 'onclick', 'showBuyFileFormModal( strCurrentFileHash )' );
                    }
                    
                    $jqSlideElem.append( objVideoPlayBuyButton );
                    
                    break;
                }
                
                if ( bolThisVideoUseEmbedPlayer )
                {
                    var strAutoload = 'off';

                	if ( arrExtensions[ intFileIndex ] == 'mp4' )
                	{
                		strAutoload = 'on';
                	}
                    
                    strHtml += '<div class="gallery2__video_container__embed_palyer">';
                    strHtml += '<script type="text/javascript" src="/embed/playerv2?hash=' + arrHashes[ intFileIndex ] + 
                        '&autoload=' + strAutoload + '&autoplay=off&w=auto&h=auto&poster_src=/thumb_video_picture.php?i=' + arrHashes[ intFileIndex ] + '&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a' +
                        '" ' +
                        'id="filesfm_embed_js__' + arrHashes[ intFileIndex ] + '"><' + '/script>';
                    strHtml += '</div>';
                }
                else
                {
                    var strVideoSrc = 'https://' + arrFileHost[ intFileIndex ]  + '/thumb_video/' + arrHashes[ intFileIndex ] + '' + strHttpCacheKey + '.mp4?v=1728930636&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a';

                    
                        if (
                                (
                                    arrExtensions[ intFileIndex ] == 'mp4'
                                    || arrMOVsWithH264Hashes.includes( arrHashes[ intFileIndex ] )
                                )
                                // If the video does not have a preview (0) or preview is being generated (2)
                                && [ 0, 2 ].includes( arrFileAttributes[ intFileIndex ][ 'hasVideoThumb' ] )
                                && arrFeeDownloadPrice[ intFileIndex ] == null
                                && ! currentFolderHasFeeDownload( intFileIndex )
                            )
                        {
                            // If the video does not have a preview
                            if ( ! arrFileAttributes[ intFileIndex ][ 'hasVideoThumb' ] )
                            {
                                // Send a request with an empty callback just to trigger generation of preview video
                                $.get( strVideoSrc, function() {} );
                            }

                            strVideoSrc = 'https://' + arrFileHost[ intFileIndex ]  + '/down.php?i=' + arrHashes[ intFileIndex ] + '&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a&pv=1&' + strHttpCacheKey + '.mp4';
                        }

                                     
                    strHtml += '<video playsinline id="video_' + arrHashes[ intFileIndex ] + '" preload="none">';
                    strHtml += '<div class="video_thumb_gen" style="visibility: hidden;" id="video_thumb_gen_' + arrHashes[ intFileIndex ] + '">Video preview is being created,<br /> please wait!<br /><br /><i class="fa fa-spin fa-spinner"></i></div>';
                    strHtml += '<source src="' + strVideoSrc + '" type="video/mp4" label="Preview" selected="true">';

                    if (
                            (
                                arrExtensions[ intFileIndex ] == 'mp4'
                                || arrMOVsWithH264Hashes.includes( arrHashes[ intFileIndex ] )
                            )
                            && arrFileAttributes[ intFileIndex ][ 'hasVideoThumb' ] == 1
                        )
                    {
                        var strOriginalVideoSrc = 'https://' + arrFileHost[ intFileIndex ]  + '/down.php?i=' + arrHashes[ intFileIndex ] + '&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a&pv=1&' + strHttpCacheKey + '.mp4';

                        strHtml += '<source src="' + strOriginalVideoSrc + '" type="video/mp4" label="Original">';
                    }

                    strHtml += 'Your browser does not support the video tag.';
                    strHtml += '</video>';
                    strHtml += '<script type="text/javascript">';
                    strHtml += 'document.getElementById("video_' + arrHashes[ intFileIndex ] + '").addEventListener("error", function(){' +
                        '        var me_ = this;' +
                        '        if (me_.src.indexOf("' + arrHashes[ intFileIndex ] + '") === -1) return;' +
                        '        last_video_src = me_.src;' +
                        '        me_.src = "";' +
                        '        setTimeout(function(){me_.src=last_video_src}, 2000);' +
                        '    });';
                    strHtml += '<'+'/script>';
                }

                strHtml += "<div class='gallery2__video_wrapper_bottom'>";
                strHtml += '</div>';
                strHtml += "</div>";

                strHtml += "</div>";

                $jqSlideElem.append( strHtml );

                if ( arrFileTypes[ intFileIndex ] === 'video' )
                {
                    if ( !useEmbedPlayer( intFileIndex ) )
                    {
                        initVideoPlayer( intFileIndex );
                    }
                }
                break;
    
            case 'audio':
                
                    if ( arrAllowDownload[ intFileIndex ] || ( false && arrFileAttributes[ intFileIndex ].hasPreviewVideo ) || arrFileAttributes[ intFileIndex ].readOnly || arrFileAttributes[ intFileIndex ].hasPreviewVideo || 
                    ( typeof PublicProfile != 'undefined' && !(arrFeeDownloadPrice[intFileIndex] > 0 || currentFolderHasFeeDownload( intFileIndex ) )) )
                    {
                        var strAllHashes = '';
                        for ( var strHash in arrHashes )
                        {
                            strAllHashes += ',' + strHash;
                        }
                        if( objAudioPlayer === null || ( objAudioPlayer.getAllUploadFileHashes() !== strAllHashes ) )
                        {
                            if ( objAudioPlayer !== null )
                            {
                                objAudioPlayer.destroy();
                                objAudioPlayer = null;
                            }

                            objAudioPlayer = new AudioPlayer();
                            objAudioPlayer.loadTracksFromGlobalArrays();
                            if ( objMainShareParams != null && typeof( objMainShareParams['all_files'] ) !== 'undefined')
                            {
                                if ( typeof PublicProfile != 'undefined' && PublicProfile.openFolderDisplayName != '' )
                                {
	                            	objAudioPlayer.setPlayListTitle( PublicProfile.openFolderDisplayName );
                                }
                                else if ( typeof PublicProfile != 'undefined' && PublicProfile.strProfileName != '' )
                                {
	                            	objAudioPlayer.setPlayListTitle( PublicProfile.strProfileName );
                                }
                                else
                                {
	                                objAudioPlayer.setPlayListTitle( strFolderName );
                                }
                            }
                            objAudioPlayer.setCurrentTrackByHash( arrHashes[ intFileIndex ] );
                            objAudioPlayer.setAllUploadFileHashes( strAllHashes );
                            objAudioPlayer.setIsPlayerForOneFile( arrHashes.length == 1 );
                            objAudioPlayer.getElem().addEventListener( 'audioTrackLoaded', function ( data )
                                {
                                    var hash = data.detail.strHash;
                                    
                                    if( arrHashes.indexOf( hash ) !== -1 && arrHashes[ intCurrentFileIndex ] !== hash )
                                    {
                                        galleryChangeLocation ( getItemLink( hash ) );
                                    }
                                }
                            );
                            objAudioPlayer.getElem().addEventListener( 'audioTrackLikeChange', function ( data )
                                {
                                    var hash = data.detail.track.strHash;
                                    var bolState = data.detail.state;
                                    var intFileIdx;
        
                                    if ( strCurrentFileHash === hash )
                                    {
                                        intFileIdx = intCurrentFileIndex;
                                    }
                                    else
                                    {
                                        for ( var i in arrHashes )
                                        {
                                            if ( arrHashes.hasOwnProperty( i ) && arrHashes[ i ] === hash )
                                            {
                                                intFileIdx = +i;
                                                break;
                                            }
                                        }
                                    }
        
                                    bolState ? arrVoteCounts[ intFileIdx ]++ : arrVoteCounts[ intFileIdx ]--;
                                    arrHasVoted[ intFileIdx ] = bolState ? 1 : 0;
                                    galleryUpdateVoteCount();
                                }
                            );
                            objAudioPlayer.getElem().addEventListener( 'audioTrackEnded', function ( data )
                                {
                                    if ( bolGalleryIsVisible )
                                    {
                                        var intNextSlideIndex = intNextIndex;

                                        if(intNextIndex == null || isNaN( intNextIndex ) && arrHashes[0] != null)
                                        {
                                            intNextSlideIndex = getItemIndex ( arrHashes[0] );
                                        }

                                        if ( intNextSlideIndex != null && !isNaN( intNextSlideIndex ) )
                                        {
                                            if (strSlideshowInterval === 'reset')
                                            {
                                                objAudioPlayer._isSlideshowOn = false;
                                                galleryChangeLocation ( getItemLink ( arrHashes[intNextSlideIndex] ) );
                                            }
                                        }
                                    }
                                    
                                }
                            );
                        }
                        $jqSlideElem.append( "<span class=\"gallery2__vertical-helper\"></span>" );
                        var jqItemAudioWrapper = $( "<div class=\"gallery2__item__audio-wrapper\"></div>" );

                        jqItemAudioWrapper.appendTo( $jqSlideElem );

                        objAudioPlayer.appendTo( jqItemAudioWrapper );
	                }
	                else
	                {
	                    var jqThumb = $( '<i />' ).addClass( 'fa-5x fa ' + arrIconClass[intFileIndex] );
                        if ( typeof( arrIconSvg ) !== 'undefined' && arrIconSvg[ intFileIndex ] )
                        {
                            jqThumb = $( '<img />' ).attr('src', '/images/file_types_v2/' + arrIconSvg[ intFileIndex ]).addClass('ext-icon');
                        }
	                    $jqSlideElem.append( '<span class="gallery2__vertical-helper"></span><span class="gallery2__item__doc-wrapper"></span>' );
	                    $( '.gallery2__item__doc-wrapper', $jqSlideElem ).append( jqThumb );
	                    $( '.gallery2__item__doc-wrapper', $jqSlideElem ).append( '<div class="gallery2__item__information-wrapper"><p class="gallery2__item__doc-filename">' + arrDisplayNames[intFileIndex] + '</p></div>' );
                        if( arrDescriptions[intFileIndex] )
                        {
                            $( '.gallery2__item__doc-wrapper', $jqSlideElem ).append( '<div class="gallery2__item__desc-wrapper"><p class="gallery2__item__desc-wrapper-text">' + arrDescriptions[intFileIndex] + '</p></div>');
	                    }
	                }
                    
                    function updateAudioDescriptionWidth()
                    {
                        $('i, .audio_player ').each(function()
                        {
                            var intVideoWidth = $(this).outerWidth();
                            if(intVideoWidth>=$('#gallery2__image-wrapper').width())
                            {
                                intVideoWidth=intVideoWidth-20;   
                            }
                            $(this).parent().find('.gallery2__item__desc-wrapper, .gallery2__item__information-wrapper').width(intVideoWidth);
                        });        
                    }
                    updateAudioDescriptionWidth();
                break;

                case 'image-raw':
                        
                    // Main container for file info/buttons/etc.
                    var $jqMainContainerHelper = $( '<span class="gallery2__vertical-helper"></span>' );
                    var $jqMainContainer = $( '<span class="gallery2__item__doc-wrapper"></span>' );

                    // Icon container
                    var $jqIconContainer = $( '<span class="gallery2__item__doc-icon ' + arrExtensions[ intFileIndex ].toLowerCase() + '"></span>' );

                    // File type icon
                    var $jqIcon = $('<i class="fa-5x fa ' + arrIconClass[ intFileIndex ] + '"></i>');
                    if ( typeof( arrIconSvg ) !== 'undefined' && arrIconSvg[ intFileIndex ] )
                    {
                        $jqIcon = $( '<img />' ).attr('src', '/images/file_types_v2/' + arrIconSvg[ intFileIndex ]).addClass('ext-icon');
                    }
                    $jqIconContainer.append($jqIcon);

                    // Loading icon
                    var $jqLoadingIcon = $('<i class="fa-5x fa fa-spinner fa-spin"></i>').hide();
                    $jqIconContainer.append($jqLoadingIcon);

                    // Error icon
                    var $jqErrorIcon = $('<i class="fa-5x fa fa-times"></i>').hide();
                    $jqIconContainer.append($jqErrorIcon);

                    // Add the icon container to the main container
                    $jqMainContainer.append( $jqIconContainer );

                    // Filename
                    var $jqFileName = $( '<p class="gallery2__item__doc-filename">' + arrDisplayNames[ intFileIndex ] + '</p>' );
                    $jqMainContainer.append( $jqFileName );

                    // A container for buttons/actions
                    var $jqButtonContainer = $('<div />').css({'white-space': 'normal'});
        
                    // Download button 
                    var $jqDownloadButton = $( '<a />' ).attr( {
                        'href': 'javascript:void(0);',
                        'onclick': 'modalGalleryDownloadFileBtn( "' + arrHashes[ intFileIndex ] + '" )',
                        'title': 'Download',
                        'class': 'gallery2__item__doc-wrapper__download_button gallery2__save_button'
                
                    } ).html( 'Download original file' );

                    // Add the download button to the button container
                    $jqButtonContainer.append( $jqDownloadButton );
                    
    
                    // Holds the load image timeout
                    var intLoadImageTimeout;

                    // Holds the image
                    var $jqImg;

                    var fnLoadImageFailed = function()
                    {
                        clearTimeout(intLoadImageTimeout);
                        $jqImg.remove();

                        $jqIcon.hide();
                        $jqErrorIcon.show();
                        $jqLoadingIcon.hide();
                    }
                    
                    var fnLoadImageSucceeded = function()
                    {
                        clearTimeout(intLoadImageTimeout);

                        $jqMainContainer.empty().append($jqImg);
                    }

                    var fnLoadImage = function()
                    {
                        $jqPreviewButton.hide();

                        $jqIcon.hide();
                        $jqErrorIcon.hide();
                        $jqLoadingIcon.show();

                        var strImageURL = 'https://'+ arrFileHost[ intFileIndex ] +'/thumb_show.php?i=' + arrHashes[intFileIndex] + '&view&v=1&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a';
                        if (arrFeeDownloadPrice[intFileIndex] > 0 || currentFolderHasFeeDownload( intFileIndex ) )
                        {
                            strImageURL += '&wm=103';
                        }

                        if ( typeof( arrFileVersion ) != 'undefined' && typeof( arrFileVersion[ intFileIndex ] ) != 'undefined' && arrFileVersion[ intFileIndex ] > 0 )
                        {
                            strImageURL += '&version=' + arrFileVersion[ intFileIndex ];
                        }

                        $jqImg = $('<img>').attr('src', strImageURL);

                        intLoadImageTimeout = setTimeout(function() {
                            fnLoadImageFailed();
                        }, 30000);

                        $jqImg.on('load', function() 
                        {
                            if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) 
                            {
                                fnLoadImageFailed();
                            } else {
                                fnLoadImageSucceeded();
                            }
                        });
                        
                    }

                    var $jqPreviewButton = $( '<a />' );

                    $jqPreviewButton.attr( {
                                'href': 'javascript:void(0);',
                                'title': 'Download',
                                'class': 'gallery2__item__doc-wrapper__download_button gallery2__save_button gallery2__item__doc-wrapper__download_button gallery2__preview_button'
                            } );
                    
                    $jqPreviewButton.css( "marginLeft", "0px" );

                    $jqPreviewButton.html( 'Preview this file' );
                    
                    $jqPreviewButton.click( function() { fnLoadImage(); } );
                                
                    
                    $jqButtonContainer.append("<br />");

                    // Add the preview button to the button container
                    $jqButtonContainer.append( $jqPreviewButton );


                    // Add the buttons container to the main item info container
                    $jqMainContainer.append($jqButtonContainer);

                    // Add the helper and the main container to the DOM
                    $jqSlideElem.append( $jqMainContainerHelper );
                    $jqSlideElem.append( $jqMainContainer );


                    break;

                case 'url' :
                {
            		var jqThumb;
                    
                    if ( arrFileAttributes[ intFileIndex ][ 'hasCustomThumb' ] )
                    {
                        jqThumb = $( "<div>" ).css({
                            'background-image': 'url("/thumb.php?i=' + arrHashes[ intFileIndex ] + '&v=1")',
                            'height': function(){
                            }
                        })
                        .addClass( 'gallery2__item__custom_thumb gallery2__item__base-width-on' );
                    }
                    else
                    {
                        jqThumb = $( '<i />' ).addClass( 'fa-5x fa ' + arrIconClass[intFileIndex] );
                        if ( typeof( arrIconSvg ) !== 'undefined' && arrIconSvg[ intFileIndex ] )
                        {
                            jqThumb = $( '<img />' ).attr('src', '/images/file_types_v2/' + arrIconSvg[ intFileIndex ]).addClass( 'gallery2__item__base-width-on ext-icon' );
                        }
                    }

                    if ( arrFeeDownloadPrice[intFileIndex] > 0 )
                    {
                    	if (bolIsOwner)
                        {
                            jqThumb.attr( 'onclick', 'showSetPriceFormModal(strCurrentFileHash)' );
                        }
                        else 
                        {
                            jqThumb.attr( 'onclick', 'showBuyFileFormModal(strCurrentFileHash)' );
                        }
                    	jqThumb.addClass( 'bx_allow_events' );
                    	jqThumb.addClass( 'has_price' );
                    }


                    $jqSlideElem.append( '<span class="gallery2__vertical-helper"></span><span class="gallery2__item__doc-wrapper' + ( arrFileAttributes[ intFileIndex ][ 'hasCustomThumb' ] ? ' has_custom_thumb' : '' ) + '"></span>' );
                    $( '.gallery2__item__doc-wrapper', $jqSlideElem ).append( jqThumb );
                    
        
                    var jqButtonContainer = $('<div />').css({'white-space': 'normal'});

                    if ( arrFeeDownloadPrice[ intFileIndex ] == null && ! currentFolderHasFeeDownload( intFileIndex ) )
                	{
                        var $jqSlideElem = $( $jqSlideElem ).closest( ".gallery2__item" );
                        var intFileIndex = $jqSlideElem.attr( 'id' ).split( "-" ).slice( -1 )[ 0 ];
            			
                        $jqSlideElem.prepend( '<div class="gallery2__item__iframe-wrapper" id="gallery2__item__iframe-wrapper__' + intFileIndex + '"><div class="gallery2__item__iframe-loading"><span class="gallery2__vertical-helper"></span><i class="fa fa-spinner fa-spin"></i></div><iframe class="gallery2__item__base-width-on" src=""></iframe><div class="gallery2__item__desc-wrapper"><p class="gallery2__item__desc-wrapper-text">' + arrDescriptions[intFileIndex] + '</p></div></div>' );
            			
                        arrIframeTimers[ intFileIndex ] = setTimeout( function ()
                        {
                            $( '#gallery2__item__iframe-wrapper__' + intFileIndex ).hide();
                        }, 30000 );
    
                        $.get( 'https://'+ arrFileHost[ intFileIndex ]  + '/down.php?i=' + arrHashes[ intFileIndex ] + '&gpv=1&view=1&truemimetype=1&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a', function( strFileContent )
                        {
                        	$( 'iframe', $jqSlideElem )
                                .attr( 'src', strFileContent )
                                .attr( 'onload', 'clearTimeout( arrIframeTimers[ ' + intFileIndex + ' ] );' )
                                .css({
                                    'height': function()
                                    {
                                        if ( arrDescriptions[intFileIndex] )
                                        {
                                            return 'calc( 100% - 60px )';
                                        }
                                        else 
                                        {
                                            return 'calc( 100% - 60px )';
                                        }
                                    },
                                    "background": "white",
                                })
                    	} );
                	} 
                    else 
                    {
                        $( '.gallery2__item__doc-wrapper', $jqSlideElem ).append( '<div class="gallery2__item__information-wrapper"><p class="gallery2__item__doc-filename">' + arrDisplayNames[intFileIndex] + '</p></div>' );
                        $( '.gallery2__item__doc-wrapper', $jqSlideElem ).append( '<div class="gallery2__item__desc-wrapper"><p class="gallery2__item__desc-wrapper-text">' + arrDescriptions[intFileIndex] + '</p></div>');
                    }
                    if( !arrDescriptions[intFileIndex] )
                    {
                        $('.gallery2__item__desc-wrapper', $jqSlideElem).hide();
                    }
                    
                    function updateURLDescriptionWidth()
                    {
                        $(".gallery2__item__base-width-on" ).each(function() {
                            switch(this.tagName) 
                            {
                                case 'IMG':
                                    intElementWidth =  $( this ).width();
                                    break;
                                case 'DIV':
                                    var objBackground = getBackgroundSize(this);
                                    intElementWidth = objBackground.width;
                                    break;
                                case 'IFRAME':
                                    intElementWidth =  $( this ).width();
                                    break;
                                default:
                                    intElementWidth =  $( this ).width();
                                    break;
                            }
                            if(intElementWidth>=$('#gallery2__image-wrapper').width())
                            {
                                intElementWidth=intElementWidth-20;   
                            }
                            $(this).siblings('.gallery2__item__desc-wrapper, .gallery2__item__information-wrapper').width( intElementWidth );   
                        }); 
                                   
                    }
                    updateURLDescriptionWidth();
                	break;
                }
        }

        if ( arrFileTypes[ intCurrentFileIndex ] !== 'audio' )
        {
            var jqPreviewButton = $( '<a />' ).attr( {
                'href': 'javascript:void(0);',
                'title': function() {
                            if (bolIsOwner)
                            {
                                return 'Sell';
                            }
                            else 
                            {
                                return 'Buy';
                            }
                        },
                'class': 'gallery2__buy_button',
                'style': "display:none;"
            } ).html( function(){
                if ( arrFeeDownloadPrice[ intCurrentFileIndex ] )
                    {
                        return 'Buy (' + arrFeeDownloadPrice[ intCurrentFileIndex ] + ' $)';
                    }
                    else 
                    {
                        return 'Buy';
                    }
            } )
                .click( function() { 
                    if (bolIsOwner)
                    {
                        return showSetPriceFormModal(strCurrentFileHash);
                    }
                    else 
                    {
                        return showBuyFileFormModal(strCurrentFileHash);
                    }
            } )

            $( '.gallery2__item__information-wrapper', $jqSlideElem ).append( jqPreviewButton );
        }
        
        if ($('.gallery2__item__information-wrapper', $jqSlideElem).find('.gallery2__preview_button').length<1) 
        {
            var jqDownloadButton = $( '<a />' ).attr( {
                'href': 'javascript:void(0);',
                'onclick': 'modalGalleryDownloadFileBtn( "' + arrHashes[ intFileIndex ] + '" )',
                'title': 'Download',
                'class': 'gallery2__item__doc-wrapper__download_button gallery2__save_button'
            } ).html( 'Download original file' );

            $( '.gallery2__item__information-wrapper', $jqSlideElem ).append( jqDownloadButton );
        }
        
        $('a', $jqSlideElem).addClass( 'bx_allow_events' );
        $('a', $jqSlideElem).find( "*" ).addClass( 'bx_allow_events' );
        $('.gallery2__video_downloadbutton', $jqSlideElem).find( "*" ).addClass( 'bx_allow_events' );

        $jqSlideElem.addClass( 'content_ready' );
    }

    function adjustDescriptionWidth() 
    {
        var intElementWidth;
        $(".gallery2__item__base-width-on").each(function() 
        {
            switch(this.tagName) 
            {
                case 'IMG':
                case 'IFRAME':
                    intElementWidth =  $( this ).width();
                    break;
                case 'DIV':
                    var objBackground = getBackgroundSize(this);
                    intElementWidth = objBackground.width;
                    break;
                default:
                intElementWidth =  $( this ).width();
                    break;
            }
            if(intElementWidth>=$('#gallery2__image-wrapper').width())
            {
                intElementWidth=intElementWidth-20;   
            }
            $(this).siblings('.gallery2__item__desc-wrapper, .gallery2__item__information-wrapper').width( intElementWidth );            
        });

        $('.vjs-poster, .filesfm__embed_player__container, .audio_player').each(function() 
        {
            intElementWidth =  $( this ).outerWidth();
            if(intElementWidth>=$('#gallery2__image-wrapper').width())
            {
                intElementWidth=intElementWidth-20;   
            }
            $(this).parent().parent().find('.gallery2__item__desc-wrapper, .gallery2__item__information-wrapper').width(intElementWidth);
        });
    }
    adjustDescriptionWidth();

    function resizeend()
    {
        adjustDescriptionWidth();
    }

    var intTimer;
    window.addEventListener('resize', function()
    {
        clearTimeout(intTimer);
        intTimer = setTimeout(resizeend, 300);
        adjustDescriptionWidth();
        checkThumbStripArrows();
    });
    
    function registerEmbedPlayerFileEventCallback( strFileHash, fncCallback )
    {
        var intEmbedPlayerFileIndex = getItemIndex ( strFileHash );
        if ( intEmbedPlayerFileIndex !== null && typeof fncCallback === 'function' )
        {
            objEmbedPlayerFileEventCallback[ intEmbedPlayerFileIndex ] = fncCallback;
        }
    }
    
    function callEmbedPlayerFileEventCallback( strEventCode, intFileIndex )
    {
        if ( typeof( objEmbedPlayerFileEventCallback[intFileIndex] ) === 'function' )
        {
            objEmbedPlayerFileEventCallback[intFileIndex]( strEventCode );
        }
    }
    
    function galleryOpenPrevItem()
    {
    	if ( intPreviousIndex != null && !isNaN( intPreviousIndex ))
		{
            galleryChangeLocation ( getItemLink ( arrHashes[intPreviousIndex] ) );
            adjustDescriptionWidth();
		}
	}
    function galleryOpenNextItem()
    {
    	if ( bolGalleryIsVisible && intNextIndex != null && !isNaN( intNextIndex ))
		{
            galleryChangeLocation ( getItemLink ( arrHashes[intNextIndex] ) );
            adjustDescriptionWidth();
		}
	}

	var resThumbLoadTimeout;

    function gallerySelectThumb( intItemIndex )
    {
		if ( bolGalleryIsVisible && bolGalleryInitalizedState < 1 )
		{
			// If dom not loaded yet, wait for it to load.
			setTimeout('gallerySelectThumb( '+ intItemIndex +' )', 100);
			return;
		}
		if (jqThumbViewport == null)
		{
			jqThumbViewport = $('#gallery2__thumb-strip');
		}
		var intViewportWidthPx = jqThumbViewport.width();

		if (jqThumbContainer == null)
		{
			jqThumbContainer = $('#gallery2__thumb-strip__inner');
		}

		var jqThumb = $('A.thumb_' + arrHashes[intItemIndex], jqThumbContainer);

		function onThumbReady()
        {
            var intThumbPossitionLeftPx = jqThumb.position().left;
            // If scrollable on mobile
            if (jqThumbViewport.css('overflow-x')=='auto')
            {
                var intThumbPossitionLeftPx = jqThumb[0].offsetLeft;
                var intThumbOffsetLeftPx = galleryCalculateOffset(jqThumb[0]).left;
                var intScrollLeft = jqThumbViewport.scrollLeft();

                var jqThImg = $('IMG', jqThumb);
                var intThisThumbWidth = intThumbWidth;
                
                if ( intThisThumbWidth < intThumbWidth )
                    intThisThumbWidth = intThumbWidth;

                if ( intThumbOffsetLeftPx + intScrollLeft > intViewportWidthPx + intScrollLeft - intThisThumbWidth )
                {
                    jqThumbViewport.scrollLeft( intThumbOffsetLeftPx + intScrollLeft - intViewportWidthPx + intThisThumbWidth );
                }
                else if (intThumbOffsetLeftPx < 0)
                {
                    jqThumbViewport.scrollLeft( intThumbPossitionLeftPx  );
                }

            }
            else
            {
                var intThumbOffsetLeftPx = jqThumb.offset().left;

                var jqThumbStrip = $('#gallery2__thumb-strip');
                var jqThumbStripInner = $('#gallery2__thumb-strip__inner');

                var intThumbWidthSum = 0;
                $('A', jqThumbStripInner).each(function (){
                    intThumbWidthSum += $(this).width();
                });

                var bolThumbsAreOutside = false;
                if (
                    jqThumbStrip.width() <= intThumbWidthSum
                )
                {
                    bolThumbsAreOutside = true;
                }

                if ( $( '#gallery2' ).hasClass( 'gallery__sidebar-visible' ) )
                {
                    intThumbOffsetLeftPx = intThumbOffsetLeftPx -360;
                }

                if ( ! bolThumbsAreOutside )
                {
                    jqThumbContainer.css({'left': '0px'});
                }
                else
                {
                    // If outside viewport
                    // If outside to the right
                    if ( intThumbOffsetLeftPx < 0 )
                    {
                        var jqThImg = $('IMG', jqThumb);
                        var intThisThumbWidth = intThumbWidth;
                        
                        if ( intThisThumbWidth < intThumbWidth )
                            intThisThumbWidth = intThumbWidth;

                        var intSetLeftPx = (-1*intThumbPossitionLeftPx + intThisThumbWidth );

                        if (intSetLeftPx > 0) 
                        {
                            jqThumbContainer.css({'left': 0});
                        } 
                        else 
                        {
                            jqThumbContainer.css({'left': intSetLeftPx + 'px'});
                        };
                       
                    }
                    // else - outside to left
                    else if ( intThumbOffsetLeftPx > intViewportWidthPx - 360 )
                    {

                        var jqThImg = $('IMG', jqThumb);
                        var intThisThumbWidth = intThumbWidth;
                        
                        if ( intThisThumbWidth < intThumbWidth )
                            intThisThumbWidth = intThumbWidth;

                        var intSetLeftPx = -1*intThumbPossitionLeftPx + intViewportWidthPx - intThisThumbWidth - intThumbWidth;

                        if (parseInt($('#gallery2__image-wrapper').width()) - parseInt($('#gallery2__thumb-strip__inner').width()) > intSetLeftPx) 
                        {
                            jqThumbContainer.css({'left': parseInt($('#gallery2__image-wrapper').width()) - parseInt($('#gallery2__thumb-strip__inner').width())})
                        } 
                        else 
                        {
                            jqThumbContainer.css({'left': intSetLeftPx + 'px'});
                        };
                    }
                }
                checkThumbStripArrows();
            }

            $('A.active', jqThumbContainer).removeClass('active');
            jqThumb.addClass('active');

            setTimeout("checkThumbStripArrows()", 500);
            setTimeout("galleryLazyloadRecalc()", 500);
        }

        if ( $('IMG', jqThumb).length===0 || ( $('IMG', jqThumb)[0].complete && $('IMG', jqThumb).attr('src')===$('IMG', jqThumb).attr('data-original') ) )
        {
            onThumbReady();
        }
        else
        {
            $('IMG', jqThumb).on('load', function (){
                if ($(this).attr('src') === $(this).attr('data-original'))
                {
                    onThumbReady();
                }
            });

            var intElementIndex = jqThumb.index();
            if (jqThumbViewport.css('overflow-x') == 'auto')
            {
                jqThumbViewport.scrollLeft(intElementIndex * intThumbWidth);
            }
            else
            {
                jqThumbContainer.css({'left': (-1 * (intElementIndex + 2) * intThumbWidth) + 'px'});
            }

            galleryLazyloadRecalc();
            setTimeout( function (){ galleryLazyloadRecalc(); }, 1000);
            setTimeout( function (){ galleryLazyloadRecalc(); }, 5000);
        }
	}
    
    function closeGallery(strScrollHash)
    {
        if ( ! bolGalleryIsVisible )
            return;

        $( 'html' ).css( 'overflow', 'auto' );
        $( '#gallery2' ).fadeOut( 'fast' );

        $('#gallery_panzoomdiv').css('display', 'none');
        $('#gallery2__content-wrapper').removeClass( 'gallery__only_image' );
        $('#gallery2__content-wrapper').removeClass( 'gallery__is_image' );
        
                    exitSlideshow();
        
        if(bolPopupOnlyGallery)
        {
            hideModal( 'popup_form' );
        }
        
        if ( strGalleryCloseHashtag )
        {
            window.location.hash = strGalleryCloseHashtag;
        }
		else
		{
            if ( window.location.href.indexOf( "filebrowser" ) !== -1 )
            {
                var intIndexOfView = window.location.hash.indexOf(';/view/');
                if (intIndexOfView == -1)
                {
                    intIndexOfView = window.location.hash.indexOf('/view/');
                    if (intIndexOfView == -1)
                    {
                        intIndexOfView = window.location.hash.length;
                    }
                }
    
                history.replaceState( null, '', ('' + window.location).split('#')[0] + window.location.hash.slice(0, intIndexOfView))
            }
            else
            {
                                history.replaceState( 'gallery', document.title, ('' + window.location).split('#')[0] );
                            }
		}
        
		bolGalleryIsVisible = false;
        strCurrentFileHash = null;

		stopActiveContent();
		
		if ($('#share_popup').is(":visible"))
        {
            hideSharePopup();
        }
    
        if ( typeof window.FileEmbedPopup !== 'undefined' )
        {
            window.FileEmbedPopup.hidePopup();
        }
        
                
        if ( strActiveCommentsEntityHash != "" ) {
            ChatFM.resetChat();
            strActiveCommentsEntityHash = "";
        }


        
        if($("#item_"+strScrollHash).length)
        {
            if ( window.location.href.indexOf( "filebrowser" ) !== -1 )
            {
                var myElem = document.getElementById("item_"+strScrollHash);
                let topOffset = myElem.getBoundingClientRect().top;

                while (myElem != document.documentElement) {
                    myElem = myElem.parentElement;
                    topOffset += myElem.scrollTop;
                }
                
                $(".main_content").animate({scrollTop: topOffset - $(".main_content").height() / 2});
            }
            else
            {
                $(document.body).animate({
                    scrollTop: $("#item_"+strScrollHash).offset().top - window.innerHeight / 2
                }, 1000);
            }
            $("#item_"+strScrollHash).addClass('active-hover');
        }

        if($('.hide-not-selected').length && typeof showSelectedFiles === 'function')
        {
            showSelectedFiles();
        }

    }

            function nextSlide()
        {
            if ( bolGalleryIsVisible )
            {
                var intNextSlideIndex = intNextIndex;

                if(intNextIndex == null || isNaN( intNextIndex ) && arrHashes[0] != null)
                {
                    intNextSlideIndex = getItemIndex ( arrHashes[0] );
                }

                if ( intNextSlideIndex != null && !isNaN( intNextSlideIndex ) )
                {
                    if(arrFileTypes[intNextSlideIndex] == 'image')
                    {
                        var domImg = document.getElementById('main_image_'+ arrHashes[intNextSlideIndex]);
                        
                        if( domImg !== null )
                        {
                            if ( domImg.complete )
                            {
                                galleryChangeLocation ( getItemLink ( arrHashes[intNextSlideIndex] ), true );
                            }
                            else
                            {
                                clearInterval(strSlideshowInterval);
                                strSlideshowInterval = null;

                                domImg.onload = function () {
                                    galleryChangeLocation ( getItemLink ( arrHashes[intNextSlideIndex] ), true );
                                    if (!strSlideshowInterval)
                                    {
                                        strSlideshowInterval = setInterval(nextSlide, 4000);
                                    }
                                }
                            }
                        }
                        else
                        {
                            galleryChangeLocation ( getItemLink ( arrHashes[intNextSlideIndex] ), true );
                        }
                    }
                    else if ( arrFileTypes[intNextSlideIndex] == 'video' )
                    {
                        galleryChangeLocation ( getItemLink ( arrHashes[intNextSlideIndex] ), true );
                    }
                    else if ( arrFileTypes[intNextSlideIndex] == 'audio' )
                    {
                        galleryChangeLocation ( getItemLink ( arrHashes[intNextSlideIndex] ), true );
                    }
                    else
                    {
                        galleryChangeLocation ( getItemLink ( arrHashes[intNextSlideIndex] ), true );
                    }
                }
            }
        }
        function pauseSlideshow()
        {
            $('#gallery2__content-wrapper').addClass( 'gallery__slideshow_paused' );
            clearInterval(strSlideshowInterval);
            strSlideshowInterval = null;
        }
        function resumeSlideshow()
        {
            $('#gallery2__content-wrapper').removeClass( 'gallery__slideshow_paused' );
            if (!strSlideshowInterval)
            {
                strSlideshowInterval = setInterval(nextSlide, 4000);
            }
        }
        function exitSlideshow()
        {
            pauseSlideshow();
            $('#gallery2__content-wrapper').removeClass( 'gallery__slideshow_paused' );
            $('#gallery2__content-wrapper').removeClass( 'gallery__slideshow' );
            if (!((document.fullScreenElement !== undefined && document.fullScreenElement === null) || (document.msFullscreenElement !== undefined && document.msFullscreenElement === null) || (document.mozFullScreen !== undefined && !document.mozFullScreen) || (document.webkitIsFullScreen !== undefined && !document.webkitIsFullScreen)))
            {
                galleryToggleFullScreen(document.body)
            }
        }
        function enterSlideshow()
        {
            if($( '#gallery2__content' ).hasClass( 'gallery__sidebar-visible' ) )
            {
                showGalleryInfo();
                $(window).trigger('resize');
            }
            $('#gallery2__content-wrapper').addClass( 'gallery__slideshow' );
            galleryToggleFullScreen(document.body)
            resumeSlideshow();
        }
        function removeActiveClass()
        {
            $('#gallery2__content-wrapper').removeClass( 'gallery__slideshow_user_active' );
        }
    
    function showGalleryInfo()
    {
        var $gallery_content = $( '#gallery2__content' );
        if( $gallery_content.hasClass( 'gallery__sidebar__info-visible' ) && $gallery_content.hasClass( 'gallery__sidebar-visible' ) )
        {
        	bolGallerySidebarVisible = false;
            bolGalleryCommentsVisible = false;
            $gallery_content.removeClass( 'gallery__sidebar-visible' );
            $( '#gallery2' ).removeClass( 'gallery__sidebar-visible' );
        }
        else
        {
            $gallery_content.removeClass( 'gallery__sidebar__comments-visible' ).addClass( 'gallery__sidebar__info-visible' );

            if( !$gallery_content.hasClass( 'gallery__sidebar-visible' ) )
            {
                $gallery_content.addClass( 'gallery__sidebar-visible' );
                $( '#gallery2' ).addClass( 'gallery__sidebar-visible' );
            }
            
        	bolGallerySidebarVisible = true;
        	galleryLoadFileInfo();
        }
        
        adjustContentWidth(true);
        
        loadGalleryInfoAd();
    }

    function showGalleryMessages()
    {
        $( '#gallery2__content' ).addClass( 'gallery__sidebar__comments-visible' ).addClass( 'gallery__sidebar__info-visible' );
    }

    function hideGalleryMessages()
    {
        $( '#gallery2__content' ).removeClass( 'gallery__sidebar__comments-visible' ).addClass( 'gallery__sidebar__info-visible' );
    }
    
    var bolGalleryInfoAdLoaded = false;
    function loadGalleryInfoAd()
    {
    	if ( bolGalleryInfoAdLoaded ) return;
    	
    	if ( typeof fncDynamicLoadBanner_gallery2__sidebar__banner == 'function' )
    	{
	    	fncDynamicLoadBanner_gallery2__sidebar__banner();
    	}
    	
    	bolGalleryInfoAdLoaded = true;
    }

    function hideSidebar()
    {
        $( '#gallery2__content' ).removeClass( 'gallery__sidebar-visible' );
        $( '#gallery2' ).removeClass( 'gallery__sidebar-visible' );
        bolGallerySidebarVisible = false;
        bolGalleryCommentsVisible = false;
        adjustContentWidth(true);
    }

    function toggleThumbs()
    {
        $( '#gallery2__content' ).toggleClass( 'gallery__thumbs-visible' );
        
        // fire resize event after transition, so audio player knows to resize
        if( typeof objAudioPlayer !== "undefined" )
        {
            setTimeout( function() {
                var evt = document.createEvent('UIEvents');
                evt.initUIEvent('resize', true, false,window,0);
                window.dispatchEvent(evt);
            }, 300 );
        }
    }

    function hideThumbs()
    {
        $( '#gallery2__content' ).removeClass( 'gallery__thumbs-visible' );
        $( '#gallery2__thumb-strip__hide_container' ).hide();
    }

    function showThumbs()
    {
        $( '#gallery2__content' ).addClass( 'gallery__thumbs-visible' );
        $( '#gallery2__thumb-strip__hide_container' ).show();
    }
    

    function getItemLink ( strHash )
    {
    	var intIndex = null;
    	for (idx in arrIDs)
    	{
    		if (arrHashes[idx] == strHash)
    		{
    		 	intIndex = idx;
    		 	break;	
			}
		}
		
        
                
        
		var strHashtag = window.location.hash;
		var intIndexOfView = strHashtag.indexOf(';/view/');
		if (intIndexOfView != -1)
	    {
	    	strHashtag = strHashtag.slice(0, intIndexOfView);
		}
		else
		{
			var intIndexOfView = strHashtag.indexOf('/view/');
			if (intIndexOfView != -1)
		    {
	    		strHashtag = strHashtag.slice(0, intIndexOfView);
			}
		}
		var intIndexOfDelimiter = strHashtag.indexOf(';/view/');
		if (intIndexOfDelimiter != -1)
	    {
	    	strHashtag = strHashtag.slice(0, intIndexOfDelimiter);
		}
		
		strHashtag = strHashtag + ( bolHashtagViewUseSemicolon ? ';' : '') + '/view/' + arrHashes[intIndex];
		
		return strHashtag;
	}
    function getItemIndex ( strHash )
    {
    	var intIndex = null;
    	for (idx in arrIDs)
    	{
    		if (arrHashes[idx] == strHash)
    		{
    		 	intIndex = idx;
    		 	break;	
			}
		}
		return intIndex;
	}
	
    function getItemIndexByHashOrName ( strHashOrName )
    {
        if( typeof arrHashes === "undefined" )
        {
            return null;
        }
        // edit: before comparisons, urldecode both strings
        strHashOrName = decodeURIComponent( strHashOrName.replace( /\+/g, ' ' ) );
    	var intIndex = null;
        for (idx in arrHashes)
        {
            if ( decodeURIComponent( arrHashes[ idx ].replace( /\+/g, ' ' ) ) === strHashOrName )
            {
                intIndex = idx;
                break;
            }
        }

        if ( intIndex === null )
        {
            var intIndex = null;
            for (idx in arrNames)
            {
                if ( decodeURIComponent( arrNames[ idx ].replace( /\+/g, ' ' ) ) === strHashOrName )
                {
                    intIndex = idx;
                    break;
                }
            }
        }

		return intIndex;
	}

    function getNextIndex ( strHash )
    {
    	var intIndex = null;
    	var intNextIndex = null;
    	for (idx in arrIDs)
    	{
    		if ( intIndex !== null )
    		{
    			intNextIndex = idx;
    			break;	
			}
    		if (arrHashes[idx] == strHash)
    		{
    		 	intIndex = idx;
			}
		}
		return parseInt(intNextIndex);
	}

    function getPreviousIndex ( strHash )
    {
    	var intPreviousIndex = null;
    	for (idx in arrIDs)
    	{
    		if (arrHashes[idx] == strHash)
    		{
    		 	break;
			}
			else
			{
				intPreviousIndex = idx;
			}
		}
		return parseInt(intPreviousIndex);
	}
	
	function preloadImage ( intIndex )
	{
		if (typeof arrIsPreloaded == 'undefined')
			arrIsPreloaded = {};

		if (typeof arrIsPreloaded[intIndex] == 'undefined')
			arrIsPreloaded[intIndex]	

		if ( arrFileTypes[intIndex] == 'image' && arrIsPreloaded[intIndex] != true )
		{
			var strHash = arrHashes[intIndex];
			var strImageURL = 'https://'+ arrFileHost[ intIndex ] +'/thumb_show.php?i=' + strHash + '&view&v=1&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a';
			if (arrFeeDownloadPrice[intIndex] > 0 || currentFolderHasFeeDownload( intIndex ) )
			{
       			strImageURL += '&wm=103';
			}

            if ( typeof( arrFileVersion ) != 'undefined' && typeof( arrFileVersion[ intIndex ] ) != 'undefined' && arrFileVersion[ intIndex ] > 0 )
            {
                strImageURL += '&version=' + arrFileVersion[ intIndex ];
            }

			$("<img />").attr("src", strImageURL);
			arrIsPreloaded[intIndex] = true;
		}
	}
    
    function preloadFileInfoData( intIndex )
    {
        if ( ! bolUseAsyncFileInfoDataLoad )
        {
            return false;
        }
        
        if ( typeof arrIsFileInfoDataPreloaded == 'undefined' )
        {
            arrIsFileInfoDataPreloaded = [];
        }

        if ( ! arrIsFileInfoDataPreloaded[ intIndex ] )
        {
            var strHash = arrHashes[ intIndex ];

            $.ajax( {
                type : "POST",
                dataType : "json",
                url : "./ajax/modal_gallery/get_file_info_data.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
                data :
                {
                    'hash' : strHash
                } ,
                success : function( arrResponse )
                {
                    if ( arrResponse[ 'success' ] )
                    {
                        var arrFileInfoData = arrResponse[ 'data' ];
                        
                        if ( typeof arrFileTitle == 'undefined' ) arrFileTitle = [];
                        if ( typeof arrFileSubject == 'undefined' ) arrFileSubject = [];
                        if ( typeof arrFileContentType == 'undefined' ) arrFileContentType = [];
                        if ( typeof arrFileCategory == 'undefined' ) arrFileCategory = [];
                        if ( typeof arrFileCategories == 'undefined' ) arrFileCategories = [];
                        if ( typeof arrFileKeywords == 'undefined' ) arrFileKeywords = [];
                        if ( typeof arrFileCreator == 'undefined' ) arrFileCreator = [];
                        if ( typeof arrFilePublisher == 'undefined' ) arrFilePublisher = [];
                        if ( typeof arrFileContributor == 'undefined' ) arrFileContributor = [];
                        if ( typeof arrFileCopyrights == 'undefined' ) arrFileCopyrights = [];
                        if ( typeof arrFileLicenseType == 'undefined' ) arrFileLicenseType = [];
                        if ( typeof arrFileLicenseDetails == 'undefined' ) arrFileLicenseDetails = [];
                        if ( typeof arrFileLanguage == 'undefined' ) arrFileLanguage = [];
                        if ( typeof arrFileLocation == 'undefined' ) arrFileLocation = [];
                        if ( typeof arrFileLocationLat == 'undefined' ) arrFileLocationLat = [];
                        if ( typeof arrFileLocationLong == 'undefined' ) arrFileLocationLong = [];
                        if ( typeof arrFileReferences == 'undefined' ) arrFileReferences = [];
                        if ( typeof arrFileRelatesTo == 'undefined' ) arrFileRelatesTo = [];
                        if ( typeof arrFileFormat == 'undefined' ) arrFileFormat = [];
                        if ( typeof arrFileDevice == 'undefined' ) arrFileDevice = [];
                        if ( typeof arrFileSource == 'undefined' ) arrFileSource = [];
                        if ( typeof arrTags == 'undefined' ) arrTags = [];
                        if ( typeof arrObjectTags == 'undefined' ) arrObjectTags = [];
                        if ( typeof arrYoloObjectTags == 'undefined' ) arrYoloObjectTags = [];
                        if ( typeof arrLabelTags == 'undefined' ) arrLabelTags = [];
                        if ( typeof arrFileGoogleCVText == 'undefined' ) arrFileGoogleCVText = [];
                        if ( typeof arrFileEasyOCRText == 'undefined' ) arrFileEasyOCRText = [];
                        if ( typeof arrFileAudioTranscription == 'undefined' ) arrFileAudioTranscription = [];
                        
                        arrFileTitle[ intIndex ] = arrFileInfoData[ 'title' ];
                        arrFileSubject[ intIndex ] = arrFileInfoData[ 'subject' ];
                        arrFileContentType[ intIndex ] = arrFileInfoData[ 'contentType' ];
                        arrFileCategory[ intIndex ] = arrFileInfoData[ 'category' ];
                        arrFileCategories[ intIndex ] = arrFileInfoData[ 'categories' ];
                        arrFileKeywords[ intIndex ] = arrFileInfoData[ 'keywords' ];
                        arrFileCreator[ intIndex ] = arrFileInfoData[ 'creator' ];
                        arrFilePublisher[ intIndex ] = arrFileInfoData[ 'publisher' ];
                        arrFileContributor[ intIndex ] = arrFileInfoData[ 'contributor' ];
                        arrFileCopyrights[ intIndex ] = arrFileInfoData[ 'copyrights' ];
                        arrFileLicenseType[ intIndex ] = arrFileInfoData[ 'licenseType' ];
                        arrFileLicenseDetails[ intIndex ] = arrFileInfoData[ 'licenseDetails' ];
                        arrFileLanguage[ intIndex ] = arrFileInfoData[ 'language' ];
                        arrFileLocation[ intIndex ] = arrFileInfoData[ 'location' ];
                        arrFileLocationLat[ intIndex ] = arrFileInfoData[ 'locationLat' ];
                        arrFileLocationLong[ intIndex ] = arrFileInfoData[ 'locationLong' ];
                        arrFileReferences[ intIndex ] = arrFileInfoData[ 'references' ];
                        arrFileRelatesTo[ intIndex ] = arrFileInfoData[ 'relatesTo' ];
                        arrFileFormat[ intIndex ] = arrFileInfoData[ 'format' ];
                        arrFileDevice[ intIndex ] = arrFileInfoData[ 'device' ];
                        arrFileSource[ intIndex ] = arrFileInfoData[ 'source' ];
                        arrTags[ intIndex ] = arrFileInfoData[ 'tags' ];
                        arrObjectTags[ intIndex ] = arrFileInfoData[ 'objectTags' ];
                        arrYoloObjectTags[ intIndex ] = arrFileInfoData[ 'yoloObjectTags' ];
                        arrLabelTags[ intIndex ] = arrFileInfoData[ 'labelTags' ];
                        arrFileGoogleCVText[ intIndex ] = arrFileInfoData[ 'googleCVText' ];
                        arrFileEasyOCRText[ intIndex ] = arrFileInfoData[ 'easyOCRText' ];
                        arrFileAudioTranscription[ intIndex ] = arrFileInfoData[ 'audioTranscription' ];
                        
                        arrIsFileInfoDataPreloaded[ intIndex ] = true;
                    }
                } ,
                error : function() { }
            } );
        }
    }
	
	function checkBeforeContentChange ()
	{
		intNextIndex = getNextIndex ( strCurrentFileHash );
		intPreviousIndex = getPreviousIndex ( strCurrentFileHash );
		
		if ( intNextIndex != null && !isNaN( intNextIndex ) )
		{
			$('#gallery2__controls_right').show();
		}
		else
		{
			$('#gallery2__controls_right').hide();
		}
		
		if ( intPreviousIndex != null && !isNaN( intPreviousIndex ) )
		{
			$('#gallery2__controls_left').show();
		}
		else
		{
			$('#gallery2__controls_left').hide();
		}
	}
	
	function useEmbedPlayer( intFileIndex )
    {
	    
	    var bolUseEmbedPlayerForThisFiles = false;

	    if ( arrFileAttributes[ intFileIndex ][ 'readOnly' ] )
	    {
	    	bolUseEmbedPlayerForThisFiles = true;
	    }
	    else if (
                typeof ( bolUseEmbedPlayer ) == 'boolean' 
                && bolUseEmbedPlayer 
                && typeof ( bolIsAnonymousUpload ) == 'boolean' 
                && arrFeeDownloadPrice[ intFileIndex ] == null 
                && ! currentFolderHasFeeDownload( intFileIndex )
                && arrAllowDownload[ intFileIndex ] 
                && arrAllowPublicDownload[ intFileIndex ] 
            )
	    {
		    if ( ( [ 'm4a', 'webm', 'ogg' ] ).indexOf( arrExtensions[ intFileIndex ] ) !== -1 )
		    {
		    	bolUseEmbedPlayerForThisFiles = true;
		    }
		    else if ( arrExtensions[ intFileIndex ] == 'mp4' )
		    {
			    if ( arrViews[ intFileIndex ] < 1000 )
			    { 
			    	bolUseEmbedPlayerForThisFiles = false;
			    }
			    else 
			    {
			    	bolUseEmbedPlayerForThisFiles = true;
			    }
		    }
	    }

        return bolUseEmbedPlayerForThisFiles;
    }
	
	function checkAfterContentChange ()
	{
		if ( ! intNextIndex )
		{
			intNextIndex = getNextIndex ( strCurrentFileHash );
		}
		if ( ! intPreviousIndex )
		{
			intPreviousIndex = getPreviousIndex ( strCurrentFileHash );
		}
		
		if ( intNextIndex != null && !isNaN( intNextIndex ) )
		{
			$('#gallery2__controls_right').show();
		}
		else
		{
			$('#gallery2__controls_right').hide();
		}
		
		if ( intPreviousIndex != null && !isNaN( intPreviousIndex ) )
		{
			$('#gallery2__controls_left').show();
		}
		else
		{
			$('#gallery2__controls_left').hide();
		}
		
		// do preloading
		for (var int=0; int<intPreloadImagesCount; int++)
		{
			var intPrev = intPreviousIndex - int;
			if (intPrev  >= 0)
			{
				if ( arrFileTypes[intPrev] == 'image' )
				{
					setTimeout('preloadImage ('+intPrev+')',300);
				}
			}
			var intNext = intNextIndex + int;
			if (intNext  < arrHashes.length)
			{
				if ( arrFileTypes[intNext] == 'image' )
				{
					setTimeout('preloadImage ('+intNext+')',300);
				}
			}
		}

        for ( var int = 0; int < intPreloadFileInfoDataCount; int++ )
        {
            var intPrev = intPreviousIndex - int;
            
            if ( intPrev  >= 0 )
            {
                setTimeout( 'preloadFileInfoData(' + intPrev + ')', 300 );
            }
            
            var intNext = intNextIndex + int;
            
            if ( intNext  < arrHashes.length )
            {
                setTimeout( 'preloadFileInfoData(' + intNext + ')', 300 );
            }
        }
	}

    function galleryToggleFullScreen(elem)
	{
	    if ((document.fullScreenElement !== undefined && document.fullScreenElement === null) || (document.msFullscreenElement !== undefined && document.msFullscreenElement === null) || (document.mozFullScreen !== undefined && !document.mozFullScreen) || (document.webkitIsFullScreen !== undefined && !document.webkitIsFullScreen)) {
	        if (elem.requestFullScreen) {
	            elem.requestFullScreen();
	        } else if (elem.mozRequestFullScreen) {
	            elem.mozRequestFullScreen();
	        } else if (elem.webkitRequestFullScreen) {
	            elem.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
	        } else if (elem.msRequestFullscreen) {
	            elem.msRequestFullscreen();
	        }
	    } else {
	        if (document.cancelFullScreen) {
	            document.cancelFullScreen();
	        } else if (document.mozCancelFullScreen) {
	            document.mozCancelFullScreen();
	        } else if (document.webkitCancelFullScreen) {
	            document.webkitCancelFullScreen();
	        } else if (document.msExitFullscreen) {
	            document.msExitFullscreen();
	        }
	    }
	}

	function updateFileDescription()
	{
		$('#file_description_edit_wrapper').removeClass('has_error');
		
		$.ajax({
			type: "POST",
			dataType: "json",
			url: "./ajax/file_info.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
			data: 
			{
				'update_file_description': true ,
				'file_hash' : strCurrentFileHash ,
				'file_description' : $('#file_description_edit_wrapper textarea').val()
			} ,
			success: function(data)
			{
				if (data['status'] == 'ok')
				{
					var intItemIndex = getItemIndex(strCurrentFileHash);
					arrDescriptions[intItemIndex] = $('#file_description_edit_wrapper textarea').val();
				}
				else
				{
					$('#file_description_edit_wrapper').addClass('has_error');
				}
			} ,
			error: function()
			{
				$('#file_description_edit_wrapper').addClass('has_error');
			}
		});
	}

	function updateFileName()
	{
		$('#file_name_edit_wrapper').removeClass('has_error');
		
		$.ajax({
			type: "POST",
			dataType: "json",
			url: "./ajax/file_info.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
			data: 
			{
                'without_extension': 1 ,
				'update_file_name': true ,
				'file_hash' : strCurrentFileHash ,
				'file_name' : $('#file_name_edit_wrapper textarea').val()
			} ,
			success: function(data)
			{
				if (data['status'] == 'ok')
				{
					var intItemIndex = getItemIndex(strCurrentFileHash);
					arrDisplayNames[intItemIndex] = $('#file_name_edit_wrapper textarea').val();
                    $('.gallery2__header__file_name_value').html(arrDisplayNames[intItemIndex]);
                    $( '#gallery2__item-' + intItemIndex + ' .gallery2__item__doc-filename' ).html(arrDisplayNames[intItemIndex]);
				}
				else
				{
					$('#file_name_edit_wrapper').addClass('has_error');
				}
			} ,
			error: function()
			{
				$('#file_name_edit_wrapper').addClass('has_error');
			}
		});
	}

	function showOrginal(strCurrentFileHash) 
	{
	    var intFileIndex = getItemIndexByHashOrName( strCurrentFileHash );
		window.open('https://'+ arrFileHost[ intFileIndex ]  +'/down.php?i='+ strCurrentFileHash +'&view&n=' + arrDisplayNames[ intFileIndex ], '_blank');
	}


    function adjustContentWidth (bolOnResize)
    {
        var intGalleryHeight = $('#gallery2').height();
        var intGalleryWidth = $('#gallery2').width();

        var intImageWrapperWidth = intGalleryWidth;
        var intThumbStripWidth = intGalleryWidth;
        var intGalleryHeaderWidth = intGalleryWidth;
        var intBannerInnerPaddingTop = 0;

        var intBannerWidth = 0;
        var intBannerHeight = 0;
        var intLeftSideWidth = 0;
        if ( bolGallerySidebarVisible || bolGalleryCommentsVisible )
        {
            intLeftSideWidth = 360;
        }
            
        if (intGalleryWidth >= 800 && intGalleryHeight >= 600)
        {
            
            if (intGalleryHeight > ( 600 + 196 + 95 ) )
            {
                intBannerInnerPaddingTop = ( (intGalleryHeight - 600 - 196 - 95) / 2 ) + 196;
            }
            else 
            {
                intThumbStripWidth = intImageWrapperWidth;

                if (intGalleryHeight < (600 + 196) )
                {
                    intGalleryHeaderWidth = intImageWrapperWidth;
                    intBannerInnerPaddingTop = 0;
                }
                else
                {
                    intBannerInnerPaddingTop = 196;
                }
            }
        }
        else
        {
            intBannerWidth = 0;
        }
        
        intImageWrapperWidth = intGalleryWidth - intBannerWidth - intLeftSideWidth;
        
        $('#gallery2__image-wrapper').width(intImageWrapperWidth + 'px');

        $('#gallery2__thumb-strip').width(intThumbStripWidth + 'px');

        $('#gallery2__banner__inner').css('padding-top', intBannerInnerPaddingTop +'px');

        $('#gallery2__header').width(intGalleryHeaderWidth +'px');
        
        
        if (bolOnResize)
        {
            jqMainSlider.redrawSlider();
        }
    
        if ( arrFileTypes[ intCurrentFileIndex ] === "video" )
        {
            if ( !useEmbedPlayer( intCurrentFileIndex ) )
            {
                var $video = $( "#video_" + arrHashes[ intCurrentFileIndex ] );
                if( $video.length)
                {
                    fitVideoPlayer( $video );
                }
            }
        }
    }

    function repositionHeartButton ()
    {
        if ( ! jqMainSlider )
            return;

        if ( strCurrentFileHash !== arrHashes[ jqMainSlider.getCurrentSlide() ] )
            return;

        var jqImage = $('#main_image_' + arrHashes[ jqMainSlider.getCurrentSlide() ]);

        if ( jqImage.length )
        {
            var objImgPosition = jqImage.offset();
            $('#vote_heart_on_image').css({
                top: (jqImage[0].y + jqImage.height() -110) + 'px',
                left: (objImgPosition.left + jqImage.width() -50) + 'px'
            });

            if ( jqImage.attr('data-image-loaded') )
            {
                $('#vote_heart_on_image').show();
            }
        }
    }
    
	function recalculateGalleryForBanner(bolOnResize)
	{
        return adjustContentWidth (bolOnResize);
	}


    function modalGalleryDownloadFileP2PBtn( intItemIndex )
    {
        if ( typeof(bolHideDownloadButtons) !== 'undefined' && bolHideDownloadButtons )
        {
            return;
        }

        if ( ! bolIsListViewForSpecificFile )
        {
            window.location = '/f/' + arrHashes[ intItemIndex ] + '?start_p2p_download';
        }
        else
        {
    
            if (
                typeof ( objWebTorrentDownloadForm ) === 'object'
                && arrFeeDownloadPrice[ intItemIndex ] == null
                && ! currentFolderHasFeeDownload( intItemIndex )
                && arrAllowDownload[ intItemIndex ]
                && ( arrAccessType[ intItemIndex ] === 'LINK' || arrAccessType[ intItemIndex ] === 'PUBLIC' )
                && arrUploadPassword[ intItemIndex ] === ''
                && arrAllowPublicDownload[ intItemIndex ]
            )
            {
                var strFileExtension = arrExtensions[ intItemIndex ];
        
                var arrExecutableExtensions = ['exe','com','dll','pif','scr','bat','bin','pl','sh','scf','sct','shs','vb','lnk','jnlp','apk','vbs','js','msi','jse','jar','dmg','bin','wsf'];
        
                if ( arrExecutableExtensions.indexOf( strFileExtension ) === -1 )
                {
                    objWebTorrentDownloadForm.showForm( 'file', arrHashes[ intItemIndex ] );
                }
                else
                {
                    fConfirm( 'This file was checked with antivirus on the serverside, but executable files may contain potentially dangerous code that antivirus software is yet unable to detect. Use it only if you trust the sender. If not sure, use Virustotal.com to double-check. Do you want to save this file?', '', 'OK', 'Cancel', function ( r )
                    {
                        if ( r )
                        {
                            objWebTorrentDownloadForm.showForm( 'file', arrHashes[ intItemIndex ] );
                        }
                    } );
                }
            }
            else
            {
                modalGalleryDownloadFileBtn( arrHashes[ intItemIndex ] );
            }
        }
    }
    
    function modalGalleryDownloadFileBtn( strFileHash, strDownloadType="simple" )
    {
        var intItemIndex = getItemIndex( strFileHash );

        if ( typeof(bolHideDownloadButtons) !== 'undefined' && bolHideDownloadButtons )
        {
            return;
        }

        if ( typeof(arrHideDownloadButtons) !== 'undefined' && arrHideDownloadButtons[intItemIndex] )
        {
            return;
        }

        var intItemIndex = getItemIndex( strFileHash );

        
        
        
        var bolUserIsAuthenticated = false;
        
        if (
            typeof(arrForbidDirectDownload) != 'undefined'
            && typeof(arrForbidDirectDownload_Authenticated) != 'undefined'
            && arrForbidDirectDownload[ intItemIndex ]
        	&& ! arrForbidDirectDownload_Authenticated[ intItemIndex ]
            && ! bolUserIsAuthenticated
        )
        {
            if ( ! bolIsListViewForSpecificFile )
                closeGallery(strCurrentFileHash);
            
            var jqSigninErrorContainer = $('#signin-modal-content-error');
            
            $('.alert_main_text', jqSigninErrorContainer)
                .html('Direct download limit reached. Please, login or signup to directly download this file');
    
            jqSigninErrorContainer.show();
            
            showSignIn();
        
        }
        else if (
            typeof(arrForbidDirectDownload) != 'undefined'
            && typeof(arrForbidDirectDownload_Authenticated) != 'undefined'
            && arrForbidDirectDownload[ intItemIndex ]
            && arrForbidDirectDownload_Authenticated[ intItemIndex ]
        )
        {
            modalGalleryDownloadFileP2PBtn(intItemIndex);
        }
        else if ( strDownloadType == 'pdf' )
        {
        	var strDateModified = ( typeof arrDatesModified != 'undefined' ? arrDatesModified[ intItemIndex ] : ( typeof arrModDate != 'undefined' ? arrModDate[ intItemIndex ] : '' ) );
            window.location = '/api/file/get_thumb_pdf.php?i=' + strFileHash + '&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a&dm=' + strDateModified + '&v=102&n=' + arrDisplayNames[ intItemIndex ] + '.pdf';
        }
        else if ( strDownloadType == 'mp4' )
        {
        	var strDateModified = ( typeof arrDatesModified != 'undefined' ? arrDatesModified[ intItemIndex ] : ( typeof arrModDate != 'undefined' ? arrModDate[ intItemIndex ] : '' ) );
            window.location = '/thumb_video/' + strFileHash + '.mp4?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a&dm=' + strDateModified + '&v=102&n=' + arrDisplayNames[ intItemIndex ] + '.mp4';
        }
        else if ( strDownloadType == 'jpg' )
        {
        	var strDateModified = ( typeof arrDatesModified != 'undefined' ? arrDatesModified[ intItemIndex ] : ( typeof arrModDate != 'undefined' ? arrModDate[ intItemIndex ] : '' ) );
            window.location = '/thumb_show.php?i=' + strFileHash + '&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a&dm=' + strDateModified + '&download&n=' + arrDisplayNames[ intItemIndex ] + '.jpg';
        }
        else if ( strDownloadType == 'my-files' )
        {
        	objUploadCopyForm.showForm(
    			strUploadHash ,
    			false ,
    			[ strFileHash ] ,
    			[] ,
    			true ,
    			'' ,
    			function( strTargetUploadHash )
    			{
    				window.location = '/filebrowser?u=' + strTargetUploadHash;
    			}
        	);
        }
        else
        {
            var strFileExtension = arrExtensions[ intItemIndex ];
    
            var arrExecutableExtensions = ['exe','com','dll','pif','scr','bat','bin','pl','sh','scf','sct','shs','vb','lnk','jnlp','apk','vbs','js','msi','jse','jar','dmg','bin','wsf'];
    
            if ( arrExecutableExtensions.indexOf( strFileExtension ) == -1 )
            {
                window.location = 'https://'+ arrFileHost[ intItemIndex ]  +'/down.php?i=' + strFileHash + '&n=' + arrDisplayNames[ intItemIndex ];
            }
            else
            {
                fConfirm( 'This file was checked with antivirus on the serverside, but executable files may contain potentially dangerous code that antivirus software is yet unable to detect. Use it only if you trust the sender. If not sure, use Virustotal.com to double-check. Do you want to save this file?', '', 'OK', 'Cancel', function( r )
                {
                    if ( r )
                    {
                        window.location = 'https://'+ arrFileHost[ intItemIndex ]  +'/down.php?i=' + strFileHash + '&n=' + arrDisplayNames[ intItemIndex ];
                    }
                } );
            }
        }
	}


	function modalGallery_changeFileThumbnail( strFileHash, intItemIndex )
    {
        var $input;
        
        $( "<form method='post'>" )
            .append( $input = $( "<input type='file' name='image' accept='image/png, image/jpeg' required>" ) );
        
        $input.change( function ( event )
        {
            var data = new FormData();
            
            if ( !event.target.files.length )
            {
                return;
            }
            
            var file = event.target.files[ 0 ];
            
            data.append( 'image', file, file.name );
            data.append( 'file_hash', strFileHash );
            
            var xhr = new XMLHttpRequest();
            //post file data for upload
            xhr.open( 'POST', '/api/file/set_thumb.php', true );
            xhr.send( data );
            
            xhr.onload = function ()
            {
                //get response and show the uploading status
                var response = JSON.parse( xhr.responseText );
                if ( xhr.status === 200 && response.success )
                {
                    $( '#gallery2__item-' + intItemIndex + ' .gallery2__item__custom_thumb' ).remove();
                    $( '#gallery2__item-' + intItemIndex + ' .fa:first-child' ).remove();
                    $( '#gallery2__item-' + intItemIndex + ' .gallery2__item__doc-wrapper' ).prepend( $( "<div>" ).css( 'background-image', 'url("/thumb.php?i=' + strFileHash + '&t=' + ( new Date ).getTime() + '")' ).addClass( 'gallery2__item__custom_thumb' ) );
                    $( '#gallery2__item-' + intItemIndex + ' .gallery2__item__doc-wrapper' ).addClass( 'has_custom_thumb' );

                    $( '#' + ( $( '#gallery2__item-' + intItemIndex + ' .filesfm__embed_player__container' ).attr( 'id' ) + '_poster' ) ).attr( 'src', '/thumb_video_picture.php?i=' + strFileHash + '&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a&t=' + ( new Date ).getTime() );
                    $( '#gallery2__item-' + intItemIndex + ' .gallery2__item__audio-wrapper .audio_image' ).css( 'background-image', 'url("/thumb.php?i=' + strFileHash + '&t=' + ( new Date ).getTime() + '")' );

                    $( '.thumb_' + strFileHash ).removeClass( 'doc-icon' );
                    $( '.thumb_' + strFileHash ).css( 'min-width', '' );
                    $( '.thumb_' + strFileHash ).html( '<div class="thumb-wrapper"><img src="/thumb.php?i=' + strFileHash + '&t=' + ( new Date ).getTime() + '" data-original="/thumb.php?i=' + strFileHash + '&t=' + ( new Date ).getTime() + '" id="thumb_strip_img_' + strFileHash + '" class="lazyload-image-gallery image-not-loaded image-loaded" style="width: auto; height: 73px; display: inline;"></div>' );

                    $( '#gallery2__sidebar__info-set-custom-thumbnail' ).html( '' );
                    $( '#gallery2__sidebar__info-set-custom-thumbnail' ).append( '<div class="gallery2__sidebar__info-button no-background" onclick="modalGallery_changeFileThumbnail( \'' +  strFileHash + '\', ' + intItemIndex + ' )"><i class="fal fa-image"></i> Change file image</div>' );
        			$( '#gallery2__sidebar__info-set-custom-thumbnail' ).append( '<div class="gallery2__sidebar__info-button no-background" onclick="modalGallery_removeFileThumbnail( \'' +  strFileHash + '\', ' + intItemIndex + ' )"><i class="fal fa-times"></i> Delete file image</div>' );

                    strThumbnailActions = 
                    '<a href="javascript:void(0)" onclick="modalGallery_changeFileThumbnail( \'' +  arrHashes[ intItemIndex ] + '\', ' + intItemIndex + ' )">' +
                        '<div class="thumbnail-actions-edit" title="Change file image"></div>' +
                    '</a>' +
                    '<a href="javascript:void(0)" onclick="modalGallery_removeFileThumbnail( \'' +  arrHashes[ intItemIndex ] + '\', ' + intItemIndex + ' )">' +
                        '<div class="thumbnail-actions-delete" title="Delete file image"></div>' +
                    '</a>';
                    
                    $( '#gallery2_info_head .thumbnail-wrapper img' ).remove();
                    $( '#gallery2_info_head .thumbnail-wrapper' ).prepend( '<img src="/thumb.php?i=' + strFileHash + '&t=' + ( new Date ).getTime() + '" id="thumb_strip_img_' + strFileHash + '" class="lazyload-image-gallery image-not-loaded image-loaded">' );
                    $( '#gallery2_info_head .thumbnail-actions' ).html('');
                    $( '#gallery2_info_head .thumbnail-actions' ).append(strThumbnailActions);
                    $( '#gallery2_info_head .thumbnail-wrapper' ).addClass("two-actions");
                    $( '#gallery2_info_head .thumbnail-wrapper' ).removeClass("one-action");
                    
                    fSuccess( 'The image has been successfully changed!', '', 'OK' );
                }
                else
                {
                    if( typeof response.bad_file !== "undefined" && response.bad_file )
                    {
                        fError( 'Please choose an image file!', '', 'OK' );
                    }
                    else if( typeof response.too_big !== "undefined" && response.too_big )
                    {
                        fError( 'The size of image must not exceed 5MB!', '', 'OK' );
                    }
                    else
                    {
                        fError( 'Failed to change file image! Please try again later!', '', 'OK' );
                    }
                }
            };
        } );
        
        $input.click();
    };

    function modalGallery_removeFileThumbnail( strFileHash, intItemIndex )
    {
        fConfirm(
            'Are you sure you want to remove the image?',
            '',
            'Yes',
            'No',
            function ( ok )
            {
                if ( !ok )
                {
                    return;
                }
                
                var data = { file_hash: strFileHash };
                
                var successCB = function ()
                {
                    $( '#gallery2__item-' + intItemIndex + ' .gallery2__item__custom_thumb' ).remove();
                    $( '#gallery2__item-' + intItemIndex + ' .gallery2__item__doc-wrapper' ).removeClass( 'has_custom_thumb' );

                    $( '#gallery2__item-' + intItemIndex + ' .gallery2__item__audio-wrapper .audio_image' ).css( 'background-image', 'url("/thumb_audio_picture.php?i=' + strFileHash + '&t=' + ( new Date ).getTime() + '")' );
                   
                    $objSliderThumb = $( '.thumb_' + strFileHash );
                    $objSliderThumb.empty();

                    var strThumbHTML = '';
                    var strClass = null;
                    if ( arrFileTypes[intItemIndex] == 'video' )
                    {
                        var strThumbPath = 'https://' + arrFileHost[ intItemIndex ]  + '/thumb_video_picture.php?i=' + arrHashes[intItemIndex] + '&PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a' ,
                        strThumbHTML = '<img src="'+strThumbPath+'" data-original="'+strThumbPath+'" id="thumb_strip_img_'+arrHashes[intItemIndex]+'" class="lazyload-image-gallery" />';
                    }
                    else if ( typeof( arrIconSvg ) !== 'undefined' && arrIconSvg[intItemIndex] )
                    {
                        strThumbHTML = '<span class="gallery2__item__thumbnail '+ arrExtensions[ intItemIndex ].toLowerCase() +' thumb-svg-icon"><img src="/images/file_types_v2/'+arrIconSvg[ intItemIndex ]+'" data-original="/images/file_types_v2/'+arrIconSvg[ intItemIndex ]+'" style="max-width: 35px" /><span class="gallery2__item__thumbnail-ext">'+ arrExtensions[ intItemIndex ].toUpperCase() +'</span></span>';
                    }
                    else if ( arrIconClass[intItemIndex] )
                    {
                        strThumbHTML = '<span class="gallery2__item__thumbnail '+ arrExtensions[ intItemIndex ].toLowerCase() +'"><i class="' + arrIconClass[intItemIndex] + '"></i><span class="gallery2__item__thumbnail-ext">'+ arrExtensions[ intItemIndex ].toUpperCase() +'</span></span>';
                        strClass = 'doc-icon';
                    }
                    else
                    {
                        strThumbHTML = '<span class="gallery2__item__thumbnail '+ arrExtensions[ intItemIndex ].toLowerCase() +'"><i class="fal fa-file"></i><span class="gallery2__item__thumbnail-ext">'+ arrExtensions[ intItemIndex ].toUpperCase() +'</span></span>';
                        strClass = 'doc-icon';
                    }
                    $objSliderThumb.addClass(strClass)
                    if( !arrFileTypes[intItemIndex] == 'video' )
                    {
                        $objSliderThumb.css('min-width', '65px');
                    }
                    
                    strThumbItemHTML = '<div class="thumb-wrapper">'+ strThumbHTML +'</div><div class="checkbox"></div>';
                    $objSliderThumb.append(strThumbItemHTML);

                    
                    $( '#gallery2__sidebar__info-set-custom-thumbnail' ).html( '' );
        			$( '#gallery2__sidebar__info-set-custom-thumbnail' ).append( '<div class="gallery2__sidebar__info-button no-background" onclick="modalGallery_changeFileThumbnail( \'' +  strFileHash + '\', ' + intItemIndex + ' )"><i class="fal fa-image"></i> Set file preview image</div>' );

                    strThumbnailActions = 
                    '<a href="javascript:void(0)" onclick="modalGallery_changeFileThumbnail( \'' +  arrHashes[ intItemIndex ] + '\', ' + intItemIndex + ' )">' +
                        '<div class="thumbnail-actions-edit" title="Set file preview image"></div>' +
                    '</a>';

                    $( '#gallery2_info_head .thumbnail-wrapper img' ).remove();
                    if ( arrFileTypes[intItemIndex] == 'video' )
                    {
                        $( '#gallery2_info_head .thumbnail-wrapper' ).prepend(strThumbHTML);
                    }
                    else
                    {
                        $( '#gallery2_info_head .thumbnail-wrapper' ).prepend( '<img src="/images/file_types_v2/'+arrIconSvg[ intItemIndex ]+'" />' );
                    }
                   
                    $( '#gallery2_info_head .thumbnail-actions' ).html('');
                    $( '#gallery2_info_head .thumbnail-actions' ).append(strThumbnailActions);
                    $( '#gallery2_info_head .thumbnail-wrapper' ).removeClass("two-actions");
                    $( '#gallery2_info_head .thumbnail-wrapper' ).addClass("one-action");
                    
                    fSuccess( 'The image has been successfully removed!', '', 'OK' );
                };
                
                var failCB = function ()
                {
                    fError( 'Failed to remove file image! Please try again later!', '', 'OK' );
                };
                
                jQuery.post(
                    '/api/file/remove_thumb.php',
                    data,
                    successCB,
                    'JSON'
                ).fail( failCB );
            }
        );
    }

    
    function isFileConvertable( strConverToFormat, intItemIndex )
    {
    	var bolIsFileConvertable = false;

    	if ( strConverToFormat == 'pdf' )
    	{
        	
        	if (
        	    	[ 'asice','edoc','zip' , 'doc','docx','odp','ods','odt','pps','ppsx','ppt','pptx','rtf','xls','xlsx','dotx' ].indexOf( arrExtensions[ intItemIndex ] ) != -1
    	    		&& arrSizesInBytes[ intItemIndex ] < 104857600        		)
        	{
            	var bolIsDocTempFile = false
    
            	if (
                		[ 'doc','docx','odp','ods','odt','pps','ppsx','ppt','pptx','rtf','xls','xlsx','dotx' ].indexOf( arrExtensions[ intItemIndex ] ) != -1
                		&& arrDisplayNames[ intItemIndex ].substring( 0, 2 ) == '~$'
            		)
            	{
            		bolIsDocTempFile = true;
            	}
    
        		if ( ! bolIsDocTempFile )
        		{
    	    		bolIsFileConvertable = true;
        		}
        	}
    	}
    	else if ( strConverToFormat == 'mp4' )
    	{
        	if ( arrFileTypes[ intItemIndex ] == 'video' && arrExtensions[ intItemIndex ] != 'mp4' )
        	{
        		bolIsFileConvertable = true;
        	}
    	}
        else if ( strConverToFormat == 'jpg' )
    	{
        	if ( arrFileTypes[ intItemIndex ] == 'image' && arrExtensions[ intItemIndex ] != 'jpg' )
        	{
        		bolIsFileConvertable = true;
        	}
            else if ( arrExtensions[ intItemIndex ] == 'jpg' && ( arrWidths[ intItemIndex ] > 3000 || arrHeights[ intItemIndex ] > 3000 ) )
            {
                bolIsFileConvertable = true;
            }
    	}
    	
    	return bolIsFileConvertable;
    }

    
    function fileCanBeSigned( strFileExtension, intFileSize )
    {
    	var bolFileCanBeSigned = false;
    	
    	if (
	    		[ 'edoc', 'pdf', 'asice' ].indexOf( strFileExtension ) != -1
	    		&& ( intFileSize / 1024 / 1024 ) < 50
    		)
    	{
    		bolFileCanBeSigned = true;
    	}

    	return bolFileCanBeSigned;
    }

    function getFileIcon (strFileHash)
    {
        var strFileIcon = 'default.svg';
        var intFileIndex = getItemIndexByHashOrName( strFileHash );

        if ( typeof( arrIconSvg ) !== 'undefined' && arrIconSvg[intFileIndex] )
        {
            strFileIcon = arrIconSvg[ intFileIndex ];
        }

        return strFileIcon;
    }
    function canBeReported (strFileHash)
    {
        var bolCanBeReported = false;

        var intFileIndex = getItemIndexByHashOrName( strFileHash );

        if( window.location.href.indexOf("filebrowser") === -1 && typeof arrReports != 'undefined' && typeof arrStatuses != 'undefined' && ! [3, 4].includes(arrStatuses[ intFileIndex ]) &&
            ( 
                typeof arrFileIsLockedByOtherUser == 'undefined' 
                || ! arrFileIsLockedByOtherUser[ intFileIndex ]
            )
        ) 
        {
           bolCanBeReported = true; 
        }

        return bolCanBeReported;
    }
    function hasReported (strFileHash)
    {
        var bolHasReported = false;
        var intFileIndex = getItemIndexByHashOrName( strFileHash );

        if( window.location.href.indexOf("filebrowser") === -1 && typeof arrReports != 'undefined' && typeof arrStatuses != 'undefined' && ! [3, 4].includes(arrStatuses[ intFileIndex ]) &&
            ( 
                typeof arrFileIsLockedByOtherUser == 'undefined' 
                || ! arrFileIsLockedByOtherUser[ intFileIndex ]
            )
        ) 
        {
            if (arrReports[ intFileIndex ] == 0)
            {
                bolHasReported = false;
            }
            else 
            {
                bolHasReported = true;
            }
        }
        return bolHasReported;
    }
    function canOrderPrints( strFileHash )
    {
        var bolCanOrderPrints = false;

        var intFileIndex = getItemIndexByHashOrName( strFileHash );
         
                
        return bolCanOrderPrints;
    }

    function canOrderProductGeneral( strFileHash )
    {
        var bolCanOrderProductGeneral = false;
        var intFileIndex = getItemIndexByHashOrName( strFileHash );
                        return bolCanOrderProductGeneral;
    }

	function canOrderProducts( strFileHash )
    {
    	var bolCanOrderProducts = false;
        var intFileIndex = getItemIndexByHashOrName( strFileHash );
                if ( arrFileHasProductSelling[ intFileIndex ] == 1 )
        {
            bolCanOrderProducts = true;
        }
                return bolCanOrderProducts;
    }

	function canBuyFile( strFileHash )
    {
    	var bolCanBuyFile = false;
        var intFileIndex = getItemIndexByHashOrName( strFileHash );


        if ( arrFeeDownloadPrice[ intFileIndex ] != null )
		{
			if ( ! bolIsOwner )
			{
				bolCanBuyFile = true;
			}
		}
    	return bolCanBuyFile;
    }

    function canSellFile( strFileHash )
    {
    	var bolCanSellFile = false;
        var intFileIndex = getItemIndexByHashOrName( strFileHash );


        if ( bolIsOwner )
        {
            bolCanSellFile = true;
        }
		
    	return bolCanSellFile;
    }

    function canSetAsThumb( strFileHash )
    {
    	var bolCanSetAsThumb = false;
        var intFileIndex = getItemIndexByHashOrName( strFileHash );

        if ( arrFileTypes[ intFileIndex ] == 'image' )
        {
            bolCanSetAsThumb = true;
        }

        if ( ! bolIsOwner )
        {
            bolCanSetAsThumb = false;
        }
		
    	return bolCanSetAsThumb;
    }
    
    function canOpenSlideshow()
    {
		
    	var bolCanOpenSlideshow = true;
        if ( arrHashes.length <= 1 )
        {
            bolCanOpenSlideshow = false;
        }
    	return bolCanOpenSlideshow;
    }

    function getFileLink( strFileHash )
    {
    	var strShareLink = '';

        strShareLink = 'https://files.fm/f/' + strFileHash;
		
    	return strShareLink;
    }

    function getFileEditLink( strFileHash )
    {
    	var strShareEditLink = '';
        var intFileIndex = getItemIndexByHashOrName( strFileHash );
        var strFileViewLink = 'https://files.fm/f/' + strFileHash;

        if ( bolCanDelete && typeof arrFileDeleteKeys != 'undefined' && arrFileDeleteKeys[ intFileIndex ] != '' )
        {
            strShareEditLink = strFileViewLink + '?fk=' + arrFileDeleteKeys[ intFileIndex ];
        }	
    	return strShareEditLink;
    }

    
    function canOpenFileInEditor( strMode, strFileExtension )
    {
    	var bolcanOpenFileInEditor = false;
    	
    	if ( strMode == 'edit' && [ 'odt','fodt','ott','doc','dot','docx','docm','rtf','txt','odm','otm','oth','ods','fods','ots','xls','xla','xlsx','xlsb','xlsm','dif','slk','csv','dbf','odp','fodp','otp','ppt','pot','pptx','pptm','potx','potm','ppsx','odg','fodg','otg' ].indexOf( strFileExtension ) != -1 )
    	{
    		bolcanOpenFileInEditor = true;
    	}

    	return bolcanOpenFileInEditor;
    }

    function canOpenImageInEditor( strFileExtension )
    {
        var bolCanOpenImageInEditor = false;

        if (
                [ 'jpg','jpeg','gif','png','bmp','svg','webp','ico','jfif','heic','heif','tiff','tif' ].indexOf( strFileExtension ) !== -1
                || [ 'cr3','cr2','nef','arw','pef','rw2','orf','raf','nrw','dng' ].indexOf( strFileExtension ) !== -1
            )
        {
            bolCanOpenImageInEditor = true;
        }

        return bolCanOpenImageInEditor;
    }
    
    function canDownload( strFileHash )
    {
        var bolCanDownload = false;

        var intItemIndex = getItemIndexByHashOrName( strFileHash );
        
        if  (
                arrFeeDownloadPrice[ intItemIndex ] == null
                && ! currentFolderHasFeeDownload( intItemIndex )
                && arrAllowDownload[ intItemIndex ]
                &&
                (
                    typeof( bolHideDownloadButtons ) === 'undefined'
                    || ! bolHideDownloadButtons
                )
                &&
                (
                    typeof( arrHideDownloadButtons ) === 'undefined'
                    || ! arrHideDownloadButtons[ intItemIndex ]
                )
            )
        {
            bolCanDownload = true;
        }
        
        return bolCanDownload;
    }
    
    function currentFolderHasFeeDownload( intFileIndex )
    {
    	var bolVal = false;
    	
    	if ( typeof bolUploadHasFeeDownload != 'undefined' )
    	{
    		bolVal = bolUploadHasFeeDownload;
    	}
    	else if ( typeof PublicProfile != 'undefined' )
    	{
            bolVal = arrParentFolderIsForSale[ intFileIndex ];
		}
		else
		{
			bolVal = false;
		}
		
		return bolVal;
	}
    

    function loadExifTags()
    {
        var jqExifTagsButton = $( '#gallery2__sidebar__info-exif_tags-button' );
       
        var imageTag = $( '#main_image_' + strCurrentFileHash )[ 0 ];

        var arrExifTable = ['Model', 'ISO', 'Lens Model', 'Focal Length', 'Aperture Value', 'Exposure Time'];

        EXIF.getData( imageTag, function ()
        {
            var strExifTags = EXIF.pretty( this );

            var arrExifTags = strExifTags.split( '\r\n' );

            arrExifTags = arrExifTags.map( ( item ) =>
            {
                if ( item != '' )
                {
                    var arrKeyValuePair = item.split( ' : ' );
                    return arrKeyValuePair;
                }
            } );

            var jqPrevExifTagRow = null;
            var bolExifRows = false;
            
            arrExifTags.forEach( ( item ) =>
            {
                var jqNewExifTagRow = $( '<tr class="gallery2__sidebar__info-exif_tags"><td class="gallery2__sidebar__exif_tags-key"></td><td class="gallery2__sidebar__exif_tags-value"></td></tr>' );

                if ( typeof( item ) != 'undefined' )
                {
                    if(arrExifTable.includes(item[ 0 ]))
                    {
                        if ( item[ 0 ] != 'Model' || (item[ 0 ] == 'Model' && $('#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value .exif-grid .Model span').html() == '') ) {
                            $('#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value .exif-grid .' + item[ 0 ].replace(/\s+/g, '') + ' span').html( item[ 1 ] );
                            $('#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value .exif-grid .' + item[ 0 ].replace(/\s+/g, '')).show();
                            $('#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value').show();
                        }
                    }
                    else
                    {
                        bolExifRows = true;
                        jqNewExifTagRow.children( '.gallery2__sidebar__exif_tags-key' ).html( item[ 0 ] );
                        jqNewExifTagRow.children( '.gallery2__sidebar__exif_tags-value' ).html( item[ 1 ] );

                        jqNewExifTagRow.css('display', 'none');

                        if ( jqPrevExifTagRow )
                        {
                            jqPrevExifTagRow.after( jqNewExifTagRow );
                        }
                        else
                        {
                            jqExifTagsButton.after( jqNewExifTagRow );
                        }

                        jqPrevExifTagRow = jqNewExifTagRow;
                    }
                }
            } );

            if ( typeof arrWidths != 'undefined' && typeof arrHeights != 'undefined' && typeof arrWidths[intCurrentFileIndex] != 'undefined' && typeof arrHeights[intCurrentFileIndex] != 'undefined' && arrWidths[intCurrentFileIndex] != '' && arrHeights[intCurrentFileIndex] != '' && arrWidths[intCurrentFileIndex] != 'undefined' && arrHeights[intCurrentFileIndex] != 'undefined' )
            {
                $('#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value .exif-grid .size span').html(arrWidths[intCurrentFileIndex] + ' x ' + arrHeights[intCurrentFileIndex]);
                $('#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value .exif-grid .size').show();
                $('#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value .exif-grid .mp span').html(Math.round((arrWidths[intCurrentFileIndex]*arrHeights[intCurrentFileIndex]/1000000) * 100) / 100+ ' MP');
                $('#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value .exif-grid .mp').show();
                $('#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value').show();
            }
            
            var strModelName =  $('#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value .exif-grid .Model span').html();
            var strLensName =  $('#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value .exif-grid .LensModel span').html();
            strLensName = strLensName.replace(strModelName,'');
            $('#gallery2__sidebar__info-mainexif .gallery2__sidebar__info-value .exif-grid .LensModel span').html(strLensName)
            
            if( !bolExifRows )
            {
                jqExifTagsButton.hide();
            }
        } );
    }


    function gpsDecimalToDMS( mixGpsDecimal, bolLatitude )
    {
        var dblGpsDecimal = Number( mixGpsDecimal )
        if ( mixGpsDecimal === '' || isNaN( dblGpsDecimal ) )
        {
            return '';
        }

        var strGpsPole;
        if ( bolLatitude )
        {
            strGpsPole = ( dblGpsDecimal < 0 ) ? 'S' : 'N';
        }
        else
        {
            strGpsPole = ( dblGpsDecimal < 0 ) ? 'W' : 'E';
        }
        dblGpsDecimal = Math.abs( dblGpsDecimal );

        var intGpsDegrees = Math.trunc( dblGpsDecimal );
        dblGpsDecimal -= intGpsDegrees;

        var intGpsMinutes = Math.trunc( dblGpsDecimal * 60 );
        dblGpsDecimal -= intGpsMinutes / 60;

        var intGpsSeconds = ( dblGpsDecimal * 3600 ).toFixed( 2 );

        return `${ intGpsDegrees }\u00B0 ${ intGpsMinutes }' ${ intGpsSeconds }" ${ strGpsPole }`;
    }


    function ocrAnalyze( objButton, strModel )
    {
        var jqButton = $( objButton );
        if ( jqButton.hasClass( 'disabled' ) )
        {
            return;
        }

        jqButton.addClass( 'disabled' );

        var strButtonText = jqButton.text();

        jqButton.text( strButtonText + ' (0s)' );
        var intStartTimestamp = Date.now();
        var stopwatch = setInterval( () => {
            jqButton.html( strButtonText + ' (' + Math.trunc( ( Date.now() - intStartTimestamp ) / 1000 ) + 's)' );
        }, 1000 );

        $.ajax( {
            type: 'GET',
            dataType: 'json',
            crossDomain: true,
            url: './ajax/image_ocr_processing.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a',
            data:
            {
                hash: strCurrentFileHash,
                model: strModel,
            },
            success: function ( data )
            {
                clearInterval( stopwatch );

                if ( ! data[ 'success' ] )
                {
                    fError( data[ 'error' ] );
                    return;
                }

                if ( strModel == 'easyocr' && typeof arrFileEasyOCRText != 'undefined' )
                {
                    arrFileEasyOCRText[ intCurrentFileIndex ] = data[ 'text' ];

                    $( '#gallery2__sidebar__info-easyocr_text .gallery2__sidebar__info-value' ).text( arrFileEasyOCRText[ intCurrentFileIndex ] );
                    if ( arrFileEasyOCRText[ intCurrentFileIndex ] != '' ) $( '#gallery2__sidebar__info-easyocr_text' ).show();
                }
                else if ( strModel == 'googlecv' && typeof arrFileGoogleCVText != 'undefined' )
                {
                    arrFileGoogleCVText[ intCurrentFileIndex ] = data[ 'text' ];

                    $( '#gallery2__sidebar__info-google_cv_text .gallery2__sidebar__info-value' ).text( arrFileGoogleCVText[ intCurrentFileIndex ] );
                    if ( arrFileGoogleCVText[ intCurrentFileIndex ] != '' ) $( '#gallery2__sidebar__info-google_cv_text' ).show();
                }
            },
        } );
    }


    function speechToText( objButton )
    {
        var jqButton = $( objButton );
        if ( jqButton.hasClass( 'disabled' ) )
        {
            return;
        }

        jqButton.addClass( 'disabled' );

        var strButtonText = jqButton.text();

        jqButton.text( strButtonText + ' (0s)' );
        var intStartTimestamp = Date.now();
        var stopwatch = setInterval( () => {
            jqButton.html( strButtonText + ' (' + Math.trunc( ( Date.now() - intStartTimestamp ) / 1000 ) + 's)' );
        }, 1000 );

        $.ajax( {
            type: 'GET',
            dataType: 'json',
            crossDomain: true,
            url: './ajax/speech_to_text.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a',
            data:
            {
                hash: strCurrentFileHash,
            },
            success: function ( data )
            {
                clearInterval( stopwatch );

                if ( ! data.success )
                {
                    fError( data.error );
                    return;
                }

                arrFileAudioTranscription[ intCurrentFileIndex ] = data.text;

                $( '#gallery2__sidebar__info-google_cloud-speech_to_text-text .gallery2__sidebar__info-value' )
                    .text( arrFileAudioTranscription[ intCurrentFileIndex ] );

                if ( arrFileAudioTranscription[ intCurrentFileIndex ] != '' )
                {
                    $( '#gallery2__sidebar__info-google_cloud-speech_to_text-text' ).show();
                }
            },
        } );
    }


    function objectsLabelsDetection( objButton )
    {
        var jqButton = $( objButton );
        if ( jqButton.hasClass( 'disabled' ) )
        {
            return;
        }

        jqButton.addClass( 'disabled' );

        var strButtonText = jqButton.text();

        jqButton.text( strButtonText + ' (0s)' );
        var intStartTimestamp = Date.now();
        var stopwatch = setInterval( () => {
            jqButton.html( strButtonText + ' (' + Math.trunc( ( Date.now() - intStartTimestamp ) / 1000 ) + 's)' );
        }, 1000 );

        $.ajax( {
            type: 'GET',
            dataType: 'json',
            crossDomain: true,
            url: './ajax/object_label_detection.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a',
            data:
            {
                hash: strCurrentFileHash,
            },
            success: function ( data )
            {
                clearInterval( stopwatch );

                if ( ! data.success )
                {
                    fError( data.error );
                    return;
                }

                arrObjectTags[ intCurrentFileIndex ] = data.text.objects;

                if ( arrObjectTags[ intCurrentFileIndex ] != '' )
                {
                    let jqObjectTagsElem = $( '#gallery2__sidebar__info-object_tags .tags' );

                    let arrExistingTags = jqObjectTagsElem.find( '.tag' ).map( function() {
                        return $( this ).text();
                    } ).get();

                    let arrObjectTagsSplitted = arrObjectTags[ intCurrentFileIndex ].split( ';' );

                    let arrTagsToBeAdded = arrObjectTagsSplitted.filter( tag => ! arrExistingTags.includes( tag ) );

                    $.each( arrTagsToBeAdded, ( i, tag ) => {
                        jqObjectTagsElem.append( '<span class="tag">' + tag + '</span>' );
                    } );

                    if ( arrObjectTags[ intCurrentFileIndex ] != '' )
                    {
                        $( '#gallery2__sidebar__info-object_tags' ).show();
                    }
                }


                arrLabelTags[ intCurrentFileIndex ] = data.text.labels;

                let jqLabelTagsElem = $( '#gallery2__sidebar__info-label_tags .tags' );

                jqLabelTagsElem.empty();

                let arrLabelTagsSplitted = arrLabelTags[ intCurrentFileIndex ].split( ';' );
                $.each( arrLabelTagsSplitted, ( i, tag ) => {
                    jqLabelTagsElem.append( '<span class="tag">' + tag + '</span>' );
                } );

                if ( arrLabelTags[ intCurrentFileIndex ] != '' )
                {
                    $( '#gallery2__sidebar__info-label_tags' ).show();
                }
            },
        } );
    }


    function objectDetection( objButton )
    {
        var jqButton = $( objButton );
        if ( jqButton.hasClass( 'disabled' ) )
        {
            return;
        }

        jqButton.addClass( 'disabled' );

        var strButtonText = jqButton.text();

        jqButton.text( strButtonText + ' (0s)' );
        var intStartTimestamp = Date.now();
        var stopwatch = setInterval( () => {
            jqButton.html( strButtonText + ' (' + Math.trunc( ( Date.now() - intStartTimestamp ) / 1000 ) + 's)' );
        }, 1000 );

        $.ajax( {
            type: 'GET',
            dataType: 'json',
            crossDomain: true,
            url: './ajax/object_detection.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a',
            data: {
                hash: strCurrentFileHash,
            },
            success: function ( data )
            {
                clearInterval( stopwatch );

                if ( ! data.success )
                {
                    fError( data.error );
                    return;
                }

                arrYoloObjectTags[ intCurrentFileIndex ] = data.objects;

                if ( arrYoloObjectTags[ intCurrentFileIndex ] == '' )
                {
                    return;
                }

                let jqObjectTagsElem = $( '#gallery2__sidebar__info-object_tags .tags' );

                let arrExistingTags = jqObjectTagsElem.find( '.tag' ).map( function() {
                    return $( this ).text();
                } ).get();

                let arrObjectTagsSplitted = arrYoloObjectTags[ intCurrentFileIndex ].split( ';' );

                let arrTagsToBeAdded = arrObjectTagsSplitted.filter( tag => ! arrExistingTags.includes( tag ) );

                $.each( arrTagsToBeAdded, ( i, tag ) => {
                    jqObjectTagsElem.append( '<span class="tag">' + tag + '</span>' );
                } );

                $( '#gallery2__sidebar__info-object_tags' ).show();
            },
        } );
    }


</script>
<script type="text/javascript">

	var intTotalItems = parseInt('1');
	var intTotalMP3Items = parseInt('0');
	var intMediaItems = parseInt('1');
	var dblGlobalVolume = 0.8;

    var bolAllowDownload = Boolean(parseInt('1'));
    var bolUploadHasFeeDownload = false;

	var bolClickAds = true;
	var intPrevAdRefreshTST = (new Date()).getTime();

	
</script>
<div id="list-container" class="theme-light files">
<style type="text/css">
			.item-list-loading {
				display: none;	
			}
			
			.horizontal_view.media-small DIV.item {
				height: 180px;
				min-width: calc(180px / 2);
			}
			.media-large.horizontal_view DIV.item {
				height: 400px;
				min-width: calc(400px / 2);
			}
			.vertical_view.media-small #all_items {
				grid-template-columns: repeat(auto-fill, minmax(200px,1fr));
			}
			.vertical_view.media-large #all_items {
				grid-template-columns: repeat(auto-fill, minmax(400px,1fr));
			}

			@media only screen and (max-width: 500px) {
				.media-small.horizontal_view DIV.item {
					height: 100px;
					min-width: calc(100px / 2);
				}
				.media-large.horizontal_view DIV.item {
					height: 190px;
					min-width: calc(190px / 2);
				}
				.vertical_view.media-small #all_items {
					grid-template-columns: repeat(auto-fill, minmax(100px,1fr));
				}
				.vertical_view.media-large #all_items {
					grid-template-columns: repeat(auto-fill, minmax(200px,1fr));
				}
			}
		</style>
<div id="right_container" class="uploadifive-allow-dd" style="min-height: 0px;">
<div id="right" style="display:block;" class="theme-light media-medium disable_select one_item horizontal_view has_files">
<div class="header-owner position-left cover-small title-Medium description-Medium">

<div class="header_backdrop">
<div class="header_backdrop__image" style="background-color: #242424"></div>
<img id="header_backdrop__image_guillotine">

<div class="header_backdrop__mask" style="background: rgba(0, 0, 0, 0.6);"></div>
</div>

<div class="header_profile_info">
<div class="header_profile_info_left" style="opacity: 1" onclick="gaev( 'upload-folder-info', 'profile-info', 'guest' ); showCreateAccount(); return;">
<div class="header_profile_image">
<div class="header-owner_image unknown" style="background-image: url( '/images/list/unknown-owner.svg' );"></div>
</div>
</div>
<div class="header_profile_info_right" onclick="gaev( 'upload-folder-info', 'profile-info', 'guest' ); showCreateAccount(); return;" style="cursor: pointer;">
<div class="header-owner_name more-space" style="color: rgba(255, 255, 255, 1)">
<div>not specified</div> <span class="pro_flag" style="opacity: 1">Free</span> </div>
</div>
</div>
<div class="header_folder_info">
<div class="header_folder_info_center">
<div class="upload_info_name" style="color: rgba(255, 255, 255, 1); font-family: AlbertaSans" onclick="">
<textarea readonly="" id="upload_info_name" spellcheck="false" name="upload_info_name" oninput="$(this).removeClass('invalid');" onchange="changeUploadName();" onkeyup="adjustHeight(this)" style="height: 130px;">-Moments-Feb-18-2024--.mp4</textarea>
</div>
<div class="upload_info_desc" style="color: rgba(255, 255, 255, 1); font-family: AlbertaSans" onclick="">
</div>
<div id="placeholder-color">
<style>
														.header-owner div:is(.upload_info_name, .upload_info_desc) textarea:-moz-placeholder {
								color: rgba(255,255,255,0.65 );
							}
							.header-owner div:is(.upload_info_name, .upload_info_desc) textarea::-moz-placeholder {
								color: rgba(255,255,255,0.65 );
							}
							.header-owner div:is(.upload_info_name, .upload_info_desc) textarea:-ms-input-placeholder {
								color: rgba(255,255,255,0.65 );
							}
							.header-owner div:is(.upload_info_name, .upload_info_desc) textarea::-webkit-input-placeholder {
								color: rgba(255,255,255,0.65 );
							}
							.header-owner div:is(.upload_info_name, .upload_info_desc) textarea::placeholder {
								color: rgba(255,255,255,0.65 );
							}
						</style>
</div>
</div>
</div>
<div class="upload_info_stats" style="color: rgba(255, 255, 255, 1)">
<span class="upload_info_stat my_tooltip" my_title="Upload date: 2024-10-14 20:20:30<br>Mod. date: 2024-10-14 20:21:10">2024-10-14</span>
<span>︱</span>
<span class="upload_info_stat my_tooltip" style="text-transform: lowercase;" my_title="Count">1 file</span>
<span>︱</span>
<span class="upload_info_stat my_tooltip" my_title="Size">21&nbsp;MB</span>
<span>︱</span>
<span class="upload_info_stat" style="display: inline-flex; margin-right: 15px; text-transform: lowercase;">9 Views</span>
</div>
<div class="upload_info__delete_warning ">Will be deleted: Oct 28, 2024 20:20</div>
<div class="header_backdrop__move"></div>
</div>
<script src="/js/ZeroClipboard.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="css/list.v2/action_line.css?t=102">
<div id="head_sticky">
<div id="head" class="">
<div id="head__all-files-actions" class=" has-download">
<div class="head_download" id="head_download__all-files">
<a class="head_download__button" href="javascript:void(0)" onclick="if($(this).hasClass('open')){$(this).next().hide(); $(this).parent().find('.dropdown_close_before').hide(); $(this).removeClass('open');}else{$(this).next().show(); $(this).parent().find('.dropdown_close_before').show(); $(this).addClass('open');}">
<span class="head_download__button_desktop">Download</span>
<span class="head_download__button_mobile">Download</span>
</a>
<div class="head_download__dropdown">
<div class="head_download__dropdown__top_transparent"></div>
<div class="head_download__dropdown__content">
<a href="https://fv5-4.files.fm/down.php?i=8ygca6f2cs&amp;n=-Moments-Feb-18-2024--.mp4" onclick="gaev('upload_action_line', 'download_this_file', 'fhazcb8kug' ); ">
Download original file </a>
<a href="javascript:void(0)" onclick="objUploadCopyForm.showForm( 'fhazcb8kug', true, [], [], true, '', function( strTargetUploadHash ) { window.location = '/filebrowser?u=' + strTargetUploadHash; } ); gaev('upload_action_line', 'list-download-add-to-my-files', '' );">
Save to my account <span class="recommended">Recommended!</span>
</a>
</div>
</div>
<div class="dropdown_close_before"></div>
</div>

<div class="head_input_field" id="head_link">
<div class="head_input_field__button" id="copy_link_button" onclick="gaev(&quot;upload_action_line&quot;, &quot;list-link-share-click&quot;, &quot;&quot; ); showSharePopup( event, {&quot;show_type_select&quot;:false,&quot;type&quot;:&quot;all_files&quot;,&quot;can_share&quot;:false,&quot;all_files&quot;:{&quot;view_url&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;,&quot;edit_url&quot;:&quot;&quot;,&quot;upload_url&quot;:&quot;&quot;,&quot;facebook&quot;:{&quot;name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;,&quot;picture_url&quot;:&quot;https:\/\/files.fm\/images\/files.fm_300.png&quot;,&quot;description&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;,&quot;return_link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug?after_fb_share&quot;},&quot;twitter&quot;:{&quot;text&quot;:&quot;files.fm: -Moments-Feb-18-2024--.mp4&quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;},&quot;share_email&quot;:{&quot;upload_hash&quot;:&quot;fhazcb8kug&quot;,&quot;file_view_hash&quot;:&quot;&quot;},&quot;item_info&quot;:{&quot;upload_hash&quot;:&quot;fhazcb8kug&quot;,&quot;item_name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;}}} );">
<span>Share</span>
</div>
</div>
<div id="head_menu">
<div id="head_menu__button" style="display: inline-flex;">
<span>More</span>
</div>
<div id="head_menu__dropdown">
<div id="head_menu__dropdown__content">
<div id="head_menu__dropdown__content_buttons">
<div class="list-view_upload-info-buttons first-group">
<a href="javascript:void(0)" onclick="showSlideshow()" class="list_view__slideshow_button upload-info-button">
Slideshow </a>
</div>

</div>
</div>
</div>
<div class="dropdown_close_before"></div>
</div>
<div id="upload_head_menu" onclick="toggleLeftInfoBlock()" class="my_tooltip" my_title="Show folder information"><span> Info</span></div>
</div>
<div id="head__selected-files-actions">
<div class="head_download" id="head_download__selected-files">
<div class="head_download__button" onclick="$(this).next().find('.head_download__dropdown__content a').eq(0).get( 0 ).onclick()">
<span>Save selected files</span>
</div>
<div class="head_download__dropdown">
<div class="head_download__dropdown__top_transparent"></div>
<div class="head_download__dropdown__content">
<a href="javascript:void(0)" onclick="listDownloadSelectedFiles(); gaev( 'upload_action_line', 'list-download-selected', 'fhazcb8kug' );">
Download selected </a>
</div>
</div>
<div class="dropdown_close_before"></div>
</div>
<script>
                    $('#head_download__selected-files .head_download__button').attr('onclick', '$(this).next().find(\'.head_download__dropdown__content a\').eq(0).get( 0 ).onclick()')
                </script>
<div id="head_share__selected-files" class="head_input_field__button" onclick="shareSelectedFiles()">
<span>Share only selected</span>
</div>
</div>
<script type="text/javascript">
	$(function (){
                $('#head_menu__button').click(function() {
            if($(this).hasClass('open'))
            {
                $('#head_menu__dropdown').hide();
                $(this).parent().find('.dropdown_close_before').hide();
                $(this).removeClass('open');
            }
            else
            {
                $('#head_menu__dropdown').show();
                $(this).parent().find('.dropdown_close_before').show();
                $(this).addClass('open');
            }
            
        });

        const el = document.querySelector("#head_sticky")
        const observer = new IntersectionObserver( 
            ([e]) => e.target.classList.toggle("is-pinned", e.intersectionRatio < 1),
            { threshold: [1] }
        );
        observer.observe(el);

	});
	
</script>
</div>
</div>
<div id="head__select-all__wrapper">
<input type="checkbox" class="small styled_chbblue_btn" onchange="checkToggleByCheckBox_All(event, this)" id="head__select-all_chkbox" style="display: none;">
<label for="head__select-all_chkbox">Select</label>
<span id="head__select-all__text">

<span id="head__select-all__text__file-count"></span>
files </span>
<span id="head__select-all__show-selected" onclick="showSelectedFiles()">
<div class="desktop">Show selected</div>
<div class="mobile">View</div>
</span>
<span id="head__select-all__show-all" onclick="showAllFiles()">
<div class="desktop">Show all</div>
<div class="mobile">All</div>
</span>
<div id="head_view_sort_switch_wrap">
<div id="head_view_sort_switch_title">Sort</div>
<div id="head_view_sort_switch_dropdown" style="display: none;">
<div class="head_view_sort_switch_dropdown_title">Layout</div>
<div id="head_view_switch_wrap">
<a class="switch-view-button list switch_to_list_view" href="/u/fhazcb8kug#/list/"></a>
<a class="switch-view-button grid switch_to_gallery_view" href="/u/fhazcb8kug#/grid/"></a>
<a class="switch-view-button hor switch_to_horizontal_view active" href="/u/fhazcb8kug#/horizontal/"></a>
<a class="switch-view-button ver switch_to_vertical_view" href="/u/fhazcb8kug#/vertical/"></a>
</div>
<div class="head_view_sort_switch_dropdown_title">Sort by</div>
<div id="head_sort_switch_wrap">
<a href="javascript:void(0)" id="sort_popup_sort_by_date_created" onclick="changeSort( 'Field', 'date_created', strList_DefaultSortField, strList_DefaultSortDirection, strDefaultView, false, true );">Date created <img class="fa-chevron-down sort-direction" src="/images/UI_icons/blue/arrow_down.svg" style="display: inline;"><img style="display: none;" class="fa-chevron-up sort-direction" src="/images/UI_icons/blue/arrow_up.svg"></a>
<a href="javascript:void(0)" id="sort_popup_sort_by_modified_date" onclick="changeSort( 'Field', 'modified_date', strList_DefaultSortField, strList_DefaultSortDirection, strDefaultView, false, true );">Date modified <img class="fa-chevron-down sort-direction" src="/images/UI_icons/blue/arrow_down.svg" style="display: inline;"><img style="display: none;" class="fa-chevron-up sort-direction" src="/images/UI_icons/blue/arrow_up.svg"></a>
<a href="javascript:void(0)" id="sort_popup_sort_by_name" onclick="changeSort( 'Field', 'name', strList_DefaultSortField, strList_DefaultSortDirection, strDefaultView, false, true );" class="active-sort">Name <img class="fa-chevron-down sort-direction" src="/images/UI_icons/blue/arrow_down.svg" style="display: none;"><img style="display: inline;" class="fa-chevron-up sort-direction" src="/images/UI_icons/blue/arrow_up.svg"></a>
<a href="javascript:void(0)" id="sort_popup_sort_by_views" onclick="changeSort( 'Field', 'views', strList_DefaultSortField, strList_DefaultSortDirection, strDefaultView, false, true );">Views <img class="fa-chevron-down sort-direction" src="/images/UI_icons/blue/arrow_down.svg" style="display: inline;"><img style="display: none;" class="fa-chevron-up sort-direction" src="/images/UI_icons/blue/arrow_up.svg"></a>
<a href="javascript:void(0)" id="sort_popup_sort_by_type" onclick="changeSort( 'Field', 'type', strList_DefaultSortField, strList_DefaultSortDirection, strDefaultView, false, true );">Type <img class="fa-chevron-down sort-direction" src="/images/UI_icons/blue/arrow_down.svg" style="display: inline;"><img style="display: none;" class="fa-chevron-up sort-direction" src="/images/UI_icons/blue/arrow_up.svg"></a>

<a href="javascript:void(0)" id="sort_popup_sort_by_size" onclick="changeSort( 'Field', 'size', strList_DefaultSortField, strList_DefaultSortDirection, strDefaultView, false, true );">Size <img class="fa-chevron-down sort-direction" src="/images/UI_icons/blue/arrow_down.svg" style="display: inline;"><img style="display: none;" class="fa-chevron-up sort-direction" src="/images/UI_icons/blue/arrow_up.svg"></a>

<a href="javascript:void(0)" id="sort_popup_sort_by_file_votes" onclick="changeSort( 'Field', 'file_votes', strList_DefaultSortField, strList_DefaultSortDirection, strDefaultView, false, true );">Likes <img class="fa-chevron-down sort-direction" src="/images/UI_icons/blue/arrow_down.svg" style="display: inline;"><img style="display: none;" class="fa-chevron-up sort-direction" src="/images/UI_icons/blue/arrow_up.svg"></a>

</div>
</div>
<div class="dropdown_close_before" style="display: none;"></div>
</div>
</div> <script type="text/javascript">

		var strList_DefaultSortField = 'name';
		var strList_DefaultSortDirection = 'ASC';
		var strDefaultView = 'horizontal';
		var strCurrentUploadHash = 'fhazcb8kug';
		var strList_SystemComments = '[]';
		var strListDefaults = '{"sort":{"field":"name","direction":"ASC"},"view":"horizontal"}';
		var bolIsOwner = 0;
		var bolUploadPaid = 0;
		
		var objMediaSizes = JSON.parse('{"horizontal":{"small":[100,180],"medium":[140,240],"large":[190,400]},"vertical":{"small":[100,200],"medium":[150,300],"large":[200,400]}}');
		var strTitleFont = 'AlbertaSans';
		var strTitleFontSize = 'Medium';
		var strDescFont = 'AlbertaSans';
		var strDescFontSize = 'Medium';
		var strHeaderTextPosition = 'left';
		var strHeaderCoverSize = 'small';
		var strMediaSize = 'medium';
		var strTheme = 'light';
		var intBackgroundPositionXProcent = 50;
		var intBackgroundPositionYProcent = 50;
		var objHeaderBackgroundColor = JSON.parse('{"r":0,"g":0,"b":0,"a":0.59999999999999997779553950749686919152736663818359375}');
		var objHeaderFontColor = JSON.parse('{"r":255,"g":255,"b":255,"a":1}');

		var objHeaderBackgroundColorDefault = JSON.parse('{"r":0,"g":0,"b":0,"a":0.59999999999999997779553950749686919152736663818359375}');
		var objHeaderFontColorDefault = JSON.parse('{"r":255,"g":255,"b":255,"a":1}');
		var strTitleFontDefault = 'AlbertaSans';
		var strTitleFontSizeDefault = 'Medium';
		var strDescFontDefault = 'AlbertaSans';
		var strDescFontSizeDefault = 'Medium';

		var strBackgroundSrc = '';

		function headerFieldClicked(domElement)
		{
			var strField = $('.sort_field', domElement).val();
			changeSort( 'Field', strField, strList_DefaultSortField, strList_DefaultSortDirection, strDefaultView );
		}

	</script>
<div class="upload_header">
<span class="item_name sort_by_name active" onclick="headerFieldClicked(this)">
<input type="hidden" class="sort_field" value="name">
<input type="hidden" class="sort_dir" value="1">
Name <i class="fal fa-chevron-down sort-direction active"></i>
<i class="fal fa-chevron-up sort-direction" style="display: none;"></i>
</span>
<span class="file_price" style="display: inline-block;">
</span>
<span class="folder-access">
</span>
<span class="file_views sort_by_views" onclick="headerFieldClicked(this)" style="display: none;">
<input type="hidden" class="sort_field" value="views">
<input type="hidden" class="sort_dir" value="0">
Views <i class="fal fa-chevron-down sort-direction"></i>
<i class="fal fa-chevron-up sort-direction" style="display: none;"></i>
</span>
<span class="file_downloads sort_by_downloads" onclick="headerFieldClicked(this)" style="display: none;">
<input type="hidden" class="sort_field" value="downloads">
<input type="hidden" class="sort_dir" value="0">
Downloads <i class="fal fa-chevron-down sort-direction"></i>
<i class="fal fa-chevron-up sort-direction" style="display: none;"></i>
</span>
<span class="file_size sort_by_size" onclick="headerFieldClicked(this)">
<input type="hidden" class="sort_field" value="size">
<input type="hidden" class="sort_dir" value="0">
Size <i class="fal fa-chevron-down sort-direction"></i>
<i class="fal fa-chevron-up sort-direction" style="display: none;"></i>
</span>
<span class="date_created sort_by_modified_date modified_date" onclick="headerFieldClicked(this)">
<input type="hidden" class="sort_field" value="modified_date">
<input type="hidden" class="sort_dir" value="0">
Modified <i class="fal fa-chevron-down sort-direction"></i>
<i class="fal fa-chevron-up sort-direction" style="display: none;"></i>
</span>
<span class="file_comments sort_by_file_comments" onclick="headerFieldClicked(this)" style="display: none;">
<input type="hidden" class="sort_field" value="file_comments">
<input type="hidden" class="sort_dir" value="0">
Comments <i class="fal fa-chevron-down sort-direction"></i>
<i class="fal fa-chevron-up sort-direction" style="display: none;"></i>
</span>
<span class="file_votes sort_by_file_votes" onclick="headerFieldClicked(this)" style="display: none;">
<input type="hidden" class="sort_field" value="file_votes">
<input type="hidden" class="sort_dir" value="0">
Likes <i class="fal fa-chevron-down sort-direction"></i>
<i class="fal fa-chevron-up sort-direction" style="display: none;"></i>
</span>
<span class="date_created sort_by_date_created" onclick="headerFieldClicked(this)" style="display: none;">
<input type="hidden" class="sort_field" value="date_created">
<input type="hidden" class="sort_dir" value="0">
Created <i class="fal fa-chevron-down sort-direction"></i>
<i class="fal fa-chevron-up sort-direction" style="display: none;"></i>
</span>
<span class="file_order sort_by_file_order" onclick="headerFieldClicked(this)" style="display: none;">
<input type="hidden" class="sort_field" value="file_order">
<input type="hidden" class="sort_dir" value="0">
Order <i class="fal fa-chevron-down sort-direction"></i>
<i class="fal fa-chevron-up sort-direction" style="display: none;"></i>
</span>
</div>
<script type="text/javascript">
	
		// Variables for modal gallery
		var arrIDs_Unordered = [];
		var arrHttpCacheKeys_Unordered = [];
		var arrFileTypes_Unordered = [];
		var arrHashes_Unordered = [];
		var arrExtensions_Unordered = [];
		var arrNames_Unordered = [];
		var arrDisplayNames_Unordered = [];
		var arrWidths_Unordered = [];
		var arrHeights_Unordered = [];
		var arrIsVideo_Unordered = [];
		var arrHasVoted_Unordered = [];
		var arrVoteCounts_Unordered = [];
		var arrOrderIndex_Unordered = [];
		var arrModDate_Unordered = [];
		var arrThumbnails_Unordered = [];
		var arrIconClass_Unordered = [];
		var arrIconSvg_Unordered = [];
		var arrIsPreloaded_Unordered = [];
		var arrFeeDownloadPrice_Unordered = [];
		var arrSizes_Unordered = [];
		var arrSizesInBytes_Unordered = [];
		var arrDates_Unordered = [];
		var arrDatesCreated_Unordered = [];
		var arrDatesModified_Unordered = [];
		var arrViews_Unordered = [];
		var arrDownloads_Unordered = [];
		var arrDescriptions_Unordered = [];
		var arrTags_Unordered = [];
        var arrObjectTags_Unordered = [];
        var arrYoloObjectTags_Unordered = [];
        var arrLabelTags_Unordered = [];
		var arrAllowDownload_Unordered = [];
		var arrAllowPublicDownload_Unordered = [];
		var arrAccessType_Unordered = [];
		var arrUploadPassword_Unordered = [];
		var arrFileHost_Unordered = [];
		var arrCommentCounts_Unordered = [];
		var arrDuration_Unordered = [];
		var arrDurationPreview_Unordered = [];
		var arrBigThumbPath_Unordered = [];
		var arrFileAttributes_Unordered = [];
        var arrFileVersion_Unordered = [];
		var arrFileIsLockedByOtherUser_Unordered = [];
		var arrFileDeleteKeys_Unordered = [];
		var arrFileAccessTypes_Unordered = [];
		var arrFileHasProductSelling_Unordered = [];
        var arrFileTitle_Unordered = [];
        var arrFileSubject_Unordered = [];
        var arrFileContentType_Unordered = [];
        var arrFileCategory_Unordered = [];
        var arrFileCategories_Unordered = [];
        var arrFileKeywords_Unordered = [];
        var arrFileCreator_Unordered = [];
        var arrFilePublisher_Unordered = [];
        var arrFileContributor_Unordered = [];
        var arrFileCopyrights_Unordered = [];
        var arrFileLicenseType_Unordered = [];
        var arrFileLicenseDetails_Unordered = [];
        var arrFileLanguage_Unordered = [];
        var arrFileLocation_Unordered = [];
        var arrFileLocationLat_Unordered = [];
        var arrFileLocationLong_Unordered = [];
        var arrFileReferences_Unordered = [];
        var arrFileRelatesTo_Unordered = [];
        var arrFileFormat_Unordered = [];
        var arrFileDevice_Unordered = [];
        var arrFileDateCreated_Unordered = [];
        var arrFileSource_Unordered = [];
        var arrFileGoogleCVText_Unordered = [];
        var arrFileEasyOCRText_Unordered = [];
        var arrFileAudioTranscription_Unordered = [];
		
		
		arrIDs_Unordered = ["1794364842"];
		arrHttpCacheKeys_Unordered = [""];
		arrFileTypes_Unordered = ["video"];
		arrHashes_Unordered = ["8ygca6f2cs"];
		arrExtensions_Unordered = ["mp4"];
		arrNames_Unordered = ["-Moments-Feb-18-2024--.mp4"];
		arrDisplayNames_Unordered = ["-Moments-Feb-18-2024--.mp4"];
		arrWidths_Unordered = [1920];
		arrHeights_Unordered = [1080];
		arrIsVideo_Unordered = [true];
		arrHasVoted_Unordered = [false];
		arrVoteCounts_Unordered = ["0"];
		arrOrderIndex_Unordered = [0];
		arrModDate_Unordered = ["2024-02-25 16:33:08"];
		arrThumbnails_Unordered = ["https://fv5-4.files.fm/thumb_video_picture.php?i=8ygca6f2cs"];
		arrIconClass_Unordered = ["fal fa-file-video-o"];
		arrIconSvg_Unordered = ["mp4.svg?v=2"];
		arrIsPreloaded_Unordered = [false];
		arrFeeDownloadPrice_Unordered = [null];
		arrSizes_Unordered = ["21&nbsp;MB"];
		arrSizesInBytes_Unordered = [22491749];
		arrDates_Unordered = ["2024-02-25"];
		arrDatesCreated_Unordered = ["2024-10-14 20:21:01"];
		arrDatesModified_Unordered = ["2024-02-25 16:33:08"];
		arrViews_Unordered = [1];
		arrDownloads_Unordered = [0];
		arrDescriptions_Unordered = [""];
		arrTags_Unordered = [""];
        arrObjectTags_Unordered = [""];
        arrYoloObjectTags_Unordered = [""];
        arrLabelTags_Unordered = [""];
		arrAllowDownload_Unordered = [true];
		arrAllowPublicDownload_Unordered = [true];
		arrAccessType_Unordered = ["LINK"];
		arrUploadPassword_Unordered = [""];
		arrFileHost_Unordered = ["fv5-4.files.fm"];
		arrCommentCounts_Unordered = ["0"];
		arrDuration_Unordered = ["9"];
		arrDurationPreview_Unordered = ["0"];
		arrBigThumbPath_Unordered = ["1"];
		arrFileAttributes_Unordered = [{"hasCustomThumb":0,"hasPreviewVideo":0,"isForSale":0,"canDownload":1,"readOnly":0,"hasVideoThumb":1}];
        arrFileVersion_Unordered = [0];
		arrFileIsLockedByOtherUser_Unordered = [0];
		arrFileDeleteKeys_Unordered = [""];
		arrFileAccessTypes_Unordered = [""];
		arrFileHasProductSelling_Unordered = ["0"];
        arrFileTitle_Unordered = [ "" ];
        arrFileSubject_Unordered = [ "" ];
        arrFileContentType_Unordered = [ "" ];
        arrFileCategory_Unordered = [ "" ];
        arrFileCategories_Unordered = [ "" ];
        arrFileKeywords_Unordered = [ "" ];
        arrFileCreator_Unordered = [ "" ];
        arrFilePublisher_Unordered = [ "" ];
        arrFileContributor_Unordered = [ "" ];
        arrFileCopyrights_Unordered = [ "" ];
        arrFileLicenseType_Unordered = [ "" ];
        arrFileLicenseDetails_Unordered = [ "" ];
        arrFileLanguage_Unordered = [ "" ];
        arrFileLocation_Unordered = [ "" ];
        arrFileLocationLat_Unordered = [ "" ];
        arrFileLocationLong_Unordered = [ "" ];
        arrFileReferences_Unordered = [ "" ];
        arrFileRelatesTo_Unordered = [ "" ];
        arrFileFormat_Unordered = [ "" ];
        arrFileDevice_Unordered = [ "" ];
        arrFileDateCreated_Unordered = [ "" ];
        arrFileSource_Unordered = [ "" ];
        arrFileGoogleCVText_Unordered = [ "" ];
        arrFileEasyOCRText_Unordered = [ "" ];
        arrFileAudioTranscription_Unordered = [ "" ];
		


		var strUploadUserNameLink = '<div>not specified</div>';
		var strUploadUserNameHref = '';

		var strUploadUserID = '';
		var strUploadUserLastProfileEditTimestamp = '';
		var strUploadHash = 'fhazcb8kug';

		var intUserLoggedIn = '';

        var bolIsAnonymousUpload = true        
        var arrIDs = ["1794364842"];
		var arrHttpCacheKeys = [""];
		var arrFileTypes = ["video"];
	    var arrHashes = ["8ygca6f2cs"];
	    var arrExtensions = ["mp4"];
	    var arrStatuses = [""];
	    var arrReports = ["0"];
	    var arrNames = ["-Moments-Feb-18-2024--.mp4"];
	    var arrDisplayNames = ["-Moments-Feb-18-2024--.mp4"];
	    var arrWidths = [1920];
	    var arrHeights = [1080];
	    var arrIsVideo = [true];
	    var arrHasVoted = [false];
	    var arrVoteCounts = ["0"];
	    var arrOrderIndex = [0];
	    var arrModDate = ["2024-02-25 16:33:08"];
	    var arrThumbnails = ["https://fv5-4.files.fm/thumb_video_picture.php?i=8ygca6f2cs"];
        var arrIconClass = ["fal fa-file-video-o"];
        var arrIconSvg = ["mp4.svg?v=2"];
		var arrIsPreloaded = [false];
		var arrFeeDownloadPrice = [null];
		var arrSizes = ["21&nbsp;MB"];
		var arrSizesInBytes = [22491749];
		var arrDates = ["2024-02-25"];
		var arrDatesCreated = ["2024-10-14 20:21:01"];
		var arrDatesModified = ["2024-02-25 16:33:08"];
		var arrDatesDelete = ["2024-10-28 20:20:30"];
		var arrViews = [1];
		var arrDownloads = [0];
		var arrDescriptions = [""];
		var arrTags = [""];
        var arrObjectTags = [""];
        var arrYoloObjectTags = [""];
        var arrLabelTags = [""];
        var arrAllowDownload = [true];
        var arrHideDownloadButtons = [false];
        var arrAllowPublicDownload = [true];
		var arrAccessType = ["LINK"];
		var arrUploadPassword = [""];
		var arrFileHost = ["fv5-4.files.fm"];
        var arrCommentCounts = ["0"];
        var arrDuration = ["9"];
        var arrDurationPreview = ["0"];
        var arrBigThumbPath = ["1"];
        var arrForbidDirectDownload = [0];
        var arrForbidDirectDownload_Authenticated = [0];
        var arrFileAttributes = [{"hasCustomThumb":0,"hasPreviewVideo":0,"isForSale":0,"canDownload":1,"readOnly":0,"hasVideoThumb":1}];
        var arrFileVersion = [0];
        var arrFileIsLockedByOtherUser = [0];
        var arrFileDeleteKeys = [""];
        var arrFileAccessTypes = [""];
		var arrFileHasProductSelling = ["0"];
        var arrFileTitle = [ "" ];
        var arrFileSubject = [ "" ];
        var arrFileContentType = [ "" ];
        var arrFileCategory = [ "" ];
        var arrFileCategories = [ "" ];
        var arrFileKeywords = [ "" ];
        var arrFileCreator = [ "" ];
        var arrFilePublisher = [ "" ];
        var arrFileContributor = [ "" ];
        var arrFileCopyrights = [ "" ];
        var arrFileLicenseType = [ "" ];
        var arrFileLicenseDetails = [ "" ];
        var arrFileLanguage = [ "" ];
        var arrFileLocation = [ "" ];
        var arrFileLocationLat = [ "" ];
        var arrFileLocationLong = [ "" ];
        var arrFileReferences = [ "" ];
        var arrFileRelatesTo = [ "" ];
        var arrFileFormat = [ "" ];
        var arrFileDevice = [ "" ];
        var arrFileDateCreated = [ "" ];
        var arrFileSource = [ "" ];
        var arrFileGoogleCVText = [ "" ];
        var arrFileEasyOCRText = [ "" ];
        var arrFileAudioTranscription = [ "" ];

	</script>
<div id="all_items" class="upload" upload_hash="fhazcb8kug" style="opacity: 1;">
 <script>
		changeSort( 'Field', strList_DefaultSortField, strList_DefaultSortField, strList_DefaultSortDirection, strDefaultView, true );
	</script><div class="item file video-item   	" onmouseover="highlightItem(this, event)" onmouseout="unhighlightItem(this, event)" file_hash="8ygca6f2cs" file_id="1794364842" display_name="-Moments-Feb-18-2024--.mp4" views="1" status="" ext="mp4" size="22491749" modified_date="2024-02-25 16:33:08" downloads="0" file_comments="0" file_votes="0" date_created="2024-10-14 20:21:01" file_order="0" file_unordered_index="0" id="item_8ygca6f2cs" style="display: inline-block; width: 426.667px;"> <div class="item_selection_chkbox_container ">
<input class="item_selector" id="checked_file_1794364842" type="checkbox" onclick="checkToggleByCheckBox(event, this)">
<label class="fa item_selector item_selector_label" for="checked_file_1794364842"></label>
</div> <div class="overlay-on-hover off-hover">
<div class="tools">
<div class="tools-middle"><a href="javascript:void(0)" onclick="listPreviewFile('8ygca6f2cs')"><img class="preview-icon-svg light" src="/images/folder_view/play_light_new.svg"><img class="preview-icon-svg dark" src="/images/folder_view/play_dark.svg"></a> </div>
</div>
</div> <a class="top_button_download my_tooltip" href="https://fv5-4.files.fm/down.php?cf&amp;i=8ygca6f2cs&amp;n=-Moments-Feb-18-2024--.mp4" my_title="Download"><img src="/images/UI_icons/white/download.svg"></a>
<div class="overlay-on-hover">
<div class="tools">
<div class="tools-top-left">
</div>
<div class="tools-bottom-right"> <a href="javascript:void(0)" class="handleContextMenuButton ellipsis" onclick="handleFileContextMenu( event, 1794364842 ); event.stopPropagation();"></a> </div>
<div class="tools-top-right"> <a class="top-embed-button" href="javascript:void(0)" onclick="window.FileEmbedPopup.showPopup( event, {&quot;show_type_select&quot;:true,&quot;type&quot;:&quot;one_file&quot;,&quot;can_share&quot;:false,&quot;all_files&quot;:{&quot;view_url&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;,&quot;edit_url&quot;:&quot;&quot;,&quot;upload_url&quot;:&quot;&quot;,&quot;facebook&quot;:{&quot;name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;,&quot;picture_url&quot;:&quot;https:\/\/files.fm\/images\/files.fm_300.png&quot;,&quot;description&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;,&quot;return_link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug?after_fb_share&quot;},&quot;twitter&quot;:{&quot;text&quot;:&quot;files.fm: -Moments-Feb-18-2024--.mp4&quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;},&quot;share_email&quot;:{&quot;upload_hash&quot;:&quot;fhazcb8kug&quot;,&quot;file_view_hash&quot;:&quot;&quot;},&quot;item_info&quot;:{&quot;upload_hash&quot;:&quot;fhazcb8kug&quot;,&quot;item_name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;}},&quot;one_file&quot;:{&quot;view_url&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;edit_url&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;facebook&quot;:{&quot;name&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;picture_url&quot;:&quot;https:\/\/fv5-4.files.fm\/thumb_video_picture.php?i=8ygca6f2cs&quot;,&quot;description&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;return_link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug?after_fb_share&quot;},&quot;twitter&quot;:{&quot;text&quot;:&quot;files.fm: &quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;},&quot;share_email&quot;:{&quot;upload_hash&quot;:&quot;&quot;,&quot;file_view_hash&quot;:&quot;8ygca6f2cs&quot;},&quot;item_info&quot;:{&quot;file_view_hash&quot;:&quot;8ygca6f2cs&quot;,&quot;upload_hash&quot;:&quot;fhazcb8kug&quot;,&quot;file_name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;,&quot;item_name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;,&quot;file_version&quot;:0,&quot;extension&quot;:&quot;mp4&quot;,&quot;owner_logged_in&quot;:0,&quot;access_type&quot;:&quot;LINK&quot;,&quot;parent_access_type&quot;:&quot;LINK&quot;},&quot;embed_player&quot;:{&quot;file_view_hash&quot;:&quot;8ygca6f2cs&quot;,&quot;file_extension&quot;:&quot;mp4&quot;,&quot;is_video&quot;:true}}} );" id="list_item_embed_button_for_file_8ygca6f2cs">
<i class="fal fa-code" style="color: #fff;"></i>
</a> <a class="top-share-button" href="javascript:void(0)" onclick="showSharePopup( event, {&quot;show_type_select&quot;:true,&quot;type&quot;:&quot;one_file&quot;,&quot;can_share&quot;:false,&quot;all_files&quot;:{&quot;view_url&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;,&quot;edit_url&quot;:&quot;&quot;,&quot;upload_url&quot;:&quot;&quot;,&quot;facebook&quot;:{&quot;name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;,&quot;picture_url&quot;:&quot;https:\/\/files.fm\/images\/files.fm_300.png&quot;,&quot;description&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;,&quot;return_link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug?after_fb_share&quot;},&quot;twitter&quot;:{&quot;text&quot;:&quot;files.fm: -Moments-Feb-18-2024--.mp4&quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;},&quot;share_email&quot;:{&quot;upload_hash&quot;:&quot;fhazcb8kug&quot;,&quot;file_view_hash&quot;:&quot;&quot;},&quot;item_info&quot;:{&quot;upload_hash&quot;:&quot;fhazcb8kug&quot;,&quot;item_name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;}},&quot;one_file&quot;:{&quot;view_url&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;edit_url&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;facebook&quot;:{&quot;name&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;picture_url&quot;:&quot;https:\/\/fv5-4.files.fm\/thumb_video_picture.php?i=8ygca6f2cs&quot;,&quot;description&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;return_link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug?after_fb_share&quot;},&quot;twitter&quot;:{&quot;text&quot;:&quot;files.fm: &quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;},&quot;share_email&quot;:{&quot;upload_hash&quot;:&quot;&quot;,&quot;file_view_hash&quot;:&quot;8ygca6f2cs&quot;},&quot;item_info&quot;:{&quot;file_view_hash&quot;:&quot;8ygca6f2cs&quot;,&quot;upload_hash&quot;:&quot;fhazcb8kug&quot;,&quot;file_name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;,&quot;item_name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;,&quot;file_version&quot;:0,&quot;extension&quot;:&quot;mp4&quot;,&quot;owner_logged_in&quot;:0,&quot;access_type&quot;:&quot;LINK&quot;,&quot;parent_access_type&quot;:&quot;LINK&quot;},&quot;embed_player&quot;:{&quot;file_view_hash&quot;:&quot;8ygca6f2cs&quot;,&quot;file_extension&quot;:&quot;mp4&quot;,&quot;is_video&quot;:true}}} );" id="list_item_share_button_for_file_8ygca6f2cs">
Share
</a> <div class="copy_button no-dropdown handleContextMenuDrawerButton" data-clipboard-text="https://files.fm/f/8ygca6f2cs" data-item-hash="8ygca6f2cs" onclick="handleFileContextMenuCopy( event, 1794364842 ); event.stopPropagation();">
<div class="copy_text">
<div class="hover mobile">Copy</div>
<div class="hover">Copy link</div>
<div class="copied">Copied</div>
</div>
</div>
<a class="top_button_download" href="https://fv5-4.files.fm/down.php?cf&amp;i=8ygca6f2cs&amp;n=-Moments-Feb-18-2024--.mp4">Download</a> <a class="top-report-button" href="javascript:void(0)" id="report_8ygca6f2cs" onclick="showFileReportModal(this, '8ygca6f2cs')"><i class="fal fa-exclamation-circle"></i></a> </div>
<div class="tools-middle"><a href="javascript:void(0)" onclick="listPreviewFile('8ygca6f2cs')"><img class="preview-icon-svg light" src="/images/folder_view/play_light_new.svg"><img class="preview-icon-svg dark" src="/images/folder_view/play_dark.svg"></a><a class="tools_button_download" href="https://fv5-4.files.fm/down.php?cf&amp;i=8ygca6f2cs&amp;n=-Moments-Feb-18-2024--.mp4"><img class="download-icon-svg-light" src="/images/list_items/download-circle-light-new.svg?v=1"><img class="download-icon-svg-dark" src="/images/list_items/download-circle-dark.svg?v=1"></a> </div>
</div>
<div class="buttons">
</div>
</div>
<ul id="file_context_menu_1794364842" class="dropdown-menu file_context_menu">
<li role="presentation" style="margin-top: 0">
<div class="file_context_menu_handle">
</div>
</li>
<li role="presentation" style="display: inline-flex;align-items: center; font-size: 12px; line-height:16px; padding: 10px 15px; color: #1A2533;width: calc(100% - 40px);"> <img style="width: 18px; height: unset; margin-right: 10px;" src="/images/file_types_v2/mp4.svg?v=2"> <span style=" display: inline-block;display: -webkit-inline-box;font-size: 12px;line-height:16px;-webkit-line-clamp: 2;-webkit-box-orient: vertical;overflow: hidden;">
-Moments-Feb-18-2024--
</span>
<div class="file_context_menu_close"> <i class="fal fa-times"></i></div>
</li>
<li role="presentation" class="divider" style="margin-top: 0"></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:void(0)" onclick="listPreviewFile('8ygca6f2cs')"><div class="context-img"><img src="/images/UI_icons/eye.svg"></div>View</a></li><li role="presentation"><a class="tools_button_download" href="https://fv5-4.files.fm/down.php?cf&amp;i=8ygca6f2cs&amp;n=-Moments-Feb-18-2024--.mp4"><div class="context-img"><img src="/images/UI_icons/download.svg"></div>Download</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:void(0)" onclick="showSharePopup( event, {&quot;show_type_select&quot;:true,&quot;type&quot;:&quot;one_file&quot;,&quot;can_share&quot;:false,&quot;all_files&quot;:{&quot;view_url&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;,&quot;edit_url&quot;:&quot;&quot;,&quot;upload_url&quot;:&quot;&quot;,&quot;facebook&quot;:{&quot;name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;,&quot;picture_url&quot;:&quot;https:\/\/files.fm\/images\/files.fm_300.png&quot;,&quot;description&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;,&quot;return_link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug?after_fb_share&quot;},&quot;twitter&quot;:{&quot;text&quot;:&quot;files.fm: -Moments-Feb-18-2024--.mp4&quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;},&quot;share_email&quot;:{&quot;upload_hash&quot;:&quot;fhazcb8kug&quot;,&quot;file_view_hash&quot;:&quot;&quot;},&quot;item_info&quot;:{&quot;upload_hash&quot;:&quot;fhazcb8kug&quot;,&quot;item_name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;}},&quot;one_file&quot;:{&quot;view_url&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;edit_url&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;facebook&quot;:{&quot;name&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;picture_url&quot;:&quot;https:\/\/fv5-4.files.fm\/thumb_video_picture.php?i=8ygca6f2cs&quot;,&quot;description&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;return_link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug?after_fb_share&quot;},&quot;twitter&quot;:{&quot;text&quot;:&quot;files.fm: &quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;},&quot;share_email&quot;:{&quot;upload_hash&quot;:&quot;&quot;,&quot;file_view_hash&quot;:&quot;8ygca6f2cs&quot;},&quot;item_info&quot;:{&quot;file_view_hash&quot;:&quot;8ygca6f2cs&quot;,&quot;upload_hash&quot;:&quot;fhazcb8kug&quot;,&quot;file_name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;,&quot;item_name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;,&quot;extension&quot;:&quot;mp4&quot;,&quot;owner_logged_in&quot;:0,&quot;access_type&quot;:&quot;LINK&quot;,&quot;parent_access_type&quot;:&quot;LINK&quot;},&quot;embed_player&quot;:{&quot;file_view_hash&quot;:&quot;8ygca6f2cs&quot;,&quot;file_extension&quot;:&quot;mp4&quot;,&quot;is_video&quot;:true}}} );" class="list_item_embed_button_for_file"><div class="context-img"><img src="/images/UI_icons/share.svg"></div>Share access link </a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:void(0)" onclick="window.FileEmbedPopup.showPopup( event, {&quot;show_type_select&quot;:true,&quot;type&quot;:&quot;one_file&quot;,&quot;can_share&quot;:false,&quot;all_files&quot;:{&quot;view_url&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;,&quot;edit_url&quot;:&quot;&quot;,&quot;upload_url&quot;:&quot;&quot;,&quot;facebook&quot;:{&quot;name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;,&quot;picture_url&quot;:&quot;https:\/\/files.fm\/images\/files.fm_300.png&quot;,&quot;description&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;,&quot;return_link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug?after_fb_share&quot;},&quot;twitter&quot;:{&quot;text&quot;:&quot;files.fm: -Moments-Feb-18-2024--.mp4&quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug&quot;},&quot;share_email&quot;:{&quot;upload_hash&quot;:&quot;fhazcb8kug&quot;,&quot;file_view_hash&quot;:&quot;&quot;},&quot;item_info&quot;:{&quot;upload_hash&quot;:&quot;fhazcb8kug&quot;,&quot;item_name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;}},&quot;one_file&quot;:{&quot;view_url&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;edit_url&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;facebook&quot;:{&quot;name&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;picture_url&quot;:&quot;https:\/\/fv5-4.files.fm\/thumb_video_picture.php?i=8ygca6f2cs&quot;,&quot;description&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;,&quot;return_link&quot;:&quot;https:\/\/files.fm\/u\/fhazcb8kug?after_fb_share&quot;},&quot;twitter&quot;:{&quot;text&quot;:&quot;files.fm: &quot;,&quot;link&quot;:&quot;https:\/\/files.fm\/f\/8ygca6f2cs&quot;},&quot;share_email&quot;:{&quot;upload_hash&quot;:&quot;&quot;,&quot;file_view_hash&quot;:&quot;8ygca6f2cs&quot;},&quot;item_info&quot;:{&quot;file_view_hash&quot;:&quot;8ygca6f2cs&quot;,&quot;upload_hash&quot;:&quot;fhazcb8kug&quot;,&quot;file_name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;,&quot;item_name&quot;:&quot;-Moments-Feb-18-2024--.mp4&quot;,&quot;extension&quot;:&quot;mp4&quot;,&quot;owner_logged_in&quot;:0,&quot;access_type&quot;:&quot;LINK&quot;,&quot;parent_access_type&quot;:&quot;LINK&quot;},&quot;embed_player&quot;:{&quot;file_view_hash&quot;:&quot;8ygca6f2cs&quot;,&quot;file_extension&quot;:&quot;mp4&quot;,&quot;is_video&quot;:true}}} );" class="list_item_embed_button_for_file"><div class="context-img"><img src="/images/UI_icons/code.svg"></div>Embed links </a></li> <li role="presentation" class="divider"></li>
<li role="presentation"><a href="javascript:void(0)" class="report_btn" onclick="showFileReportModal(this, '8ygca6f2cs')"><div class="context-img"><img src="/images/UI_icons/alert.svg?v=1"></div>Report a problem </a></li> </ul> <div class="thumb" onclick="">
<div class="overlay-bg"></div>
<img src="https://fv5-4.files.fm/thumb_video_picture.php?i=8ygca6f2cs" data-original="" class="" data-height-width-ratio="0.5625" data-stretch="true">&nbsp; </div><div class="item_name"><span class="file-name">-Moments-Feb-18-2024--<span class="filename-extension" style="">.mp4</span></span><a href="javascript:void(0)" onclick="listPreviewFile('8ygca6f2cs')"><span class="full-file-name">-Moments-Feb-18-2024--<span class="filename-extension" style="">.mp4</span></span></a></div>
<div class="file_price" style="display: inline-block;"> </div> <div class="folder-access"> <div class="folder-access-image link"></div></div> <div class="file_views" style="display: none;"> 1 </div>
<div class="file_downloads" style="display: none;"> </div>
<div class="file_size">21&nbsp;MB</div>
<span class="modified_date ">2024-02-25<br> 16:33</span>
<div class="file_comments" style="display: none;"> </div>
<div class="file_votes" style="display: none;"> </div>
<div class="date_created" style="display: none;">2024-10-14<br> 20:21</div> <div class="file_order" style="display: none;">0</div>
<input type="hidden" class="OrderID" name="OrderID[]" value="1794364842">
<input type="hidden" class="OrderIndex" name="OrderIndex[]" value="0">
</div>
</div>
<script type="text/javascript">
		$("img.lazyload-image").lazyload({failure_limit : 10, skip_invisible: false, event: 'scroll touchmove',threshold : 350});
		
		$('.tools A, .buttons:not(.gallery2_item_info_padded) A').on('click', function (e){
			e.stopPropagation();
		});
		arrMasonryItemsWidths = getAllMasonryItemsHorWidths($( "#all_items" ))
		resizeAllMasonryItemsHor($( "#all_items" ));
	</script>
<div class="clearfix"></div>
</div>
</div>
<script type="text/javascript">
			// Show gallery if url contine link to file gallery 
			galleryCheckHashtag();

			strViewClass = 'horizontal_view';
			// Old links
		    if (window.location.hash.slice(1,4) == '/G/')
		    {
                clearHashFromURL();
		        strViewClass = 'grid_view';
		    }
		    else if (window.location.hash.slice(1,4) == '/L/')
		    {
    			window.location.hash = '/list/';
		        strViewClass = 'list_view';
		    }
		    else if (window.location.hash.slice(1,4) == '/P/')
		    {
    			window.location.hash = '/player/';
		        strViewClass = 'list_view';
		        $('#right .item:not(.audio-item)').css({'display':'none'});
			}
			// New links
		    else if (window.location.hash.slice(1,7) == '/list/')
		    {
		        strViewClass = 'list_view';
		    }
		    else if (window.location.hash.slice(1,7) == '/grid/')
		    {
		        strViewClass = 'grid_view';
		    }
		    else if (window.location.hash.slice(1,11) == '/vertical/')
		    {
		        strViewClass = 'vertical_view';
		    }
		    else if (window.location.hash.slice(1,9) == '/player/')
		    {
		        strViewClass = 'list_view';
		        $('#right .item:not(.audio-item)').css({'display':'none'});
		    }
		    $('#right').removeClass('grid_view').removeClass('list_view').removeClass('vertical_view').removeClass('horizontal_view').addClass(strViewClass).removeClass('item-list-loading');
		</script>
<style type="text/css">
			.item-list-loading {
				display: block;	
			}
		</style>
<div id="left" class="upload_without_owner">
<div id="left_container_close" onclick="toggleLeftInfoBlock()">
<i class="fal fa-times"></i>
</div>
<div id="upload_info">
<div id="folder-info">Folder information:</div>
<div id="upload_info_image_details">
<ul id="upload_info_details">
<li>
<span class="upload_info_details_desc">Folder</span>
<div class="upload_info_details_text">-Moments-Feb-18-2024--.mp4</div>
</li>
<li>
<span class="upload_info_details_desc">User</span>
<span class="upload_info_details_text"><div id="header-owner_name"><div>not specified</div></div></span>
</li>
<li>
<span class="upload_info_details_desc">Modified</span>
<span class="upload_info_details_text my_tooltip" my_title="Upload date: 2024-10-14 20:20:30<br>Mod. date: 2024-10-14 20:21:10">2024-10-14</span>
</li>
<li style="font-weight: bold; color: #EE2B3A">
<span class="upload_info_details_desc">Will be deleted</span>
<span class="upload_info_details_text">2024-10-28 20:20</span>
</li>
<li>
<span class="upload_info_details_desc">Count</span>
<span class="upload_info_details_text">1</span>
</li>
<li>
<span class="upload_info_details_desc">Size</span>
<span class="upload_info_details_text">21&nbsp;MB</span>
</li>
<li>
<span class="upload_info_details_desc">Views</span>
<span class="upload_info_details_text">9</span>
</li>
</ul>
</div>
<div id="upload-info-button-container">
</div>
<div id="stick-top">
<div style="margin-top: 12px;display: flex;justify-content: center;">
<div id="files_300x250_sidebar_desktop_1">
<script>
                            if ( typeof googletag != 'undefined' && typeof googletag.cmd != 'undefined' )
                            {
                                googletag.cmd.push(function() { googletag.display('files_300x250_sidebar_desktop_1'); });
                            }
                        </script>
</div>
</div>
<div style="margin-top: 12px;display: flex;justify-content: center;">
<div id="files_300x250_sidebar_desktop_2">
<script>
                            if ( typeof googletag != 'undefined' && typeof googletag.cmd != 'undefined' )
                            {
                                googletag.cmd.push(function() { googletag.display('files_300x250_sidebar_desktop_2'); });
                            }
                        </script>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">checkLeftInfoBlockVisibility();</script>
</div>
<div class="clear"></div>
<script type="text/javascript">

		
	
    $( "#head_menu__dropdown__content_buttons .list-view_upload-info-buttons" ).each(function() {
        if($.trim($( this ).text()) == "")
        {
            $( this ).remove();
        }
    });
	if ( $( "#head_menu__dropdown__content_buttons .list-view_upload-info-buttons a" ).length < 1 ) 
	{
		$( "#head_menu__button" ).hide();

		if( !$.trim($( "#head__all-files-actions" ).html()) )
		{
			$( "#head" ).addClass('no-buttons');
		}

		$( "#head__all-files-actions" ).css("gap", "0");
	}
	else
	{
		$( "#head_menu__button" ).css("display", "inline-flex");
		$( "#head__all-files-actions" ).css("gap", "");

		if( !$.trim($( "#head__all-files-actions" ).html()) )
		{
			$( "#head" ).addClass('no-sharewrap');
			$( "#head__all-files-actions" ).hide();
		}
		
	}


	function updateToggleOption( objToggleOptionContainer )
    {
		if(0)
        {
            return;
        }
        
        if ( 
                typeof $( objToggleOptionContainer ).attr( 'data-toggle-option-status' ) != 'undefined' &&
                typeof $( objToggleOptionContainer ).attr( 'data-toggle-option-name' ) != 'undefined' &&
                typeof $( objToggleOptionContainer ).attr( 'data-toggle-option-display-name' ) != 'undefined' &&
                ( $( objToggleOptionContainer ).attr( 'data-toggle-option-status' ) == 'on' || $( objToggleOptionContainer ).attr( 'data-toggle-option-status' ) == 'off' ) 
            )
        {
            var strToggleOptionName = $( objToggleOptionContainer ).attr( 'data-toggle-option-name' );
            var strToggleOptionStatus = $( objToggleOptionContainer ).attr( 'data-toggle-option-status' );
            var strToggleOptionDisplayName = $( objToggleOptionContainer ).attr( 'data-toggle-option-display-name' );

            var strAjaxUrl = '';
            var objAjaxUpdateData = {};
    
            var fnPost = function () {
                if ( strAjaxUrl != '' && ! $.isEmptyObject( objAjaxUpdateData ) )
                {
                    $( objToggleOptionContainer ).attr( 'data-toggle-option-status', 'wait' );
            
                    $.ajax( {
                        type: "POST",
                        dataType: "json",
                        url: strAjaxUrl ,
                        data: objAjaxUpdateData ,
                        success: function( data )
                        {
                            if ( data[ 'status' ] == 'ok' )
                            {
                                if ( strToggleOptionStatus == 'on' )
                                {
                                    $( objToggleOptionContainer ).attr( 'data-toggle-option-status', 'off' );
                                }
                                else
                                {
                                    $( objToggleOptionContainer ).attr( 'data-toggle-option-status', 'on' );
                                }
                            }
                            else
                            {
                                $( objToggleOptionContainer ).attr( 'data-toggle-option-status', strToggleOptionStatus );
                                fError( 'Unable to update "'+ strToggleOptionDisplayName +'". Please try again!' );
                            }
                        } ,
                        error: function()
                        {
                            $( objToggleOptionContainer ).attr( 'data-toggle-option-status', strToggleOptionStatus );
                            fError( 'Unable to update "'+ strToggleOptionDisplayName +'". Please try again!' );
                        }
                    });
                }
            };
            
            if ( strToggleOptionName == 'hide_download_buttons' )
            {
                                objSubscriptionForm.showForm_FeeFeature( 'filebrowser__hide_download_buttons' );
                return;
                
                var intUploadHideDownloadButtons_New;
                if ( strToggleOptionStatus == 'on' )
                {
                    intUploadHideDownloadButtons_New = 0;
                }
                else
                {
                    intUploadHideDownloadButtons_New = 1;
                }

                strAjaxUrl = "/ajax/upload_info.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a";
                objAjaxUpdateData = {
                    'set_upload_hide_download_buttons': true ,
                    'upload_hash' : 'fhazcb8kug' ,
                    'hide_download_buttons' : intUploadHideDownloadButtons_New
                };

            }
                   
            fnPost();            
        }
    }

	function ShowDescription(hash)
	{
		$('#descr_text_'+hash).hide();
		$('#change_descr_'+hash).hide();
		$('#edit_icon_'+hash).css({'visibility': 'hidden'});
		$('#descr_form_'+hash).show();
		$('#save_descr_icon_'+hash).show();
		
	}
	
	function deleteUpload(hash, del_key)
	{
		jQuery.getJSON('/api/delete_upload.php', {'u': hash, 'del_key': del_key, 'source':'list', 'PHPSESSID': '40bdb754ce23cdfc13a344b0230a4e21f5e0785a'}, function (res){

			resp = res;
			if (resp['error'] == 1 || resp['deleted_id'] <= 0)
			{
                if ( typeof resp[ 'upload_read_only' ] !== 'undefined' && resp[ 'upload_read_only' ] )
                {
                    fError( "This folder cannot be deleted because it contains shared files!" );
                }
                else
                {
                    fError( "There was an error deleting one of the folders!" );
                }
                
                return false;
			}
			else
			{
				fSuccess('Folder has been deleted!',null,null,function(){
					window.location.reload();
				});
			}
		});
	}

	function voteForFile(strHash, fnCallback) {
        if( typeof fnCallback === "undefined" )
        {
            fnCallback = function(){}
        }
		
    	var intFileIndex = null;
    	for (idx in arrIDs)
    	{
    		if (arrHashes[idx] == strHash)
    		{
    		 	intFileIndex = idx;
    		 	break;	
			}
		}
		
		$.ajax({
			type: "POST",
			dataType: "json",
			url: "./ajax/vote_for_file.php?i=PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
			data: {
				'vote' : true ,
				'h' : strHash
			},
			success: function(data) {
				if (data['status'] == 'ok') {
					
					var bol = null;
					if (data['action'] == 'vote') {
												
						$('#vote_' + strHash).addClass('has_voted').attr('my_title', 'Unlike');
						bol = true;
					}
					else {
						
						$('#vote_' + strHash).removeClass('has_voted').attr('my_title', 'Like');
						bol = false;
					}
					
					if ( intFileIndex )
					{
						arrHasVoted[intFileIndex] = bol;
						arrVoteCounts[intFileIndex] = parseInt(arrVoteCounts[intFileIndex]) + ( bol ? 1 : -1);
						
						if ( typeof(bolGalleryIsVisible) !='undefined' && bolGalleryIsVisible && typeof(galleryUpdateVoteCount) == 'function')
						{
							galleryUpdateVoteCount();	
						}
					}
                    
                    document.dispatchEvent( new CustomEvent('fileVoteStateChange', { detail: {hash: strHash, state: bol} }) );
                    fnCallback(bol);
				}
			}
		});
	}
	

	function deleteFile(strKey, strUploadH, strFileH, strFileName)
	{
		fConfirm( 'Do you really want to delete this file?</br><b>"' + strFileName + '"</b>', 'Delete', 'Yes, delete!', 'Cancel', function(r){
			if( r == true )
			{
				$.ajax({
					type: "POST",
					dataType: "json",
					url: "./ajax/delete_file.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
					data: {
						'delete_file': true,
						'k'			 : strKey,
						'u'			 : strUploadH,
						'f'			 : strFileH ,
						'source'	 : 'list'
					},
					success: function( data ){
						if( data['status'] == 'ok' )
						{
							fSuccess( "File \""+ strFileName +"\" has been <b>deleted</b>!", "" );
							location.reload();
						}
						else
						{
						    if( typeof data[ 'file_read_only' ] !== 'undefined' && data[ 'file_read_only' ] ) 
                            {
                                fError( "The file cannot be deleted because it is shared!", "Info" );
                            }
						    else if ( typeof data[ 'file_is_locked' ] !== 'undefined' && data[ 'file_is_locked' ] ) 
                            {
                                fError( "This file cannot be deleted because it is locked.", "Info" );
                            }
                            else
                            {
                                fError( "There was an error, the file was not deleted", "Info" );
                            }
						}
					}
				});
			}
		});
		return false;
	}


    var intUpload_HideDownloadButtons = 0;
    var intUpload_IsPublic = 0;
    var intUpload_PropagateSettings = 0;

    function changePropagateSettings()
    {
        var intPropagateChanges_New;
        if ( intUpload_PropagateSettings == 1 )
        {
            intPropagateChanges_New = 0;
        }
        else if ( intUpload_PropagateSettings == 0 )
        {
            intPropagateChanges_New = 1;
        }
        else
        {
            return;
        }
        
        var fnPost = function ()
        {
            $.ajax( {
                type: "POST",
                dataType: "json",
                url: "/ajax/upload_info.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a",
                data: {
                    'set_upload_propagate_settings': true,
                    'upload_hash': 'fhazcb8kug',
                    'propagate_settings': intPropagateChanges_New
                },
                success: function ( data )
                {
                    if ( data.status === 'ok' )
                    {
                        location.reload();
                    }
                    else
                    {
                        fError( "Something went wrong. Please try again." )
                    }
                }
            } );
        };
        
        if ( intPropagateChanges_New === 1 )
        {
            fConfirm(
                "After setting inheritance is turned on, the settings of all sub-directories (Private access, Password, Published, Allow Download) will be overwritten with this folder’s settings and any further changes to this folder’s settings will be applied to its sub-directories.",
                "Are you sure you want to turn on inheritance?",
                "Yes",
                "No", 
                function( bolResponse ) {
                    if ( bolResponse )
                    {
                        fnPost();
                    }
                } 
            );
        }
        else
        {
            fnPost();
        }
    }
        
    function changeHideDownloadButtons()
    {
        if ( intUpload_PropagateSettings > 0 )
        {
            return;
        }
        
        var intUpload_HideDownloadButtons_New;
        if ( intUpload_HideDownloadButtons == 1 )
        {
        	intUpload_HideDownloadButtons_New = 0;
        }
        else
        {
        	intUpload_HideDownloadButtons_New = 1;
        }
        
        $.ajax({
            type: "POST",
            dataType: "json",
            url: './ajax/upload_info.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a' ,
            data: {
                'set_upload_hide_download_buttons': true ,
                'upload_hash' : 'fhazcb8kug' ,
                'hide_download_buttons' : intUpload_HideDownloadButtons_New
            } ,
            success: function(data)
            {
            	if (data['status'] == 'ok')
				{
					location.reload();
				}
            }
        });
    }

    
    function changePublic()
    {
        if ( intUpload_PropagateSettings > 0 )
        {
            return;
        }
        
        var intUpload_IsPublic_New;
        if ( intUpload_IsPublic == 1 )
        {
            intUpload_IsPublic_New = 0;
        }
        else
        {
            intUpload_IsPublic_New = 1;
        }
        
        $.ajax({
            type: "POST",
            dataType: "json",
            url: './ajax/upload_info.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a' ,
            data: {
                'set_upload_published_value': true ,
                'upload_hash' : 'fhazcb8kug' ,
                'is_public' : intUpload_IsPublic_New
            } ,
            success: function(data)
            {
                if (data['status'] == 'ok')
                {
                    intUpload_IsPublic = data[ 'updated_value' ];
                    
                    if ( intUpload_IsPublic == 1 )
                    {
                        fSuccess( 'Files added to the public profile.' );
                        $('#upload-info-button-add-to-public-catalog-text ').text('Remove from public catalog');
                    }
                    else
                    {
                        fSuccess( 'Files removed from the public profile' );
                        $('#upload-info-button-add-to-public-catalog-text').text('Publish to my public profile');
                    }
                }
            }
        });
    }

    
    function changeUploadPrivate()
    {
        if ( intUpload_PropagateSettings > 0 )
        {
            return;
        }
        
    	$.ajax({
			type: "POST",
			dataType: "json",
			url: './ajax/upload_info.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a' ,
			data: {
				'set_upload_access_type': true ,
				'upload_hash' : 'fhazcb8kug' ,
                'upload_access_type': 'PRIVATE'
			} ,
			success: function(data)
			{
				if (data['status'] == 'ok')
				{
					location.reload();
				}
			}
		});
    }
	
	function changeUploadName()
    {
		var strFolderName = $('#upload_info_name').val();

		function bolCheckData()
		{
			if ( strFolderName == '' )
			{
				$('#upload_info_name').val('New folder')
				strFolderName = 'New folder';
				return true;
			}
			if ( checkFileNameIsValid ( strFolderName ) === false )
			{
				$('#upload_info_name').addClass('invalid');
				return false;
			}
			else if ( strFolderName === '-Moments-Feb-18-2024--.mp4' )
			{
				return false;
			}
			else
			{
				return true;
			}
		}

		if(bolCheckData())
		{
			var objData = {
				'upload_hash' : 'fhazcb8kug' ,

				'update_upload_name': true ,
				'upload_name' : strFolderName
			}

			$.ajax({
				type: "POST",
				dataType: "json",
				url: './ajax/upload_info.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a' ,
				data: objData ,
				success: function(data)
				{
					if (data['status'] == 'ok')
					{
						location.reload();
					}
				}
			});
		}
    }
	
	function changeUploadDesc()
    {
		var strFolderDesc = $('#upload_info_desc').val();

		var objData = {
			'upload_hash' : 'fhazcb8kug' ,

			'update_upload_description': true ,
			'upload_description' : strFolderDesc
		}

		$.ajax({
			type: "POST",
			dataType: "json",
			url: './ajax/upload_info.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a' ,
			data: objData ,
			success: function(data)
			{
				if (data['status'] == 'ok')
				{
					location.reload();
				}
			}
		});
    }
function showSlideshow(strFileHash)
{
	if (typeof(strFileHash) === 'undefined')
	{
		strFileHash = arrHashes[0];
	}
	if(typeof(bolActivateSlideshowOnOpen) !== 'undefined')
	{
		bolActivateSlideshowOnOpen = true;
		listPreviewFile( strFileHash )
	}
	else
	{
		fError( 'Failed to open slideshow' );		
	}
}
	
</script>
<link rel="stylesheet" type="text/css" media="all" href="css/embed_upload_form.css?v=2">
<section id="embed_upload_form" class="modal-container" tabindex="-1" role="dialog" aria-labelledby="modal-label" aria-hidden="true">
<div class="modal-inner">
<div class="modal-content">
<div id="embed_upload_form_header">
<div id="embed_upload_form_header_main_text">
Embed gallery on website </div>
<div id="embed_upload_form_header_sub_text">
You can integrate file/photo/video/audio gallery or content sales on your website by copying below code. More about <a href="/sell-files" target="_blank">selling</a>.
<br><br>
Supports different layouts, specify via <b>&amp;view=horizontal or &amp;view=grid</b> parameters. horizontal is suitable for photo/video galleries.
<br><br>
To embed a single photo/video, see also "Embed content" for each file.
<br><br>
For feedback and customisation: [email protected] </div>
</div>
<div id="embed_upload_form__subscribe_alert">
<table class="alert_container alert_container_danger">
<tbody><tr>
<td>
<i class="fa fa-exclamation-circle"></i>
</td>
<td>
<div class="alert_main_text">
To use content embedding on other websites, subscribe to a Pro or Business account: <a href="https://files.fm/storage-plans" target="_blank">https://files.fm/storage-plans</a>. Contact us if you need help. </div>
</td>
</tr>
</tbody></table>
</div>
<div id="embed_upload_form_content">
<div id="embed_upload_form_select-wrapper">
<div class="embed_upload_form_select-label">Gallery layout</div>
<div id="embed_upload_form_select">
<div class="select__trigger"><span>Horizontal view</span>
</div>
<div class="custom-options">
<div class="custom-option" data-value="grid">
<div class="value">Grid view</div>
<div class="desc">Suitable for various types of files</div>
</div>
<div class="custom-option" data-value="list">
<div class="value">List view</div>
<div class="desc">Suitable for various types of files</div>
</div>
<div class="custom-option selected" data-value="horizontal">
<div class="value">Horizontal view</div>
<div class="desc">Suitable for photo / video galleries</div>
</div>
<div class="custom-option" data-value="vertical">
<div class="value">Vertical view</div>
<div class="desc">Suitable for photo / video galleries</div>
</div>
</div>
</div>
</div>
<textarea id="embed_upload_form__textarea" readonly="readonly" onclick="setTimeout(function(){document.getElementById('embed_upload_form__textarea').select();}, 0);"></textarea>
<div class="embed_upload_form_iframe-label">iFrame preview:</div>
</div>
</div>
</div>
<div id="embed_upload_form_modal_close" onclick="$( '#embed_upload_form__iframe' ).remove();" class="modal-close" data-dismiss="modal" data-close="Close"></div>
</section>
<script type="text/javascript">

    function getEmbedUploadCode( objUploadEmbedOptions, view )
    {
        var strEmbedUploadCode = '';

        if ( typeof objUploadEmbedOptions.upload_hash != 'undefined' && objUploadEmbedOptions.upload_hash != '' )
        {
        strEmbedUploadCode = '<script type="text/javascript" src="https://files.fm/gallery_module/v1/js/?hash='+ objUploadEmbedOptions.upload_hash;

        if ( typeof objUploadEmbedOptions.user != 'undefined' && objUploadEmbedOptions.user != '' && typeof objUploadEmbedOptions.ihash != 'undefined' && objUploadEmbedOptions.ihash != '' )
        {
            strEmbedUploadCode += '&user='+ objUploadEmbedOptions.user +'&ihash='+ objUploadEmbedOptions.ihash;
        }

        if(view)
        {
            strEmbedUploadCode += '&view=' + view;
        }
        else
        {
            strEmbedUploadCode += '&view=horizontal';
        }
       
        strEmbedUploadCode += '" id="files_fm_upload_script_tag"></'+ 'script>';
        }

        return strEmbedUploadCode;

    }

	function showEmbedUploadForm( objUploadEmbedOptions )
    {
        $( '#embed_upload_form__textarea' ).text( getEmbedUploadCode( objUploadEmbedOptions, $( '.custom-option.selected' ).attr('data-value') ) );

    
        $( '#embed_upload_form__iframe' ).remove();
        $( '#embed_upload_form_content' ).append('<div id="embed_upload_form__iframe" style="overflow: auto; max-height: 300px; ">'+getEmbedUploadCode( objUploadEmbedOptions, 'horizontal' )+'</div>')

        $( "#embed_upload_form_select" ).removeClass('open');

        $("#embed_upload_form_select-wrapper").unbind('click');
        $(".custom-option").unbind('click');

        $( "#embed_upload_form_select-wrapper" ).click(function() {
            $( "#embed_upload_form_select" ).toggleClass('open');
        });
        $( ".custom-option" ).click(function() {
            if (!$( this ).hasClass('selected'))
            {
                $( this ).parent().find('.selected').removeClass('selected');
                $( this ).addClass('selected');
                $( '.select__trigger' ).text($( this ).find('.value').text());


                $( '#embed_upload_form__textarea' ).text( getEmbedUploadCode( objUploadEmbedOptions,  $( this ).attr('data-value') ) );


                $( '#embed_upload_form__iframe' ).remove();
                $( '#embed_upload_form_content' ).append('<div id="embed_upload_form__iframe" style="overflow: auto; max-height: 300px; ">'+getEmbedUploadCode( objUploadEmbedOptions, $( this ).attr('data-value') )+'</div>')
            }
        });
        // Hide dropdown if mouse clicked
        $(document).on('click', function (e) 
        {
            var jqTarget = $(e.target);
            if (
                jqTarget.parents('#embed_upload_form_select').size()==0 && 
                jqTarget.attr('id')!='embed_upload_form_select'
            )
            {
                $( "#embed_upload_form_select" ).removeClass('open');
            } 
        });
        
        // hide all open popups
        if( typeof window.FileEmbedPopup !== "undefined" )
        {
            window.FileEmbedPopup.hidePopup();
        }
    
        if ( $( '#share_popup' ).is( ":visible" ) )
        {
            hideSharePopup();
        }

		showModal( 'embed_upload_form' );
	}

</script>
<style>
	#add-info .modal-inner {
		width: 730px;
		margin-left: -365px;
		text-align: justify;
	}
	#add-info .modal-close:after {
		margin-left: 335px;
	}
	
	#add-info .modal-inner b {
		display: inline-block;
		margin-top: -4px;
	}
	#add-info-header {
		font-size: 20px;
		color: #CA1913;
		font-weight: bold;
		padding: 30px;
	}
	#add-info-modal-content {
		color: #2b3d52;
		padding: 30px;
		font-size: 16px;
		line-height: 1.5; 
	}
	#subscribe_pro_btn {
		background-color: #CA1913; 
		cursor: pointer; 
		padding: 20px; 
		font-size: 20px;
		height: 20px; 
		line-height: 20px; 
		color: white; 
		width: 400px;
		font-weight: bold;
		text-align: center;
		margin: 60px auto 30px auto;
		border:0;
		display: block;
	}
	@media only screen and (max-width: 750px) {
		#add-info .modal-inner {
		    width: auto;
		    left: 20px;
		    right: 20px;
		    margin-left: 0;
		}
		#add-info .modal-close:after {
			margin-left: 40%;
		}
	}
	@media only screen and (max-width: 30em) {
		#add-info .modal-inner {
		    left: 0;
		    right: 0;
		    margin-left: 0;
			overflow: auto;
		}
		#add-info .modal-close:after {
			margin-left: 0;
		}
		#subscribe_pro_btn {
			width: auto;
		}
	}
</style>
<section id="add-info" class="modal-container" tabindex="-1" role="dialog" aria-labelledby="modal-label" aria-hidden="true">
<div class="modal-inner">
<header id="add-info-header">
Do you want to use Files.fm without ads? Subscribe to a PRO account! </header>
<div id="add-info-modal-content" class="modal-content">
<div>
<div style="margin-bottom: 30px;">
Ads are shown on Files.fm to provide the service to free users. </div>
<div>
If you want to <b>remove ads</b>
for yourself and your file viewers or just want to <b></b>
<b>support</b>
us <b>subscribe to a PRO account.</b>
This will help us to continue develop services and new features. Thank you! </div>
<div>
<div id="subscribe_pro_btn" class="standard_button" onclick="gaev('CloseAdd', 'SubscribeProClick', ''); window.location.assign('/storage-plans#pro');">Subscribe to a PRO account</div>
</div>
</div>
</div>
</div>
<div class="modal-close" data-dismiss="modal" data-close="Close"></div>
</section>
<script type="text/javascript">

	function showAddInfo() {

		showModal('add-info');

		gaev('CloseAdd', 'CloseAddClick', '');
	}

	function closeAdd(intAddId) {

		if ($('#any_media_banner_'+intAddId).length > 0) {

			$('#any_media_banner_'+intAddId).remove();
			showAddInfo();
		}
	}

</script><script type="text/javascript">
	$('body').click(function(){
		if ((new Date()).getTime() - intPrevAdRefreshTST > 60000) {
			intPrevAdRefreshTST = (new Date()).getTime();
		}
	});
</script>
</div>
<script type="text/javascript">

	var objPosterForm;
	
	$( function()
	{
		objPosterForm = new PosterForm( '40bdb754ce23cdfc13a344b0230a4e21f5e0785a', 11 );
		objPosterForm.init();
	} );

</script>
<link rel="stylesheet" type="text/css" media="all" href="/css/poster_form.css?v=6">
<script type="text/javascript" src="/js/poster_form.js?v=11"></script>
<div id="popup-poster">
<div id="popup-poster_close_btn">
</div>
<div id="popup-poster_inner">
<img id="popup-poster_image">
</div>
</div>
</div>
<link rel="stylesheet" type="text/css" media="all" href="/css/footer.css?v=16">
</div>
<div id="info_tooltip_global"></div>
<script>
    function CloseSuggestion(id) {
        
        if (id == 'suggest_lang') {
            $.get("includes/suggest_language.php", {sLang: 1});
        }
        else if (id == 'suggest_register'){
            $.get("includes/suggest_language.php", {sReg: 1});
        }
        
        document.getElementById(id).style.display='none';
    }
</script>
<script>
        
        $(window).bind("load", function() {
            $( "#register_from_ico" ).val( 0 );
            if	(window.location.hash == '#sign_up') {
                
                showCreateAccount();
            }
            else if	(window.location.hash == '#log_in') {
                
                showSignIn();
            }
            else if	(window.location.hash == '#forgot_password') {
                
                showForgotPassword();
            }
        });
    
    </script>
<div id="files_970x90_sticky_anchorad_responsive" data-google-query-id="CPbTisjAjokDFVlUpAQdC_UVpA" style="display: none;">
<script>
        if ( typeof googletag != 'undefined' && typeof googletag.cmd != 'undefined' )
        {
            googletag.cmd.push(function() { googletag.display('files_970x90_sticky_anchorad_responsive'); });
        }
    </script>
<div id="google_ads_iframe_/19238985/files_320x100_sticky_anchorad_mobile_0__container__" style="border: 0pt none; width: 320px; height: 0px;"></div></div>
<script>
    window.addEventListener("stpdRendered", function (e) {
        var adName =  e.detail.name;
        var adWinner = e.detail.winner;
        var cleanEventName = adName.split('/')[2];

        if ( ( (cleanEventName == "files_970x90_sticky_anchorad_desktop") || (cleanEventName == "files_320x100_sticky_anchorad_mobile") ) && (adWinner != "passback")  ) {
            setTimeout(function () {
                var anchorParent = top.document.querySelector("#files_970x90_sticky_anchorad_responsive");
                var anchorIframe = top.document.querySelector("#files_970x90_sticky_anchorad_responsive > div > iframe");
                var anchorClose = top.document.querySelector("#stpd_close");
                if(window.innerWidth > 1000) {
                    anchorParent.style.cssText += "width: " + (anchorIframe.clientWidth + 100) + "px";
                    anchorClose.style.cssText += "width: 40px; height: 35px; padding-top: 5px; border-top: unset; border-left: unset; border: 5px solid red; border-radius: 50%; background: rgb(255 255 255);";
                } else {
                    anchorClose.style.cssText += "width: 30px; height: 30px; border-top: unset; border-left: unset; border: 5px solid red; border-radius: 50%; background: rgb(255 255 255); top: -40px;";
                }
            }, 50);
        }
    });
</script>
<div id="failiem_970x90_sticky_anchorad_responsive">
<script>
                    if ( typeof googletag != 'undefined' && typeof googletag.cmd != 'undefined' )
                    {
						googletag.cmd.push(function() { googletag.display('failiem_970x90_sticky_anchorad_responsive'); });
					}
				</script>
</div>
<script>
    window.addEventListener("stpdRendered", function (e) {
        var adName =  e.detail.name;
        var adWinner = e.detail.winner;
        var cleanEventName = adName.split('/')[2];

        if ( ( (cleanEventName == "failiem_970x90_sticky_anchorad_desktop") || (cleanEventName == "failiem_320x100_sticky_anchorad_mobile") ) && (adWinner != "passback")  ) {
            setTimeout(function () {
                var anchorParent = top.document.querySelector("#failiem_970x90_sticky_anchorad_responsive");
                var anchorIframe = top.document.querySelector("#failiem_970x90_sticky_anchorad_responsive > div > iframe");
                var anchorClose = top.document.querySelector("#stpd_close");
                if(window.innerWidth > 1000) {
                    anchorParent.style.cssText += "width: " + (anchorIframe.clientWidth + 100) + "px";
                    anchorClose.style.cssText += "width: 40px; height: 35px; padding-top: 5px; border-top: unset; border-left: unset; border: 5px solid red; border-radius: 50%; background: rgb(255 255 255);";
                } else {
                    anchorClose.style.cssText += "width: 30px; height: 30px; border-top: unset; border-left: unset; border: 5px solid red; border-radius: 50%; background: rgb(255 255 255); top: -40px;";
                }
            }, 50);
        }
    });
</script>
<div id="float_div">
<div id="float_div_close" onclick="gaev('Corner-Poster', 'Content-Closed', 'Click'); $(this).parent().remove(); document.cookie='Corner-Poster_closed=1; max-age=600'"></div>
<div class="float_div_content" id="float_div_content">
<div id="files_300x250_desktop_left_sticky">
<script>
              if ( typeof googletag != 'undefined' && typeof googletag.cmd != 'undefined' )
              {
                  googletag.cmd.push(function() { googletag.display('files_300x250_desktop_left_sticky'); });
              }
		  </script>
</div>
</div>
</div>
<script>
        window.addEventListener('stpdRendered', function(e) {
            setTimeout(function() {
                var adName = e.detail.name;
                var adWinner = e.detail.winner;
                var cleanEventName = adName.split('/')[2];

                if (cleanEventName == 'files_300x250_desktop_left_sticky' && adWinner != 'passback') {
                    var div = document.getElementById('float_div');
                    if (div != null) {
                        div.style.display = 'block';
                    }
                }
            });
        });
    </script>
<style>
	   @media(min-width: 100px) {
		  #float_div {
			width: 300px;
			height: 250px;
			position: fixed;
			display: none;
			background-color: rgba(0,0,0,0.5);
			z-index: 2147483648;
			bottom: 0;
			left: 0;
		  }
		  #float_div_close {
			position: absolute;
			font-size: 0;
			border: 2px solid white;
			border-radius: 20px;
			background: url(/images/popups/close-shadow3.svg) center no-repeat;
			cursor: pointer;
			z-index: 1;
			background-size: contain;
			height: 20px;
			width: 20px;
			padding: 0;
			margin: 0;
			background-color: rgba(0,0,0,0.3);
			right: 0;
		  }
	   }
	</style>
<script type="text/javascript">
		gaev('Corner-Poster', 'Content-Shown', 'true');

		$(document).ready( function() {

		  setTimeout(function() {
			  var overiFrame = -1;
			  $('iframe').hover( function() {
				  overiFrame = $(this).closest('.float_div_content').attr('id');
			  }, function() {
				  overiFrame = -1
			  });

			  $(window).blur( function() {
				  if( overiFrame != -1 ) {
					  gaev('Corner-Poster', 'Content-Opened', 'Click');  
					  $('.float_div').remove(); 
					  document.cookie='Corner-Poster_closed=1; max-age=600'
				  }
			  });
		  }, 1000);

		});
		
		// JV:remove banner box if there was a click on top of it
		document.addEventListener('DOMContentLoaded', function() {
			// Get the div by its ID
			var floatDiv = document.getElementById('float_div');
			
			// Attach a click event listener to the div
			floatDiv.addEventListener('click', function() {
				// Remove the div from the DOM when clicked
				// floatDiv.parentNode.removeChild(floatDiv);
				floatDiv.remove();
				
				document.cookie='Corner-Poster_closed=1; max-age=600';
			});
		});
 
	</script>

<div id="footer_bottom_floating_line" class="footer_bottom_floating_line__listphp  cookies_msg_active ">
<div id="footer_bottom_floating_line__cookies">
<div id="footer_bottom_floating_line__cookies__text">
By using this website, you agree to Files.fm <a href="https://files.fm/terms" target="_blank">terms</a> and <a href="https://files.fm/privacy-policy" target="_blank">cookie policy.</a> </div>
<button id="footer_bottom_floating_line__cookies__ok_btn" onclick="gaev('CookiePolicy', 'CloseButton', ''); $('#footer_bottom_floating_line__cookies').hide(); document.cookie='cookie_info_closed=true; max-age=31536000'; $( '#footer_bottom_floating_line' ).removeClass( 'cookies_msg_active' );">
OK </button>
</div>
</div>
<link rel="stylesheet" type="text/css" media="all" href="/css/share_popup.css?v=1725008979"><link rel="stylesheet" type="text/css" media="all" href="/css/bootstrap-tagsinput.css?v=1715343650">
<script src="/js/bootstrap-tagsinput.js?v=1715343643"></script><link rel="stylesheet" type="text/css" media="all" href="/css/elements/upload_access_switch.css?v=114">
<script type="text/javascript">

	var bolUploadAccessSwitch_closeAllSelect_Binded = false;
	var bolSessionUser_IsStorageSubscriber = false;
	var bolSessionUser_HasLifetimeStorage = false;

	function UploadAccessSwitch( objParentElement, objUploadAccessSwitchSettings )
	{
		this.objParentElement = objParentElement;
		this.bolAccessTypeChanged = false;


		this.strItemType = 'upload';

		if ( typeof objUploadAccessSwitchSettings.item_type != 'undefined' && objUploadAccessSwitchSettings.item_type == 'file' )
		{
			this.strItemType = objUploadAccessSwitchSettings.item_type;
		}
		
		
		this.strUploadHash = objUploadAccessSwitchSettings.upload_hash;
		this.strFileHash = objUploadAccessSwitchSettings.file_hash;
		this.strParentAccessType = objUploadAccessSwitchSettings.parent_access_type;

		
		this.bolOwnerLoggedIn;

		if ( typeof objUploadAccessSwitchSettings.owner_logged_in == 'undefined' )
		{
			this.bolOwnerLoggedIn = 1;
		}
		else
		{
			this.bolOwnerLoggedIn = objUploadAccessSwitchSettings.owner_logged_in;
		}

		this.strAccessType;
		this.strUploadPassword = '';

		if ( objUploadAccessSwitchSettings.access_type == 'PRIVATE' )
		{
			this.strAccessType = 'private';
		}
		else if ( this.strItemType == 'upload' && objUploadAccessSwitchSettings.password != null && objUploadAccessSwitchSettings.password != '' )
		{
			this.strAccessType = 'password';
			this.strUploadPassword = objUploadAccessSwitchSettings.password;
		}
		else if ( this.strItemType == 'upload' && objUploadAccessSwitchSettings.is_public == 1 )
		{
			this.strAccessType = 'public';
		}
		else
		{
			this.strAccessType = 'link';
		}

		
		if ( objUploadAccessSwitchSettings.access_type != 'PRIVATE' && typeof objUploadAccessSwitchSettings.from_eparaksts != 'undefined' && objUploadAccessSwitchSettings.from_eparaksts )
		{
			this.strAccessType = 'link-can-edit';
			$( '.copy_button_wrapper_popup' ).addClass('no-dropdown');
		}
		else
		{
			$( '.copy_button_wrapper_popup' ).removeClass('no-dropdown');
		}

		if ( objUploadAccessSwitchSettings.access_type == 'link-can-upload' )
		{
			this.strAccessType = 'link-can-upload';
		}

		this.strUploadAccessSwitchType = 'default';

		if ( typeof objUploadAccessSwitchSettings.upload_access_switch_type != 'undefined' )
		{
			this.strUploadAccessSwitchType = objUploadAccessSwitchSettings.upload_access_switch_type;
		}

		this.strEmbedPlace = objUploadAccessSwitchSettings.embed_place;

		
		
		var _this = this;
		
		
		this.init = function()
		{
			var objTypeCopyWrap = $( '#copy_button_drawer_popup' );
			objTypeCopyWrap.html('');
			$( '.copy_button_wrapper_popup' ).removeClass('copy_input_value_to_clipboard_no_tooltip');
			
			var strHtml = '';

			var objTypeSelectWrap = $( '<div></div>' ).attr( {
        						'class' : 'styled-select upload-access-switch-select' ,
        					} )
			var objTypeSelect = $( '<select></select>' ).attr( {
                    				'class' : 'upload-access-switch_type-select' ,
                    				'disabled' : ( this.strUploadAccessSwitchType == 'default' && ! this.bolOwnerLoggedIn ? true : false )
                    			} );

			objTypeSelect.append(
				$( '<option></option>' ).text( '&nbsp;' )
			);
			if ( this.bolOwnerLoggedIn )
			{
				objTypeSelect.append(
    					$( '<option></option>' ).attr( {
    						'value' : 'private' ,
    						'desc' : 'Only you or users invited by email can access.' ,
    						'selected' : ( this.strAccessType == 'private' ? true : false )
    					} )
    					.text( 'Only with private permission' )
    				);
			}
			
			if ( this.strUploadAccessSwitchType == 'default' )
			{ 
    			objTypeSelect.append(
						$( '<option></option>' ).attr( {
							'value' : 'link' ,
							'desc' : 'View and download access' ,
							'selected' : ( this.strAccessType == 'link' ? true : false )
						} )
						.text( 'Anyone with a link' )
					);

				strHtml = 	'<div id="drawer_copy_button_view" class="share-input copy_input_value_to_clipboard_no_tooltip checked" onclick="updateSharePopupLink(1)">' +
								'<span>Copy view link</span>' +
								'<span class="desc_popup">Can be viewed and downloaded</span>' +
							'</div>';
			}
			else if ( this.strUploadAccessSwitchType == 'sharing_form' )
			{
    			objTypeSelect.append(
    					$( '<option></option>' ).attr( {
    						'value' : 'link-can-view' ,
    						'desc' : 'View and download.' ,
    						'selected' : ( this.strAccessType == 'link' ? true : false ) ,
    						'class' : 'upload-access-switch_type-select_option_link-can-view'
    					} )
    					.text( 'via link to access content' )
    				);
					
				if ( !( objUploadAccessSwitchSettings.access_type != 'PRIVATE' && typeof objUploadAccessSwitchSettings.from_eparaksts != 'undefined' && objUploadAccessSwitchSettings.from_eparaksts ) )
				{
					strHtml = 	'<div id="drawer_copy_button_view" class="share-input copy_input_value_to_clipboard_no_tooltip checked" onclick="updateSharePopupLink(1)">' +
								'<span>Copy view link</span>' +
								'<span class="desc_popup">Can be viewed and downloaded</span>' +
							'</div>';
							objTypeCopyWrap.append(strHtml);
				}

    			objTypeSelect.append(
    					$( '<option></option>' ).attr( {
    						'value' : 'link-can-edit' ,
    						'desc' : 'Link to add, edit or delete content.' ,
    						'selected' : ( this.strAccessType == 'link-can-edit' ? true : false ) ,
    					} )
    					.text( 'Get a link to edit content' )
    				);

					strHtml = 	'<div id="drawer_copy_button_edit" class="share-input copy_input_value_to_clipboard_no_tooltip" onclick="updateSharePopupLink(2)">' +
									'<span>Copy edit link</span>' +
									'<span class="desc_popup">Can add, edit content, e-sign and delete</span>' +
								'</div>';
								objTypeCopyWrap.append(strHtml);

    			if ( this.strItemType == 'upload' )
    			{
        			objTypeSelect.append(
        					$( '<option></option>' ).attr( {
        						'value' : 'link-can-upload' ,
        						'desc' : 'Visitors can add files, but can’t delete or edit existing.' ,
        						'selected' : ( this.strAccessType == 'link-can-upload' ? true : false ) ,
        					} )
        					.text( 'Get Link to add content' )
        				);

					if ( !( objUploadAccessSwitchSettings.access_type != 'PRIVATE' && typeof objUploadAccessSwitchSettings.from_eparaksts != 'undefined' && objUploadAccessSwitchSettings.from_eparaksts ) )
					{
						strHtml = 	'<div id="drawer_copy_button_upload" class="share-input copy_input_value_to_clipboard_no_tooltip" onclick="updateSharePopupLink(3)">' +
										'<span>Copy add link</span>' +
										'<span class="desc_popup">You can add files, but not delete or edit existing files</span>' +
									'</div>';
									objTypeCopyWrap.append(strHtml);
					}
    			}
			}
			else if ( this.strUploadAccessSwitchType == 'modal_gallery' )
			{
    			objTypeSelect.append(
    					$( '<option></option>' ).attr( {
    						'value' : 'link-can-view' ,
    						'desc' : 'View and download.' ,
    						'selected' : ( this.strAccessType == 'link' ? true : false ) ,
    						'class' : 'upload-access-switch_type-select_option_link-can-view'
    					} )
    					.text( 'via link to access content' )
    				);

    			objTypeSelect.append(
    					$( '<option></option>' ).attr( {
    						'value' : 'link-can-edit' ,
    						'desc' : 'Link to add, edit or delete content.' ,
    						'selected' : ( this.strAccessType == 'link-can-edit' ? true : false ) ,
    					} )
    					.text( 'Get a link to edit content' )
    				);

    			if ( this.strItemType == 'upload' )
    			{
        			objTypeSelect.append(
        					$( '<option></option>' ).attr( {
        						'value' : 'link-can-upload' ,
        						'desc' : 'Visitors can add files, but can’t delete or edit existing.' ,
        						'selected' : ( this.strAccessType == 'link-can-upload' ? true : false ) ,
        					} )
        					.text( 'Get Link to add content' )
        				);
    			}
			}

			if ( this.strItemType == 'upload' && this.bolOwnerLoggedIn )
			{
				objTypeSelect.append(
    					$( '<option></option>' ).attr( {
    						'value' : 'password' ,
    						'desc' : 'Visitors must enter a password to access' ,
    						'selected' : ( this.strAccessType == 'password' ? true : false )
    					} )
    					.text( 'Set password' )
    				);
			
				objTypeSelect.append(
    					$( '<option></option>' ).attr( {
    						'value' : 'public' ,
    						'desc' : 'Visible to anyone on your profile and via search.' ,
    						'selected' : ( this.strAccessType == 'public' ? true : false )
    					} )
    					.text( 'Posted on my profile page' )
    				);
			}

			objTypeSelectWrap.append( objTypeSelect );

			$('.url_wrapper ').removeClass('switch');
			
			if ( this.strUploadAccessSwitchType == 'sharing_form' )
			{
				strHtml = 	'<div id="upload-access-switch_type-toggle_wrapper">'+
							'<input type="checkbox" class="upload-access-switch_type-toggle"'+
							( this.strAccessType == 'private' ? ' ' : 'checked ' )+
							//'disabled="'+( this.strUploadAccessSwitchType == 'default' && ! this.bolOwnerLoggedIn ? true : false )+'"'+
							'id="upload-access-switch_type-toggle">'+
							'<label for="upload-access-switch_type-toggle"></label>'+
							'<div>Private</div>'+
							'<div>Link</div>'+
							'</div>';


				if (this.strItemType == 'upload' )
				{
					$('.url_wrapper ').addClass('switch');
					strHtml += '<div id="upload-access-switch-password-download-wrap">'+
									'<div class="upload-access-switch_password-wrapper ' + (this.strAccessType == 'password' ? 'has_password' : '') + '">'+
										'<label onclick="$(this).parent().addClass(\'open\'); $(this).parent().find(\'input\').focus()"> ' + (this.strAccessType == 'password' ? 'Password:' : 'Set password') + '</label>'+
										'<input onclick="$(this).parent().addClass(\'open\')" type="text" class="upload-access-switch_password" value="'+this.strUploadPassword+'"></input>'+
										'<input onclick="$(this).parent().addClass(\'open\')" type="password" class="upload-access-switch_password_placeholder" value="111111"></input>'+
										'<div class="upload-access-switch_password-save-btn">Save</div>'+
									'</div>';
					
					if (typeof objUploadAccessSwitchSettings.hide_download_buttons !== 'undefined' && ! (! bolSessionUser_IsStorageSubscriber && ! bolSessionUser_HasLifetimeStorage) )
					{
						strHtml +=	'<div class="upload-access-switch-hide-download">' +
										'<label for="upload-access-switch_hide-download-toggle">Hide download buttons:</label>' +
										'<input type="checkbox" class="upload-access-switch_hide-download-toggle" '+ (objUploadAccessSwitchSettings.hide_download_buttons == '1' ? 'checked' : '') +' id="upload-access-switch_hide-download-toggle">' +
										'<label for="upload-access-switch_hide-download-toggle"></label>' +
										'<label>'+(objUploadAccessSwitchSettings.hide_download_buttons == '1' ? 'Yes' : 'No')+'</label>'+
									'</div>';	
					}
					
					strHtml += '</div>';
				}

				$( this.objParentElement ).html(

					$( '<div></div>' ).attr( {
						'class' : 'upload-access-switch ' + (typeof objUploadAccessSwitchSettings.propagate_settings !== 'undefined' && objUploadAccessSwitchSettings.propagate_settings == 2 ? 'disabled' : '') ,
						'data-selected-access-type' : this.strAccessType 
					} )
					.append(
						$( '<div></div>' ).attr( {
							'class' : 'upload-access-switch_type-wrapper' 
						} )
						.append(
							$( '<label></label>' ).text( ( this.strUploadAccessSwitchType == 'sharing_form' ? 'Access rights:' : 'Access:' ) )
						)
						.append(
							$( '<label></label>' ).attr( {
							'class' : 'upload-access-switch_type-wrapper-desc' 
							} ).text(( this.strAccessType == 'private' ? 'Only with private permission' : 'Anyone with a link' ))
						)
					)
					.append( strHtml )

					
					
				);
			}
			else
			{
				$( this.objParentElement ).html(

					$( '<div></div>' ).attr( {
						'class' : 'upload-access-switch' ,
						'data-selected-access-type' : this.strAccessType 
					} )
					.append(
						$( '<div></div>' ).attr( {
							'class' : 'upload-access-switch_type-wrapper' 
						} )
						.append(
							$( '<label></label>' ).text( ( this.strUploadAccessSwitchType == 'sharing_form' ? 'Link and Access rights:' : 'Access:' ) )
						)
						.append( objTypeSelectWrap )
					)
					.append(
						$( '<div></div>' ).attr( {
							'class' : 'upload-access-switch_password-wrapper'
						} )
						.append(
							$( '<label></label>' ).text( 'Password:' )
						)
						.append(
							$( '<input/>' ).attr( {
								'class' : 'upload-access-switch_password' ,
								'type' : 'text' ,
								'title' : 'Enter a password' ,
								'value' : this.strUploadPassword
							} )
						)
						.append(
							$( '<div></div>' ).attr( {
								'class' : 'upload-access-switch_password-save-btn'
							} ).text( 'Save' )
						)
					)
					.append(
						$( '<div></div>' ).attr( {
							'class' : 'upload-access-switch_loading-mask'
						} )
						.append(
							$( '<i></i>' ).attr( {
								'class' : 'fal fa-spinner fa-spin'
							} )
						)
					)
				);
			}
		


			checkTooltips();
			
			var x, i, j, selElmnt, a, b, c, d, e;
			/*look for any elements with the class "styled-select":*/
			x = document.getElementsByClassName("upload-access-switch-select");
			
			for (i = 0; i < x.length; i++) 
			{
				if (x[i].getElementsByClassName("select-selected").length < 1) 
				{
					selElmnt = x[i].getElementsByTagName("select")[0];
					/*for each element, create a new DIV that will act as the selected item:*/
					a = document.createElement("DIV");
					a.setAttribute("class", "select-selected");
					a.innerHTML = selElmnt.options[selElmnt.selectedIndex].innerHTML;
					x[i].appendChild(a);
					/*for each element, create a new DIV that will contain the option list:*/
					b = document.createElement("DIV");
					b.setAttribute("class", "select-items select-hide");
					for (j = 1; j < selElmnt.length; j++) {
						/*for each option in the original select element,
						create a new DIV that will act as an option item:*/
						c = document.createElement("DIV");
						d = document.createElement("DIV");
						if(selElmnt.options[j].value == selElmnt.value)
						{
							c.setAttribute("class", "checked");
						}
						e = document.createElement("DIV");
						e.setAttribute("class", "value");
						d.setAttribute("class", "desc");
						//c.innerHTML = selElmnt.options[j].innerHTML;
						e.innerHTML = selElmnt.options[j].innerHTML;
						d.innerHTML = selElmnt.options[j].getAttribute('desc');
						c.appendChild(e);
						c.appendChild(d);
						if ( !!selElmnt.id && !!selElmnt.options[j].value )
						{
							c.setAttribute( 'id', selElmnt.id + '_' + selElmnt.options[j].value );
						}
						c.addEventListener("click", function(e) {
							/*when an item is clicked, update the original select box,
							and the selected item:*/
							var y, i, k, s, sjq, h, clicked;
							clicked = this;
							s = this.parentNode.parentNode.getElementsByTagName("select")[0];
							sjq = $(s);
							$(clicked).parents().children().removeClass('checked');
							$(clicked).addClass('checked');

									
							h = this.parentNode.previousSibling;
							for (i = 0; i < s.length; i++) {
								if (s.options[i].innerHTML == this.getElementsByClassName("value")[0].innerHTML) {
									s.selectedIndex = i;
									h.innerHTML = this.getElementsByClassName("value")[0].innerHTML;
									y = this.parentNode.getElementsByClassName("same-as-selected");
									for (k = 0; k < y.length; k++) {
										y[k].removeAttribute("class");
									}
									this.setAttribute("class", "same-as-selected checked");
									sjq.trigger("change");
									break;
								}
							}
							h.click();
						});
						b.appendChild(c);
					}
					x[i].appendChild(b);
					a.addEventListener("click", function(e) {
						/*when the select box is clicked, close any other select boxes,
						and open/close the current select box:*/
						e.stopPropagation();
						closeAllSelect(this);
						this.nextSibling.classList.toggle("select-hide");
						this.classList.toggle("select-arrow-active");
						this.parentElement.classList.toggle("blue-border");
						if (this.parentElement.previousElementSibling)
						{
							this.parentElement.previousElementSibling.classList.toggle("blue-span");
						}
						
					});
				}
			}
			function closeAllSelect(elmnt) {
				/*a function that will close all select boxes in the document,
				except the current select box:*/
				var x, y, i, arrNo = [];
				x = document.getElementsByClassName("select-items");
				y = document.getElementsByClassName("select-selected");
				for (i = 0; i < y.length; i++) {
					if (elmnt == y[i]) {
						arrNo.push(i)
					} else {
						y[i].classList.remove("select-arrow-active");
					}
				}
				for (i = 0; i < x.length; i++) {
					if (arrNo.indexOf(i)) {
						x[i].classList.add("select-hide");
						x[i].parentElement.classList.remove("blue-border");
						if (x[i].parentElement.previousElementSibling)
						{
							x[i].parentElement.previousElementSibling.classList.remove("blue-span");
						}
					}
				}
			}
			/*if the user clicks anywhere outside the select box,
			then close all select boxes:*/
			if ( ! bolUploadAccessSwitch_closeAllSelect_Binded )
			{
				document.addEventListener("click", closeAllSelect);
				bolUploadAccessSwitch_closeAllSelect_Binded = true;
			}

			if ( ! this.bolOwnerLoggedIn )
			{
				if ( this.strUploadAccessSwitchType == 'sharing_form' )
				{
					// do nothing
				}
				else
				{
        			$( this.objParentElement ).on( 'click', function( event )
        			{
        				showCreateAccount();
        			} );
				}
			}
			else
			{
    			$( this.objParentElement ).find( '.upload-access-switch_type-select' ).on( 'change', function()
    			{
    				_this.changeAccessType( $( this ).val() );
    			} );
    
				$( this.objParentElement ).find( '.upload-access-switch_password' ).on( 'blur', function()
    			{
					if($( this ).val().trim() != '' ) {
						$(this).parent().delay(500).queue(function(next) {
							$(this).removeClass('open');
							$( '.upload-access-switch_password-save-btn' ).html('Save');
							$( '.upload-access-switch_password-save-btn' ).removeClass("green");
							next();
						});
					}
					else
					{
						$( this ).parent().removeClass('has_password').removeClass('open');
						$( '.upload-access-switch_password-save-btn' ).html('Save');
						$( '.upload-access-switch_password-save-btn' ).removeClass("green");
					}
				} );

    			$( this.objParentElement ).find( '.upload-access-switch_password' ).on( 'change', function()
    			{
					$(this).parent().addClass('has_password');
    				_this.changeAccessType( 'password' );
    			} );

				$( this.objParentElement ).find( '#upload-access-switch_type-toggle' ).on( 'change', function()
    			{
					if ($(this).is(':checked'))
					{
						_this.changeAccessType( 'link' );
					}
					else
					{
						_this.changeAccessType( 'private' );
					}
    				
    			} );

				$( this.objParentElement ).find( '.upload-access-switch_hide-download-toggle' ).on( 'change', function()
    			{

					if ($(this).is(':checked'))
					{
						_this.changeHideDownloadButtons( 1 );
						$(this).next().next().html('Yes');
					}
					else
					{
						_this.changeHideDownloadButtons( 0 );
						$(this).next().next().html('No');
					}
    			} );
				

				$( this.objParentElement ).find( '.upload-access-switch_password' ).on( 'input', function()
    			{
					$( '.upload-access-switch_password-save-btn' ).html('Save');
            		$( '.upload-access-switch_password-save-btn' ).removeClass("green");
    			} );
			}
		}

		this.init();

		this.changeHideDownloadButtons = function( intHideDownloadButtons )
		{
			this.showLoadingMask();

			var strAjax_Url = '';
            var objAjax_Data = null;

            if ( this.strItemType == 'upload' )
            {
            	strAjax_Url = '/ajax/upload_info.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a';
            	
            	objAjax_Data = {
                    'set_upload_hide_download_buttons': true ,
					'upload_hash' : this.strUploadHash ,
					'hide_download_buttons' : intHideDownloadButtons
                };
            }
            
            			
            $.ajax(
            {
                type: "POST",
                dataType: "json",
                url: strAjax_Url ,
                data: objAjax_Data ,
                success: function( data )
                {
                    if ( data['status'] == 'ok' )
                    {
                    	if ( _this.strItemType == 'upload' && ( _this.strEmbedPlace == 'filebrowser' || _this.strEmbedPlace == 'list' ) )
            			{
                        	location.reload();
            			}

            			_this.hideLoadingMask();
                    }
                    else
                    {
                        _this.afterErrorOn_changeAcceccType();
                    }
                } ,
                error: function()
                {
                    _this.afterErrorOn_changeAcceccType();
                }
            } );
		}
		

		this.changeAccessType = function( strNewAccessType )
		{
			$( this.objParentElement ).find( '.upload-access-switch' ).attr( 'data-selected-access-type', strNewAccessType );

			
			if ( strNewAccessType == 'password' && $( this.objParentElement ).find( '.upload-access-switch_password' ).val().trim() == '' )
			{
				if ( this.strUploadAccessSwitchType == 'sharing_form' )
				{
					this.changeAccessType( 'link' );
					$( this.objParentElement ).find( '.upload-access-switch_password' ).parent().removeClass('has_password').removeClass('open');
					$( '.upload-access-switch_password-save-btn' ).html('Save');
					$( '.upload-access-switch_password-save-btn' ).removeClass("green");
				}
				return;
			}

			if (
					strNewAccessType == 'link-can-view'
					|| strNewAccessType == 'link-can-edit'
					|| strNewAccessType == 'link-can-upload'
				)
			{
				strNewAccessType = 'link';
			}
   
			
			this.showLoadingMask();


			var strAjax_Url = '';
            var objAjax_Data = null;

            if ( this.strItemType == 'upload' )
            {
            	strAjax_Url = '/ajax/upload_info.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a';
            	
            	objAjax_Data = {
                    'set_upload_access_type' : true ,
					'upload_hash' : this.strUploadHash ,
					'upload_access_type' : strNewAccessType ,
					'upload_password' : $( this.objParentElement ).find( '.upload-access-switch_password' ).val()
                };
            }
            else if ( this.strItemType == 'file' )
            {
            	strAjax_Url = '/ajax/file_info.php?PHPSESSID=40bdb754ce23cdfc13a344b0230a4e21f5e0785a';
            	
            	objAjax_Data = {
                    'set_file_access_type' : true ,
					'file_hash' : this.strFileHash ,
					'file_access_type' : strNewAccessType 
                };
            }
            
            			
            $.ajax(
            {
                type: "POST",
                dataType: "json",
                url: strAjax_Url ,
                data: objAjax_Data ,
                success: function( data )
                {
                    if ( data['status'] == 'ok' )
                    {
                    	_this.strAccessType = strNewAccessType;
                    	_this.bolAccessTypeChanged = true;

                    	if ( _this.strItemType == 'upload' )
                    	{
                			if ( strNewAccessType != 'password' )
                			{
                				$( _this.objParentElement ).find( '.upload-access-switch_password' ).val( '' );
								$( _this.objParentElement ).find( '.upload-access-switch_password-wrapper' ).find('label').eq(0).html('Set password');
								$( _this.objParentElement ).find( '.upload-access-switch_password' ).parent().removeClass('has_password').removeClass('open');
                			}
							else 
							{
								$( '.upload-access-switch_password-save-btn' ).html('Saved!');
            					$( '.upload-access-switch_password-save-btn' ).addClass("green");
								$( _this.objParentElement ).find( '.upload-access-switch_password-wrapper' ).find('label').eq(0).html('Password:');
							}
    
                			if ( strNewAccessType == 'link' )
                			{
                    			$( '#upload_button__publish' ).show();
                    			$( '#upload_button__unpublish' ).hide();
                			}
                			else if ( strNewAccessType == 'public' )
                			{
                    			$( '#upload_button__publish' ).hide();
                    			$( '#upload_button__unpublish' ).show();
                			}
                			else 
                			{
                    			$( '#upload_button__publish' ).hide();
                    			$( '#upload_button__unpublish' ).hide();
                			}
    
                			if ( _this.strEmbedPlace == 'filebrowser' )
                			{
    							gaev( 'filebrowser-folder-info', 'access', strNewAccessType );
                			}
                    	}

                    	if ( _this.strEmbedPlace == 'filebrowser' || _this.strEmbedPlace == 'list' )
            			{
                        	location.reload();
            			}

            			_this.hideLoadingMask();
            			
                    }
                    else
                    {
                        _this.afterErrorOn_changeAcceccType();
                    }
                } ,
                error: function()
                {
                    _this.afterErrorOn_changeAcceccType();
                }
            } );
		}

		this.afterErrorOn_changeAcceccType = function( strErrorMsg )
		{
			if ( this.strAccessType == 'link' && this.strUploadAccessSwitchType == 'sharing_form' )
			{
				this.strAccessType = 'link-can-view';
			}
    					
			$( this.objParentElement ).find( '.upload-access-switch' ).attr( 'data-selected-access-type', this.strAccessType );
			$( this.objParentElement ).find( '.upload-access-switch_type-select option[value="' + this.strAccessType + '"]' ).attr( 'selected', 'selected' );

			$( this.objParentElement ).find( '.upload-access-switch_type-select' ).trigger( 'change' );

			if ( typeof strErrorMsg == 'undefined' )
			{
				strErrorMsg = 'An error occurred. Try again!';
			}
			
			fError( strErrorMsg );

			this.hideLoadingMask();
		}

		this.showLoadingMask = function()
		{
			$( this.objParentElement ).find( '.upload-access-switch_loading-mask' ).show();
		}

		this.hideLoadingMask = function()
		{
			$( this.objParentElement ).find( '.upload-access-switch_loading-mask' ).hide();
		}
	}

</script>
<section id="share_popup" class="modal-container">
<div class="modal-inner">
<div class="inner">
<div class="head clearfix">
<div class="content">
<div id="shared-icon"></div>
<h5>
<span class="head-label">Share link to:</span>
<span class="item-name"></span>
</h5>
</div>
</div>
<div id="share-popup_all-files-sharing-info">
<i class="fa fa-exclamation-triangle"></i>
Will be shared <b>all <span id="share-popup_all-files-sharing-info_file-count"></span>
files </b>
from folder <b><span class="item-name"></span></b>
</div>
<div class="content">
<div>
<div id="share-popup_upload-access-switch"></div>
</div>
<div class="share-popup_inner-content">
<div class="url_wrapper url_wrapper__sher-link">
<div id="url_wrapper__sher-link-icon"></div>
<input id="share_popup_url" class="copy_input_value_to_clipboard_no_tooltip" type="text" value="" readonly="">
<div class="copy_button_wrapper_popup" onmouseover="$(this).addClass('open_popup');" onmouseleave="$(this).removeClass('open_popup');">
<div id="copy_button_popup" class="copy_button_popup">
<div class="copy_text_popup">
<div class="hover_popup">Copy</div>
<div class="copied">Copied!</div>
</div>
</div>
<div id="copy_button_drawer_popup"></div>
</div>
<span id="share_popup_ext_link_cont">
<a target="_blank" id="share_popup_ext_link" href=""></a>
</span>
</div>
<link rel="stylesheet" type="text/css" media="all" href="/css/elements/upload_valid_to_date_user_set.css?v=1715343650"><link rel="stylesheet" type="text/css" media="all" href="/js/datepicker/datepicker.min.css?v=1715343642"><table class="share-popup__upload_valid_to_date_user_set__wrapper">

<script src="/js/elements/upload_valid_to_date_user_set.js?v=1715343643"></script>
<script src="/js/datepicker/datepicker.min.js?v=1715343642"></script>
<tbody><tr class="valid_to_date_user_set_date">
<td>Delete this folder after:</td>
<td>
<div class="toggle_option_container toggle_option_container__valid_to_date_user_set_delete_files">
<div class="toggle_option__value_container on">
<img src="/images/UI_icons/inputs/toggle_on.svg">
<span>Yes</span>
</div>
<div class="toggle_option__value_container off">
<img src="/images/UI_icons/inputs/toggle.svg">
<span>No</span>
</div>
<div class="toggle_option__wait">
<i class="fal fa-spinner fa-spin"></i>
</div>
</div>
</td>
<td class="my_tooltip" my_title="The folder and its files will be automatically deleted after the specified date and time."><i class="fal fa-question-circle"></i></td>
</tr>
<tr class="valid_to_date_user_set_date valid_to_date_user_set_date__row">
<td>
Delete after:
</td>
<td>
<div class="valid_to_date_user_set_date__wrapper">
<input class="valid_to_date_user_set_date__input valid_to_date_user_set_date__input_date" type="text" autocomplete="off">
<input class="valid_to_date_user_set_date__input valid_to_date_user_set_date__input_h" type="text" autocomplete="off">
<span class="valid_to_date_user_set_date__time_divider">:</span>
<input class="valid_to_date_user_set_date__input valid_to_date_user_set_date__input_min" type="text" autocomplete="off">
<div class="valid_to_date_user_set_date__wait">
<i class="fal fa-spinner fa-spin"></i>
</div>
</div>
</td>
<td></td>
</tr>
<script type="text/javascript">

	var objElementUploadValidToDateUserSet_Translations = {
        'FILEBROWSER-UpdateUploadValidToDateUserSet-Error-InvalidDate' : 'Enter a valid date and time!' ,
        'FILEBROWSER-UpdateUploadValidToDateUserSet-Error-OnUpdate' : 'An error occurred while changing the expiration date. Please try again!' ,
	};
    
</script> </tbody></table>
<div class="social_wrapper clearfix">
<div class="social_inner">
<span class="social_button messenger"></span>
<span class="social_button facebook"></span>
<span class="social_button whatsapp"></span>
<span class="social_button twitter"></span>
<span class="social_button telegram"></span>
<span class="social_button linkedin"></span>
<span class="social_button qr"></span>
</div>
</div>
<div class="link-can-upload">
<div id="seperator-or"><span>Or</span></div>
</div>
<div class="link-can-upload">
<div class="email_container share_type_container" style="display: block; margin-left: 0;">
<div class="email_wrapper">
<label for="share_em">Give and send private email access:</label>
<div class="email_input_wrapper">
<input id="email_input" type="text" placeholder="Enter e-mails to grant private access">
<input class="ui-autocomplete-input" type="text" name="e" id="share_em" value="" placeholder="Enter e-mails to grant private access" autocomplete="off">

</div>
</div>
</div>
<div class="share_access_rights__wrapper">
<div class="share_access_rights__label">with rights:</div>
<input type="checkbox" class="share_access_rights styled_radioblue_btn small" checked="checked" id="share_access_rights__allow_view"><label for="share_access_rights__allow_view">view</label>
<input type="checkbox" class="share_access_rights styled_radioblue_btn small" checked="checked" id="share_access_rights__allow_download"><label for="share_access_rights__allow_download">download</label>
<input type="checkbox" class="share_access_rights styled_radioblue_btn small" id="share_access_rights__allow_write"><label for="share_access_rights__allow_write">edit</label>
<input type="checkbox" class="share_access_rights styled_radioblue_btn small" id="share_access_rights__allow_delete"><label for="share_access_rights__allow_delete">delete</label>
</div>
<div class="active_date_input enterprise_feature">
<div class="active_date__label">
for period: </div>
<div class="active_date_input__radio_item">
<input type="radio" name="share_popup__active_date_input_active_radio" id="active_date_input_active_radio_off" checked="checked" value="0" class="styled_radioblue_btn small">
<label for="active_date_input_active_radio_off">unlimited</label>
</div>
<div class="active_date_input__radio_item">
<input type="radio" name="share_popup__active_date_input_active_radio" id="active_date_input_active_radio_on" value="1" class="styled_radioblue_btn small">
<label for="active_date_input_active_radio_on">limited</label>
</div>
<div class="active_date_input__input_item" style="display: none">
<label for="active_date_input_from">from:</label><input type="text" id="active_date_input_from" value="2024-10-14 00:00">
<label for="active_date_input_to">to:</label><input type="text" id="active_date_input_to" value="2024-11-14 00:00">
</div>
</div>
<div class="enterprise_feature share_email__send_share_email_element">
<input type="checkbox" class="styled_radioblue_btn small" id="share_email__send_share_email" checked="checked">
<label for="share_email__send_share_email">Send sharing notification email</label>
</div>
<div class="email_description_input_wrapper share_email__send_share_email_element">
<textarea id="description_input" placeholder="Type a message"></textarea>
</div>
<div class="clearfix email_send_wrapper">
<button id="share_popup__cancel_button" class="cancel_button">
Cancel </button>
<button id="share_popup__send_button" class="send_button">
Send access </button>
</div>
<div class="shared_with_container">
</div>
</div>
</div>
</div>
</div>
</div>
<div id="share_popup__close" class="modal-close" data-dismiss="modal" data-close="Aizvērt" onclick="hideSharePopup()"></div>
</section>
<script type="text/javascript">

    var arrSharePopupAllowEmbedPlayer_Extensions = ["mp4","webm","ogg","mp3","wav","jpeg","jpg","png","gif","svg","pdf"];

    var jqSharePopupContainer = $('#share_popup');

    var objSharePopupUploadAccessSwitch = null;
    
    var strErrorMsgNoExternalGroup = 'There are currently no external user groups added to your account. You can create an external user group <a href="/manage_users/external_user_group_list.php" target="_blank">here</a>.';
    
	$( function(){
	    $( '#share_popup #share_popup_url' ).on( 'keydown', function(){
// 	        return false;
	    });
        
        $(document).on('click', '#share_popup .copy_input_value_to_clipboard_no_tooltip, #share_popup #url_wrapper__sher-link-icon, #share_popup #copy_button_popup', function (e)
        {
            var el = document.createElement( 'textarea' );
            el.value = $( "#share_popup_url" ).val();
            document.body.appendChild( el );
            el.select();
            document.execCommand( 'copy' );
            document.body.removeChild( el );

            $('#share_popup #copy_button_popup').addClass('copied').delay(4000).queue(function(next) {
                $(this).removeClass('copied');
                next();
            });
            if($( this ).attr('id') != 'copy_button_popup')
            {
                $('#share_popup .copy_button_wrapper_popup').removeClass('open_popup');
            }
            else
            {
                $('#share_popup .copy_button_wrapper_popup').addClass('open_popup');
            }
        } );

		$(document).on('click', '#share_popup .social_button.facebook', function() {

			shareOnFacebook(
				arrSharePopupParametres[ strSharePopupType ][ 'facebook' ][ 'name' ],
				arrSharePopupParametres[ strSharePopupType ][ 'facebook' ][ 'picture_url' ],
				arrSharePopupParametres[ strSharePopupType ][ 'facebook' ][ 'description' ],
				arrSharePopupParametres[ strSharePopupType ][ 'facebook' ][ 'link' ],
                arrSharePopupParametres[ strSharePopupType ][ 'facebook' ][ 'return_link' ]
			);
		});
        
        $(document).on('click', '#share_popup .social_button.twitter', function() {
            
            shareOnTwitter(
                arrSharePopupParametres[ strSharePopupType ][ 'twitter' ][ 'text' ] ,
                arrSharePopupParametres[ strSharePopupType ][ 'twitter' ][ 'link' ]
            );
        });
        $(document).on('click', '#share_popup .social_button.telegram', function() {
    
            shareOnTelegram(
                arrSharePopupParametres[ strSharePopupType ][ 'twitter' ][ 'text' ] ,
                arrSharePopupParametres[ strSharePopupType ][ 'twitter' ][ 'link' ]
            );
        });
        
        $(document).on('click', '#share_popup .social_button.whatsapp', function() {
            window.open( "https://api.whatsapp.com/send?text=" + encodeURIComponent( $( "#share_popup_url" ).val() ), "_blank" );
        });

        
        $(document).on('click', '#share_popup .social_button.qr', function() {
            showQrPopup( event, $('#share_popup_url').val() );
        });
        
        $( 'input[type=radio][name=share_popup__share_type_radio]', jqSharePopupContainer ).change( function ()
        {
            $( '.share_type_container', jqSharePopupContainer ).hide();
            
            if ( this.value === 'email' )
            {
                $( '.email_container', jqSharePopupContainer ).show();
            }
            else if ( this.value === 'business_account_user' )
            {
                $( '.business_account_user_container', jqSharePopupContainer ).show();
            }
            else if ( this.value === 'business_account_user_group' )
            {
                $( '.business_account_user_group_container', jqSharePopupContainer ).show();
            }
            else if ( this.value === 'business_account_external_user' )
            {
                $( '.business_account_external_user_container', jqSharePopupContainer ).show();
            }
            else if ( this.value === 'business_account_external_user_group' )
            {
                $( '.business_account_external_user_group_container', jqSharePopupContainer ).show();
            }
            else if ( this.value === 'project_internal_user' )
            {
                $( '.project_internal_user_container', jqSharePopupContainer ).show();
            }
            else if ( this.value === 'project_external_user' )
            {
                $( '.project_external_user_container', jqSharePopupContainer ).show();
            }
        } );


        $( document ).on( 'change', '#share_email__send_share_email', function()
		{
    		if ( $( this ).prop('checked') )
    		{
                $( '.email_description_input_wrapper', jqSharePopupContainer ).show();
                $( 'label[for="share_email_send_notification"]', jqSharePopupContainer ).show();
                $( '#share_popup__send_button', jqSharePopupContainer ).text( 'Send access' );
    		}
    		else
    		{
                $( '.email_description_input_wrapper', jqSharePopupContainer ).hide();
                $( 'label[for="share_email_send_notification"]', jqSharePopupContainer ).hide();
                $( '#share_popup__send_button', jqSharePopupContainer ).text( 'Save' );
    		}
		} );


        $( document ).on( 'change', '.share_access_rights', function()
		{
    		var strAccessRightVal = $( this ).attr( 'id' ).replace( "share_access_rights__allow_", "" );

    		var bolIsChecked = $( this ).is(":checked");

    		if ( bolIsChecked )
    		{
				if ( strAccessRightVal == 'delete' )
				{
					$( '#share_access_rights__allow_write' ).prop( 'checked', true );
					$( '#share_access_rights__allow_download' ).prop( 'checked', true );
					$( '#share_access_rights__allow_view' ).prop( 'checked', true );
				}
				else if ( strAccessRightVal == 'write' )
				{
					$( '#share_access_rights__allow_download' ).prop( 'checked', true );
					$( '#share_access_rights__allow_view' ).prop( 'checked', true );
				}
				else if ( strAccessRightVal == 'download' )
				{
					$( '#share_access_rights__allow_view' ).prop( 'checked', true );
				}
    		}
    		else
    		{
				if ( strAccessRightVal == 'view' )
				{
					$( '#share_access_rights__allow_download' ).prop( 'checked', false );
					$( '#share_access_rights__allow_write' ).prop( 'checked', false );
					$( '#share_access_rights__allow_delete' ).prop( 'checked', false );
				}
				else if ( strAccessRightVal == 'download' )
				{
					$( '#share_access_rights__allow_write' ).prop( 'checked', false );
					$( '#share_access_rights__allow_delete' ).prop( 'checked', false );
				}
				else if ( strAccessRightVal == 'write' )
				{
					$( '#share_access_rights__allow_delete' ).prop( 'checked', false );
				}
    		}
    		
		} );

        $( document ).on( 'change', '#share-popup_upload-access-switch .upload-access-switch_type-select', function()
		{
    		var strAccessSwitchType = $( this ).val();
            if (bolSharePopupReceiveFolder)
            {
                $('.link-can-upload').show();
            }
            
    		if ( strAccessSwitchType == 'private' )
    		{
        		//$( '#share_popup .url_wrapper__sher-link' ).hide();
        		$( '#share_popup .social_wrapper' ).hide();
                //$( '#seperator-or' ).hide();
                $( '#share_popup  #url_wrapper__sher-link-icon' ).addClass('locked');
                $( '#share_popup  .upload-access-switch_password-wrapper' ).hide();
                $( '#share_popup .upload-access-switch_type-wrapper-desc' ).html('Only with private permission');
    		}
    		else 
    		{
        		$( '#share_popup .url_wrapper__sher-link' ).show();
        		$( '#share_popup .social_wrapper' ).show();
                $( '#seperator-or' ).show();
                $( '#share_popup  #url_wrapper__sher-link-icon' ).removeClass('locked');
                $( '#share_popup  .upload-access-switch_password-wrapper' ).show();
                $( '#share_popup .upload-access-switch_type-wrapper-desc' ).html('Anyone with a link');
    		}
    		
    		if ( strAccessSwitchType == 'link-can-view' )
    		{
    			updateSharePopupLink( 1 );
    		}
    		else if ( strAccessSwitchType == 'link-can-edit' )
    		{
    			updateSharePopupLink( 2 );
    		}
    		else if ( strAccessSwitchType == 'link-can-upload' )
    		{
    			updateSharePopupLink( 3 );
                if (bolSharePopupReceiveFolder)
                {
                    $('.link-can-upload').hide();
                }
    		}
		} )
        
        $( document ).on( 'change', '#share-popup_upload-access-switch #upload-access-switch_type-toggle', function()
		{
            if ($(this).is(':checked'))
            {
                var strAccessSwitchType = 'link';
            }
            else
            {
                var strAccessSwitchType = 'private';
            }

            if (bolSharePopupReceiveFolder)
            {
                $('.link-can-upload').show();
            }
            
    		if ( strAccessSwitchType == 'private' )
    		{
        		//$( '#share_popup .url_wrapper__sher-link' ).hide();
        		$( '#share_popup .social_wrapper' ).hide();
        		$( '#share_popup  #url_wrapper__sher-link-icon' ).addClass('locked');
                $( '#share_popup  .upload-access-switch_password-wrapper' ).hide();
                //$( '#seperator-or' ).hide();
                $( '#share_popup .upload-access-switch_type-wrapper-desc' ).html('Only with private permission');
    		}
    		else 
    		{
                $( '#share_popup  #url_wrapper__sher-link-icon' ).removeClass('locked');
                $( '#share_popup  .upload-access-switch_password-wrapper' ).show();
        		$( '#share_popup .url_wrapper__sher-link' ).show();
        		$( '#share_popup .social_wrapper' ).show();
                $( '#seperator-or' ).show();
                $( '#share_popup .upload-access-switch_type-wrapper-desc' ).html('Anyone with a link');
    		}
		} );
    });


    var arrSharePopupParametres = {};
    var strSharePopupType = '';
    var bolSharePopupReceiveFolder = false;

    function showSharePopup( event, arrParametres, bolReceiveFolder )
    {
    	arrSharePopupParametres = arrParametres;
        bolSharePopupReceiveFolder = bolReceiveFolder;
    
        if ( window.location.href.indexOf( "filebrowser" ) !== -1 )
        {
            if ( typeof arrParametres[ 'one_file' ] !== "undefined" && typeof arrParametres[ 'one_file' ][ 'facebook' ] !== "undefined" )
            {
                arrParametres[ 'one_file' ][ 'facebook' ][ 'return_link' ] = window.location.href;
            }
        
            if ( typeof arrParametres[ 'all_files' ] !== "undefined" && typeof arrParametres[ 'all_files' ][ 'facebook' ] !== "undefined" )
            {
                arrParametres[ 'all_files' ][ 'facebook' ][ 'return_link' ] = window.location.href;
            }
        }

        // Hide inputs if not allowed to share.
        if ( ! arrSharePopupParametres['can_share'] )
        {
            $( '#share_popup .active_date_input' ).hide();
            $( '#share_popup .share_type_radio' ).hide();
            $( '#share_popup .share_type_container' ).hide();
            $( '#share_popup .email_container' )
                .addClass('cannot_share')
                .show();
        }
        else
        {
            //$( '#share_popup.is_enterprise .active_date_input' ).show();
            $( '#share_popup.is_business_account .share_type_radio' ).show();
            $( '#share_popup .email_container' )
                .removeClass('cannot_share');
        }
        
        if ( arrSharePopupParametres[ 'show_type_select' ] )
        {
            $( '#share_popup .share_popup__type__select_item' ).show();
        }
        else
        {
        	$( '#share_popup .share_popup__type__select_item' ).hide();
        }

        
        if ( typeof arrSharePopupParametres[ 'show_soc_sharing' ] == 'undefined' || arrSharePopupParametres[ 'show_soc_sharing' ] )
        {
			$( '#share_popup .social_wrapper' ).show();
        }
        else 
        {
			$( '#share_popup .social_wrapper' ).hide();
        }
        
        
        if (
        		typeof arrParametres.upload_info != 'undefined'
        		&& typeof arrParametres.upload_info.valid_to_date_user_set != 'undefined'
        		&& arrParametres.upload_info.owner_logged_in
        		&& typeof initUploadValidToDateUserSet != 'undefined'
        		&& arrParametres.type == 'all_files'
    		)
        {
        	$( '.share-popup__upload_valid_to_date_user_set__wrapper' ).show();
        	initUploadValidToDateUserSet( arrParametres.upload_info.upload_hash, arrParametres.upload_info.valid_to_date_user_set );
        }
        else 
        {
        	$( '.share-popup__upload_valid_to_date_user_set__wrapper' ).hide();
        }

        
    	event.preventDefault();

        changeSharePopupType( arrSharePopupParametres[ 'type' ], bolSharePopupReceiveFolder );

        hideSharePopup();
    
        sharePopupInputSetup();
        
        // don't show two popups at once
        if ( typeof window.FileEmbedPopup !== 'undefined' )
        {
            window.FileEmbedPopup.hidePopup();
        }
        
        if ( typeof ( arrSharePopupParametres[ 'disable_email' ] ) !== "undefined" && arrSharePopupParametres[ 'disable_email' ] === true )
        {
            $( "#share_popup .email_container" ).hide();
            $( '#seperator-or' ).hide();
            $( "#share_popup .email_description_input_wrapper" ).hide();
            $( "#share_popup #share_popup__send_button" ).hide();
            $( "#share_popup #share_popup__cancel_button" ).hide();
            $( '#share_popup .email_send_wrapper').hide();
            $( "#share_popup.is_enterprise label[for='share_email_send_notification']" ).hide();
            $("#share_popup.is_enterprise .share_access_rights__wrapper").hide();
            $("#share_popup.is_enterprise .enterprise_feature").hide();
        }
        else if ( ! arrSharePopupParametres['can_share'] || $( 'input[type=radio][name=share_popup__share_type_radio]:checked' ).val() === 'email' )
        {
            $( "#share_popup .email_container" ).show();
            $( '#seperator-or' ).show();
            $( "#share_popup .email_description_input_wrapper" ).hide(); //show only when email is provided
            $( "#share_popup.is_enterprise .email_description_input_wrapper" ).show();
            $( "#share_popup #share_popup__send_button" ).show();
            $( "#share_popup #share_popup__cancel_button" ).hide(); //show only when email is provided
            $( "#share_popup.is_enterprise label[for='share_email_send_notification']" ).css('display', 'block');
            
            if ( arrSharePopupParametres[ 'type' ] != 'dvs_document' )
            {
	            $( "#share_popup.is_enterprise .share_access_rights__wrapper" ).show();
            }
            
            $( "#share_popup.is_enterprise .enterprise_feature" ).show();
            $( '#share_popup__send_button' ).addClass( 'active' );
        }
    
        if ( typeof ( arrSharePopupParametres[ 'disable_link_types' ] ) !== "undefined" && arrSharePopupParametres[ 'disable_link_types' ] === true )
        {
            $( ".dropdown_wrapper" ).hide();
        }
        else
        {
            $( ".dropdown_wrapper" ).show();
        }

        var strUploadHash;
        var strFileViewHash;
        var intDvsDocumentId;
        
        if ( strSharePopupType == 'dvs_document' )
        {
        	intDvsDocumentId = arrSharePopupParametres[ 'dvs_document_id' ];
        }
        else if( typeof arrSharePopupParametres[ strSharePopupType ][ 'share_email' ] !== 'undefined' )
        {
            strUploadHash = arrSharePopupParametres[ strSharePopupType ][ 'share_email' ][ 'upload_hash' ];
            strFileViewHash = arrSharePopupParametres[ strSharePopupType ][ 'share_email' ][ 'file_view_hash' ];
        }
        else if ( typeof arrSharePopupParametres[ strSharePopupType ][ 'item_info' ] !== 'undefined' )
        {
            strUploadHash = arrSharePopupParametres[ strSharePopupType ][ 'item_info' ][ 'upload_hash' ];
            strFileViewHash = arrSharePopupParametres[ strSharePopupType ][ 'item_info' ][ 'file_view_hash' ];
        }
        
        if ( ! strUploadHash && ! strFileViewHash && ! intDvsDocumentId )
        {
            $('#share_popup .email_container').hide();
        }
        

        
        
        if ( typeof arrSharePopupParametres[ 'from_eparaksts' ] != 'undefined' && arrSharePopupParametres[ 'from_eparaksts' ] )
        {
			$( '#share-popup_all-files-sharing-info_file-count' ).text( arrSharePopupParametres[ 'file_count_for_share' ] );			

			if ( arrSharePopupParametres.type == 'all_files' && arrSharePopupParametres.file_count_for_share > 1 )
			{
				$( '#share-popup_all-files-sharing-info' ).show();
			}
			else 
			{
				$( '#share-popup_all-files-sharing-info' ).hide();
			}
            
			$( '#share_popup .email_input_wrapper' ).css( 'border', '1px solid #008ddf' );
			$( '#share_access_rights__allow_write' ).attr( 'checked', true );

			updateSharePopupLink( 2 );
        }
        else 
        {
			$( '#share-popup_all-files-sharing-info' ).hide();
			
			$( '#share_popup .email_input_wrapper' ).css( 'border', '' );
			$( '#share_popup #description_input' ).text( '' );
			$( '#share_access_rights__allow_write' ).attr( 'checked', false );
        }

        if ( typeof arrSharePopupParametres[ 'from_bf_individual_catalog_settings' ] != 'undefined' && arrSharePopupParametres[ 'from_bf_individual_catalog_settings' ] )
        {
            $( '#share-popup_upload-access-switch .upload-access-switch_type-select option[value="link-can-edit"]' ).hide();
            $( '#share-popup_upload-access-switch .upload-access-switch_type-select option[value="link-can-upload"]' ).hide();
            $( '#share-popup_upload-access-switch .upload-access-switch_type-select option[value="public"]' ).hide();

			$( '#share_popup .email_input_wrapper' ).css( 'border', '1px solid #008ddf' );
			$( '#share_popup #description_input' ).text( ' has sent you access to the photo catalog. Open the link, view and order photos.' );

			$( '#share_popup .share_access_rights' ).attr( 'checked', false );
			$( '#share_access_rights__allow_view' ).attr( 'checked', true );

			$( '#share_email_send_notification' ).attr( 'checked', false );
			$( '#share_popup label[for="share_email_send_notification"]' ).hide();
        }
        
        
        showModal('share_popup');
        $('#share_popup .modal-inner').show();
        return false;
    }

    function sharePopupLoadSharedWithTable ( bolShowOpen )
    {
        var strUploadHash;
        var strFileViewHash;
        var intDvsDocumentId;
        
        if ( strSharePopupType == 'dvs_document' )
        {
        	intDvsDocumentId = arrSharePopupParametres[ 'dvs_document_id' ];
        }
        else if( typeof arrSharePopupParametres[ strSharePopupType ][ 'share_email' ] !== 'undefined' )
        {
            strUploadHash = arrSharePopupParametres[ strSharePopupType ][ 'share_email' ][ 'upload_hash' ];
            strFileViewHash = arrSharePopupParametres[ strSharePopupType ][ 'share_email' ][ 'file_view_hash' ];
        }
        else if ( typeof arrSharePopupParametres[ strSharePopupType ][ 'item_info' ] !== 'undefined' )
        {
            strUploadHash = arrSharePopupParametres[ strSharePopupType ][ 'item_info' ][ 'upload_hash' ];
            strFileViewHash = arrSharePopupParametres[ strSharePopupType ][ 'item_info' ][ 'file_view_hash' ];
        }
    
        var jqSharedWithContainer = $('#share_popup .shared_with_container');
    
        jqSharedWithContainer.html( '' ).css({'visibility': 'hidden'});
        $.ajax( {
            type: "GET",
            dataType: "json",
            url: "/api/sharing.php",
            data: {
                "Action": "GetSharingTable",
                "UploadHash": strFileViewHash ? null : strUploadHash ,
                "FileHash": strFileViewHash ? strFileViewHash : null ,
                "DvsDocumentId": intDvsDocumentId ? intDvsDocumentId : null ,
            },
            success: function ( data )
            {
                $( '#share_type__group_container__project_team' ).hide();
                
                var html = '';
                if ( data.Success )
                {
                    html = data.HTML;
                    if ( data.ItemNameHTML && data.ItemNameHTML != '' )
                    {
                        $('#share_popup .head .item-name').html( '"' + data.ItemNameHTML + '"' );
                    }

                    if ( data.ProjectTeamInfo.ShowTeamInfo )
                    {
                    	$( '#share_type__group_container__project_team' ).show();

                    	$( '#share_popup .project_internal_user_container' ).html( '' );
                    	$.each( data.ProjectTeamInfo.TeamInfo.InternalUsers , function( key, objUser )
                    	{
                    		$( '#share_popup .project_internal_user_container' ).append(
                        		'<div>' +
                        			'<input type="checkbox" name="share_popup__project_internal_user_select" value="' + objUser.ID + '" id="share_popup__project_internal_user_select__' + objUser.ID + '" class="styled_radioblue_btn small">' +
	    							'<label for="share_popup__project_internal_user_select__' + objUser.ID + '">' + objUser.User + '</label>' +
    							'</div>' 
                    		);
                		} );

                    	$( '#share_popup .project_external_user_container' ).html( '' );
                    	$.each( data.ProjectTeamInfo.TeamInfo.ExternalUsers , function( key, objUser )
                    	{
                    		$( '#share_popup .project_external_user_container' ).append(
                        		'<div>' +
                        			'<input type="checkbox" name="share_popup__project_external_user_select" value="' + objUser.ID + '" id="share_popup__project_external_user_select__' + objUser.ID + '" class="styled_radioblue_btn small">' +
	    							'<label for="share_popup__project_external_user_select__' + objUser.ID + '">' + objUser.User + '</label>' +
    							'</div>' 
                    		);
                		} );
                    }
                }
    
                jqSharedWithContainer.html( html );
                
                setTimeout(function (){
                    jqSharedWithContainer.show().css({'visibility': 'visible'});
    
                    if ( bolShowOpen )
                    {
                        $('#upload_sharing_form__table').show();
                        $('#show_upload_sharing_form__table_link').hide();
                    }
                }, 100);
            }
        } );

    }
    
    var jqSharePopupTagsInput = $('#email_input');
    
    var bolShare_ErrorModal_PopupOpen = false;
    function sharePopup_CheckAlerts ()
    {
        if ( bolShare_ErrorModal_PopupOpen )
            return;
    
        bolShare_ErrorModal_PopupOpen = true;
        
        var arrItems = jqSharePopupTagsInput.tagsinput( 'items' );
        var objItem_ToAlert = null;
        for ( var i = 0; i < arrItems.length; i++ )
        {
            if ( ( ! arrItems[ i ].can_email || ! arrItems[ i ].is_valid_email || (arrItems[ i ].may_be_wrong_email ) ) && ! arrItems[ i ].wrong_email__is_accepted )
            {
                objItem_ToAlert = arrItems[ i ];
            }
        }
        
        if ( objItem_ToAlert )
        {
            var fncCallback = function ( bolChange )
            {
                if ( bolChange )
                {
                    if ( objItem_ToAlert.may_be_wrong_email_suggest )
                    {
                        objItem_ToAlert.value = objItem_ToAlert.may_be_wrong_email_suggest;
                    }
                    else
                    {
                        jqSharePopupTagsInput.tagsinput( 'remove', objItem_ToAlert );
                    }
                }
    
                objItem_ToAlert.wrong_email__is_accepted = true;
                
                jqSharePopupTagsInput.tagsinput( 'refresh' );
    
                bolShare_ErrorModal_PopupOpen = false;
    
                setTimeout(function (){
                    $( "#share_em" ).focus();
                    sharePopup_CheckAlerts();
                }, 50);
            };
            
            var strTitle = 'Incorrect e-mail address';
            
            if ( ! objItem_ToAlert.is_valid_email )
            {
                var strMessage = 'The [[INCORRECT_EMAIL]] email address you entered is incorrect! ';
                strMessage = strMessage.replace('[[INCORRECT_EMAIL]]', objItem_ToAlert.value);
                fConfirm( strMessage, strTitle, 'Remove', 'Cancel', fncCallback );
                return;
            }
    
    
            if (objItem_ToAlert.may_be_wrong_email && ! objItem_ToAlert.wrong_email__is_accepted)
            {
                if ( objItem_ToAlert.may_be_wrong_email_suggest )
                {
                    var strMessage = 'The [[INCORRECT_EMAIL]] email address you entered may be incorrect, do you want to correct it to: [[CORRECT_EMAIL]]? ';
                    strMessage = strMessage.replace('[[INCORRECT_EMAIL]]', objItem_ToAlert.value);
                    strMessage = strMessage.replace('[[CORRECT_EMAIL]]', objItem_ToAlert.may_be_wrong_email_suggest);
                    fConfirm( strMessage, strTitle, 'Correct', 'Cancel', fncCallback );
                    return;
                }
                else
                {
                    var strMessage = 'The [[INCORRECT_EMAIL]] email address you entered may be incorrect! ';
                    strMessage = strMessage.replace('[[INCORRECT_EMAIL]]', objItem_ToAlert.value);
                    fConfirm( strMessage, strTitle, 'Remove', 'Cancel', fncCallback );
                    return;
                }
            }
    
            if ( ! objItem_ToAlert.can_email )
            {
                var strMessage = '[[EMAIL]] e-mail address owner has opted out of receiving e-mail! ';
                strMessage = strMessage.replace('[[EMAIL]]', objItem_ToAlert.value);
                fConfirm( strMessage, strTitle, 'Remove', 'Cancel', fncCallback );
                return;
            }
            
        }
        else
        {
            bolShare_ErrorModal_PopupOpen = false;
        }
    }

    var intSharePopup_ValidationActiveCount = 0;
    var resSharePopupSubmitEmailsTimeout = null;
    function sharePopup_SubmitEmails()
    {
        if ( resSharePopupSubmitEmailsTimeout )
            clearTimeout( resSharePopupSubmitEmailsTimeout );
    
        // Wait for validation to complete.
        if ( intSharePopup_ValidationActiveCount > 0 )
        {
            resSharePopupSubmitEmailsTimeout = setTimeout( sharePopup_SubmitEmails, 50 );
            return;
        }
        
        var arrItems = jqSharePopupTagsInput.tagsinput( 'items' );
    
        var bolAllOk = true;
        for ( var i = 0; i < arrItems.length; i++ )
        {
            if ( ( ! arrItems[ i ].is_valid_email || arrItems[ i ].may_be_wrong_email ) && ! arrItems[ i ].wrong_email__is_accepted  )
                bolAllOk = false;
        }
    
        if ( arrItems.length === 0 || ! bolAllOk )
        {
            $( '#share_popup__send_button' ).text( 'Send access' );
            return;
        }

      

        if ( $( '#share_type_select__external_user_group' ).length > 0 )
        {
    		if ( $( '#share_type_select__external_user_group' ).val() == 0 )
    		{
    			$( '#share_type_select__external_user_group' ).addClass( 'has_error' );
    			fError( 'Select the external user group' )
    			return;
    		}
    		else
    		{
    			$( '#share_type_select__external_user_group' ).removeClass( 'has_error' );
    		}
        }
        
        var strUploadHash;
        var strFileViewHash;
        var intDvsDocumentId;
        
        if ( strSharePopupType == 'dvs_document' )
        {
        	intDvsDocumentId = arrSharePopupParametres[ 'dvs_document_id' ];
        }
        else if( typeof arrSharePopupParametres[ strSharePopupType ][ 'share_email' ] !== 'undefined' )
        {
            strUploadHash = arrSharePopupParametres[ strSharePopupType ][ 'share_email' ][ 'upload_hash' ];
            strFileViewHash = arrSharePopupParametres[ strSharePopupType ][ 'share_email' ][ 'file_view_hash' ];
        }
        else if ( typeof arrSharePopupParametres[ strSharePopupType ][ 'item_info' ] !== 'undefined' )
        {
            strUploadHash = arrSharePopupParametres[ strSharePopupType ][ 'item_info' ][ 'upload_hash' ];
            strFileViewHash = arrSharePopupParametres[ strSharePopupType ][ 'item_info' ][ 'file_view_hash' ];
        }
        
        if ( arrItems.length>0 && bolAllOk )
        {
            if ( strUploadHash || strFileViewHash || intDvsDocumentId )
            {
                var arrTmpItems = [];
                for ( var i = 0; i < arrItems.length; i++ )
                {
                    var obj = arrItems[i];
                    obj.item_type = 'email';
                    arrTmpItems.push( obj );
                }
                
                var objRights = {
                    view: 1,
                    download: 1,
                    write: 0,
                    delete: 0,
                    share: 0
                };

                objRights.view = $('#share_access_rights__allow_view').prop('checked') ? 1 : 0;
                objRights.download = $('#share_access_rights__allow_download').prop('checked') ? 1 : 0;
                objRights.write = $('#share_access_rights__allow_write').prop('checked') ? 1 : 0;
                objRights.delete = $('#share_access_rights__allow_delete').prop('checked') ? 1 : 0;
                objRights.share = $('#share_access_rights__allow_share').prop('checked') ? 1 : 0;

                var intExternalUserGroup = 0;

                if ( $( '#share_type_select__external_user_group' ).length > 0 )
                {
                	intExternalUserGroup = $( '#share_type_select__external_user_group' ).val();
                }

                
                $.post( '/ajax/share.php', {
                    items: arrTmpItems ,
                    upload_hash: strFileViewHash ? null : strUploadHash ,
                    file_view_hash: strFileViewHash ? strFileViewHash : null ,
                    dvs_document_id : intDvsDocumentId ? intDvsDocumentId : null ,
                    description: $('#description_input').val(),
                    send_share_email: ( $('#share_email__send_share_email').prop('checked') ? '1' : '0' ),
                    send_notification_once_open: ( $('#share_email_send_notification').prop('checked') ? '1' : '0' ),
                    date_active_enabled: $( 'input[type=radio][name=share_popup__active_date_input_active_radio]:checked' ).val(),
                    date_active_from: $( '#active_date_input_from' ).val(),
                    date_active_to: $( '#active_date_input_to' ).val(),
                    rights: objRights ,
                    submit: 1 ,
                    external_user_group : intExternalUserGroup ,
                    from_bf_individual_catalog_settings : ( typeof arrSharePopupParametres[ 'from_bf_individual_catalog_settings' ] != 'undefined' && arrSharePopupParametres[ 'from_bf_individual_catalog_settings' ] ? 1 : 0 ) ,
                    from_eparaksts : ( typeof arrSharePopupParametres[ 'from_eparaksts' ] != 'undefined' && arrSharePopupParametres[ 'from_eparaksts' ] ? 1 : 0 )
                }, function ( strResponse )
                {
                    var data = JSON.parse( strResponse );
                    $( '#share_popup__send_button', jqSharePopupContainer ).text( 'Send access' );
                    if (data['status'] === 'ok')
                    {
                        $('#email_input').val('');
                        jqSharePopupTagsInput.tagsinput('removeAll');
                        sharePopupLoadSharedWithTable (true);
                        
                        var strClass = 'f_dialog_success';
                        if ( data['sent_emails'].length === 0 )
                        {
                            strClass = 'f_dialog_error';
                        }
                        else if ( data['unsubscribed_emails'].length > 0 )
                        {
                            strClass = 'f_dialog_warning';
                        }
                        
                        var strMessage = '';
                        if ( data['sent_emails'].length > 0 )
                        {
                            strMessage += "E-mails were sent to: <span style='color:green;'>" + data['sent_emails'] + "</span>";
                        }
                        else
                        {
                            strMessage += "Failed to send e-mails!";
                        }
    
                        strMessage += '<br>';
                        
                        if ( data['unsubscribed_emails'].length > 0 )
                        {
                            strMessage += "E-mails weren’t sent to: <span style='color:orange'>" + data['unsubscribed_emails'] + "</span><br>" +
                                "<span style='font-size: 13px;line-height: 16px;display:block;padding-top:6px;'>We weren’t able to send all e-mails because some of the recipients have opted out of receiving files.fm sharing emails. To share files with these e-mail addresses, please inform their owners to change their accounts privacy settings.</span>";
                        }
    
                        if ( data['invalid_emails'].length > 0 )
                        {
                            strMessage += '<br>';
                            strMessage += "E-mails have not been sent, wrong recipient: <span style='color:orange'>" + data['invalid_emails'] + "</span>";
                        }
                        
                        fModal(
                            strClass,
                            strMessage,
                            "",
                            'OK',
                            null
                        );
                    }
                    else if (typeof data['message'] !== 'undefined' && data['message'] === 'free_emails_exhausted')
                    {
                        var strMsg = 'File sharing via e-mail limit has been reached. To send more than 5 file sharing e-mails and use additional features, subscribe to a PRO or business account. More information about subscriptions <a target="_blank" href="https://files.fm/storage-plans">here</a>';
        
                        if (typeof data.logged_in === 'undefined')
                        {
                            // something went wrong
                            fError(strMsg);
                            return;
                        }
        
                        var errorTable = $(
                            '<table id="free_emails_exhausted_alert" class="alert_container alert_container_danger"' +
                            '    <tr>' +
                            '        <td>' +
                            '            <i class="fa fa-exclamation-circle"></i>' +
                            '        </td>' +
                            '        <td>' +
                            '            <div class="alert_main_text">'
                            + strMsg +
                            '            </div>' +
                            '        </td>' +
                            '    </tr>' +
                            '</table>'
                        ).css('display', 'table');
        
                        hideSharePopup();
        
                        // if logged in show account creation form
                        if (!data.logged_in)
                        {
                            showCreateAccount();
                        }
                        else
                        {
                            // it not logged in show subscription form
                            var objSubscriptionForm = new SubscriptionForm();
                            objSubscriptionForm.showForm( 'share_popup__email_limit' );
                            if ($('#free_emails_exhausted_alert').length)
                            {
                                $('#free_emails_exhausted_alert').remove();
                            }
                            $("#subscription-form_global-alert").append(
                                $("<div/>").append(errorTable)
                            )
                        }
                    }
                    else if ( typeof data[ 'message' ] !== 'undefined' && data[ 'message' ] === 'marked_as_spam' )
                    {
                        fError( 'Email protection: email is not sent because too many similar emails have been sent! Please subscribe for a PRO account, to validate.' );
                    }
                    else if ( typeof data[ 'message' ] !== 'undefined' && data[ 'message' ] === 'already_shared' )
                    {
                        fError( 'Already shared with this user.' );
                    }
                    else if ( typeof data['error'] !== 'undefined' )
                    {
                        fError(data['error']);
                    }
                    else
                    {
                        fError( 'An error occurred while sending the e-mail. Please try again or contact [email protected].<br/>At one time it is not allowed to send more than 200 emails.' );
                    }
                } );
            }
        }
    }
    
    function sharePopupInputSetup () {
    
        jqSharePopupTagsInput.tagsinput({
            itemText: function(item) {
                return item.value;
            },
            tagClass: function(item) {
                switch (item.is_valid_email) {
                    case null: return 'processing';
                    case true: {
                        if ( item.may_be_wrong_email && ! item.wrong_email__is_accepted )
                        {
                            return 'processing'
                        }
                        else
                        {
                            return '';
                        }
                    }
                    case false: return 'error';
                }
            },
            confirmKeys: [13, 32, 44, 59],
            maxChars: 1024,
            trimValue: true,
            freeInput: true
        });
    
        //jqSharePopupTagsInput.tagsinput( 'removeAll' );
        $( ".bootstrap-tagsinput input" ).hide();
        
        
        jqSharePopupTagsInput.on('beforeItemAdd', function ( event )
        {
            if ( typeof( event.item ) === 'string' )
            {
                var arrItems = jqSharePopupTagsInput.tagsinput( 'items' );
                for(var i=0; i<arrItems.length; i++)
                {
                    if (arrItems[i].value === event.item )
                    {
                        event.cancel = true;
                        return;
                    }
                }
                
                event.item = {
                    value: event.item,
                    is_valid_email: null,
                    may_be_wrong_email: null,
                    may_be_wrong_email_suggest: null,
                    user_id: null
                };
    
                intSharePopup_ValidationActiveCount++;
                $.post('/ajax/share.php', {
                    items: [ event.item ],
                    validate: 1
                }, function (strResponse){
                    var objResponse = JSON.parse(strResponse);
                    
                    if ( objResponse.status='ok' )
                    {
                        if ( objResponse.items[ event.item.value ] )
                        {
                            event.item.value = objResponse.items[ event.item.value ].value;
                            event.item.is_valid_email = objResponse.items[ event.item.value ].is_valid_email;
                            event.item.may_be_wrong_email = objResponse.items[ event.item.value ].may_be_wrong_email;
                            event.item.may_be_wrong_email_suggest = objResponse.items[ event.item.value ].may_be_wrong_email_suggest;
                            event.item.wrong_email__is_accepted = null;
                            event.item.can_email = objResponse.items[ event.item.value ].can_email;
                            event.item.user_id = objResponse.items[ event.item.value ].user_id;
                        }
                    }
    
                    jqSharePopupTagsInput.tagsinput('refresh');
    
                    setTimeout(sharePopup_CheckAlerts, 50);
                })
                .always(function() {
                    intSharePopup_ValidationActiveCount--;
                });
            }
        });
        
        
        $('#share_popup__send_button').off('click').on('click', function ()
        {
            switch ( $( 'input[type=radio][name=share_popup__share_type_radio]:checked' ).val() )
            {
                default:
                case 'email':
                    $('#share_popup__send_button').text( 'Sending..' );
                    sharePopup_SubmitEmails();
                    break;
                case 'business_account_user':
                case 'business_account_user_group':
                case 'business_account_external_user_group':
                case 'business_account_external_user':
                case 'project_internal_user':
                case 'project_external_user':
                    sharePopup_RequestOrgUserOrGroupShare ()
                    break;
            }
            //
        })
        
        $('.email_input_wrapper').off('click').on('click', function (){
            $(this).css({'min-height': '72px'});
            $( "#share_em" ).focus();
        })
    }

    function keyCombinationInList(keyPressEvent, lookupList) {
        var found = false;
        $.each(lookupList, function (index, keyCombination) {
            if (typeof (keyCombination) === 'number' && keyPressEvent.which === keyCombination) {
                found = true;
                return false;
            }

            if (keyPressEvent.which === keyCombination.which) {
                var alt = !keyCombination.hasOwnProperty('altKey') || keyPressEvent.altKey === keyCombination.altKey,
                    shift = !keyCombination.hasOwnProperty('shiftKey') || keyPressEvent.shiftKey === keyCombination.shiftKey,
                    ctrl = !keyCombination.hasOwnProperty('ctrlKey') || keyPressEvent.ctrlKey === keyCombination.ctrlKey;
                if (alt && shift && ctrl) {
                    found = true;
                    return false;
                }
            }
        });
        return found;
    }
    function split( val ) {
		return val.split( /,\s*/ );
	}
	function extractLast( term ) {
		return split( term ).pop();
	}
	$(function (){
		jQuery( "#share_em" )
            .bind( 'keypress', 'input', function( event ) {
                if(keyCombinationInList(event, [13, 32, 44, 59]) || event.keyCode === jQuery.ui.keyCode.TAB ) {
                    event.preventDefault();
					$(".bootstrap-tagsinput input").val(this.value);
                    $(".bootstrap-tagsinput input").trigger( "focusout" );
                    $(this).val("");
                }
                toggleSendButton();
			})
            .focusout(function(){
                $(".bootstrap-tagsinput input").val(this.value);
                $(".bootstrap-tagsinput input").trigger( "focusout" );
                $(this).val("");
                setTimeout(toggleSendButton, 100);
            })
			.autocomplete({
				source: function( request, response ) {
					jQuery.getJSON( "/ajax/get_user_sent_email_addresses.php", {
						term: extractLast( request.term )
					}, response );
				},
				search: function() {
					// custom minLength
					var term = extractLast( this.value );
					if ( term.length < 2 ) {
						return false;
					}
				},
				focus: function() {
					// prevent value inserted on focus
					return false;
				},
				select: function( event, ui ) {
					$(".bootstrap-tagsinput input").val(ui.item.value );
                    $(".bootstrap-tagsinput input").trigger( "focusout" );
                    $(this).val("");
                    toggleSendButton();
					return false;
				}
			});

            function toggleSendButton( ) {
                if($('.bootstrap-tagsinput').find('span.tag').length === 0)
                {
                    $("#share_popup__send_button").removeClass( "active" );
                    $("#share_popup__cancel_button").hide();
                    $(".email_description_input_wrapper").hide();
                    $( "#share_popup.is_enterprise .email_description_input_wrapper" ).show();
                    $( "label[for='share_email_send_notification']").hide();
                    $( "#share_popup.is_enterprise label[for='share_email_send_notification']" ).css('display', 'block');
                }
                else
                {
                    $("#share_popup__send_button").addClass( "active" );
                    $("#share_popup__cancel_button").show();
                    $(".email_description_input_wrapper").show();
                    $("label[for='share_email_send_notification']").css('display', 'block');
                    
                }
	        }

            $("#share_popup__cancel_button").click(function() {
                $('#email_input').tagsinput( 'removeAll' );

                $("#share_popup__send_button").removeClass( "active" );
                $("#share_popup__cancel_button").hide();
                $(".email_description_input_wrapper").hide();
                $( "#share_popup.is_enterprise .email_description_input_wrapper" ).show();
                $( "label[for='share_email_send_notification']" ).hide();
                $( "#share_popup.is_enterprise label[for='share_email_send_notification']" ).css('display', 'block');
            });
            
	});

    function changeSharePopupType( strType, bolSharePopupReceiveFolder )
    {
        if (bolSharePopupReceiveFolder)
        {
            $('.link-can-upload').show();
        }

        if ( strType != 'all_files' && strType != 'one_file' && strType != 'dvs_document' )
        {
            strType = 'all_files';
        }
    
        strSharePopupType = strType;
    
    
        $( '#shared-icon' ).removeClass();
        if ( strSharePopupType == 'one_file' )
        {
            $( '#share_popup__type__all_files' ).attr( 'checked', false );
            $( '#share_popup__type__only_this_file' ).attr( 'checked', true );
            $( '#shared-icon' ).addClass( 'one_file' );
        }
        else
        {
            $( '#share_popup__type__all_files' ).attr( 'checked', true );
            $( '#share_popup .dropdown' ).val( 1 ).trigger( 'change' );
            $( '#shared-icon' ).addClass( 'all_files' );
        }
    
    
        if ( strType == "one_file" || ( arrSharePopupParametres[ strSharePopupType ][ 'edit_url' ] == '' && arrSharePopupParametres[ strSharePopupType ][ 'upload_url' ] == '' ) )
        {
            $( '#share_popup .dropdown' ).hide();
            $( '#share_popup .dropdown_only_text' ).show();
        }
        else
        {
            $( '#share_popup .dropdown' ).show();
            $( '#share_popup .dropdown_only_text' ).hide();
        }

        if ( 
            0 
            || ! arrSharePopupParametres[ strSharePopupType ][ 'embed_player' ] 
            || ! arrSharePopupParametres[ strSharePopupType ][ 'embed_player' ][ 'file_view_hash' ] 
            || arrSharePopupAllowEmbedPlayer_Extensions.indexOf(arrSharePopupParametres[strSharePopupType]['embed_player']['file_extension']) === -1 )
        {
            $( '#p2p_embed_select' ).removeClass( "first" ).hide();
            $( "#simple_down_link" ).addClass( "first" );
        }
        else
        {
            $( '#p2p_embed_select' )
                .addClass( "first" )
                .show();
            $( "#simple_down_link" ).removeClass( "first" );
        }
        
        if( arrSharePopupParametres[ strSharePopupType ][ 'edit_url' ] == '' || strType == "one_file" )
        {
            $( '#share_popup .dropdown > option:nth-child(2)' ).hide();
        }
        else
        {
            $( '#share_popup .dropdown > option:nth-child(2)' ).show();
        }

        if( arrSharePopupParametres[ strSharePopupType ][ 'upload_url' ] == '' || strType == "one_file" )
        {
            $( '#share_popup .dropdown > option:nth-child(3)' ).hide();
        }
        else
        {
            $( '#share_popup .dropdown > option:nth-child(3)' ).show();
        }


        if ( typeof arrSharePopupParametres[ strSharePopupType ][ 'item_info' ] != 'undefined' && arrSharePopupParametres[ strSharePopupType ][ 'item_info' ] != '' )
        {
	        $( '#share_popup .item-name' ).text('"' + arrSharePopupParametres[ strSharePopupType ][ 'item_info' ][ 'item_name' ] + '"' );
            $( '#seperator-or' ).show();
        }
        else 
        {
            $( '#seperator-or' ).hide();
        }
            
        
        $( '.copy_input_value_to_clipboard_no_tooltip' ).removeClass( 'checked' );
        
        $( '#share_popup_url' ).val( arrSharePopupParametres[ strSharePopupType ][ 'view_url' ] );
        $( '#share_popup_url' ).attr( 'data-clipboard-text', arrSharePopupParametres[ strSharePopupType ][ 'view_url' ] );
        $( '#share_popup_copy_url' ).attr( 'data-clipboard-text', arrSharePopupParametres[ strSharePopupType ][ 'view_url' ] );

        if (bolSharePopupReceiveFolder)
        {
            var strHtml = 	'<div id="drawer_copy_button_view" class="share-input copy_input_value_to_clipboard_no_tooltip checked" onclick="updateSharePopupLink(1)">' +
								'<span>Copy view link</span>' +
								'<span class="desc_popup">Can be viewed and downloaded</span>' +
							'</div>';

            strHtml += 	'<div id="drawer_copy_button_upload" class="share-input copy_input_value_to_clipboard_no_tooltip" onclick="updateSharePopupLink(3)">' +
                                '<span>Copy add link</span>' +
                                '<span class="desc_popup">You can add files, but not delete or edit existing files</span>' +
                            '</div>';

            
		    $( '#copy_button_drawer_popup' ).append(strHtml);
		    $( '.copy_button_wrapper_popup' ).removeClass('copy_input_value_to_clipboard_no_tooltip');
        }
        else
        {
            $( '.copy_button_wrapper_popup' ).addClass('copy_input_value_to_clipboard_no_tooltip');
        }

        if (bolSharePopupReceiveFolder)
        {
            $( '#drawer_copy_button_upload' ).addClass( 'checked' );
        }
        else
        {
            $( '#drawer_copy_button_view' ).addClass( 'checked' );
        }
            
    
        $( "#share_popup_ext_link" ).attr( 'href', arrSharePopupParametres[ strSharePopupType ][ 'view_url' ] );
    
    
        sharePopupLoadSharedWithTable ();
        
        $( '#share_popup .inner .content' ).prop('scrollTop', 0);


		$( '#share-popup_upload-access-switch' ).hide();
		
		if ( strType == 'all_files' && typeof arrSharePopupParametres.upload_info != 'undefined' && typeof arrSharePopupParametres.can_share != 'undefined' && arrSharePopupParametres.can_share )
		{
			var objUploadAccessSwitchSettings = arrSharePopupParametres.upload_info;
			objUploadAccessSwitchSettings.upload_access_switch_type = 'sharing_form';

	        if ( typeof arrSharePopupParametres[ 'from_eparaksts' ] != 'undefined' && arrSharePopupParametres[ 'from_eparaksts' ] )
	        {
	        	objUploadAccessSwitchSettings.from_eparaksts = true;
	        }
	        else 
	        {
	        	objUploadAccessSwitchSettings.from_eparaksts = false;
	        }
	        
        	objSharePopupUploadAccessSwitch = new UploadAccessSwitch(
        		$( '#share-popup_upload-access-switch' ) ,
        		arrSharePopupParametres.upload_info
        	);
        	
        	$( '#share-popup_upload-access-switch' ).show();

        	if ( arrSharePopupParametres.upload_info.access_type == 'PRIVATE' )
        	{
        		//$( '#share_popup .url_wrapper__sher-link' ).hide();
        		$( '#share_popup .social_wrapper' ).hide();
        		//$( '#seperator-or' ).hide();
                $( '#share_popup  #url_wrapper__sher-link-icon' ).addClass('locked');
                $( '#share_popup  .upload-access-switch_password-wrapper' ).hide();
                $( '#share_popup .upload-access-switch_type-wrapper-desc' ).html('Only with private permission');
        	}
        	else 
        	{
        		$( '#share_popup .url_wrapper__sher-link' ).show();
        		$( '#share_popup .social_wrapper' ).show();
                $( '#seperator-or' ).show();
                $( '#share_popup  #url_wrapper__sher-link-icon' ).removeClass('locked');
                $( '#share_popup  .upload-access-switch_password-wrapper' ).show();
                $( '#share_popup .upload-access-switch_type-wrapper-desc' ).html('Anyone with a link');
        	}
		}
		else if ( strType == 'one_file' && typeof arrSharePopupParametres[ 'one_file' ][ 'item_info' ] != 'undefined' && typeof arrSharePopupParametres.can_share != 'undefined' && arrSharePopupParametres.can_share )
		{
			var objFileInfo = arrSharePopupParametres[ 'one_file' ][ 'item_info' ];

			if ( objFileInfo.access_type == '' || objFileInfo.access_type == null )
			{
				objFileInfo.access_type = objFileInfo.parent_access_type;
			}
	        
        	objSharePopupUploadAccessSwitch = new UploadAccessSwitch(
        		$( '#share-popup_upload-access-switch' ) ,
        		{
            		item_type : 'file' ,
            		file_hash : objFileInfo.file_view_hash ,
        			owner_logged_in : objFileInfo.owner_logged_in ,
        			access_type : objFileInfo.access_type,
        			parent_access_type : objFileInfo.parent_access_type,
        			upload_access_switch_type : 'sharing_form' ,
        			from_eparaksts : ( typeof arrSharePopupParametres[ 'from_eparaksts' ] != 'undefined' && arrSharePopupParametres[ 'from_eparaksts' ] ? true : false )
        		}
        	);
        	
        	$( '#share-popup_upload-access-switch' ).show();

        	if ( objFileInfo.access_type == 'PRIVATE' )
        	{
        		//$( '#share_popup .url_wrapper__sher-link' ).hide();
        		$( '#share_popup .social_wrapper' ).hide();
                //$( '#seperator-or' ).hide();
                $( '#share_popup  #url_wrapper__sher-link-icon' ).addClass('locked');
                $( '#share_popup  .upload-access-switch_password-wrapper' ).hide();
                $( '#share_popup .upload-access-switch_type-wrapper-desc' ).html('Only with private permission');
        	}
        	else 
        	{
        		$( '#share_popup .url_wrapper__sher-link' ).show();
        		$( '#share_popup .social_wrapper' ).show();
                $( '#seperator-or' ).show();
                $( '#share_popup  #url_wrapper__sher-link-icon' ).removeClass('locked');
                $( '#share_popup  .upload-access-switch_password-wrapper' ).show();
                $( '#share_popup .upload-access-switch_type-wrapper-desc' ).html('Anyone with a link');
        	}
		}

        if (strType == 'all_files' && ((typeof arrSharePopupParametres.upload_info != 'undefined' && arrSharePopupParametres.upload_info.access_type =='link-can-upload') || arrSharePopupParametres.all_files.upload_url )) 
        {
            updateSharePopupLink( 1 );
            if (bolSharePopupReceiveFolder)
            {
                updateSharePopupLink( 3 );
                $('.link-can-upload').hide();
            }
        }
        
        if ( strType == 'dvs_document' )
        {
        	$( '#share_popup .url_wrapper' ).hide();
        	$( '#share_popup .social_wrapper' ).hide();
        	$( '#share_popup #seperator-or' ).hide();
        	
        	$( '#share_popup #share_type__group_container__project_team' ).hide();
        	$( '#share_popup #share_type__group_container__company_users' ).hide();
        	$( '#share_popup .share_access_rights__wrapper' ).hide();
        	$( '#share_popup .active_date_input' ).hide();
        	$( '#share_popup .active_date_input' ).removeClass( 'enterprise_feature' );
        	$( '#share_popup #share_email_send_notification_wrapper' ).hide();;
        }
    }

    function hideSharePopup()
    {
        if ( ! $('#share_popup .modal-inner').is(":visible") )
        {
            return;
        }
        
        $( 'html' ).css( 'overflow', '' );
        

        if( window.location.hash.indexOf( ';/share_popup' ) !== -1)
        {
	        window.location.hash = window.location.hash.replace(';/share_popup', '');
        }
        
        $('#share_popup .modal-inner').hide();
        hideModal('share_popup');

        if ( objSharePopupUploadAccessSwitch != null && objSharePopupUploadAccessSwitch.bolAccessTypeChanged )
        {
        	location.reload();
        }
    }

    function updateSharePopupLink(intSelected)
    {
        $( '#share_access_rights__allow_view' ).attr( 'checked', true );
        $( '#share_access_rights__allow_download' ).attr( 'checked', true );
        
		if ( intSelected == 2 && arrSharePopupParametres[ strSharePopupType ][ 'edit_url' ] != '' )
		{
            $( '.copy_input_value_to_clipboard_no_tooltip' ).removeClass( 'checked' );
            $( '#drawer_copy_button_edit' ).addClass( 'checked' );
			$( '#share_popup_url' ).val( arrSharePopupParametres[ strSharePopupType ][ 'edit_url' ] );
	        $( '#share_popup_url' ).attr( 'data-clipboard-text', arrSharePopupParametres[ strSharePopupType ][ 'edit_url' ] );
	        $( '#share_popup_copy_url' ).attr( 'data-clipboard-text', arrSharePopupParametres[ strSharePopupType ][ 'edit_url' ] );
            $( "#share_popup_ext_link" ).attr( 'href', arrSharePopupParametres[ strSharePopupType ][ 'edit_url' ] );

            $( '#share_access_rights__allow_write' ).attr( 'checked', true );
            $( '#share_access_rights__allow_delete' ).attr( 'checked', true );
		}
		else if( intSelected == 3 && arrSharePopupParametres[ strSharePopupType ][ 'upload_url' ] )
		{
            $( '.copy_input_value_to_clipboard_no_tooltip' ).removeClass( 'checked' );
            $( '#drawer_copy_button_upload' ).addClass( 'checked' );
            $( '#share_popup_url' ).val( arrSharePopupParametres[ strSharePopupType ][ 'upload_url' ] );
            $( '#share_popup_url' ).attr( 'data-clipboard-text', arrSharePopupParametres[ strSharePopupType ][ 'upload_url' ] );
            $( '#share_popup_copy_url' ).attr( 'data-clipboard-text', arrSharePopupParametres[ strSharePopupType ][ 'upload_url' ] );
            $( "#share_popup_ext_link" ).attr( 'href', arrSharePopupParametres[ strSharePopupType ][ 'upload_url' ] );

            $( '#share_access_rights__allow_write' ).attr( 'checked', true );
            $( '#share_access_rights__allow_delete' ).attr( 'checked', false );
        }
        else
		{
            $( '.copy_input_value_to_clipboard_no_tooltip' ).removeClass( 'checked' );
            $( '#drawer_copy_button_view' ).addClass( 'checked' );
			$( '#share_popup_url' ).val( arrSharePopupParametres[ strSharePopupType ][ 'view_url' ] );
	        $( '#share_popup_url' ).attr( 'data-clipboard-text', arrSharePopupParametres[ strSharePopupType ][ 'view_url' ] );
	        $( '#share_popup_copy_url' ).attr( 'data-clipboard-text', arrSharePopupParametres[ strSharePopupType ][ 'view_url' ] );
            $( "#share_popup_ext_link" ).attr( 'href', arrSharePopupParametres[ strSharePopupType ][ 'view_url' ] );

            $( '#share_access_rights__allow_write' ).attr( 'checked', false );
            $( '#share_access_rights__allow_delete' ).attr( 'checked', false );
		}
    }

    var bolSharePopUpDeclineSuggest = false;


    function shareOnFacebook(strFileName, strPictureURL, strDescription, strFbLink, strReturnLink)
    {
    	window.open(
    	        'http://www.facebook.com/dialog/feed?app_id='+ FB_APP_ID +
    	        '&name=' + encodeURIComponent(strFileName) +
    	        '&picture=' + encodeURIComponent(strPictureURL) +
    	        '&description=' + encodeURIComponent(strDescription) +
    	        '&link=' + encodeURIComponent(strFbLink) +
    	        '&redirect_uri=' + encodeURIComponent(strReturnLink)
    	        ,
    	        '_parent'
    	        );
    }


    function shareOnTwitter( strText, strLink )
    {
        window.open(
            'http://twitter.com/intent/tweet?source=webclient&text=' +
            encodeURIComponent( strText ) +
            '&url=' +
            encodeURIComponent( strLink ) ,
            '',
            'location=1,status=1,scrollbars=0,resizable=0,width=640,height=480'
        );
    
        return false;
    }

    function shareOnTelegram( strText, strLink )
    {
        window.open(
            'https://telegram.me/share/?url=' +
            encodeURIComponent( strLink ) +
            '&text=' +
            encodeURIComponent( strText ),
            '',
            'location=1,status=1,scrollbars=0,resizable=0,width=640,height=480'
        );
    
        return false;
    }
</script>
<section id="file_embed_popup" class="modal-container">
<div class="modal-inner">
<div class="inner">
<div class="content">
<form>
<section class="file_embed_section" id="file_embed_section_image">
<div class="file_embed_section_title">
Image embedding codes for web pages: </div>
<div class="input-label" id="file_embed_item_image_html" onclick="window.FileEmbedPopup.onClickItem(event, 'image', 'html')">
<label for="file_embed_image_html">
For websites (HTML) </label>
<input id="file_embed_image_html" type="text" readonly="">
<div class="copy_button_embed">
<div class="copy_text">
<div class="hover">Copy link</div>
<div class="copied">Copied</div>
</div>
</div>
</div>
<div class="input-label" id="file_embed_item_image_bbcode" onclick="window.FileEmbedPopup.onClickItem(event, 'image', 'bbcode')">
<label for="file_embed_image_bbcode">
Forums: BBCode </label>
<input id="file_embed_image_bbcode" type="text" readonly="">
<div class="copy_button_embed">
<div class="copy_text">
<div class="hover">Copy link</div>
<div class="copied">Copied</div>
</div>
</div>
</div>
<div class="input-label" id="file_embed_item_image_thumb_small" onclick="window.FileEmbedPopup.onClickItem(event, 'image', 'thumb_small')">
<label for="file_embed_image_thumb_small">
Small picture thumbnail </label>
<input id="file_embed_image_thumb_small" type="text" readonly="">
<div class="copy_button_embed">
<div class="copy_text">
<div class="hover">Copy link</div>
<div class="copied">Copied</div>
</div>
</div>
</div>
<div class="input-label" id="file_embed_item_image_full" onclick="window.FileEmbedPopup.onClickItem(event, 'image', 'full')">
<label for="file_embed_image_full">
Web size image </label>
<input id="file_embed_image_full" type="text" readonly="">
<div class="copy_button_embed">
<div class="copy_text">
<div class="hover">Copy link</div>
<div class="copied">Copied</div>
</div>
</div>
</div>
</section>
<section class="file_embed_section" id="file_embed_section_default">
<div class="file_embed_section_title">
File links for integrations </div>
<div class="input-label" id="file_embed_item_default_web_link_to_file" onclick="window.FileEmbedPopup.onClickItem(event, 'default', 'web_link_to_file')">
<label for="file_embed_default_web_link_to_file">
Direct link to the file in the browser </label>
<input id="file_embed_default_web_link_to_file" type="text" readonly="">
<div class="copy_button_embed">
<div class="copy_text">
<div class="hover">Copy link</div>
<div class="copied">Copied</div>
</div>
</div>
</div>
<div class="input-label" id="file_embed_item_default_P2P" onclick="window.FileEmbedPopup.onClickItem(event, 'default', 'P2P')">
<label for="file_embed_default_P2P">
For inclusion in WEB pages together with a video player <img src="/images/UI_icons/info.svg" class="my_tooltip" my_title="Copy this code into your web page. Contact [email protected] for assistance. This is the right way to embed content with unlimited traffic. Possible additional attributes:<br /> <b>w</b> - file width (css value);<br /> <b>h</b> - file height (css value);<br /> <b>autoload</b> - load the file immediately after inclusion;<br /> <b>autoplay</b> - start playing video/audio immediately after loading;<br /> <b>poster_src</b> - preview image link;">
</label>
<input id="file_embed_default_P2P" type="text" readonly="">
<div class="copy_button_embed">
<div class="copy_text">
<div class="hover">Copy link</div>
<div class="copied">Copied</div>
</div>
</div>
</div>
<div class="input-label" id="file_embed_item_default_direct_simple" onclick="window.FileEmbedPopup.onClickItem(event, 'default', 'direct_simple')">
<label for="file_embed_default_direct_simple">
Direct download link. Limited. For integrations contact us. </label>
<input id="file_embed_default_direct_simple" type="text" readonly="">
<div class="copy_button_embed">
<div class="copy_text">
<div class="hover">Copy link</div>
<div class="copied">Copied</div>
</div>
</div>
</div>
<div class="input-label" id="file_embed_item_default_direct_path" onclick="window.FileEmbedPopup.onClickItem(event, 'default', 'direct_path')">
<label for="file_embed_default_direct_path">
Direct link including full path </label>
<input id="file_embed_default_direct_path" type="text" readonly="">
<div class="copy_button_embed">
<div class="copy_text">
<div class="hover">Copy link</div>
<div class="copied">Copied</div>
</div>
</div>
</div>
</section>
</form>
<div class="for_help">
For help: <a href="mailto:[email protected]">
[email protected] </a>
</div>
</div>
</div>
</div>
<div id="file_embed_popup__close" class="modal-close" data-dismiss="modal" data-close="Aizvērt" onclick="hideQrPopup()"></div>
</section>
<script type="text/javascript" src="/js/popups/more_options_popup.js?v=103"></script>
<script type="text/javascript">
    function EmbedPopup( strPopupID )
    {
        ListButtonPopup.call( this, strPopupID );
    }
    
    EmbedPopup.prototype = Object.create( ListButtonPopup.prototype );
    EmbedPopup.prototype.constructor = ListButtonPopup;
    
    EmbedPopup.prototype.onBeforeShowed = function ()
    {
        this.populateSections();
    
        if ( $( '#share_popup' ).is( ":visible" ) )
        {
            hideSharePopup();
        }
    };
    
    EmbedPopup.prototype.populateSections = function ()
    {
        var arrSections = JSON.parse( "{\"image\":[\"html\",\"bbcode\",\"thumb_small\",\"full\"],\"default\":[\"web_link_to_file\",\"P2P\",\"direct_simple\",\"direct_path\"]}" );
        var objInfo = this.getFileInfo();
        this.sections = {
            'image': new ImageSection(),
            'default': new DefaultSection()
        };
        
        for ( var strSectionKey in arrSections )
        {
            if ( !arrSections.hasOwnProperty( strSectionKey ) ) continue;
            
            // verify that the section can be showed
            if ( !this.sections[ strSectionKey ].canShow( objInfo ) )
            {
                $( "#file_embed_section_" + strSectionKey ).hide();
                continue;
            }
            else
            {
                $( "#file_embed_section_" + strSectionKey ).show();
            }
            
            var arrItems = arrSections[ strSectionKey ];
            
            for ( var i in arrItems )
            {
                if ( !arrItems.hasOwnProperty( i ) ) continue;
                
                var strItemKey = arrItems[ i ];
                
                if ( this.sections[ strSectionKey ].canShowItem( strItemKey, objInfo ) )
                {
                    $( "#file_embed_" + strSectionKey + "_" + strItemKey ).val(
                        this.sections[ strSectionKey ].getItemValue( strItemKey, objInfo )
                    );
                    
                    $("#file_embed_item_" + strSectionKey + "_" + strItemKey).show();
                }
                else
                {
                    $("#file_embed_item_" + strSectionKey + "_" + strItemKey).hide();
                }
            }
        }
    };
    
    EmbedPopup.prototype.getFileInfo = function ()
    {
        var params = window.arrSharePopupParametres;
        var type = params.type;
    
        var embed_player,
            file_hash,
            upload_hash,
            is_image,
            file_name,
            logged_in_user_is_owner;
    
        if ( typeof params[ type ] !== "undefined" )
        {
            embed_player = params[ type ][ 'embed_player' ];
        }
        
        file_hash = params[ 'one_file' ][ 'item_info' ][ 'file_view_hash' ];
        upload_hash = params[ 'one_file' ][ 'item_info' ][ 'upload_hash' ];
        logged_in_user_is_owner = typeof params[ 'all_files' ][ 'logged_in_user_is_owner' ] !== "undefined" ? params[ 'all_files' ][ 'logged_in_user_is_owner' ] : undefined;
        is_image = $.inArray( params[ 'one_file' ][ 'item_info' ][ 'extension' ], [ 'jpeg', 'jpg', 'png', 'gif' ] ) !== -1;
        file_name = params[ 'one_file' ][ 'item_info' ][ 'file_name' ];
        file_version = params[ 'one_file' ][ 'item_info' ][ 'file_version' ];

        return {
            'file_hash': file_hash,
            'upload_hash': upload_hash,
            'file_name': file_name,
            'file_version': file_version,
            'embed_player': embed_player,
            'domain': "https://files.fm",
            'is_img': is_image,
            'logged_in_user_is_owner': logged_in_user_is_owner,
            'file_extension' : params[ 'one_file' ][ 'item_info' ][ 'extension' ]
        };
    };
    
    EmbedPopup.prototype.onClickItem = function ( event, strSectionKey, strItemKey )
    {
        var objInfo = this.getFileInfo();
        
        // deselecct all other input fields
        $( ".file_embed_select" ).blur();
        
        // select event target field
        if ( this.sections[ strSectionKey ].canCopyItem( strItemKey, objInfo ) )
        {
            var el = document.createElement( 'textarea' );
            el.value = $( "#file_embed_" + strSectionKey + "_" + strItemKey ).val();
            document.body.appendChild( el );
            el.select();
            document.execCommand( 'copy' );
            document.body.removeChild( el );

            $( "#file_embed_item_" + strSectionKey + "_" + strItemKey + " .copy_button_embed").addClass( 'copied' ).delay( 4000 ).queue( function( next )
			{
				$( this ).removeClass( 'copied' );
				next();
			} );
            
            $( "#file_embed_" + strSectionKey + "_" + strItemKey ).select();
        }

        gaev('file_embed_popup', strSectionKey, strItemKey );
    };
    
    window.FileEmbedPopup = new EmbedPopup( "file_embed_popup" );
    
    function EmbedPopupSection()
    {
    }
    
    EmbedPopupSection.prototype = {
        canShow: function ( objInfo )
        {
        },
        canShowItem: function ( strItemKey, objInfo )
        {
        },
        canCopyItem: function ( strItemKey, objInfo )
        {
        },
        getItemValue: function ( strItemKey, objInfo )
        {
        }
    };
    
    function ImageSection()
    {
        EmbedPopupSection.call( this );
    }
    
    ImageSection.prototype = Object.create( EmbedPopupSection.prototype );
    ImageSection.prototype.constructor = EmbedPopupSection;
    
    ImageSection.prototype.canShow = function ( objInfo )
    {
        return objInfo.is_img;
    };
    
    ImageSection.prototype.getItemValue = function ( strItemKey, objInfo )
    {
        var strUploadListViewURL = objInfo.domain + "/u/" + objInfo.upload_hash + "#/view/" + encodeURI( objInfo.file_name );
        var strFileListViewURL = objInfo.domain + "/f/" + objInfo.file_hash;
        var strFileThumbShowURL = objInfo.domain + "/thumb_show.php?i=" + objInfo.file_hash;
        var strFileThumbURL = objInfo.domain + "/thumb.php?i=" + objInfo.file_hash;

        if ( typeof( objInfo.file_version ) != 'undefined' && objInfo.file_version > 0 )
        {
            strFileThumbShowURL += '&v=' + objInfo.file_version;
            strFileThumbURL += '&v=' + objInfo.file_version;
        }
    
        var isListViewForSpecificFile = 0;
        
        switch ( strItemKey )
        {
            case 'html' :
                return "<a href=\"" + (isListViewForSpecificFile ? strFileListViewURL : strUploadListViewURL) + "\">" +
                    "<img src=\"" + strFileThumbShowURL + "\">" +
                    "</a>";
            case 'bbcode':
                return "[URL=" + (isListViewForSpecificFile ? strFileListViewURL : strUploadListViewURL) + "][IMG]" + strFileThumbShowURL + "[/IMG][/URL]";
            case 'thumb_small':
                return strFileThumbURL;
            case 'full':
                return strFileThumbShowURL;
        }
    };
    
    ImageSection.prototype.canShowItem = function ( strItemKey, objInfo )
    {
        // image embed urls are available to all users
        return true;
    };
    
    ImageSection.prototype.canCopyItem = function ( strItemKey, objInfo )
    {
        return true;
    };
    
    function DefaultSection()
    {
        EmbedPopupSection.call( this );
    }

    DefaultSection.pathUrlCache = [];
    
    DefaultSection.prototype = Object.create( EmbedPopupSection.prototype );
    DefaultSection.prototype.constructor = EmbedPopupSection;
    
    DefaultSection.prototype.getItemValue = function ( strItemKey, objInfo )
    {
        switch ( strItemKey )
        {
            case 'P2P':
                if ( ( [ 'mp4', 'ogg', 'webm' ] ).indexOf( objInfo.embed_player.file_extension ) !== -1 )
                {
                    return '<script type="text/javascript" src="' + objInfo.domain
                        + '/embed/playerv2?hash=' + objInfo.embed_player.file_view_hash
                        + '&autoplay=off&autoload=off&w=100%&h=auto&poster_src=' + objInfo.domain
                        + '/thumb_video_picture.php?i=' + objInfo.embed_player.file_view_hash
                        + '" id="filesfm_embed_js__' + objInfo.embed_player.file_view_hash + '"><' + '/script>';
                }
                else
                {
                    return '<script type="text/javascript" src="' + objInfo.domain + '/embed/player?hash='
                        + objInfo.embed_player.file_view_hash + '&w=100%&h=auto" '
                        + 'id="filesfm_embed_js__' + objInfo.embed_player.file_view_hash + '"><' + '/script>';
                }
			case 'web_link_to_file':
                return objInfo.domain + "/f/" + objInfo.file_hash;
            case 'direct_simple':
                return objInfo.domain + "/down.php?i=" + objInfo.file_hash;
            case 'direct_path':
                if( typeof this.constructor.pathURLCache === "undefined" )
                {
                    this.constructor.pathURLCache = [];   
                }
                
                // cache the paths
                if ( typeof this.constructor.pathURLCache[ objInfo.file_hash ] !== "undefined" )
                {
                    return this.constructor.pathURLCache[ objInfo.file_hash ];
                }
                
                var _this = this;
                
                // don't have path cached -> request it from api
                $.ajax( {
                    type: "GET",
                    url: "/api/embed_urls.php",
                    data: {
                        'i': objInfo.file_hash
                    },
                    success: function ( data )
                    {
                        data = JSON.parse( data );
                        if ( data[ 'path_access_url' ] )
                        {
                            // add url to local cache
                            _this.constructor.pathURLCache[ objInfo.file_hash ] = data[ 'path_access_url' ];
                            
                            $( "#file_embed_default_direct_path" ).val( data[ 'path_access_url' ] );
                        }
                        else
                        {
                            $( '#file_embed_item_default_direct_path' ).hide();
                        }
                    }
                } );
                return "";
        }
    };
    
    DefaultSection.prototype.canShow = function ( objInfo )
    {
        return true;
    };
    
    DefaultSection.prototype.canShowItem = function ( strItemKey, objInfo )
    {
        var isLoggedIn = !! 0;
        
        switch ( strItemKey )
        {
            case 'P2P':
                return typeof objInfo.embed_player !== "undefined"
                    && typeof objInfo.embed_player.file_view_hash !== "undefined"
                    && objInfo.embed_player.file_view_hash !== null
                    && $.inArray( objInfo.embed_player.file_extension, [ 'mp4', 'webm', 'jpeg', 'jpg', 'png', 'gif', 'mp3' ] ) >= 0;
            case 'direct_path':
                return isLoggedIn && (typeof objInfo.logged_in_user_is_owner === "undefined" || objInfo.logged_in_user_is_owner === true);
            case 'direct_simple':
                if (
                        (
                            (
                                typeof(bolHideDownloadButtons) === 'undefined' 
                                || ! bolHideDownloadButtons 
                            ) 
                            || bolIsOwner 
                        )
                        && objInfo.file_extension != 'filesfm_url'
                	)
                {
                    return true;
                }
                else
                {
                    return false
                }
            default:
                return true;
        }
    };
    
    DefaultSection.prototype.canCopyItem = function ( strItemKey, objInfo )
    {
        var isSubscriber = !!0;
        var isLoggedIn = !! 0;
        
        switch ( strItemKey )
        {
            case 'P2P':
                return true;
            case 'direct_path':
            case 'direct_simple':
                if ( !isSubscriber )
                {
                    if ( isLoggedIn )
                    {
                        objSubscriptionForm.showForm( 'direct_access_share_link' );
                    }
                    else
                    {
                        showSignIn();
                    }
                    window.FileEmbedPopup.hidePopup();
                }
                return isSubscriber;
            default:
                return true;
        }
    };
</script>
<link rel="stylesheet" type="text/css" href="/new/css/popups/more_options_popup.css?v=101">
<link rel="stylesheet" type="text/css" href="/new/css/popups/file_embed_popup.css?v=102"><link rel="stylesheet" type="text/css" media="all" href="/css/qr_popup.css?v=1725008979">
<script src="/js/qrcode/qrcode.min.js?v=1715343643"></script>
<section id="qr_popup" class="modal-container">
<div class="modal-inner">
<div class="inner">
<div class="content">
<h1>Scan or download QR code</h1>
<div id="qrcode"></div>
<a id="qr_download" hidden="">Download</a>
</div>
</div>
</div>
<div id="qr_popup__close" class="modal-close" data-dismiss="modal" data-close="Aizvērt" onclick="hideQrPopup()"></div>
</section>
<script type="text/javascript">

    function showQrPopup( event, strUrl )
    {
        $('#qrcode img').remove();
        let objButton = document.querySelector('#qr_download')
        objButton.removeAttribute('href');
        objButton.removeAttribute('download');
        objButton.setAttribute('hidden', true);

        const makeQR = (url, strFilename) => {
            var objQrCode = new QRCode('qrcode', {
                text: url,
                width: 250,
                height: 250,
                colorDark: '#242424',
                colorLight: '#ffffff',
                correctLevel: QRCode.CorrectLevel.H
            });
            objQrCode.makeCode(url)

            var intTries = 0;
            var checkExist = setInterval(function() {
                intTries ++;
                if (intTries > 5)
                {
                    clearInterval(checkExist);
                }
                if (objQrCode._oDrawing._bIsPainted)
                {
                    let objImage = document.querySelector('#qrcode img')
                    let strQrLink = objImage.getAttribute('src');
                    objButton.setAttribute('href', strQrLink);
                    objButton.setAttribute('download', strFilename);
                    objButton.removeAttribute('hidden');
                    clearInterval(checkExist);
                }
                
            }, 100); // check every 100ms if qrcode has been drawn and create download button
        }

        makeQR(strUrl, 'qr-code.png')
        
        showModal('qr_popup');
        $('#qr_popup .modal-inner').show();
        return false;
    }

    function hideQrPopup()
    {
        if ( ! $('#qr_popup .modal-inner').is(':visible') )
        {
            return;
        }
        
        $( 'html' ).css( 'overflow', '' );
        
        $('#qr_popup .modal-inner').hide();
        hideModal('qr_popup');
    }
</script>
<script src="/js/inputs.js?v=1715343640"></script>
<script src="/ts/chat/dist/index.js?v=1715343647"></script>
<script defer="" src="https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" data-cf-beacon="{&quot;rayId&quot;:&quot;8d29a416c9062160&quot;,&quot;version&quot;:&quot;2024.10.1&quot;,&quot;serverTiming&quot;:{&quot;name&quot;:{&quot;cfExtPri&quot;:true,&quot;cfL4&quot;:true,&quot;cfSpeedBrain&quot;:true,&quot;cfCacheStatus&quot;:true}},&quot;token&quot;:&quot;920d49a89d024a45b0d7a0081fbadb80&quot;,&quot;b&quot;:1}" crossorigin="anonymous"></script>


<div id="gallery_panzoomdiv" style="overflow:hidden;height:100%;width:100%;position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 999999999; background: #666666; display: none;" height="100%" width="100%"></div><ul class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content" id="ui-id-1" tabindex="0" style="display: none;"></ul><span role="status" aria-live="assertive" aria-relevant="additions" class="ui-helper-hidden-accessible"></span><iframe src="https://gum.criteo.com/syncframe?origin=publishertag&amp;topUrl=files.fm#{&quot;uid&quot;:{&quot;origin&quot;:0},&quot;lwid&quot;:{&quot;origin&quot;:0},&quot;bundle&quot;:{&quot;origin&quot;:0},&quot;optout&quot;:{&quot;value&quot;:false,&quot;origin&quot;:0},&quot;sid&quot;:{&quot;origin&quot;:0},&quot;tld&quot;:&quot;files.fm&quot;,&quot;topUrl&quot;:&quot;files.fm&quot;,&quot;version&quot;:144,&quot;cw&quot;:true,&quot;lsw&quot;:true,&quot;origin&quot;:&quot;publishertag&quot;,&quot;requestId&quot;:&quot;0.7802365457656673&quot;}" width="0" height="0" frameborder="0" style="border-width: 0px; margin: 0px; display: none;" class="my_tooltip" my_title="Criteo GUM iframe"></iframe></body><iframe sandbox="allow-scripts allow-same-origin" id="612e951e3708ede" frameborder="0" allowtransparency="true" marginheight="0" marginwidth="0" width="0" hspace="0" vspace="0" height="0" style="height:0px;width:0px;display:none;" scrolling="no" src="https://eb2.3lift.com/sync?gdpr=&amp;cmp_cs=&amp;us_privacy=&amp;redir=https%3A%2F%2Fprebid-stag.setupad.net%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D%26gdpr_consent%3D%26gpp%3D%26gpp_sid%3D%26f%3Db%26uid%3D%24UID">
    </iframe><iframe sandbox="allow-scripts allow-same-origin" id="183b5eba2e72b08d" frameborder="0" allowtransparency="true" marginheight="0" marginwidth="0" width="0" hspace="0" vspace="0" height="0" style="height:0px;width:0px;display:none;" scrolling="no" src="https://eb2.3lift.com/sync?">
    </iframe><iframe sandbox="allow-scripts allow-same-origin" id="184e94873a8456cd" frameborder="0" allowtransparency="true" marginheight="0" marginwidth="0" width="0" hspace="0" vspace="0" height="0" style="height:0px;width:0px;display:none;" scrolling="no" src="https://adxbid.info/sync-all.html?gdpr=0&amp;gdpr_consent=&amp;us_privacy=">
    </iframe><iframe sandbox="allow-scripts allow-same-origin" id="1856dbe4a623b6a8" frameborder="0" allowtransparency="true" marginheight="0" marginwidth="0" width="0" hspace="0" vspace="0" height="0" style="height:0px;width:0px;display:none;" scrolling="no" src="https://prebid.a-mo.net/isyn?gdpr_consent=&amp;gdpr=0&amp;us_privacy=&amp;gpp=&amp;gpp_sid=">
    </iframe><iframe sandbox="allow-scripts allow-same-origin" id="18625d15b424e41d" frameborder="0" allowtransparency="true" marginheight="0" marginwidth="0" width="0" hspace="0" vspace="0" height="0" style="height:0px;width:0px;display:none;" scrolling="no" src="https://eb2.3lift.com/sync?">
    </iframe></html>