// Configuration parameters
// ------------------------
var measureUnit = "px"; // Measure unit in pixel (px) or points (pt)
var minStyleSize = 12; // Minimum size allowed for STYLE attribute (like in <FONT STYLE="font-size: 10px"> )
var maxStyleSize = 20; // Maximum size allowed for STYLE attribute
var defaultStyleSize = 12; // Start size for tags with no font-size STYLE or CLASS attribute defined
var stepStyleSize = 4; // Increasing step for STYLE definition (measure previously declared will be used)

function loadzoom(){
    var myfontsize = Get_Cookie('ZoomSize');

    if((myfontsize!=undefined) && (parseInt(myfontsize)>=minStyleSize)){
        changeFontSize(parseInt(myfontsize));
    }
}

//&& !$(obj).hasClass('imageCaption')

function changeFontSizeRecursive(obj,newStyleSize){
  if(obj.innerHTML!=""){
  	
		//exclusions from zooming - embedded image caption inside zoomable content
  	if ($(obj).hasClass('imageCaption') || $(obj).hasClass('photo_caption')) return;  
    
		if(obj.style!=undefined){
      if(obj.style.fontSize==""){
//      	alert($(obj).attr('class'));
        $(obj).css('font-size',newStyleSize+measureUnit);
      } else {
        var size=parseInt(obj.style.fontSize)+newStyleSize-defaultStyleSize;
        $(obj).css('font-size',size+measureUnit);
      }
    }
    for(var i=0;i<obj.childNodes.length;i++){
      changeFontSizeRecursive(obj.childNodes[i],newStyleSize);
    }
  }
}

function changeFontSize(newStyleSize) {
  var zoomed=$(".zoomMe");
  for(var i=0;i<zoomed.length;i++){
    changeFontSizeRecursive(zoomed[i],newStyleSize);
  }
  /*saves new font size*/
  defaultStyleSize=newStyleSize;
  Set_Cookie('ZoomSize',newStyleSize,365,'','','');
}
  
function increaseFontSize() {
    if(defaultStyleSize<maxStyleSize){
      var newStyleSize=Math.min(parseInt(defaultStyleSize)+stepStyleSize,maxStyleSize);
      changeFontSize(newStyleSize);
    }
}

function decreaseFontSize() {
  if(defaultStyleSize>minStyleSize){
    var newStyleSize=Math.max(parseInt(defaultStyleSize)-stepStyleSize,minStyleSize);
    changeFontSize(newStyleSize);
  }
}