manages = {
  ttempArg: null,
  tinterfaceURL: 'manage-interface.aspx',
  tinterfaceContentID: 'rightContent',
  tSaveOrderInitIdAry: '',
  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))
    {
      if (tstrers.indexOf('<!--alert-->') != -1) manage.message.tAlert(tstrers);
      else
      {
        setInnerHTML($I(manages.tinterfaceContentID), tstrers);
        var tstrHighlightObj = $I(cls.tgetParameter(manages.ttempArg, 'highlight'));
        if (tstrHighlightObj)
        {
          tstrHighlightObj.className = 'spanHrefSelected';
          tstrHighlightObj.setAttribute('primaryClass', 'spanHrefSelected');
        };
      };
    };
  },
  tAdd: function(_strfname)
  {
    var tstrfname = _strfname;
    var tformObj = $I(tstrfname);
    if (tformObj)
    {
      var tformBeObj = $I(tstrfname + 'BeforeAction');
      if (tformBeObj) eval(tformBeObj.value);
      if (manage.validator.tCheck(tformObj))
      {
        var tAction = tformObj.action;
        var tstrform = cls.form.tgetValues(tformObj);
        $I('ajaxSubmit').disabled = true;
        manage.windows.tShowPanelLoading();
        cls.tiposts(tAction, tstrform, manages.tAdds);
      };
    };
    return false;
  },
  tAdds: function(_strers)
  {
    var tstrers = _strers;
    $I('ajaxSubmit').disabled = false;
    manage.windows.tHidePanelLoading();
    if (manage.tckBackString(tstrers))
    {
      manage.message.tAlert(tstrers);
      if (tstrers.indexOf('<!--200-->') != -1) manages.tRefresh();
    };
  },
  tEdit: function(_strfname)
  {
    var tstrfname = _strfname;
    var tformObj = $I(tstrfname);
    if (tformObj)
    {
      var tformBeObj = $I(tstrfname + 'BeforeAction');
      if (tformBeObj) eval(tformBeObj.value);
      if (manage.validator.tCheck(tformObj))
      {
        var tAction = tformObj.action;
        var tstrform = cls.form.tgetValues(tformObj);
        $I('ajaxSubmit').disabled = true;
        manage.windows.tShowPanelLoading();
        cls.tiposts(tAction, tstrform, manages.tEdits);
      };
    };
    return false;
  },
  tEdits: function(_strers)
  {
    var tstrers = _strers;
    $I('ajaxSubmit').disabled = false;
    manage.windows.tHidePanelLoading();
    if (manage.tckBackString(tstrers))
    {
      manage.message.tAlert(tstrers);
      if (tstrers.indexOf('<!--200-->') != -1) manages.tRefresh();
    };
  },
  tDelete: function(_strid)
  {
    var tstrid = _strid;
    manage.windows.tShowPanelLoading();
    cls.tigets(manages.tinterfaceURL + '?type=action&atype=delete&id=' + tstrid, manages.tDeletes);
  },
  tDeletes: function(_strers)
  {
    var tstrers = _strers;
    manage.windows.tHidePanelLoading();
    if (tstrers == '200') manages.tLoad(manages.ttempArg);
  },
  tSaveOrder: function(_stridary)
  {
    var tstridary = _stridary;
    if (manages.tSaveOrderInitIdAry != tstridary)
    {
      manages.tSaveOrderInitIdAry = tstridary;
      cls.tigets(manages.tinterfaceURL + '?type=action&atype=order&idary=' + tstridary, nll);
    };
  },
  tSaveOrderInit: function(_stridary)
  {
    var tstridary = _stridary;
    manages.tSaveOrderInitIdAry = tstridary;
  },
  tRefresh: function()
  {
    manages.tLoad(manages.ttempArg);
  }
};

manages.cls = {
  tSelGenre: function(_strers, _bool)
  {
    var tbool = _bool;
    var tstrers = _strers;
    var tobj = $I('popedom-child-' + tstrers);
    if (tobj)
    {
      if (tbool) tobj.className = '';
      else tobj.className = 'hidden';
    };
  },
  tSelGenreInit: function()
  {
    var tobjs = document.getElementsByName('popedom');
    if (tobjs)
    {
      for (ti = 0; ti < tobjs.length; ti ++) manages.cls.tSelGenre(tobjs[ti].value, tobjs[ti].checked);
    };
  },
  tSelCategory: function(_strers)
  {
    var tstrers = _strers;
    var tvalue = '';
    var tobj = $I(tstrers + '-category');
    if (tobj) tvalue = tobj.value;
    manages.popup.tLoad('?type=category&genre=' + tstrers + '&value=' + escape(tvalue));
  },
  tSelCategoryInit: function(_strers)
  {
    var tstrers = _strers;
    if (tstrers)
    {
      var tobjs = document.getElementsByName('category');
      if (tobjs)
      {
        for (ti = 0; ti < tobjs.length; ti ++)
        {
          if (cinstr(tstrers, tobjs[ti].value, ',')) tobjs[ti].checked = true;
        };
      };
    };
  },
  tSetCategory: function(_strers)
  {
    var tstrers = _strers;
    var tvalues = cls.tgetCheckboxsValue('category');
    var tobj = $I(tstrers + '-category');
    if (tobj) tobj.value = tvalues;
    manages.popup.tClose();
  }
};

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();
  }
};
