var luna_startFontSize = 62.5;
var luna_currentFontSize = luna_startFontSize;
var luna_cookieDuration = 15; //days
var luna_cookieName = "fontcchanger";
var luna_fontIncreaseAmmount = 5;

if(luna_getCookie() == ".")
{
	luna_saveCookie();
}
else
{
	luna_currentFontSize = parseFloat(luna_getCookie());
}

function luna_saveCookie()
{
    createCookie(luna_cookieName, luna_currentFontSize, luna_cookieDuration);
}

function luna_getCookie()
{
    if(isNaN(unescape(readCookie(luna_cookieName))))
        return luna_startFontSize;
    else
        return unescape(readCookie(luna_cookieName));
}

function luna_increaseFont()
{
	var b = document.body;
	if(b)
	{
		luna_currentFontSize =luna_currentFontSize + luna_fontIncreaseAmmount;
		luna_saveCookie();
		b.style.fontSize = luna_currentFontSize + "%";
	}
}
function luna_decreaseFont()
{
	var b = document.body;
	if(b)
	{
		luna_currentFontSize =luna_currentFontSize - luna_fontIncreaseAmmount;
		luna_saveCookie();
		b.style.fontSize = luna_currentFontSize + "%";
	}
}
function luna_smallFont()
{
	var b = document.body;
	if(b)
	{
		luna_currentFontSize =luna_startFontSize - 10;
		luna_saveCookie();
		b.style.fontSize = luna_currentFontSize + "%";
	}
}
function luna_bigFont()
{
	var b = document.body;
	if(b)
	{
		luna_currentFontSize =luna_startFontSize + 10;
		luna_saveCookie();
		b.style.fontSize = luna_currentFontSize + "%";
	}
}
function luna_biggerFont()
{
	var b = document.body;
	if(b)
	{
		luna_currentFontSize =luna_startFontSize + 20;
		luna_saveCookie();
		b.style.fontSize = luna_currentFontSize + "%";
	}
}
function luna_setDefaultFontSize()
{
	var b = document.body;
	if(b)
	{
		luna_currentFontSize = luna_startFontSize;
		luna_saveCookie();
		b.style.fontSize = luna_currentFontSize + "%";
	}
}
function luna_increaseFontToCookieSize()
{
	var b = document.body;
	if(b)
	{
		b.style.fontSize = luna_currentFontSize + "%";
	}
}

function luna_addEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}
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;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

luna_addEvent(window, 'load', luna_increaseFontToCookieSize);
