//  set up Text Resizer function....

$(document).ready(function(){
	// section is the selector for the elements you want to have the same height
	var section = "";
	// extsection is the section list, plus any containers that need resizing too
	var extsection = "";
	// since units are not specified, it defaults to pixels on all this stuff.
	var maxfont = 24;
	var basefont = 14;
	var minfont =12;
	var fontsteps = 2;
	var lineheight = 1.5;  // must reset this, else it is 1.5 of the original value
	//
	if ($('body').hasClass('page-template-doctor-table-php')) {
		//section = "#doctortable";
		//extsection = "#doctortable,#content";
	}
	else if ($('body').hasClass('home')) {
		section="#alpha,#beta,#gamma";
		extsection = "#alpha,#beta,#gamma";
	}
	else {
		section       = "#maincontent,#sidebar";
		extsection = "#maincontent,#sidebar,#content";
	}

  	// Reset Font Size
	//var originalFontSize = $(section).css('font-size');
  	$(".resetFont").click(function(){
		$(section).css('height','auto');
    	$(section).css('font-size', basefont); 
    	$(section).css('line-height', lineheight);
		// reset page height
		resetpageheight();
		//var tmax = 0;
		//$(section).each(function() { tmax = Math.max(tmax, $(this).height()); }).height(tmax);
		//$(extsection).height(tmax);
		//
  	});

  	// Increase Font Size
  	$(".increaseFont").click(function(){
		$(extsection).css('height','auto');
    	var currentFontSize = $(section).css('font-size');
    	var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum < (maxfont - fontsteps) ? currentFontSizeNum + fontsteps :  maxfont;
    	$(section).css('font-size', newFontSize);
    	$(section).css('line-height', lineheight);
		// reset page height
		resetpageheight();
		//var tmax = 0;
		//$(section).each(function() { tmax = Math.max(tmax, $(this).height()); }).height(tmax);
		//$(extsection).height(tmax);
		//
    	return false;
  	});

  	// Decrease Font Size
  	$(".decreaseFont").click(function(){
		$(extsection).css('height','auto');
    	var currentFontSize = $(section).css('font-size');
    	var currentFontSizeNum = parseFloat(currentFontSize, 10);
 		var newFontSize = currentFontSizeNum > (minfont + fontsteps) ? currentFontSizeNum - fontsteps :  minfont;
   		$(section).css('font-size', newFontSize);
    	$(section).css('line-height', lineheight);
		// reset page height
		resetpageheight();
		//var tmax = 0;
		//$(section).each(function() { tmax = Math.max(tmax, $(this).height()); }).height(tmax);
		//$(extsection).height(tmax);
		//
   		return false;
  	});
  
  	// reset heights
  	function resetpageheight () {
	  // this sets both columns to the tallest height of them....
		var tmax = 0;
		$(section).each(function() { tmax = Math.max(tmax, $(this).height()); }).height(tmax);
		$(extsection).height(tmax);
	  }
});