if (!YUKU) window.YUKU = {};

YUKU.fontSize = {
   pc_base : 14.814814,
   min : 8,
   max : 28,
   current : 0,
   first : 0,
   original : 0,
   remember : false,

   toggle : function (s)
   {
      if ((this.current <= this.min && s == -1) || (this.current >= this.max && s == 1))
         return;

      this.current = this.current + s;
      document.body.style.fontSize = this.current + 'px';

      if (this.remember)
         YUKU.set_cookie('fontsize', this.current);
   },

   init : function (remember)
   {
      var base = (YUKU.current_style(document.body, isIE ? 'fontSize' : 'font-size'));
      this.original = base;

      if (base.indexOf('%') != -1)
         this.current = (parseFloat(base.replace('%', '')) / 100) * this.pc_base;
      else if (base.indexOf('px') != -1)
         this.current = parseFloat(base.replace('px', ''));
      else
         this.current = parseFloat(base);

      this.first = this.current;
      this.remember = remember;

      document.body.style.fontSize = this.current + 'px';
   },

   load : function ()
   {
      var size = YUKU.get_cookie('fontsize', false);
      if (size)
         document.body.style.fontSize = size + 'px';
   },

   reset : function ()
   {
      if (this.remember)
         YUKU.set_cookie('fontsize', 0, -28); // kill cookie

      document.body.style.fontSize = this.original;
      this.current = this.first;
   }
}