$(document).ready(function () {

/* Make Hank's face send you to home page
------------------------------- */
	$('#header-top').click( function() {
		document.location = "http://www.millerwalks.com/";
	});

/* Handle toggling of seach box in navigation bar
------------------------------- */
	$('#navbar-search').click( function() {
		$('#navbar-searchbox').toggle();
		$('#navbar-searchbox input#search').focus();
	})

/* Set font size
------------------------------- */
	var curr_size = $.cookie('font_size');

	$('a#navbar-font-smaller').click(function() {
		if(curr_size == "1") {
			setFontSize(.8);
		}
		else if(curr_size == "1.15") {
			setFontSize(1);
		}
		else {
			setFontSize(.8);
		}
	});

	$('a#navbar-font-larger').click(function() {
		if(curr_size == ".8") {
			setFontSize(1);
		}
		else if(curr_size == "1") {
			setFontSize(1.15);
		}
		else {
			setFontSize(1.15);
		}
	});

	// Set the font size and set a cookie
	function setFontSize(size) {
		$("#body, input.text, textarea").animate({ fontSize: size + "em" }, 500).fadeIn();
		curr_size = size;
		createCookie(size);
	}

	// Create and read coookies
	// Code functions by: Peter-Paul Koch
	// http://www.quirksmode.org/js/cookies.html
	function createCookie(value) {
		var date = new Date();
		date.setTime(date.getTime()+(30*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		document.cookie = "font_size="+value+expires+"; path=/";
	}
	var font_size = $.cookie('font_size');
	if (font_size == '0.8') {
		$('#body').css("font-size",".8em");
	}
	if (font_size == '1.15') {
		$('#body').css("font-size","1.15em");
	}
	if (font_size == '1') {
		$('#body').css("font-size","1em");
	}

});
