﻿/**
 * Script for resizing the font in the main window
 */
var Font = {

    init: function () {
        jQuery('#resize-small').click(Font.smallClicked);
        jQuery('#resize-med').click(Font.medClicked);
        jQuery('#resize-large').click(Font.largeClicked);
        // if we have previously set the size, resize the content to that size
        var fontSize = jQuery.cookie("font-size");
        if (fontSize != null) {
            Font.resizeText(fontSize);
        }
    },

    smallClicked: function () {
        Font.resizeText(100);
    },

    medClicked: function () {
        Font.resizeText(110);
    },

    largeClicked: function () {
        Font.resizeText(130);
    },

    resizeText: function (size) {

        // are we on the homepage?
        var content = jQuery('#homeLeft .col_2_Wrap');
        if (content.length > 0) {
            // yep!
            Font.adjustFontSize(content, size);
            content = jQuery('#homeRight .module_w339');
            Font.adjustFontSize(content, size);

        }


        content = jQuery("#mainContentWrap");
        if (content.length == 0) {
            content = jQuery('#mainContentWrap_wide');
        }
        if (content.length != 0) {
            Font.adjustFontSize(content, size);
        }
    },

    adjustFontSize: function (element, size) {

        element.css("font-size", size + "%");
        jQuery('#leftColWrap').css("font-size", size + "%");
        jQuery('#rightColWrap').css("font-size", size + "%");

        Cufon.refresh();
        jQuery.cookie("font-size", size);
    }

};

jQuery(Font.init);
