// this will be taken care of in the namespace method in MTCA.js
if (!MTCA) { var MTCA = {}; }
if (!MTCA.components) { MTCA.components = {}; }

MTCA.components.searchButtons = {

    init: function() {
        $("input#button-clear-activities").click(function() {
            $("ul#activities input[type=checkbox]").attr('checked', false);
        });

        $("input#button-select-all-regions").click(function() {
            $("ul#regions input[type=checkbox]").attr('checked', true);
        });


        $("input#button-unselect-all-regions").click(function() {
            $("ul#regions input[type=checkbox]").attr('checked', false);
        });

    }


};

MTCA.components.fontChanger = {

    /** Settings can be overwritten by passing in an options object to this.init() */
    settings: {
        originalFontSize: "11px"
    },

    /**
    * Initializing method that sets all properties and extends any options
    * @param options {Object} Overwrite the default settings with this object.
    */
    init: function(options) {

        $.extend(this.settings, options || {});

        $("#font-plus").click(function() {
            var currentFontSize = $("#content-copy p").css("font-size");
            var currentFontSizeNum = parseFloat(currentFontSize, 10);
            var currentLineHeight = $("#content-copy p").css("line-height");
            var currentLineHeightNum = parseFloat(currentLineHeight, 10);

            var newFontSize = currentFontSizeNum + 1;
            var newLineHeight = currentLineHeightNum + 2;
            $("#content-copy p, #content-copy ul, #content-copy ol").css("font-size", newFontSize + "px");
            $("#content-copy p, #content-copy ul, #content-copy ol").css("line-height", newLineHeight + "px");
            return false;
        });

        $("#font-minus").click(function() {
            var currentFontSize = $("#content-copy p").css("font-size");
            var currentFontSizeNum = parseFloat(currentFontSize, 10);
            var currentLineHeight = $("#content-copy p").css("line-height");
            var currentLineHeightNum = parseFloat(currentLineHeight, 10);


            var newFontSize = currentFontSizeNum - 1;
            var newLineHeight = currentLineHeightNum - 2;
            $("#content-copy p, #content-copy ul, #content-copy ol").css("font-size", newFontSize + "px");
            $("#content-copy p, #content-copy ul, #content-copy ol").css("line-height", newLineHeight + "px");
            return false;
        });
    }

};


MTCA.components.sideNavigationToggle = {

    /** Settings can be overwritten by passing in an options object to this.init() */
    settings: {
        subheaderid: ""
    },

    /**
    * Initializing method that sets all properties and extends any options
    * @param options {Object} Overwrite the default settings with this object.
    */
    init: function(options) {

        this.settings = $.extend({}, this.settings, options);

        if (this.settings.subheaderid) {
            $("#side-navigation h3" + this.settings.subheaderid).next("ul").show();
            $("#side-navigation h3" + this.settings.subheaderid).toggleClass("selected");
        }



    }

};

MTCA.components.menuItemBold = {

    /** Settings can be overwritten by passing in an options object to this.init() */
    settings: {
        pageid: ""
    },

    /**
    * Initializing method that sets all properties and extends any options
    * @param options {Object} Overwrite the default settings with this object.
    */
    init: function() {


       $("#side-navigation a[href='" + location.pathname + "']").css("text-decoration", "underline");

    }

};


MTCA.components.backgroundRotator = {

    /** Settings can be overwritten by passing in an options object to this.init() */
    settings: {
        backgroundCount: 6
    },

    /**
    * Initializing method that sets all properties and extends any options
    * @param options {Object} Overwrite the default settings with this object.
    */
    init: function() {

        var rand = Math.ceil(Math.random() * 5);
        $("body").css("background", "url(/template/images/background-0" + rand + ".jpg) #004B8C");
        $("body").css("background-position", "top left");



    }

};

/** Initialize the component when the DOM is ready */
$(function() {
    MTCA.components.fontChanger.init();
    MTCA.components.searchButtons.init();
    if (typeof subheaderid != "undefined") {
        MTCA.components.sideNavigationToggle.init({ subheaderid: subheaderid });
    }

    MTCA.components.menuItemBold.init();


    MTCA.components.backgroundRotator.init();

});

