/**
 * jquery.fontResizer.js
 * @use 'jQuery - http://jquery.com/' & 'jquery.cookie.js - http://plugins.jquery.com/project/Cookie'
 * @license: Dual licensed under the MIT and GPL licenses:
 *           http://www.opensource.org/licenses/mit-license.php
 *           http://www.gnu.org/licenses/gpl.html
 */
(function($){
var fontsize = $.cookie('fontsize');

$(function(){
	$('img[src*="fontresizer"]').each(function(){
		if($(this).attr('src').match(/fontresizer([0-9]+)/)){
			var size = RegExp.$1;
			$(this).clone().attr('src', $(this).attr('src').replace(/\_off\.([^\.]+)$/, "_on.$1")).hide().insertAfter($(this));
			
			$(this).css('cursor','pointer').click(function(){
				fontsize = size;
				$.cookie('fontsize', fontsize, {expires: 7});
				fontResizer();
			});
		}
		fontResizer();
	});
});

function fontResizer(){
	$('img[src*="fontresizer"]').each(function(){
		if($(this).attr('src').match(/\_on\.[^\.]+/)){
			$(this).hide();
		}else{
			$(this).show().css('display','inline');
		}
	}).filter('img[src*="fontresizer'+fontsize+'"]').each(function(i){
		if(i){
			$(this).show().css('display','inline');
		}else{
			$(this).hide();
		}
	});
	
	if(fontsize && fontsize != null){
		$('.fontResizerTarget').css({
			fontSize: (isNaN(fontsize-0)) ? fontsize : fontsize + '%'
		});
	}
}
})(jQuery);
