var maxSize = 200;
var minSize = 60;
var fontIncrement = 10;

function setFontSize(fontSize) 
{
    document.body.style.fontSize = fontSize+ '%';
    createCookie('txtsize',fontSize,5);
}

function increaseFontSize() 
{  
    if (document.body.style.fontSize)
    {
        var s = parseInt(document.body.style.fontSize.replace("%",""));            
    }
    else
    {
	var s = 80;    
    }

    s += fontIncrement;

    if (s > maxSize)
    {
        s = maxSize;
    }

    document.body.style.fontSize = s+ '%';
    createCookie('txtsize',s,5);
}
      
function decreaseFontSize() 
{
    if (document.body.style.fontSize)
    {
        var s = parseInt(document.body.style.fontSize.replace("%",""));            
    }
    else
    {
	var s = 80;    
    }

    s -= fontIncrement;

    if (s < minSize)
    {
        s = minSize;
    }


    document.body.style.fontSize = s+ '%';
    createCookie('txtsize',s,5);
}

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 resetFontSize() 
{
    document.body.style.fontSize = '80%';
}

function loadFontSize()
{

    var s = readCookie('txtsize');

    if(s == null)
    {
        return;
    }

    document.body.style.fontSize = s + '%';

}
