﻿/*
NOTE: This script makes use of the jquery.cookie.js plugin which must also be installed and included.

How it works:

Create some links with class of "size" and a rel attribute equal to the desired font sizes. 
ex: <a class="size smallestLink" rel="10px">A</a> <a class="size middleLink" rel="12px">A</a>

On click the cookie will be set to the new font size and then the base font size will be set in the CSS.
*/

(function ($) {

    $.fn.fontresize = function () {
        $(this).click(function () {
            var currSize = $(this).attr('rel');
            $.cookie('fontsize', currSize);
            setCurrentFontsize();
        });
    }

})(jQuery);


$(document).ready(function () {
    // add the resize function to the appropriate elements
    $("a.size").fontresize();

    // set the fontsize for the page
    setCurrentFontsize();
});

function setCurrentFontsize() {
    if ($.cookie('fontsize') == null) {
        // set a default fontsize
        $.cookie('fontsize', '12px');
        var currSize = $.cookie('fontsize');
        $("body").css({ "font-size": currSize });
    } else {
        var currSize = $.cookie('fontsize');
        $("body").css({ "font-size": currSize });
    }
}



