﻿//This script works in conjunction with the text sizing links in the masterpage to adjust
//the font size in the browser.  The script supports multiple size options.
//A cookie is utilized to save the setting for the user.
; (function($) {

    $.initTextSize = function() { initTextSize(); };
    $.textResize = function(size) { textResize(size); };

    function initTextSize() {
        var body = $('body');
        var cookie_val = $.cookie('shstextsize');
        if (!cookie_val) {
            $.cookie('shstextsize', 'Sm', { path: '/', expires: 365 });
            textResize('Sm');
            //console.log('initialized cookie_val to: Md');
        }
        else {
            //console.log('existing cookie_val = ' + cookie_val);
            body.addClass('text' + cookie_val);
            $('a.text' + cookie_val).addClass('selected');
        }
    }
    function textResize(size) {
        var body = $('body');
        switch (size) {
            case 'Sm':
                body.removeClass('textMd textLg').addClass('textSm');
                $.cookie('shstextsize', 'Sm', { path: '/', expires: 365 });
                $('a.textMd').removeClass('selected');
                $('a.textLg').removeClass('selected');
                $('a.textSm').addClass('selected');
                break;
            case 'Md':
                body.removeClass('textSm textLg').addClass('textMd');
                $.cookie('shstextsize', 'Md', { path: '/', expires: 365 });
                $('a.textSm').removeClass('selected');
                $('a.textLg').removeClass('selected');
                $('a.textMd').addClass('selected');
                break;
            case 'Lg':
                body.removeClass('textSm textMd').addClass('textLg');
                $.cookie('shstextsize', 'Lg', { path: '/', expires: 365 });
                $('a.textSm').removeClass('selected');
                $('a.textMd').removeClass('selected');
                $('a.textLg').addClass('selected');
                break;
        }
        //console.log('textResize: ' + size);
    }
})(jQuery);