manages = {
  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);
  },
  tFolderAdd: function(_strfname)
  {
    var tstrfname = _strfname;
    var tformObj = $I(tstrfname);
    if (tformObj)
    {
      var tformBeObj = $I(tstrfname + 'BeforeAction');
      if (tformBeObj) eval(tformBeObj.value);
      var tAction = tformObj.action + '&path=' + cls.tgetParameter(manages.ttempArg, 'path');
      var tstrform = cls.form.tgetValues(tformObj);
      manage.windows.tShowPanelLoading();
      $I('popup-ajaxSubmit1').disabled = true;
      cls.tiposts(tAction, tstrform, manages.tFolderAdds);
    };
    return false;
  },
  tFolderAdds: function(_strers)
  {
    var tstrers = _strers;
    manage.windows.tHidePanelLoading();
    $I('popup-ajaxSubmit1').disabled = false;
    if (manage.tckBackString(tstrers))
    {
      if (tstrers.indexOf('<!--200-->') != -1)
      {
        manages.tRefresh();
        manages.popup.tClose();
      }
      else manage.message.tAlert(tstrers, 'manages.popup.tClose();');
    };
  },
  tFolderEdit: function(_strfname)
  {
    var tstrfname = _strfname;
    var tformObj = $I(tstrfname);
    if (tformObj)
    {
      var tformBeObj = $I(tstrfname + 'BeforeAction');
      if (tformBeObj) eval(tformBeObj.value);
      var tAction = tformObj.action;
      var tstrform = cls.form.tgetValues(tformObj);
      manage.windows.tShowPanelLoading();
      $I('popup-ajaxSubmit2').disabled = true;
      cls.tiposts(tAction, tstrform, manages.tFolderEdits);
    };
    return false;
  },
  tFolderEdits: function(_strers)
  {
    var tstrers = _strers;
    manage.windows.tHidePanelLoading();
    $I('popup-ajaxSubmit2').disabled = false;
    if (manage.tckBackString(tstrers))
    {
      if (tstrers.indexOf('<!--200-->') != -1)
      {
        manages.tRefresh();
        manages.popup.tClose();
      }
      else manage.message.tAlert(tstrers, 'manages.popup.tClose();');
    };
  },
  tFolderDelete: function(_strurl)
  {
    var tstrurl = _strurl;
    tstrurl = manages.tinterfaceURL + tstrurl;
    manage.windows.tShowPanelLoading();
    cls.tigets(tstrurl, manages.tFolderDeletes);
  },
  tFolderDeletes: function(_strers)
  {
    var tstrers = _strers;
    manage.windows.tHidePanelLoading();
    if (tstrers == '200') manages.tLoad(manages.ttempArg);
    else
    {
      if (manage.tckBackString(tstrers)) manage.message.tAlert(tstrers, 'manages.popup.tClose();');
    };
  },
  tFileAdd: function(_strfname)
  {
    var tstrfname = _strfname;
    var tformObj = $I(tstrfname);
    if (tformObj)
    {
      var tformBeObj = $I(tstrfname + 'BeforeAction');
      if (tformBeObj) eval(tformBeObj.value);
      var tAction = tformObj.action + '&path=' + cls.tgetParameter(manages.ttempArg, 'path');
      var tstrform = cls.form.tgetValues(tformObj);
      manage.windows.tShowPanelLoading();
      $I('popup-ajaxSubmit3').disabled = true;
      cls.tiposts(tAction, tstrform, manages.tFileAdds);
    };
    return false;
  },
  tFileAdds: function(_strers)
  {
    var tstrers = _strers;
    manage.windows.tHidePanelLoading();
    $I('popup-ajaxSubmit3').disabled = false;
    if (manage.tckBackString(tstrers))
    {
      if (tstrers.indexOf('<!--200-->') != -1)
      {
        manages.tRefresh();
        manages.popup.tClose();
      }
      else manage.message.tAlert(tstrers, 'manages.popup.tClose();');
    };
  },
  tFileEdit: function(_strfname)
  {
    var tstrfname = _strfname;
    var tformObj = $I(tstrfname);
    if (tformObj)
    {
      var tformBeObj = $I(tstrfname + 'BeforeAction');
      if (tformBeObj) eval(tformBeObj.value);
      var tAction = tformObj.action;
      var tstrform = cls.form.tgetValues(tformObj);
      manage.windows.tShowPanelLoading();
      $I('popup-ajaxSubmit4').disabled = true;
      cls.tiposts(tAction, tstrform, manages.tFileEdits);
    };
    return false;
  },
  tFileEdits: function(_strers)
  {
    var tstrers = _strers;
    manage.windows.tHidePanelLoading();
    $I('popup-ajaxSubmit4').disabled = false;
    if (manage.tckBackString(tstrers))
    {
      if (tstrers.indexOf('<!--200-->') != -1)
      {
        manages.tRefresh();
        manages.popup.tClose();
      }
      else manage.message.tAlert(tstrers, 'manages.popup.tClose();');
    };
  },
  tFileDelete: function(_strurl)
  {
    var tstrurl = _strurl;
    tstrurl = manages.tinterfaceURL + tstrurl;
    manage.windows.tShowPanelLoading();
    cls.tigets(tstrurl, manages.tFileDeletes);
  },
  tFileDeletes: function(_strers)
  {
    var tstrers = _strers;
    manage.windows.tHidePanelLoading();
    if (tstrers == '200') manages.tLoad(manages.ttempArg);
    else
    {
      if (manage.tckBackString(tstrers)) manage.message.tAlert(tstrers, 'manages.popup.tClose();');
    };
  },
  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 tDoneIndexOf = tserverData.indexOf('<!--200-->');
      if (tDoneIndexOf != -1) manages.tRefresh();
      else manage.message.tAlert(tserverData);
    };
  },
  tRefresh: function()
  {
    manages.tLoad(manages.ttempArg);
  }
};

manages.popup = {
  tLoad: function(_strArg)
  {
    var tstrArg = _strArg;
    var tstrURL = manages.tinterfaceURL;
    if (tstrArg) tstrURL += tstrArg;
    manage.windows.tShowPanelLoading();
    cls.tigets(tstrURL, manages.popup.tLoads);
  },
  tLoads: function(_strers)
  {
    var tstrers = _strers;
    manage.windows.tHidePanelLoading();
    if (manage.tckBackString(tstrers))
    {
      cls.mask.tShow(tstrers);
      cls.mask.tSetStyle();
    };
  },
  tClose: function()
  {
    cls.mask.tClose();
  }
};
