var Cookie = {
	save: function(name, value, expire){
		document.cookie
			= name + '=' + escape(value) + "; path=/"
				+ ((expire==null)?'':('; expires='+expire.toGMTString()));
	},
	load: function(name){
		var search = name + '=';
		if(document.cookie.length > 0) {
			var offset = document.cookie.indexOf(search);
			if(offset >= 0){
				offset += search.length;
				var end = document.cookie.indexOf(';', offset);
				if(end < 0)
					end = document.cookie.length;
				return unescape(document.cookie.substring(offset, end));
			}
		}
		return null;
	}
};

var Accessibility = new Object();

Accessibility.FontSizeControl = function(current, min, max, inc){
	this.current	= parseInt(current)	|| 100;
	this.min		= parseInt(min)		|| 20;
	this.max		= parseInt(max)		|| 1000;
	this.inc		= parseInt(inc)		|| 20;
	this.cookieName = "fontSize";
}

Accessibility.FontSizeControl.prototype = {
	apply: function(){
		document.body.style.fontSize = this.current + "%";
	},
	moreLarge: function(){
		if(this.current <= this.max)
			this.current += this.inc;
		this.apply();
		this.save();
	},
	moreSmall: function(){
		if(this.current > this.min)
			this.current -= this.inc;
		this.apply();
		this.save();
	},
	setSmall: function(){
		this.current = 100;
		this.apply();
		this.save();
	},
	setMiddle: function(){
		this.current = 120;
		this.apply();
		this.save();
	},
	setLarge: function(){
		this.current = 140;
		this.apply();
		this.save();
	},
	setDefault: function(){
		this.current = 100;
		this.apply();
		this.save();
	},
	save: function(){
		Cookie.save(this.cookieName, this.current, null);
	},
	load: function(){
		this.current = parseInt(Cookie.load(this.cookieName)) || 100;
		this.apply();
	}
};
