var textZoom = {    
  init:function(){
    this.DEFAULT_INDEX = 1;
    this.LEVELS = [65, 81, 85, 100];
    this.SIZE_DESCRIPTIONS = ["small", "medium-small", "medium-large", "large"];
    this.index = Number(site.getCookie('zoom') || this.DEFAULT_INDEX);
    this.update();
  },
  
  zoomIn: function(obj){ 
    this.index = Math.min(this.index + 1, this.LEVELS.length - 1);
    this.update(obj);
  },

  zoomOut: function(obj){
    this.index = Math.max(this.index - 1, 0);
    this.update(obj); 
  },
  
  zoomDefault: function(obj){
    this.index = this.DEFAULT_INDEX;
    this.update(obj);
  },
  
  update: function(obj){
    document.body.style.fontSize = this.LEVELS[this.index] + '%';
    site.setCookie('zoom', this.index, 365, '/');
		if (obj != null) {
      site.analytics.callAdapters('changeFontSize', this.SIZE_DESCRIPTIONS[this.index]);
		}
  }
};

$(document).ready(function() {
  textZoom.init();
  $(".zoom .minus").click(function(e){e.preventDefault();e.stopImmediatePropagation();textZoom.zoomOut(this);});
  $(".zoom .aaa").click(function(e){e.preventDefault();e.stopImmediatePropagation();textZoom.zoomDefault(this);});
  $(".zoom .plus").click(function(e){e.preventDefault();e.stopImmediatePropagation();textZoom.zoomIn(this);});
});

