
FontSwitcher = Class.create();
FontSwitcher.prototype = {
	
	
	initialize : function(){
		this.cookieManager = null;
		this.cookieName = 'body.style.fontSize';
		this.setup = false;
		
		this._cbwl = this._cbwl.bind(this);
		Event.observe(window, 'load', this._cbwl);
		
		this.cbSmall = this.cbSmall.bind(this);
		this.cbMiddle = this.cbMiddle.bind(this);
		this.cbLarge = this.cbLarge.bind(this);
	},
	
	_cbwl : function(e){
		this.cookieManager = new CookieManager();
		this.cookieManager.cookieShelfLife = 90;
		this.img_small  = $("img_small");
		this.img_middle = $("img_middle");
		this.img_large  = $("img_large");
		Event.observe($("btn_small"),  'click', this.cbSmall);
		Event.observe($("btn_middle"), 'click', this.cbMiddle);
		Event.observe($("btn_large"),  'click', this.cbLarge);
		this.setup = true;
		
		var size = this.cookieManager.getCookie(this.cookieName);
		if (size == 'small')      this.cbSmall();
		else if(size == 'middle') this.cbMiddle();
		else if(size == 'large')  this.cbLarge();
		
	},
	
	cbSmall : function(e){
		if(e) Event.stop(e);
		if(!this.setup) return;
		
		this.img_small.src  = "images/txt_size_btn01a.gif";
		this.img_middle.src = "images/txt_size_btn02.gif";
		this.img_large.src  = "images/txt_size_btn03.gif";
		
		Element.setStyle(document.body, { 'fontSize' : '84%' });
		this.cookieManager.setCookie(this.cookieName, 'small');
	},
	cbMiddle : function(e){
		if(e) Event.stop(e);
		if(!this.setup) return;
		
		this.img_small.src  = "images/txt_size_btn01.gif";
		this.img_middle.src = "images/txt_size_btn02a.gif";
		this.img_large.src  = "images/txt_size_btn03.gif";

		Element.setStyle(document.body, { 'fontSize' : '100%' });
		this.cookieManager.setCookie(this.cookieName, 'middle');
	},
	cbLarge : function(e){
		if(e) Event.stop(e);
		if(!this.setup) return;
		
		this.img_small.src  = "images/txt_size_btn01.gif";
		this.img_middle.src = "images/txt_size_btn02.gif";
		this.img_large.src  = "images/txt_size_btn03a.gif";

		Element.setStyle(document.body, { 'fontSize' : '120%' });
		this.cookieManager.setCookie(this.cookieName, 'large');
	}

};
FontSwitcher = new FontSwitcher();
