/**
 *	stellt methoden zur dynamischen Änderung der Schriftgröße im Contentbereich zu Verfügung
 */

var feg_fontsize = new Class
({
 	mContainer : null,
	mStep : null,
	mLimits : {},
 
	initialize : function(pConf,pOptions)
	{
		if($(pOptions.container.toString()))
		{
			this.mContainer = $(pOptions.container.toString());
		}

		if(pOptions.step)
		{
			this.mStep = pOptions.step;
		}
		else
		{
			this.mStep = pConf.fontsize.step;
		}
		
		if(pOptions.limits)
		{
			this.mLimits = pOptions.limits;
		}
		else
		{
			this.mLimits = pConf.fontsize.limits;
		}
	
		pOptions.buttons.each(function(button){
			if($(button.toString()))
			{
				$(button.toString()).addEvent('click',function(ev){
					var ev = new Event(ev);
					ev.stop();
					if(button.toString() == 'fsplus')
					{
						this.setSize('+');
					}
					if(button.toString() == 'fsminus')
					{
						this.setSize('-');
					}
				}.bind(this));
			}
		}.bind(this));
	},
	
	getStep : function()
	{
		return this.mStep.toFloat();
	},
	
	getContainer : function()
	{
		return this.mContainer;
	},
	
	getLimits : function()
	{
		return this.mLimits;
	},
	
	setSize : function(mode)
	{
		var size = this.getFontsize();
		if(size.round(2) < this.getLimits().maxLimit)
		{
			if(mode == '+')
			{
				size += this.getStep();
			}
		}
		
		if(size.round(2) > this.getLimits().minLimit)
		{		
			if(mode == '-')
			{
				size -= this.getStep();
			}
			this.modifyFontsize(size);
			this.saveSessionSize(size);
		}
	},
	
	modifyFontsize : function(size)
	{
		this.getContainer().setStyle('font-size',size + 'em');
	},
	
	getFontsize : function()
	{
		var size = this.getContainer().getStyle('font-size');

		if(size.contains('px'))
		{
			size = size.toFloat();
			size /= 10;
		}
		else
		{
			size = size.toFloat();
		}
		return size;

	},
	
	saveSessionSize : function(size)
	{
		setSessionData('fontsize',size);
	}
 });