manages = {
  tSwfObj: null,
  tSwfUploading: false,
  ttempArg: null,
  tinterfaceURL: 'manage-interface.aspx',
  tinterfaceContentID: 'rightContent',
  tInit: function(_strArg)
  {
    var tstrArg = _strArg;
    manages.tLoad(tstrArg);
  },
  tLoad: function(_strArg)
  {
    var tstrArg = _strArg;
    manages.ttempArg = tstrArg;
    var tstrURL = manages.tinterfaceURL;
    if (tstrArg) tstrURL += tstrArg;
    manage.windows.tShowPanelLoading();
    cls.tigets(tstrURL, manages.tLoads);
  },
  tLoads: function(_strers)
  {
    var tstrers = _strers;
    manage.windows.tHidePanelLoading();
    if (manage.tckBackString(tstrers)) setInnerHTML($I(manages.tinterfaceContentID), tstrers);
  },
  tSWFUploadInit: function(_argVars)
  {
    var targVars = _argVars;
    var tSwfSettings = {
      debug: false,
      upload_url: targVars.upload_url,
      post_params: targVars.post_params,
      flash_url: targVars.flash_url,
      file_post_name: 'file1',
      file_size_limit: targVars.file_size_limit,
      file_types: targVars.file_types,
      file_upload_limit: 100,
      file_queue_limit: 0,

      button_cursor: SWFUpload.CURSOR.HAND,
      button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
      button_image_url: targVars.button_image_url,
      button_width: targVars.button_width,
      button_height: targVars.button_height,
      button_placeholder_id: targVars.button_placeholder_id,

      file_queued_handler: manages.tSWFUploadQueued,
      upload_progress_handler: manages.tSWFUploadProgress,
      upload_success_handler: manages.tSWFUploadSuccess
    };
    manages.tSwfObj = new SWFUpload(tSwfSettings);
  },
  tSWFUploadQueued: function()
  {
    var tStats = manages.tSwfObj.getStats();
    if (!manages.tSwfUploading)
    {
      if (tStats.files_queued > 0)
      {
        manages.tSwfObj.startUpload();
        manages.tSwfUploading = true;
        var tHolderObj = $I('tr-holder');
        var tLoadingObj = $I('tr-loading');
        var tLoadingBarObj = $I('loadingBar');
        if (tHolderObj && tLoadingObj && tLoadingBarObj)
        {
          tHolderObj.className = 'hidden';
          tLoadingObj.className = '';
          tLoadingBarObj.style.display = 'block';
        };
      }
      else manages.tSwfUploading = false;
    };
  },
  tSWFUploadProgress: function(_file, _bytesLoaded, _bytesTotal)
  {
    var tfile = _file;
    var tbytesLoaded = _bytesLoaded;
    var tbytesTotal = _bytesTotal;
    var tnpercent = Math.round(tbytesLoaded / tbytesTotal * 100) ;
    var tBarContentObj = $I('loadingBarContent');
    if (tBarContentObj) tBarContentObj.style.width = tnpercent + '%';
  },
  tSWFUploadSuccess: function(_file, _serverData)
  {
    var tfile = _file;
    var tserverData = _serverData;
    manages.tSwfUploading = false;
    var tHolderObj = $I('tr-holder');
    var tLoadingObj = $I('tr-loading');
    if (tHolderObj && tLoadingObj)
    {
      tHolderObj.className = '';
      tLoadingObj.className = 'hidden';
    };
    if (manage.tckBackString(tserverData))
    {
      var tURLIndexOf = tserverData.indexOf('<!--url-->');
      if (tURLIndexOf == -1) manage.message.tAlert(tserverData);
      else
      {
        var tNewManageURL = tserverData.substr(tURLIndexOf + 10);
        manage.message.tConfirm(tserverData.substr(0, tURLIndexOf), 'manage.tHref(\'' + tNewManageURL + '\', event);');
      };
    }
  },
  tRefresh: function()
  {
    manages.tLoad(manages.ttempArg);
  }
};
