jQuery(function(){

	var $body = $('body');
	var defaultFontSize = $body.css('fontSize');
	var cookieFontSize = document.cookie.match('schriftgroesse=[a-z0-9]{1,6}');
	
	if (cookieFontSize) $body.css('fontSize',cookieFontSize[0].split("=")[1]);	

	$('ul.size-change li').each(function(){
		$this = $(this);
		if ($this.attr('class')) (function($t){ $t.click(function(){ changeFontSize($t); }); })($this);
	});
	
	function changeFontSize($btn) {
		
		var newFontSize = '';
		var currFontSize = $body.css('fontSize');
		var pxValue = parseInt(currFontSize.substring(0, currFontSize.length - 1));
	
		if ($btn.hasClass('smaller') && pxValue > 8) newFontSize = (pxValue - 1) + 'px';
		else if ($btn.hasClass('normal')) newFontSize = defaultFontSize;
		else if ($btn.hasClass('bigger') && pxValue < 20) newFontSize = (pxValue + 1) + 'px';
		else newFontSize = currFontSize;
	
		$body.css('fontSize',newFontSize);
		$('#Fontsize').attr('class', $btn.attr('class'));
		document.cookie = document.cookie + "\n" + "schriftgroesse=" + newFontSize + " ;path=/";
	}  
}
);

