﻿function PageController() {
    this.GlobalNavigation;
    this.SectionNavigation;
    this.Init = function() {

        $(".NewWindow").attr("target", "_blank");
        this.GlobalNavigation = new GlobalNavigation();
        this.GlobalNavigation.Container = $(".NavigationContainer");
        this.GlobalNavigation.Init();

        delete this.Init;
    }
}

function GlobalNavigation() {
    this.Container;
    this.Init = function() {
        var navigationDropDownMenu = this;
        this.Container.find(".GlobalNavigationLink").each(function() {
            $(this).hover
                (
                    function() { navigationDropDownMenu.HoverIn($(this)); },
                    function() { navigationDropDownMenu.HoverOut($(this)); }
                );
        });
        delete this.Init;
    }
    this.HoverIn = function(sender) {

        var css = {
            display: "block",
            top: sender.position().top + sender.height() + parseInt(sender.css("padding-top")) + parseInt(sender.css("padding-bottom")),
            left: sender.position().left
        }

        sender.parent().find(".DropDownMenuContainer").css(css)
            .hover(
                function() {
                    sender.addClass("Hover");
                    $(this).css(css);
                },
                function() {
                    sender.removeClass("Hover");
                    $(this).css({ "display": "none" });
                }
            );
    }
    this.HoverOut = function(sender) {
        sender.parent().find(".DropDownMenuContainer").css({ "display": "none" });
    }
}

