var TOT = function() {
    this._aryNavItems = [];
    this.IE7 = false;
    this.IE8 = false;
    this.IE9 = false;
    this.Animate = {
        FadeSpeed: 500
        , FadeOutOpacity: 0.75
    };
};

TOT.prototype = {

    init: function() {
        this.repositionBG();
        this.checkBrowser();
        $(window).bind("resize", null, $.proxy(this, "repositionBG"));
        $(".topNavItem").each(function(i) {
            $TOT._aryNavItems[i] = $(this).context.id;
        });
        for (var i = 0, l = this._aryNavItems.length; i < l; i++) {
            $("#" + this._aryNavItems[i]).bind("mouseover", null, $.proxy(this, "navMouseOver"));
            $("#" + this._aryNavItems[i]).bind("mouseout", null, $.proxy(this, "navMouseOut"));
        }
        this.updateCopyrightYear();
    },

    dispose: function() {
        if (this._aryNavItems) {
            for (var i = 0, l = this._aryNavItems.length; i < l; i++) {
                $("#" + this._aryNavItems[i]).unbind();
            }
        }
        $(window).unbind();
        this._aryNavItems = null;
    },
    
    checkBrowser: function() {
        if ($.browser.msie) {
            var intVersion = 0;
            try { intVersion = parseInt($.browser.version, 10); } catch (e) { intVersion = 0; }
            if (intVersion == 7) this.IE7 = true;
            if (intVersion == 8) this.IE8 = true;
            if (intVersion == 9) this.IE9 = true;
        }
    },

    repositionBG: function() {
        $("body").height($(document).height() - 15);
        $("#divFade").height($(document).height());
        $("#divFade").width($(window).width());
    },

    navMouseOver: function(e) {
        if ($("#" + e.currentTarget.id).attr("class").indexOf("topNavItemSelected") >= 0) return;
        var img = $("#" + e.currentTarget.id).find("img");
        var src = img.attr("src");
        if (src.indexOf("_s.gif" < 0) && src.indexOf("_x.gif" < 0)) img.attr("src", src.replace(".gif", "_x.gif"));
    },

    navMouseOut: function(e) {
        var img = $("#" + e.currentTarget.id).find("img");
        var src = img.attr("src");
        if (src.indexOf("_x.gif" >= 0)) img.attr("src", src.replace("_x.gif", ".gif"));
    },

    updateCopyrightYear: function() {
        var dtm = new Date();
        $("#spnCopyrightYear").html(dtm.getFullYear().toString().substr(2, 2));
        dtm = null;
    }

};
