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([
			'<ul id="' + id + '">',
			'<li><p>文字サイズ</p></li>',
			'<li><a href="javascript:void(0)" id="' + id + '-medium" class="fsm">文字サイズ：中</a></li>',
			'<li><a href="javascript:void(0)" id="' + id + '-large" class="fss">文字サイズ：大</a></li>',
			'</ul>'
		].join("\n"));
		
		Event.observe($(id + '-medium' ), 'click', this.onClickMedium.bind(this));
		Event.observe($(id + '-large'), 'click', this.onClickLarge.bind(this))
	},
	
	onClickMedium: function(e) { this.change('73%'); },
	onClickLarge:  function(e) { this.change('83%'); }
};


FontChanger.start = function(id) 
{
	var fontChanger = new FontChanger(id);
	fontChanger.show();
};
