var YUKU = YUKU || {};

YUKU.posticons =
{
   users : function (users)
   {
      var none = YUKU.get_by_id('none');
      if (!none) return;

      var name = this.get_name();
      if (!YUKU.in_array(users, name))
         YUKU.remove_el(none.parentNode.parentNode);

      none.parentNode.parentNode.style.display = 'block';
   },

   sa : function ()
   {
      var none = YUKU.get_by_id('none');
      if (!none) return;

      if (!this._issa)
         YUKU.remove_el(none.parentNode.parentNode);

      none.parentNode.parentNode.style.display = 'block';
   },

   _issa : function ()
   {
      if (window.gs.sa && window.gs.sa == 1)
         return true;
      else if (window.gs.sa && window.gs.sa == 0)
         return false;

      var el = YUKU.get_by_id('mgr-navigation-content');
      var kids = YUKU.get_by_tag('DIV', el);
      for (var i = 0; kid = kids[i]; i++)
      {
         if (kid.nodeName == 'DIV' && kid.className.indexOf('super-admin') != -1)
         {
            window.gs.sa = 1;
            return true;
         }
      }

      window.gs.sa = 0;

      return window.gs.sa;
   },

   get_name : function ()
   {
      if (window.gs.username)
         return window.gs.username;

      var p = YUKU.get_by_tag('P')[0];
      if (!YUKU.class_name.test(p, 'welcome-message'))
         return '';

      var a = YUKU.get_by_tag('A', p)[0];
      window.gs.username = a.innerHTML;

      return window.gs.username;
   }
}