@using System.Collections.Specialized
@using System.Drawing
@using OurUmbraco.Our
@inherits Umbraco.Web.Macros.PartialViewMacroPage

@{
    @* Get the root of the website *@
    var root = CurrentPage.AncestorOrSelf(1);
    Image avatarImage = null;
    if (Members.IsLoggedIn())
    {
        avatarImage = Utils.GetMemberAvatarImage(Members.GetCurrentMember());
    }
}

<ul>
    @foreach (var page in root.Children.Where("Visible"))
    {
        <li class="@(page.IsAncestorOrSelf(CurrentPage) ? "current" : null)">
            <a href="@page.Url">@page.Name</a>
        </li>
    }

    <li>
        @if (Members.IsLoggedIn() && Members.GetCurrentMember() != null)
        {
            var member = Members.GetCurrentMember();
            <div class="user">
                @Html.Raw(Utils.GetMemberAvatar(member, 75))
                @if (avatarImage != null && (avatarImage.Width < 400 || avatarImage.Height < 400))
                {
                    <span class="notificationCount">1</span>
                }
            </div>
        }
        else
        {
            <a href="/member/login?redirectUrl=@(Server.UrlEncode(Request.Url.AbsolutePath))">Sign in</a><strong> / </strong><a href="/member/Signup">Register</a>
        }
    </li>
</ul>