var fontSize = new Class({
	standard: 101,
	steps: 10,
	body: false,
	els: [],
	current: false,

	initialize: function() {
		var _this = this;
		this.body = $$('body')[0];
		this.current = this.read();
		if(this.current === false) this.current = this.standard;
		this.set(this.current);
		this.els = $$('#fontswitch ul li a');
		if($chk(this.body) && $chk(this.els) && this.els.length >= 3) {
			//größer
			this.els[0].addEvent('click',function(e) {
				new Event(e).preventDefault();
				this.blur();
				_this.bigger();
			});
			//normal
			this.els[1].addEvent('click',function(e) {
				new Event(e).preventDefault();
				this.blur();
				_this.reset();
			});
			//kleiner
			this.els[2].addEvent('click',function(e) {
				new Event(e).preventDefault();
				this.blur();
				_this.smaller();
			});
		};
	},

	set: function(fontSize) {
		this.body.style.fontSize = fontSize+'%';
		this.current = fontSize;
		this.write(fontSize);
	},

	read: function() {
		var fontSize = Cookie.read('fontsize');
		if($chk(fontSize)) return parseInt(fontSize);
		else return false;
	},

	write: function(value) {
		var domain = window.location.hostname;
		Cookie.write('fontsize',value);
	},

	bigger: function() {
		this.set(Math.round(this.current+this.steps));
	},

	smaller: function() {
		this.set(Math.round(this.current-this.steps));
	},

	reset: function() {
		this.set(this.standard);
	}
});

window.addEvent('domready',function () { new fontSize(); });
