﻿
function initFonts() {
	if ( !$('body') ) {
		return;
	}
	
	var f = ( readCookie("fontFamily") || "Georgia, serif" );
	$('body').setStyle({ fontFamily: f });
	createCookie( "fontFamily", f, 60 );

	var s = readCookie("fontSize");
	if ( s == null || isNaN(parseInt(s)) )  s = "100%";
	$('body').setStyle({ fontSize: s });
	createCookie( "fontSize", s, 60 );
}

function changeFontSize(d) {
	var s = parseInt( $('body').getStyle("fontSize") ) + d;
	var s = Math.min( 140, Math.max( 80, s ) ) + "%";
	
	$('body').setStyle({ fontSize: s });
	createCookie( "fontSize", s, 60 );
}

function toggleFontFamily() {
	var f = $('body').getStyle("fontFamily");
	
	if ( f.include('sans-serif') )
		f = "Georgia, serif";
	else
		f = "Verdana, sans-serif";
	
	$('body').setStyle({ fontFamily: f });
	createCookie( "fontFamily", f, 60 );
}

function resetFont() {
	var f = "Georgia, serif";	
	$('body').setStyle({ fontFamily: f });
	createCookie( "fontFamily", f, 60 );

	var s = "100%";
	$('body').setStyle({ fontSize: s });
	createCookie( "fontSize", s, 60 );
}
