﻿var fontsize = new Class({	
    options: 
	{	
	},  
    initialize:function(options)
    {
        this.setOptions(options);   
        this.sizes = {
        'small':12,
        'medium':14,
        'large':16
        }        
                            
        var current = this.getSize();
        
        if(!current)
        {
            this.setSize('small');    
        }
        else
        {
            this.setSize(current);
        }
        
        $('small').onclick = this.setSmall.bind(this);
        $('medium').onclick = this.setMedium.bind(this);
        $('large').onclick = this.setLarge.bind(this);
                               
		if (this.options.initialize) 
		{
		    this.options.initialize.call(this);
		}                
    },   
    getSize:function()
    {    
        return Cookie.get('fontsize');    
    },
    saveSize:function(size)
    {
       
        Cookie.set('fontsize',size,{duration: 30});
                          
    },
    setSize:function(size)
    {
        var s = this.sizes[size];
        $('_body').setStyle('font-size',s);
    },
    setSmall:function()
    {    
        this.saveSize('small');
        location.href = location.href;
    },
    setMedium:function()
    {
        this.saveSize('medium');
        location.href = location.href;
    },
    setLarge:function()
    {
        this.saveSize('large');
        location.href = location.href;
    }           
       
});
fontsize.implement(new Options);  