	$(function(){// onpageready fire

      $('div#controls').css('display','block');// show the controls

	  var cookieName = "textSize"; // define the name of the cookie that were going to use to store the size value
      var validCookieCondition = ($.cookie(cookieName)) && ($.cookie(cookieName) != '-1');
      var rootNode = $('body'); // set the root node to make the transformations on
  	  var originalSize = rootNode.css('fontSize'); // grab the original size for reset purposes

	  if (validCookieCondition) // if the fontsize is set, reflect the persistence in the checkbox
      {
		$('body').css('fontSize', $.cookie(cookieName)); // set the current font size to reflect the previous setting
      }

		$('a.resize').click(function(){ // event listener for clicks on inputs with the correct ID
			var ourText = $('body'); // reference for html root, body tag
			var currFontSize = ourText.css('fontSize'); // grabs the current CSS value of the font size
			var finalNum = parseFloat(currFontSize, 10); // converts the text into a number
			var stringEnding = currFontSize.slice(-2); // removes the unit text from the end of CSS value and stores it

			if(this.id == 'increase') { // if the id of the calling object is 'increase'
				if (finalNum < 40) // set a maximum limit on font size
				{
				  finalNum *= 1.2; // increase value
				 // $.cookie("fontSize", finalNum + stringEnding, {expires: 180 }); // amend the cookie with the new value // use this for offline testing
				 $.cookie(cookieName, finalNum + stringEnding, {expires: 180, path: '/' }); // amend the cookie with the new value // use this for online deployment
				}
				ourText.css("fontSize", finalNum + stringEnding); // reapply the original font unit text
			}
			else if (this.id == 'reduce'){
			    if (finalNum > 14) // set a minimum limit on font size
			    {
				  finalNum /=1.2; // decrease value accordingly
				  //$.cookie("fontSize", finalNum + stringEnding, {expires: 180 }); // use this for offline testing
                  $.cookie(cookieName, finalNum + stringEnding, {expires: 180, path: '/' }); // use this for online deployment
			    }
			    ourText.css("fontSize", finalNum + stringEnding); // reapply the original font unit text

			} else if (this.id == 'reset') // on reset click
			{ 
              ourText.css("fontSize", originalSize);

  			    //$.cookie("fontSize", finalNum, {path: '/' }); // use this for online deployment
//			    $.cookie("fontSize", '-1'); // use this for offline testing
				$.cookie(cookieName, '-1', {path: '/'}); // use this for online deployment
			};
		});	
	});
