/**
 * Main Menu class to handle the main navigation bar related events
 * Refer: http://www.phpied.com/3-ways-to-define-a-javascript-class/
 */
var Menu = {
    /**
     * Initializing the common activities for the page
     */
    init: function() {
        $("#footer_content ul li a").live('click', function(e) {
            var url = $(this).attr('href');
            window.location.href = url;
            window.location.reload();
            $("body").scrollTop(0);
        });

        $("body").scrollTop(0);
    },

    /**
     * Called to select a particular
     * item in the main navigation menu bar
     * @param item      the item to be selected on Main Menu nav bar
     */
    select: function(item) {
        $("li[id=" + item + "]").ready(function(e) {
            $(".nav li#" + item).css("background-position-y", -70);
        });
        $("body").scrollTop(0);
    },

    /**
     * Called to select a particular
     * item in the left navigation menu bar
     * @param item      the item to be selected on Main Menu nav bar
     */
    navSelect: function(item) {
        var itemVal = $("a[id=" + item + "]").text();
        if ($("a[id=" + item + "]").attr('class') == 'small_text') {
            $("a[id=" + item + "]").replaceWith("<span id='" + item + "'" + " class='selected_small_nav_box_item'>" + itemVal + "</span>");
        }
        else {
            $("a[id=" + item + "]").replaceWith("<span id='" + item + "'" + " class='selected_nav_box_item'>" + itemVal + "</span>");
        }

        $("body").scrollTop(0);
    },

    /**
     * Initialize the navigation box links
     */
    navBoxInit: function() {
        $("#nav_box a").live('click', function(e) {
            var itemVal = $("#nav_box ul span").text();
            var id = $("#nav_box ul span").attr('id');
            var klass = $("#nav_box ul span").attr('class');
            if (klass == 'selected_small_nav_box_item') {
                $("#nav_box ul span").replaceWith("<a id=" + id + " href=\"" + id + ".html\" class='small_text' >" + itemVal + "</a>");
            }
            else {
                $("#nav_box ul span").replaceWith("<a id=" + id + " href=\"" + id + ".html\" >" + itemVal + "</a>");
            }

            e.preventDefault();
            $("#nav_content").load($(this).attr('href'));
            Menu.navSelect($(this).attr('id'));
            $(".small_text").css("font-size", 13);
            $(".small_text").css("padding-left", 18);
            $("body").scrollTop(0);
        });
    }

};
