Fx.FontPlus = new Class({
	initialize: function(elements, sid, gid, gmid, growsize, growmoresize){
		this.growsize = (growsize) ? growsize : 2;
		this.growmoresize = (growmoresize) ? growmoresize : 4;
		
		this.elements = [];
 		elements.each(function(el){
		this.elements.push([el,el.getStyle('font-size').toInt()]);									   
		},this);
		



		$(gmid).onclick = function(){this.growmore()}.bind(this);
		$(gid).onclick = function(){this.grow()}.bind(this);
		$(sid).onclick = function(){this.shrink()}.bind(this);		

		this.getCookieSize();
		
	},
	
	growmore: function(){
		
		this.elements.each(function(el){
				el[0].setStyle('font-size',el[1]+this.growmoresize+'px');
		},this);
		Cookie.set('fontSize','large',{path: '/'});
	},
	
	grow: function(){		
		this.elements.each(function(el){
				el[0].setStyle('font-size',el[1]+this.growsize+'px');	
		},this);
		
		//remember the users preference, keep the data for 1 day
		Cookie.set('fontSize','medium',{path: '/'});

	},
	
	shrink: function(){
		this.elements.each(function(el){
				el[0].setStyle('font-size',el[1]+'px');
		},this);		
	Cookie.set('fontSize','normal',{path: '/'});		

	},
	getCookieSize:function(){
			switch(Cookie.get('fontSize'))
			{
			case 'normal':
			this.shrink();
			break;
			case 'medium':
			this.grow()
			break;
			case 'large':
			this.growmore()
			break;		
			}
	}
});

window.addEvent('load', function() {
	if($defined($('content'))){	 
	var elems = $('content').getElements('.resizable');
	var elements = Array();
	if(elems) 
	elems.each(function(item){
	elements.extend(item.getElements('*'));
	}.bind(this));
	
	if(elements.length > 0)
   var fxfont = new Fx.FontPlus(elements,'shrink','grow','growmore');
	}
 
});
