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 + '">',
	'<strong>Font Size</strong>',
	'<ul>',
	'<li><a href="javascript: void(0);" id="' + id + '_small_eng">Small</a></li>',
	'<li class="fontmBt"><a href="javascript: void(0);" id="' + id + '_medium_eng">Medium</a></li>',
	'<li><a href="javascript: void(0);" id="' + id + '_large_eng">Large</a></li>',
	'</ul>',
	'</div>'
    ].join("\n"));
    Event.observe($(id + '_small_eng' ), 'click', this.onClickSmall.bind(this));
    Event.observe($(id + '_medium_eng'), 'click', this.onClickMedium.bind(this));
    Event.observe($(id + '_large_eng' ), 'click', this.onClickLarge.bind(this));
  },
  onClickSmall:  function(e) { this.change('65%' ); },
  onClickMedium: function(e) { this.change('72%'); },
  onClickLarge:  function(e) { this.change('105%'); }
};
// Bootstrap
FontChanger.start = function(id) {
  var fontChanger = new FontChanger(id);
  fontChanger.show();
};
