Fx.FontPlus = new Class({
	initialize: function(elements, sid, gid, gmid, growsize, growmoresize){



		this.growsize = (growsize) ? growsize : 2;
		this.growmoresize = (growmoresize) ? growmoresize : 4;
		this.elements = [];
		
		var currentSize;
 		elements.each(function(el){
			//store the fontsize of 'el'
			currentSize = el.getStyle('font-size').toInt();
			
			//check if you have the Cookie module and if fontSize is set and if so if it's set to 'large'
			if(Cookie.get != null && (size = Cookie.get('fontSize')) && size == 'large'){
				el.setStyle('font-size',currentSize+this.growsize+'px');
			}
			if(Cookie.get != null && (size = Cookie.get('fontSize')) && size == 'small'){
				el.setStyle('font-size',currentSize+this.growsize+'px');
			}
			
			this.elements.push([el,currentSize]);									   
		},this);
		
		$(gmid).onclick = function(){this.growmore()}.bind(this);
		$(gid).onclick = function(){this.grow()}.bind(this);
		$(sid).onclick = function(){this.shrink()}.bind(this);	
			
	},
	
	growmore: function(){
		this.elements.each(function(el){
			var currentfsize = el[0].getStyle('font-size').toInt();
			if(currentfsize == el[1]) {
				el[0].effect('font-size',{duration:100,unit:'px'}).custom(el[1],el[1]+this.growmoresize);
				el[0].effect('line-height',{duration:100,unit:'px'}).custom(el[1],el[1]+this.growmoresize);
			}
			else if(currentfsize == el[1]+this.growsize) {
				el[0].effect('font-size',{duration:100,unit:'px'}).custom(el[1]+this.growsize,el[1]+this.growmoresize);	
				el[0].effect('line-height',{duration:100,unit:'px'}).custom(el[1]+this.growsize,el[1]+this.growmoresize);	
			}		
		},this);
		Cookie.set('fontSize','large',1);							
	},
	
	grow: function(){		
		this.elements.each(function(el){
			var currentfsize = el[0].getStyle('font-size').toInt();
			if(currentfsize == el[1]) {
				el[0].effect('font-size',{duration:100,unit:'px'}).custom(el[1],el[1]+this.growsize);
				el[0].effect('line-height',{duration:100,unit:'px'}).custom(el[1],el[1]+this.growsize);
			}
			else if(currentfsize == el[1]+this.growmoresize) {
				el[0].effect('font-size',{duration:100,unit:'px'}).custom(el[1]+this.growmoresize,el[1]+this.growsize);	
				el[0].effect('line-height',{duration:100,unit:'px'}).custom(el[1]+this.growmoresize,el[1]+this.growsize);	
			}
		},this);
		Cookie.set('fontSize','medium',1);							
	},
	
	shrink: function(){
		this.elements.each(function(el){
			var currentfsize = el[0].getStyle('font-size').toInt();
			if(currentfsize == el[1]+this.growsize) {
				el[0].effect('font-size',{duration:100,unit:'px'}).custom(el[1]+this.growsize, el[1]);
				el[0].effect('line-height',{duration:100,unit:'px'}).custom(el[1]+this.growsize, el[1]);
			}
			else if(currentfsize == el[1]+this.growmoresize) {
				el[0].effect('font-size',{duration:100,unit:'px'}).custom(el[1]+this.growmoresize, el[1]);
				el[0].effect('line-height',{duration:100,unit:'px'}).custom(el[1]+this.growmoresize, el[1]);
			}
		},this);
		Cookie.set('fontSize','small',1);		
	}						
});