FontChanger = Class.create();
FontChanger.prototype = {
  id: null,
  cookieManager: null,
  cookieName: 'body.style.fontSize',
  initialize: function(id) {
    this.id = id || 'fontChanger';
    this.cookieManager = new CookieManager();
    var fontSize = this.cookieManager.getCookie(this.cookieName);
    if (fontSize) document.body.style.fontSize = fontSize;
  },
  setCookieShelfLife: function(days) {
    this.cookieManager.cookieShelfLife = days;
  },
  change: function(fontSize) {
    document.body.style.fontSize = fontSize;
    this.cookieManager.setCookie(this.cookieName, fontSize);
  },
  reset: function() {
    document.body.style.fontSize = '';
    this.cookieManager.clearCookie(this.cookieName);
  },
  show: function() {
    var id = this.id;
    document.writeln([
'<div id="' + id + '" style="padding:36px 0 0 0; width:87px;">',
'<table width="87" border="0" cellspacing="0" cellpadding="0">',
'<tr>',
   '<td width="29"><span style="cursor: pointer; font-size: 10px;" id="' + id + '-small" ><img src="images/common/small.jpg"></span></td>',
   '<td width="29"><span style="cursor: pointer; font-size: 12px;" id="' + id + '-medium"><img src="images/common/midiam.jpg"></span></td>',
   ' <td width="29"><span style="cursor: pointer; font-size: 16px;" id="' + id + '-large" ><img src="images/common/large.jpg"></span></td>',
 '</tr>',
'</table>',
'</div>'
    ].join("\n"));
    Event.observe($(id + '-small' ), 'click', this.onClickSmall.bind(this));
    Event.observe($(id + '-medium'), 'click', this.onClickMedium.bind(this));
    Event.observe($(id + '-large' ), 'click', this.onClickLarge.bind(this));
  },
  onClickSmall:  function(e) { this.change('10px' ); },
  onClickMedium: function(e) { this.change('12px'); },
  onClickLarge:  function(e) { this.change('16px'); }
};
// Bootstrap
FontChanger.start = function(id) {
  var fontChanger = new FontChanger(id);
  fontChanger.show();
};