    Imports System
    Imports System.Collections
    Imports System.Web.Security
    Imports ASPNET.StarterKit.TimeTracker.BusinessLogicLayer

    Namespace ASPNET.StarterKit.TimeTracker.Web

        ' UserControl that contains the top logo as well as the main navigation tabs
        Public MustInherit Class Banner
            Inherits System.Web.UI.UserControl
            Protected WithEvents LogOff As System.Web.UI.WebControls.LinkButton
            Protected tabs As System.Web.UI.WebControls.DataList

    #Region " Web Form Designer Generated Code "

            'This call is required by the Web Form Designer.
             Private Sub InitializeComponent()

            End Sub

            Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
                'CODEGEN: This method call is required by the Web Form Designer
                'Do not modify it using the code editor.
                InitializeComponent()
            End Sub

    #End Region

            Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                Dim tabItems As New ArrayList()

                If Request.IsAuthenticated Then
                    ' add the Log tab (all users can see this tab)
                    tabItems.Add(New TabItem("Log", "TimeEntry.aspx?index=" & tabItems.Count))
                End If

                'Show log off button if user is form authenticated
                If Context.User.Identity.AuthenticationType Is "Forms" Then
                    LogOff.Visible = True
                End If

                If TTSecurity.IsInRole(TTUser.UserRoleAdminPMgr) Then
                    tabItems.Add(New TabItem("Reports", "Reports.aspx?index=" & tabItems.Count))
                    tabItems.Add(New TabItem("Administration", "ProjectList.aspx?index=" & tabItems.Count))
                End If

                tabs.DataSource = tabItems
                tabs.SelectedIndex = IIf(Request("index") Is Nothing, 0, Convert.ToInt32(Request("index")))
                tabs.DataBind()
            End Sub 'Page_Load

            Private Sub LogOff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LogOff.Click
                FormsAuthentication.SignOut()

                ' Invalidate roles token
                Response.Cookies("userroles").Value = ""
                Response.Cookies("userroles").Path = "/"
                Response.Cookies("userroles").Expires = New System.DateTime(1999, 10, 12)

                Context.User = Nothing
                Response.Redirect("Default.aspx", False)
            End Sub
        End Class 'Banner
    End Namespace 'ASPNET.StarterKit.TimeTracker.Web