
var FontSize = 
{
    DEFAULT_SIZE: 0,
    MAX_SIZE: 3,    
    currentSize : 0,
    
    initialize : function()
    {
		$$("body")[0].addClass("js-enabled");
		
        this.currentSize = Cookie.get("FONT_SIZE");
        this.currentSize = this.currentSize || "0";
        this.currentSize = Math.max(parseInt(this.currentSize), 0);
        this.currentSize = Math.min(this.currentSize, this.MAX_SIZE);
        this.setSize(this.currentSize);
    },
        
    setSize : function(size)
    {
        size = Math.min(size, this.MAX_SIZE);
        size = Math.max(size, 0);
        var pattern = /\s*size\d+\s*/;
        document.body.className = (" " + document.body.className + " ").replace(pattern, " ").clean();
        document.body.className = (document.body.className + " size" + size).clean();        
        Cookie.set("FONT_SIZE", size, { duration: false, path: "/" });
    },
    
    Increase : function()
    {
        this.currentSize = Math.min(this.currentSize + 1, this.MAX_SIZE);
        this.setSize(this.currentSize);
    },
    
    Decrease : function()
    {
        this.currentSize = Math.max(this.currentSize - 1, 0);
        this.setSize(this.currentSize);
    }
};

FontSize.initialize();