/*
 * fontSizeController - 
 */

function FontSizeController() {
    this._currentFont = "mediumFont";
}

FontSizeController.prototype = {
    getBody: function() {
        return $($("body").get(0));
    },

    setFont: function(font) {
        var pageBody = this.getBody();
        if (pageBody.hasClass(this._currentFont)) pageBody.removeClass(this._currentFont);
        pageBody.addClass(font);
        this._currentFont = font;
    },

    increaseFont: function() {
        var pageBody = this.getBody();
        if (pageBody.hasClass("smallestFont")) this.setFont("smallerFont");
        else if (pageBody.hasClass("smallerFont")) this.setFont("smallFont");
        else if (pageBody.hasClass("smallFont")) this.setFont("mediumFont");
        else if (pageBody.hasClass("mediumFont")) this.setFont("largeFont");
        else if (pageBody.hasClass("largeFont")) this.setFont("largerFont");
        else if (pageBody.hasClass("largerFont")) this.setFont("largestFont");
        else this.setFont("largeFont");
    },

    decreaseFont: function() {
        var pageBody = this.getBody();

        if (pageBody.hasClass("smallerFont")) this.setFont("smallestFont");
        else if (pageBody.hasClass("smallFont")) this.setFont("smallerFont");
        else if (pageBody.hasClass("mediumFont")) this.setFont("smallFont");
        else if (pageBody.hasClass("largeFont")) this.setFont("mediumFont");
        else if (pageBody.hasClass("largerFont")) this.setFont("largeFont");
        else if (pageBody.hasClass("largestFont")) this.setFont("largerFont");
        else this.setFont("smallFont");
    }
}

$(document).ready(function() {
    var fontSizeController = new FontSizeController();

    $(".smallestFont").click(function() { fontSizeController.setFont("smallestFont"); });
    $(".smallerFont").click(function() { fontSizeController.setFont("smallerFont"); });
    $(".smallFont").click(function() { fontSizeController.setFont("smallFont"); });
    $(".mediumFont").click(function() { fontSizeController.setFont("mediumFont"); });
    $(".largeFont").click(function() { fontSizeController.setFont("largeFont"); });
    $(".largerFont").click(function() { fontSizeController.setFont("largerFont"); });
    $(".largestFont").click(function() { fontSizeController.setFont("largestFont"); });
    $(".increaseFont").click(function() { fontSizeController.increaseFont(); });
    $(".decreaseFont").click(function() { fontSizeController.decreaseFont(); });
});

