// FontChanger
// Copyright (c) 2007 Hirotaka Ogawa
// REQUIRES: prototype.js, cookiemanager.js
FontChanger = Class.create();
FontChanger.prototype = {
  id: null,
  cookieManager: null,
  cookieName: 'body.style.fontSize',
  initialize: function(id) {
    this.id = id || 'fontChanger';
    this.cookieManager = new CookieManager();
    this.cookieManager.cookieShelfLife = 90;
    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([
'<span id="' + id + '"><img src="http://www.createsdhd.co.jp/img/base/menu01.gif" /><div class="fl"><img src="http://www.createsdhd.co.jp/img/base/mainmenu04.gif" /></div><ul id="mainmenu2"><li><a href="javascript: void(0);" id="' + id + '-small" title="文字を標準に戻す" class="mm11">標準</a></li><li><a href="javascript: void(0);" id="' + id + '-medium" title="文字を大きくする" class="mm12">大</a></li><li><a href="javascript: void(0);" id="' + id + '-large" title="文字を特大にする" class="mm13">特大</a></li></ul><div class="clear"><img src="http://www.createsdhd.co.jp/img/base/menu01.gif" /></div></span>'
    ]);
    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('100%'); },
  onClickMedium: function(e) { this.change('131%'); },
  onClickLarge:  function(e) { this.change('153.9%'); }
};
// Bootstrap
FontChanger.start = function(id) {
  var fontChanger = new FontChanger(id);
  fontChanger.show();
};