﻿registerNS("Tegud.Menu");

Tegud.Menu.Init = function () {
    var topMenu = $("#SiteMenu");

    if (g_currentPage == "")
        $("#MenuItem_Blog").addClass("Selected");
    else
        $("#MenuItem_" + g_currentPage).addClass("Selected");

    topMenu.children()
            .click(function (e) {
                if (e.target.Name == "a")
                    return;

                $(window).attr("location", $(this).children("a").attr("href"));
            });

    $("#GoToLoginButton").live("click", function () { $(window).attr("location", "/Admin/"); });

    if ($.support.transition)
        return;

    $("#GoToLoginButton")
        .css("opacity", 0.1)
        .live("mouseenter", function () { $(this).stop().animate({ opacity: 1.0 }, 300); })
        .live("mouseleave", function () { $(this).stop().animate({ opacity: 0.1 }, 300); });

    topMenu.children(":not(.Selected)")
        .mouseover(function () {
            var colourBlock = $(this).children(":first");

            colourBlock
                .stop()
                .animate({ height: "2.1em" }, 500);
        })
        .mouseout(function () {
            var colourBlock = $(this).children(":first");

            colourBlock
                .stop()
                .animate({ height: "5px" }, 500);
        });
}
