text: var $iBoxTotalOpen = 0;
  var $iCurrentZIndex = 1;
  var $aBoxHistory = {};
  var iImageIterationCount = 0;
  var iCurrentImageIterationCount = 0;
  var $sCurrentId = null;
  var sLastOpenUrl = null;
  var bIsPhotoImage = false;
  
  
  function js_box_remove($oObj, $bResetCloseWarning) {
    var closeBoxFunc = function ($oObj) {
      $('#main_core_body_holder').show();
  
      $('.feed_share_on_item a').removeClass('active');
  
      var $oParent = $($oObj).parents('.js_box:first'),
        boxImageHolderFull = $($oObj).parents('.js_box_image_holder_full:first'),
        boxImageHolder = $($oObj).parents('.js_box_image_holder:first'),
        boxHolder = $($oObj).parents('.js_box_holder:first'),
        $sLink = $oParent.find('.js_box_history:first').html();
  
      if (isset($aBoxHistory[$sLink])) {
        delete $aBoxHistory[$sLink];
      }
  
      boxImageHolderFull.fadeOut(100, function () {
        $(this).remove();
      });
      boxImageHolder.fadeOut(100, function () {
        $(this).remove();
        if ($('.js_box_image_holder:visible, .js_box_holder:visible').length == 0) {
          if (typeof $Core.enableScroll !== 'undefined') {
            $Core.enableScroll();
          }
        }
      });
      boxHolder.fadeOut(100, function () {
        $(this).remove();
        if ($('.js_box_image_holder:visible, .js_box_holder:visible').length == 0) {
          if (typeof $Core.enableScroll !== 'undefined') {
            $Core.enableScroll();
          }
        }
      });
      $oParent.fadeOut(100, function () {
        $(this).remove();
      });
  
      $('#global_attachment_list_inline').hide();
  
      if (bIsPhotoImage) {
        bIsPhotoImage = false;
      }
      $(document).trigger('jsbox.closed');
    }
  
      let oJsBox = $($oObj).closest('.js_box');
      if (oJsBox.length) {
          if (!bUsingConfirmPopupForPreventingReload) {
              var oForm = $($oObj).closest('.js_box').find('form:first');
              if (oForm.length) {
                  var parentObjectId = oForm.attr('id');
                  $Core.reloadValidation.preventReload(parentObjectId);
  
                  function closePopupForPreventReload() {
                      $Core.reloadValidation.reset(true, parentObjectId, true);
                      $Core.reloadValidation.preventReload();
                      closeBoxFunc($oObj);
                      bUsingConfirmPopupForPreventingReload = false;
                  }
  
                  if (close_warning_checked === true) {
                      if ($bResetCloseWarning) {
                          closePopupForPreventReload();
                      } else {
                          $Core.jsConfirm({title: null, message: oTranslations['changes_you_made_may_not_be_saved'], is_prevent_reload: true}, closePopupForPreventReload, function() {
                              bUsingConfirmPopupForPreventingReload = false;
                          });
                      }
                  } else {
                      $Core.reloadValidation.preventReload();
                      closeBoxFunc($oObj);
                  }
              } else {
                  closeBoxFunc($oObj);
              }
          } else {
              bUsingConfirmPopupForPreventingReload = false;
          }
      }
  
    return false;
  }
  
  function tb_show_new_image(
    thisObject, sSrc, imageWidth, imageHeight, iCurrentIte) {
    $('.js_box_image_gallery img').removeClass('is_active');
    $(thisObject).find('img').addClass('is_active');
  
    iCurrentImageIterationCount = iCurrentIte;
  
    $('#js_thickbox_core_image').attr({
      'src': sSrc,
      'width': imageWidth,
      'height': imageHeight,
    });
  }
  
  function js_box_next_image() {
    iCurrentImageIterationCount++;
  
    var thisObject = $('#js_next_image_thumb_' + iCurrentImageIterationCount);
  
    if (thisObject.length <= 0) {
      iCurrentImageIterationCount = 0;
  
      return js_box_next_image();
    }
  
    var aParts = explode('|', thisObject.attr('rel'));
  
    tb_show_new_image('#js_next_image_thumb_' + iCurrentImageIterationCount, '' +
      thisObject.attr('href') + '', aParts[0], aParts[1],
      iCurrentImageIterationCount);
  
    return false;
  }
  
  function tb_show(caption, url, thisObject, sForceMessage, bForceNoClick, sType, hidden, holderId) {
    $('.js_box').unbind('click');
    var baseURL;
    if (url.indexOf('?') !== -1) {
      baseURL = url.substr(0, url.indexOf('?'));
    } else {
      baseURL = url;
    }
  
    var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/,
      urlType = baseURL.toLowerCase().match(urlString);
  
    if (urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' ||
      urlType == '.gif' || urlType == '.bmp') {
      imgPreloader = new Image();
      imgPreloader.onload = function () {
        imgPreloader.onload = null;
  
        var pagesize = tb_getPageSize();
        var x = pagesize[0] - 150;
        var y = pagesize[1] - 150;
        var imageWidth = imgPreloader.width;
        var imageHeight = imgPreloader.height;
  
        if (imageWidth > x) {
          imageHeight = imageHeight * (x / imageWidth);
          imageWidth = x;
          if (imageHeight > y) {
            imageWidth = imageWidth * (y / imageHeight);
            imageHeight = y;
          }
        } else if (imageHeight > y) {
          imageWidth = imageWidth * (y / imageHeight);
          imageHeight = y;
          if (imageWidth > x) {
            imageHeight = imageHeight * (x / imageWidth);
            imageWidth = x;
          }
        }
  
        TB_WIDTH = imageWidth + 30;
        TB_HEIGHT = imageHeight + 60;
  
        $('.js_box_image_holder').remove();
        $('.js_box_image_holder').unbind('click');
  
        var $aAllBoxIndex = new Array();
        $('.js_box_holder').each(function () {
          $aAllBoxIndex.push(parseInt($(this).css('z-index')));
        });
  
        var sHtml = '';
        sHtml += '<div class="js_box_image_holder" style="z-index: ' + (parseInt(Math.max.apply(Math, $aAllBoxIndex)) + 1) + ';"><div class="js_box ' +
          (oParams['bJsIsMobile'] ? 'mobile_js_box' : '') +
          ' js_box_image" style="display:block;"><div class="js_box_content">';
  
        if ($(thisObject).parents('.js_box_thumbs_holder').length > 0) {
          var sCurrentSource = $(thisObject).find('img:first').attr('src');
          var sNewSource = '';
          var SubimgPreloaderImageWidth = '';
          var SubimgPreloaderImageHeight = '';
          var SubArrayWidth = new Array();
          var SubArrayHeight = new Array();
          var sSubHtml = '';
          var aUrlParts = new Array();
          var aUrlPartsNew = new Array();
          // p('Current: ' + sCurrentSource);
  
          iImageIterationCount = 0;
          iCurrentImageIterationCount = 0;
  
          sHtml += '<div>';
          $(thisObject).parents('.js_box_thumbs_holder').find('.js_box_image_holder_thumbs').find('.thickbox').each(function () {
            iImageIterationCount++;
            sNewSource = $(this).find('img').attr('src');
  
            aUrlParts = explode('_', sCurrentSource);
            aUrlPartsNew = explode('_', sNewSource);
  
            if (aUrlParts[0] == aUrlPartsNew[0]) {
              iCurrentImageIterationCount = iImageIterationCount;
            }
  
            //	if (sCurrentSource != sNewSource)
            {
              SubimgPreloader = new Image();
  
              SubimgPreloader.src = $(this).attr('href');
  
              SubimgPreloaderImageWidth = SubimgPreloader.width;
              SubimgPreloaderImageHeight = SubimgPreloader.height;
  
              if (SubimgPreloaderImageWidth > x) {
                SubimgPreloaderImageHeight = SubimgPreloaderImageHeight *
                  (x / SubimgPreloaderImageWidth);
                SubimgPreloaderImageWidth = x;
                if (imageHeight > y) {
                  SubimgPreloaderImageWidth = SubimgPreloaderImageWidth *
                    (y / SubimgPreloaderImageHeight);
                  imageHeight = y;
                }
              } else if (imageHeight > y) {
                SubimgPreloaderImageWidth = SubimgPreloaderImageWidth *
                  (y / SubimgPreloaderImageHeight);
                SubimgPreloaderImageHeight = y;
                if (SubimgPreloaderImageWidth > x) {
                  SubimgPreloaderImageHeight = SubimgPreloaderImageHeight *
                    (x / SubimgPreloaderImageWidth);
                  SubimgPreloaderImageWidth = x;
                }
              }
  
              SubArrayWidth.push(SubimgPreloaderImageWidth);
              SubArrayHeight.push(SubimgPreloaderImageHeight);
  
              sSubHtml += '<a rel="' + SubimgPreloaderImageWidth + '|' +
                SubimgPreloaderImageHeight + '" id="js_next_image_thumb_' +
                iImageIterationCount + '" href="' + $(this).attr('href') +
                '" onclick="tb_show_new_image(this, \'' +
                $(this).attr('href') + '\', ' + SubimgPreloaderImageWidth +
                ', ' + SubimgPreloaderImageHeight + ', ' +
                iImageIterationCount + '); return false;"><img src="' +
                sNewSource + '" alt="" ' + (aUrlParts[0] == aUrlPartsNew[0]
                  ? ' class="is_active" '
                  : '') + ' /></a>';
            }
          });
  
          TB_WIDTH = ((Math.max.apply(Math, SubArrayWidth)) + 30);
          TB_HEIGHT = ((Math.max.apply(Math, SubArrayHeight)));
  
          sHtml += '<div class="js_box_image_holder_browse">';
          sHtml += '<div class="js_box_image_gallery_display" style="height:' +
            TB_HEIGHT + 'px; line-height:' + TB_HEIGHT + 'px;">';
          sHtml += '<a href="#" onclick="return js_box_next_image();"><img src="' +
            url + '" width="' + imageWidth + '" height="' + imageHeight +
            '" alt="" id="js_thickbox_core_image" /></a>';
          sHtml += '</div>';
          sHtml += '<div class="js_box_image_gallery">' + sSubHtml + '</div>';
          sHtml += '</div>';
  
          sHtml += '</div>';
        } else {
          sHtml += '<a href="#" onclick="js_box_remove($(this).closest(\'.js_box_content\')); return false;"><img src="' +
            url + '" width="' + imageWidth + '" height="' + imageHeight +
            '" alt="" id="js_thickbox_core_image" style="min-width: ' +
            imageWidth + 'px;min-height:' + imageHeight + 'px;"/></a>';
        }
  
        sHtml += '</div></div></div>';
        if (typeof $Core.disableScroll !== 'undefined' && (typeof hidden === 'undefined' || !hidden)) {
          $Core.disableScroll();
        }
        $('body').prepend(sHtml);
  
        $('.js_box_image').css(
          {
            top: (($(window).height() - $('.js_box_image').outerHeight()) / 2) +
              'px',
            left: (($(window).width() - $('.js_box_image').outerWidth()) / 2) +
              'px',
            display: 'block',
          });
  
        var bCanCloseImageBox = true;
  
        $('.js_box').click(function () {
          bCanCloseImageBox = false;
        });
  
        $('.js_box_image_holder').click(function () {
          if (!bCanCloseImageBox) {
            bCanCloseImageBox = true;
          } else {
            js_box_remove($(this).find('.js_box_content'));
          }
        });
  
        if ($.browser.msie && $.browser.version == '7.0') {
          $Behavior.ie7FixZindex();
        }
      };
      imgPreloader.src = url;
  
      return false;
    }
  
    var bIsAlreadyOpen = false;
    if ($(thisObject).hasClass('photo_holder_image') &&
      !empty($(thisObject).attr('rel'))) {
      return;
    } else {
      if ($Core.exists('.js_box_image_holder_full')) {
        js_box_remove(
          $('.js_box_image_holder_full').find('.js_box_content:first'));
      }
  
      if (url.indexOf('#') != -1) {
        var aParams = url.split('#');
        url = '#' + aParams[1];
      }
  
      var queryString = url.replace(/^[^\?]+\??/, '');
      var params = tb_parseQuery(queryString);
  
    }
    if (!bIsPhotoImage && isset(
      $aBoxHistory[params['' + getParam('sGlobalTokenName') + '[call]']])) {
      return false;
    }
  
    if (!bIsAlreadyOpen) {
      $iBoxTotalOpen++;
      $iCurrentZIndex++;
      if (typeof params[getParam('sGlobalTokenName') + '[call]'] != 'undefined' && (typeof hidden === 'undefined' || !hidden)) {
        $aBoxHistory[params[getParam('sGlobalTokenName') + '[call]']] = true;
      }
  
      $sCurrentId = 'js_box_id_' + $iBoxTotalOpen;
    }
  
    if (caption === null) {
      caption = '';
    }
  
    var bIsFullMode = false,
      _w = $(window).width(),
      _h = $(window).height();
  
    if (params['width'] == 'full') {
      params['width'] = _w;
      params['height'] = _h;
      bIsFullMode = true;
    } else if (params['width'] == 'scan') {
      params['width'] = (_w - (oCore['core.is_admincp'] ? 100 : 150));
      params['height'] = (_h - (oCore['core.is_admincp'] ? 100 : 150));
    }
  
    if (_w < 600) {
      params['width'] = _w - 20;
    }
  
    TB_WIDTH = (!empty(params['width']) ? ((params['width'] * 1) + 30) : 630);
    TB_HEIGHT = (params['height'] * 1) + 40 || 440;
  
    var pagesize = tb_getPageSize();
    if (TB_HEIGHT > pagesize[1]) {
      TB_HEIGHT = (pagesize[1] - 75);
    }
  
    if (TB_WIDTH > pagesize[0]) {
      TB_WIDTH = (pagesize[0] - 75);
    }
  
    var ajaxContentW = TB_WIDTH - 30,
      ajaxContentH = TB_HEIGHT - 45;
  
    if (_w < 600) {
      TB_WIDTH = _w - 20;
      ajaxContentW = TB_WIDTH - 10;
    }
  
    if (!bIsAlreadyOpen) {
      var sHtml = '';
  
      if (bIsPhotoImage) {
        $('.js_box_image_holder').remove();
        $('.js_box_image_holder').unbind('click');
        sHtml += '<div class="js_box_image_holder_full">';
        sHtml += '<div class="js_box_image_holder_full_loader" style="position:absolute; top:50%; left:50%;"><img src="' +
          oJsImages['loading_animation'] + '" alt="" /></div>';
        sHtml += '<div style="display:none;" id="' + $sCurrentId +
          '" class="js_box' +
          (oParams['bJsIsMobile'] ? ' mobile_js_box' : ' ') +
          (isset(params['no_remove_box']) ? ' js_box_no_remove' : '') +
          '" style="width:' + ajaxContentW + 'px;">';
        sHtml += '<div class="js_box_content"></div>';
        sHtml += '<div class="js_box_close"><a href="#" onclick="return js_box_remove(this);">' +
          oTranslations['close'] + '</a><span class="js_box_history">' +
          params[getParam('sGlobalTokenName') + '[call]'] + '</span></div>';
        sHtml += '</div>';
        sHtml += '</div>';
      } else {
        sHtml += '<div class="js_box_holder' + ((typeof hidden !== 'undefined' && hidden) ? ' hidden' : '') + '" ';
        if (typeof holderId !== 'undefined' && holderId) {
          sHtml += 'id="' + holderId + '" ';
        }
        sHtml += '>';
  
        if (bForceNoClick) {
          sHtml += '<div class="js_box_image_holder">';
        }
  
        var extraClass = ($(thisObject).attr('rel')) ? ' ' +
          $(thisObject).attr('rel') : ' ';
        sHtml += '<div id="' + $sCurrentId + '" class="js_box ' + extraClass +
          (oParams['bJsIsMobile'] ? ' mobile_js_box' : ' ') +
          (params['fullmode'] ? ' js_box_fullmode' : ' ') +
          (isset(params['no_remove_box']) ? ' js_box_no_remove' : '') +
          '" style="width:' + ajaxContentW + 'px;">';
  
        if (!bIsPhotoImage) {
          sHtml += '<div class="js_box_title"><div class="js_box_title_content">' + caption + '</div>';
          sHtml += '</div>';
        }
  
        if (typeof hidden !== 'undefined' && hidden) {
          sHtml += '<div class="js_box_close"><a role="button"><i class="fa fa-close"></i></a><span class="js_box_history"></span></div>';
        } else {
          sHtml += '<div class="js_box_close"><a href="#" onclick="return js_box_remove(this);"><i class="fa fa-close"></i></a><span class="js_box_history">' +
            params[getParam('sGlobalTokenName') + '[call]'] + '</span></div>';
        }
        sHtml += '<div class="js_box_content"><span class="js_box_loader"><i class="fa fa-spin fa-spinner"></i></span></div>';
        sHtml += '</div>';
  
        if (bForceNoClick) {
          sHtml += '</div>';
        }
  
        if (bIsPhotoImage) {
          sHtml += '</div>';
        } else {
          sHtml += '</div>';
        }
      }
  
      if (typeof $Core.disableScroll !== 'undefined' && (typeof hidden === 'undefined' || !hidden)) {
        $Core.disableScroll();
      }
      $('body').prepend(sHtml);
  
      var $oNew = $('#' + $sCurrentId + '');
  
      tb_position($oNew, (bIsFullMode ? bIsFullMode : ''));
  
      if (!bIsPhotoImage) {
        $oNew.show();
      } else {
        $('.js_box_image_holder_full_loader').css({
          'margin-left': '-' +
            ($('.js_box_image_holder_full_loader').find('img:first').width() / 2) +
            'px',
          'margin-top': '-' +
            ($('.js_box_image_holder_full_loader').find('img:first').height() / 2) +
            'px',
        });
      }
    } else {
      $oNew = $('.js_box_image_holder_full').find('.js_box:first');
    }
  
    if (getParam('bJsIsMobile')) {
      queryString += '&js_mobile_version=true';
    }
    if (url.indexOf('TB_inline') != -1) {
  
      if (params['type']) {
        switch (params['type']) {
          case 'delete':
            var sHtml = '';
            var sMainUrl = url + '&do_delete=true';
            sHtml += '<div id="js_inline_delete">';
            if (!params['call']) {
              sHtml += '<form method="post" action="' + sMainUrl + '">';
              sHtml += '<div><input type="hidden" name="' +
                getParam('sGlobalTokenName') + '[security_token]" value="' +
                getParam('sSecurityToken') + '" />';
            }
            sHtml += '<div>';
            sHtml += getPhrase('are_you_sure');
            sHtml += '<div class="t_center p_4">';
            sHtml += ' <input type="hidden" name="item_id" value="' +
              params['itemId'] + '" id="js_inline_delete_id" /> ';
  
            if ($Core.exists('.admincp-fixed-menu')) {
              sHtml += '<div class="js_box_buttonpane">';
            }
  
            if (!params['call']) {
              sHtml += ' <input class="btn btn-primary" type="submit" value="' +
                getPhrase('yes') + '" class="btn" /> ';
            } else {
              sHtml += ' <input class="btn btn-primary" type="button" value="' +
                getPhrase('yes') +
                '" onclick="$(\'#js_inline_delete_id\').ajaxCall(\'' +
                params['call'] + '\', \'' + queryString +
                '\'); tb_remove();" /> ';
            }
            sHtml += ' <input class="btn btn-default" type="button" value="' +
              getPhrase('no') + '" class="btn" onclick="tb_remove();" /> ';
  
            if ($Core.exists('.admincp-fixed-menu')) {
              sHtml += '</div>';
            }
  
            sHtml += '</div>';
            sHtml += '</div>';
            if (!params['call']) {
              sHtml += '</form>';
            }
            sHtml += '</div>';
  
            break;
        }
  
        $oNew.find('.js_box_content').html('');
        $oNew.find('.js_box_content').html(sHtml);
      } else {
        var sHtml = $('#' + params['inlineId']).children();
      }
  
      $oNew.find('.js_box_content').html('');
      $oNew.find('.js_box_content').html(sHtml);
  
      return;
    } else if (isset(params['TB_iframe'])) {
      var sIframe = '';
      $oNew.find('.js_box_content').html('');
      $oNew.find('.js_box_content').html(sIframe);
    } else {
      if (!empty(sForceMessage)) {
        $oNew.find('.js_box_content').html('');
        $oNew.find('.js_box_content').html(sForceMessage);
        return;
      }
  
      var sAjaxType = 'GET';
      if ((params['' + getParam('sGlobalTokenName') + '[call]'] ==
        'share.popup') || sType == 'POST') {
        sAjaxType = 'POST';
      }
  
      if (thisObject instanceof jQuery && thisObject.hasClass('popup')) {
        if (thisObject.data('custom-class')) {
          $oNew.addClass(thisObject.data('custom-class'));
          $oNew.attr('style', '');
        }
  
        $.ajax({
          url: thisObject.attr('href'),
          contentType: 'application/json',
          headers: {popup: 'on'},
          success: function (e) {
            if (typeof (e.goto) == 'string') {
              window.location.href = e.goto;
              return;
            }
  
            if (typeof (e.error) == 'string' && typeof (e.content) != 'string') {
              $oNew.find('.js_box_content').html('<div class="error_message">' + e.error + '</div>');
              return;
            }
  
            if (typeof (e.iNumberRequest) != 'undefined' &&
              typeof (e.iNumberNotification) != 'undefined' &&
              typeof (e.iNumberMessage) != 'undefined') {
              $Core.refresh_counter(e.iNumberRequest, e.iNumberNotification,
                e.iNumberMessage);
            }
  
            $oNew.find('.js_box_title:first').html(((e.h1_clean && e.h1_clean.length)
              ? e.h1_clean
              : e.actual_title));
            $oNew.find('.js_box_content').html('');
            $oNew.find('.js_box_content').html(e.content);
            $oNew.find('.js_box_title:first').show();
            $oNew.find('.js_box_close:first').show();
            if (typeof e.files !== 'undefined') {
              $Core.loadStaticFiles(e.files);
            }
            $Core.loadInit();
            $Core.reloadValidation.initClosePopupWithForm($oNew);
          },
        });
  
        return;
      }
  
      $.ajax(
        {
          type: sAjaxType,
          dataType: 'html',
          url: getParam('sJsAjax'),
          data: queryString,
          success: function (sMsg) {
            $oNew.find('.js_box_content').html('');
            $oNew.find('.js_box_content').html(sMsg);
            if (!empty($oNew.find('.js_box_title_store:first').html())) {
              $oNew.find('.js_box_title:first').html($oNew.find('.js_box_title_store:first').html());
            }
            $oNew.find('.js_box_title:first').show();
            $oNew.find('.js_box_close:first').show();
  
            if (bIsFullMode) {
              $oNew.find('.js_box_content').height(ajaxContentH);
            }
            $Core.loadInit();
            $Core.reloadValidation.initClosePopupWithForm($oNew);
          },
        });
    }
  }
  
  $Behavior.thickboxBrowser = function () {
    $(document).off('keyup.thickboxBrowser').on('keyup.thickboxBrowser', function (e) {
      if (e.keyCode === 27) {
        var boxHolders = ['.js_box_image_holder_full', '.js_box_holder'];
        for (var i in boxHolders) {
          if ($Core.exists(boxHolders[i])) {
            const eleTarget = $(boxHolders[i]).first();
            if (eleTarget.data('callback')) {
              eval(eleTarget.data('callback'));
            }
            if (eleTarget.hasClass('no_delete')) {
              eleTarget.addClass('hidden');
            } else {
              js_box_remove(eleTarget.find('.js_box_content'));
            }
          }
        }
      }
    });
  };
  
  function tb_get_active() {
    var $aAllBoxIndex = new Array();
    var $aAllBoxIndexHolder = new Array();
    $('.js_box').each(function () {
      $aAllBoxIndex[parseInt($(this).css('z-index'))] = $(this).attr('id');
      $aAllBoxIndexHolder.push(parseInt($(this).css('z-index')));
    });
  
    var $iFocusBox = parseInt(Math.max.apply(Math, $aAllBoxIndexHolder));
  
    if (isset($aAllBoxIndex[$iFocusBox]) &&
      $('#' + $aAllBoxIndex[$iFocusBox]).length > 0) {
      return $aAllBoxIndex[$iFocusBox];
    }
  
    return null;
  }
  
  function tb_remove() {
    $('#main_core_body_holder').show();
  
    var $aAllBoxIndex = new Array();
    var $aAllBoxIndexHolder = new Array();
    $('.js_box').each(function () {
      $aAllBoxIndex[parseInt($(this).css('z-index'))] = $(this).attr('id');
      $aAllBoxIndexHolder.push(parseInt($(this).css('z-index')));
    });
  
    var $iFocusBox = parseInt(Math.max.apply(Math, $aAllBoxIndexHolder));
  
    if (isset($aAllBoxIndex[$iFocusBox]) &&
      $('#' + $aAllBoxIndex[$iFocusBox]).length > 0) {
      var $sLink = $('#' + $aAllBoxIndex[$iFocusBox]).find('.js_box_history:first').html();
      var holder = $('#' + $aAllBoxIndex[$iFocusBox]).closest('.js_box_holder');
      $('#' + $aAllBoxIndex[$iFocusBox]).fadeOut('100', function () {
        $(this).remove();
      });
      $('#' + $aAllBoxIndex[$iFocusBox]).parent('.js_box_image_holder').fadeOut('100', function () {
        $(this).remove();
      });
  
      delete $aBoxHistory[$sLink];
  
      holder.fadeOut(100, function () {
        $(this).remove();
        if (typeof $Core.enableScroll !== 'undefined') {
          $Core.enableScroll();
        }
      });
  
    }
  
    $('#global_attachment_list_inline').hide();
  
    return false;
  }
  
  function tb_draggable($oObj) {
    if ($($oObj).parent().hasClass('js_box_image_holder_full')) {
      return false;
    }
  
    $($oObj).draggable(
      {
        handle: '.js_box_title',
        opacity: 0.35,
        zIndex: 3000,
        start: function (event, ui) {
          if ($('#global_attachment_list_inline').length > 0) {
            $('#global_attachment_list_inline').hide();
          }
        },
        stop: function (event, ui) {
          if ($('#global_attachment_list_inline').length > 0) {
            $Core.updateInlineBox();
            $('#global_attachment_list_inline').show();
          }
        },
      });
  }
  
  function tb_position($oObj, bFull) {
    if (bFull !== true) {
      if (!$.ui) {
        $Core.loadStaticFile(getParam('sJsHome') + 'static/jscript/jquery/ui.js');
      }
  
      tb_draggable('.js_box');
    }
  
    var $aAllBoxIndex = new Array();
    $('.js_box').each(function () {
      $aAllBoxIndex.push(parseInt($(this).css('z-index')));
    });
  
    if (bFull === true) {
      $($oObj).css(
        {
          top: '20%',
          left: '50%',
          'margin-left': '-' + (($($oObj).width() / 2) + 12) + 'px',
          'z-index': (parseInt(Math.max.apply(Math, $aAllBoxIndex)) + 1),
          'max-height': $(window).height() - $(window).height() * 0.2 - 10,
          // 'overflow': 'auto'
        });
    } else {
      $($oObj).css(
        {
          top: '20%',
          left: '50%',
          'margin-left': '-' + (($($oObj).width() / 2) + 0) + 'px',
          'z-index': (parseInt(Math.max.apply(Math, $aAllBoxIndex)) + 1),
          'max-height': $(window).height() - $(window).height() * 0.2 - 10,
          // 'overflow': 'auto'
        });
    }
  
    $($oObj).parent().css({'z-index': (parseInt(Math.max.apply(Math, $aAllBoxIndex)) + 1)});
  
    if ($.browser.msie && $.browser.version == '7.0') {
      $Behavior.ie7FixZindex();
    }
  }
  
  function tb_parseQuery(query) {
    var Params = {};
    if (!query) {
      return Params;
    }
  
    var Pairs = query.split(/[;&]/);
    for (var i = 0; i < Pairs.length; i++) {
      var KeyVal = Pairs[i].split('=');
      if (!KeyVal || KeyVal.length != 2) {
        continue;
      }
      var key = unescape(KeyVal[0]);
      var val = unescape(KeyVal[1]);
      val = val.replace(/\+/g, ' ');
  
      Params[key] = val;
    }
  
    return Params;
  }
  
  function tb_getPageSize() {
    var de = document.documentElement;
    var w = window.innerWidth || self.innerWidth || (de && de.clientWidth) ||
      document.body.clientWidth;
    var h = window.innerHeight || self.innerHeight || (de && de.clientHeight) ||
      document.body.clientHeight;
    arrayPageSize = [w, h];
  
    return arrayPageSize;
  }
  