window.addEvent('domready', function () {
	document.fontSizeSwitcher = new FontSizeSwitcher();
	document.fontSizeSwitcher.init();
});

var FontSizeSwitcher = new Class({

	currentSize: 0,
	basicSize: 1,
	unit: 'em',
	increment: 0.1,
	min: 0.8,
	max: 2.0,
	
	init: function() {
	
		this.currentSize = this.basicSize;
		this.setSize();
	},
	
	increase: function() {
	
		this.currentSize += this.increment;
		this.setSize();
	},
	
	decrease: function() {
	
		this.currentSize -= this.increment;
		this.setSize();
	},
	
	checkSize: function() {
	
		if(this.currentSize < this.min) {
		
			this.currentSize = this.min;
		}
		
		if(this.currentSize > this.max) {
		
			this.currentSize = this.max;
		}
	},
	
	setSize: function() {
	
		this.checkSize();
		$('page').setStyle('font-size', this.currentSize + this.unit);
	}
});