// JavaScript Document

// 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();
    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 + '">',
//'<span style="font-size:80%">文字の大きさが変えられます→ </span>',
//'<span style="cursor: pointer; font-size: 80% ;" id="' + id + '-small" >小</span>',
//'<span style="cursor: pointer; font-size: 100%;" id="' + id + '-medium">中</span>',
//'<span style="cursor: pointer; font-size: 120%;" id="' + id + '-large" >大</span>',
//'</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));
//  },
// fontchanger.jsの25行目から39行目

//---------改編ここから-------
document.writeln([
'<div id="' + id + '">',
'<span class="fontcaption"> </span>',
'<div id="font_L"><a href="javascript: void(0);return false;" id="' + id + '-large" title="文字を大きくする">大</a></div>',
'<div id="font_m"><a href="javascript: void(0);return false;" id="' + id + '-medium" title="文字を標準に戻す">中</a></div>',
'<div id="font_s"><a href="javascript: void(0);return false;" id="' + id + '-small" title="文字を小さくする">小</a></div>',
'</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('80%' ); },
  onClickMedium: function(e) { this.change('100%'); },
  onClickLarge:  function(e) { this.change('120%'); }
};
// Bootstrap
FontChanger.start = function(id) {
  var fontChanger = new FontChanger(id);
fontChanger.setCookieShelfLife(90);
fontChanger.show();
};





