// 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="cursor: pointer; font-size: 80% ;" id="' + id + '-small" ><img src="http://uchinoko.jp/images/head/t_03.gif" alt="小" width="21" height="21" /></span>',

'<span style="cursor: pointer; font-size: 100%;" id="' + id + '-medium"><img src="http://uchinoko.jp/images/head/t_02.gif" alt="中" width="21" height="21" /></span>',

'<span style="cursor: pointer; font-size: 120%;" id="' + id + '-large" ><img src="http://uchinoko.jp/images/head/t_01.gif" alt="大" width="21" height="21" /></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));

  },

  onClickSmall:  function(e) { this.change('12px'); activess=getActiveStyleSheet(); setActiveStyleSheet('small'); setActiveStyleSheet(activess);/*this.css_get('top_small.css');*/  },

  onClickMedium: function(e) { this.change('14px'); activess=getActiveStyleSheet(); setActiveStyleSheet('mid'); setActiveStyleSheet(activess);/*this.css_get('top_mid.css');*/  },

  onClickLarge:  function(e) { this.change('18px'); activess=getActiveStyleSheet(); setActiveStyleSheet('big'); setActiveStyleSheet(activess);/*this.css_get('top_big.css');*/  }

};







// Bootstrap

FontChanger.start = function(id) {

  var fontChanger = new FontChanger(id);

  fontChanger.show();

};



/*onClick時に今何が選択されているのかを受け取り下記CSSを３種類変えたい*/

css_name='<link href="http://uchinoko.jp/css/change_css/'+'top_mid.css'+'" rel="stylesheet" type="text/css" />';

//new Date('<link href="http://uchinoko.jp/css/change_css/top_big.css" rel="stylesheet" type="text/css" />');

////<link href="http://uchinoko.jp/css/change_css/top_big.css" rel="stylesheet" type="text/css" />

////<link href="http://uchinoko.jp/css/change_css/top_mid.css" rel="stylesheet" type="text/css" />

////<link href="http://uchinoko.jp/css/change_css/top_small.css" rel="stylesheet" type="text/css" />




