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(lang) {
		var id = this.id;

		if(lang == "j"){
			document.writeln([
			'<div id="' + id + '">',
			'<span style="cursor: default; " id="' + id + '_txt" ><img src="http://www.carbonoffset-network.jp/img/cmn_fontsize.gif" alt="文字サイズ" width="93" height="17" /></span>',
			'<span style="cursor: pointer; " id="' + id + '_S" ><img src="http://www.carbonoffset-network.jp/img/cmn_fontsize_s.gif" alt="小" width="18" height="17" /></span>',
			'<span style="cursor: pointer; " id="' + id + '_M" ><img src="http://www.carbonoffset-network.jp/img/cmn_fontsize_m.gif" alt="中" width="18" height="17" /></span>',
			'<span style="cursor: pointer; " id="' + id + '_L" ><img src="http://www.carbonoffset-network.jp/img/cmn_fontsize_l.gif" alt="大" width="18" height="17" /></span>',
			'</div>',
			'<hr class="alt" / >'
			].join("\n"));

		}else if(lang == "e"){
			document.writeln([
			'<div id="' + id + '">',
			'<span style="cursor: default; " id="' + id + '_txt" ><img src="http://www.carbonoffset-network.jp/e/img/cmn_efontsize.gif" alt="FONT SIZE" width="93" height="17" /></span>',
			'<span style="cursor: pointer; " id="' + id + '_S" ><img src="http://www.carbonoffset-network.jp/e/img/cmn_efontsize_s.gif" alt="S" width="18" height="17" /></span>',
			'<span style="cursor: pointer; " id="' + id + '_M" ><img src="http://www.carbonoffset-network.jp/e/img/cmn_efontsize_m.gif" alt="M" width="18" height="17" /></span>',
			'<span style="cursor: pointer; " id="' + id + '_L" ><img src="http://www.carbonoffset-network.jp/e/img/cmn_efontsize_l.gif" alt="L" width="18" height="17" /></span>',
			'</div>',
			'<hr class="alt" / >'
			].join("\n"));

		}
	
		Event.observe($(id + '_S' ), 'click', this.onClickSmall.bind(this));
		Event.observe($(id + '_M' ), 'click', this.onClickMedium.bind(this));
		Event.observe($(id + '_L' ), 'click', this.onClickLarge.bind(this));
	
	},
	
	onClickSmall:  function(e) { this.change('80%' ); },
	onClickMedium: function(e) { this.change('100%'); },
	onClickLarge:  function(e) { this.change('120%'); }

};

FontChanger.start = function(id,lang) {

//document.writeln(BrowserDetect.browser);
//document.writeln(BrowserDetect.version);
//document.writeln(BrowserDetect.OS);

  var fontChanger = new FontChanger(id,lang);
  fontChanger.show(lang);

};

