var defaultSize = .73; // the same size as in the CSS
var maxSize = 0.9;
var minSize = .6;
var size;
var difference = 0.07; // add/substract by this value
var fontCookieName = 'ANHIFontSize';
var p = document.getElementsByTagName('body');
var currentSize = readCookie(fontCookieName);

function setFontSize()
{    
    //if there's a cookie with currentSize then set the size to that
    if (currentSize != null)
    {
        size = parseFloat(currentSize);
    }
    else 
    {
        size = defaultSize;
    }
    //change the body font size to the size it was set above
    p[0].style.fontSize = size + "em";
}

function increaseFont()
{//everytime the user tries to increase the font size it will call this function
//which will set the size as well as place a cookie with that value.
    if (size<maxSize)
    {
        size = size + difference;
    }
    p[0].style.fontSize = size + "em";
   createCookie(fontCookieName, size, 0.1);
}

function decreaseFont()
{//everytime the user tries to decrease the font size it will call this function
//which will set the size as well as place a cookie with that value.
    if (size>minSize)
    {
        size = size - difference;
    }
    p[0].style.fontSize = size + "em";
    createCookie(fontCookieName, size, 0.1);
}

function createCookie(name,value,days) 
{
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
