﻿FontResize = Class.create();
FontResize.prototype = {

fsize: {
  'small':  {'id': 'FONT-SMALL',  'size':  '80%'},
  'normal': {'id': 'FONT-NORMAL', 'size': '100%'},
  'large':  {'id': 'FONT-LARGE',  'size': '120%'}
},

initialize: function(option, table) {
  this.props = { target: 'content', expire: 0 };
  if(option) for(var key in option) this.props[key] = option[key];
  this.cookiemgr = 
    new CookieManager({expire: this.props.expire});
  this.currentFontSize = 'normal';

  if (table) this.fsize = table;
  for (key in this.fsize)
    $(this.fsize[key]['id']).observe(
      'click', function(k){this.resizeFont(k);}.bind(this,key)
    ).addClassName('normal').style['cursor'] = 'pointer';
  var cookieValue = this.cookiemgr.getCookie("currentFontSize");
  if (cookieValue) this.currentFontSize = cookieValue;
  this.resizeFont(this.currentFontSize);
},

resizeFont: function(size) {
  for (key in this.fsize)
    $(this.fsize[key]['id']).removeClassName('select');
  var obj = this.fsize[size];
  $(this.props.target).style.fontSize = obj['size'];
  $(obj['id']).addClassName('select');
  this.cookiemgr.setCookie("currentFontSize", size);
}
}//prototype

