
var FONT_SIZE_INCREASER_SELECTOR=".fontSizeIncreaser";var FONT_SIZE_DECREASER_SELECTOR=".fontSizeDecreaser";var DEFAULT_FONT_SIZE="77%";var FONT_SIZE_INCREMENT_FACTOR=0.19;var FONT_SIZE_INCREMENT_MIN_FACTOR=1;var FONT_SIZE_INCREMENT_MAX_FACTOR=3;var FONT_SIZE_BOUND_NUMERALS={em:{min:0.9,max:13.5},px:{min:76,max:110},'%':{min:77,max:107}};var NAMES={cookies:{fontSizeFactor:"userPrefs.font.size.factor",fontSizeOriginalValue:"userPrefs.font.size.originalValue"}};var userPreferences={font:{size:{defaultFactor:1,factorIncrement:FONT_SIZE_INCREMENT_FACTOR,minFactor:FONT_SIZE_INCREMENT_MIN_FACTOR,maxFactor:FONT_SIZE_INCREMENT_MAX_FACTOR,defaultValue:DEFAULT_FONT_SIZE,getOriginalValue:function(){var value="";if(cookieManager.get(NAMES.cookies.fontSizeOriginalValue)){value=cookieManager.get(NAMES.cookies.fontSizeOriginalValue);}
return String(value);},setOriginalValue:function(value){cookieManager.add(NAMES.cookies.fontSizeOriginalValue,value,365,null,null,null);},getFactor:function(){var factor="";if(cookieManager.get(NAMES.cookies.fontSizeFactor)){factor=parseFloat(cookieManager.get(NAMES.cookies.fontSizeFactor));}
return factor;},setFactor:function(factor){if(isFinite(factor)&&this.minFactor<=parseFloat(factor)&&this.maxFactor>=parseFloat(factor)){cookieManager.add(NAMES.cookies.fontSizeFactor,factor,365,null,null,null);}},getReferenceObject:function(){var o=null;try{o=document.getElementsByTagName('body')[0];}catch(e){var msg="userPreferences.font.size.getReferenceObject, object not found";alert(msg);throw new Error(msg);}
return o;},increase:function(){this.getReferenceObject().increaseFontSize();},decrease:function(){this.getReferenceObject().decreaseFontSize();}}}};function initUserPreferences(){var prefName="";var refObject=userPreferences.font.size.getReferenceObject();REF_OBJECT_TOOLING:{refObject.getFontSize=function(){try{var fontSize=this.style.fontSize;if(!fontSize){fontSize=null;}
return fontSize;}catch(e){var msg="[ERROR] FontSizeReferenceObject.getFontSize: "+e.message;alert(msg);throw new Error(msg);}};refObject.setFontSize=function(fontSize){try{this.style.fontSize=fontSize;}catch(e){var msg="FontSizeReferenceObject.setFontSize: "+e.message;alert(msg);throw new Error(msg);}};refObject.setDefaultFontSize=function(){this.style.fontSize=userPreferences.font.size.defaultValue;};refObject.getFontSizeUnit=function(){var FONT_SIZE_UNIT_RE=/\D+$/g;return String(this.getFontSize().match(FONT_SIZE_UNIT_RE));};refObject.hasNumericFontSize=function(){return isFinite(this.getFontSize().replace(/\D+$/g,""));};refObject.getFontSizeNumeral=function(fontSize){return this.getFontSize().replace(/\D+$/g,"");};refObject.shiftFontSize=function(direction){if(-1!=direction&&0!=direction&&1!=direction){var msg="changeFontSize, direction must -1, 0 or +1 : "+direction;alert(msg);throw new Error(msg);}
direction=parseInt(direction);var fontSize=this.getFontSize();var factorBefore=userPreferences.font.size.getFactor();var fontSizeBefore=fontSize;if(!fontSize){throw new Error("[ASSERTION ERROR] fontSize should be defined");}
if(this.hasNumericFontSize()){var origValue=userPreferences.font.size.getOriginalValue();userPreferences.font.size.setFactor(userPreferences.font.size.getFactor()+
(direction*userPreferences.font.size.factorIncrement));var factor=userPreferences.font.size.getFactor();var numeral=origValue.replace(/\D+$/,"");var numeralBefore=fontSizeBefore.replace(/\D+$/,"");var numCopy=numeral;numeral*=factor;var unit=this.getFontSizeUnit();var fontSize=null;switch(unit){case"em":case"ex":case"%":break;case"px":numeral=Math.round(numeral);if(numCopy==numeral){numeral+=direction;}
break;default:throw new Error("[ASSERTION ERROR] unknown unit : "+unit);break;}
if(FONT_SIZE_BOUND_NUMERALS[unit]["min"]>numeral){numeral=numeralBefore;userPreferences.font.size.setFactor(factorBefore);}else if(FONT_SIZE_BOUND_NUMERALS[unit]["max"]<numeral){numeral=numeralBefore;userPreferences.font.size.setFactor(factorBefore);}
this.setFontSize(numeral+unit);}};refObject.increaseFontSize=function(){this.shiftFontSize(+1);};refObject.decreaseFontSize=function(){this.shiftFontSize(-1);};refObject.init=function(){if(!(this.getFontSize())){this.setDefaultFontSize();}
if(!userPreferences.font.size.getOriginalValue()){userPreferences.font.size.setOriginalValue(this.getFontSize());}
if(!userPreferences.font.size.getFactor()){userPreferences.font.size.setFactor(userPreferences.font.size.defaultFactor);}
refObject.shiftFontSize(0);};}
refObject.init();}
$jq(document).ready(function(){initUserPreferences();$jq(FONT_SIZE_INCREASER_SELECTOR).click(function(){userPreferences.font.size.increase();});$jq(FONT_SIZE_DECREASER_SELECTOR).click(function(){userPreferences.font.size.decrease();});});