var font =
{
    defaultFontSize: 80,
    currentFontSize: 0,
    increment: 10,
    max: 3,

    init: function() {
        var fontsize = document.getElementById("fontsize");
        var anchors = fontsize.getElementsByTagName("a");

        for (var i = 0; i < anchors.length; i++) {
            switch (anchors[i].className) {
                case "Smaller":

                    anchors[i].onclick = font.down;

                    break;

                case "Larger":

                    anchors[i].onclick = font.up;

                    break;

                default:

                    anchors[i].onclick = font.reset;
            }
        }

        return true;
    },

    up: function() {
        if (font.currentFontSize < font.max) {
            font.currentFontSize++;

            document.getElementsByTagName("body")[0].style.fontSize = font.defaultFontSize + (font.currentFontSize * font.increment) + "%";
        }

        return false;
    },

    down: function() {
        if (font.currentFontSize > -font.max) {
            font.currentFontSize--;

            document.getElementsByTagName("body")[0].style.fontSize = font.defaultFontSize + (font.currentFontSize * font.increment) + "%";
        }

        return false;
    },

    reset: function() {
        font.currentFontSize = 0;

        document.getElementsByTagName("body")[0].style.fontSize = font.defaultFontSize + "%";

        return false;
    }
};

$(document).ready(function() {

    // when the document is ready, attach the click events to the A tags
    font.init();

});

