﻿/*

	Variables
	
*/
var startingFontSize = 14;
var minFontSize = 10;
var maxFontSize = 16;

/*

	Runs when document has finished loading
	
*/
$(document).ready(function() {	
	setInitialFontSize();
});


/*

	Sets initial font size from cookie
	
*/
function setInitialFontSize() {

	var currentFontSize = startingFontSize;
	
	if ( $.cookie('currentFontSize') != null )
		currentFontSize = $.cookie('currentFontSize');	
		
	$('body').css('fontSize', currentFontSize + 'px');		

}

/*

	Increases font size unless max has already reached

*/
function increaseFontSize() {

	var currentFontSize = startingFontSize;
	
	if ( $.cookie('currentFontSize') != null )
		currentFontSize = $.cookie('currentFontSize');

	if ( currentFontSize < maxFontSize ) {
		currentFontSize++;
		$.cookie('currentFontSize', currentFontSize)	
	}
	
	$('body').css('fontSize', currentFontSize + 'px');
   
}

/*

	Decreases font size unless min has already been reached

*/
function decreaseFontSize() {

	var currentFontSize = startingFontSize;
	
	if ( $.cookie('currentFontSize') != null )
		currentFontSize = $.cookie('currentFontSize');

	if ( currentFontSize > minFontSize ) {
		currentFontSize--;
		$.cookie('currentFontSize', currentFontSize)	
	}
   
	$('body').css('fontSize', currentFontSize + 'px');

}