(function(global, doc, $){
	
	if(!$) return;
	
	var body 
	, setSize = function(size){
		
		body || (body = $('body'));
		
		$.cookie('fontSize', size, {
			path: '/'
		});
		
		// when normal
		body.removeClass('bigger-font')
			.removeClass('biggest-font');
		
		if(size == 'bigger'){
			body.addClass('bigger-font');
		} else if (size == 'biggest'){
			body.addClass('biggest-font');
		}
		
		$(doc).trigger("font-resize");
	};
	
	var currentSize = $.cookie('fontSize');
	currentSize && setSize(currentSize);
	
	$.fn.fontSizer = function(config){
		
		config = $.extend({
			normal: '',
			bigger: 'bigger-font',
			biggest: 'biggest-font'
		}, config);
		
		this.each(function(){
	    	var self = $(this) 
	    	, body = $('body')
	    	, links = self.find('span');
	    	
	    	self.delegate('span', 'click', function(e){
	    		e.preventDefault();
	    		
	    		var link = $(this);
	    		
	    		currentSize = this.className.match(/normal|bigger|biggest/g)[0];
	    		
	    		links.removeClass('active');
	    		link.addClass('active');
	    		
	    		setSize(currentSize);
	    	});
		});
		
	}
	
}(this, this.document, jQuery));
