Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Initialize()

        If _NotifyText <> "" Then
            Dim iTime As Int16 = 5
            ajax.ResponseScripts.Add("ShowNotify('" & _NotifyText & "', " & iTime & ", 0);")
            _NotifyText = ""
        End If

        DetectPage()

    End Sub

#Region "  DETEKOVAT STRANKU  "

    Sub DetectPage()

        Dim sURL As String
        sURL = Request.RawUrl
        Dim bAdresaNalezena As Boolean = False

        cHeader._Titulek("")

        If bAdresaNalezena = False Then Me.Uvodni_strana(sURL, bAdresaNalezena)
        If bAdresaNalezena = False Then Me.Aktuality(sURL, bAdresaNalezena)
        If bAdresaNalezena = False Then Me.Projekty(sURL, bAdresaNalezena)
        If bAdresaNalezena = False Then Me.Sluzby(sURL, bAdresaNalezena)
        If bAdresaNalezena = False Then Me.Onas(sURL, bAdresaNalezena)
        If bAdresaNalezena = False Then Me.Kontakt(sURL, bAdresaNalezena)
        If bAdresaNalezena = False Then Me.Nastaveni(sURL, bAdresaNalezena)
        If bAdresaNalezena = False Then Me.Systemove_adresy(sURL, bAdresaNalezena)

        If bAdresaNalezena = False Then  '# STRANKA NENI NALEZENA

            Response.Redirect(gadrUvodniStrana)

        End If

    End Sub

#End Region

#Region "  UVODNI STRANA  "

    Sub Uvodni_strana(sURL As String, ByRef bAdresaNalezena As Boolean)

        If sURL = gadrUvodniStrana Then

            gTopMenuSelected = _TopMenu.UvodniStrana : gSubMenuSelected = _SubMenu.UvodniStrana_Zaznam
            Dim ctrl As UvodniStrana_Zaznam = CType(LoadControl("~\Pages\Uvodni-strana\Zaznam.ascx"), UvodniStrana_Zaznam)
            frmMain.DefaultButton = "ctl00$cmdSave"
            phContent.Controls.Add(ctrl)
            cTitle._Nadpis("Úvodní strana")
            bAdresaNalezena = True

        ElseIf sURL = gadrUvodniStrana_slider Then

            gTopMenuSelected = _TopMenu.UvodniStrana : gSubMenuSelected = _SubMenu.UvodniStrana_Slider
            Dim ctrl As UvodniStrana_Slider_Seznam = CType(LoadControl("~\Pages\Uvodni-strana\Slider.ascx"), UvodniStrana_Slider_Seznam)
            phContent.Controls.Add(ctrl)
            cTitle._Nadpis("Úvodní strana")
            cTitle._Podnadpis("Slider")
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadrUvodniStrana_slider_upravit) Then

            gTopMenuSelected = _TopMenu.UvodniStrana : gSubMenuSelected = _SubMenu.UvodniStrana_Slider

            Dim ctrl As UvodniStrana_Slider_Upravit = CType(LoadControl("~\Pages\Uvodni-strana\Slider-upravit.ascx"), UvodniStrana_Slider_Upravit)
            ctrl.cTitle = cTitle
            frmMain.DefaultButton = "ctl00$cmdSave"
            phContent.Controls.Add(ctrl)
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadrUvodniStrana_slider_odstranit) Then

            Response.Redirect("/Pages/Uvodni-strana/Slider-odstranit.aspx?id=" & Request.QueryString("id"))

        End If

    End Sub

#End Region

#Region "  AKTUALITY  "

    Sub Aktuality(sURL As String, ByRef bAdresaNalezena As Boolean)

        If sURL = gadrAktuality Then

            gTopMenuSelected = _TopMenu.Aktuality
            Dim ctrl As Aktuality_Seznam = CType(LoadControl("~\Pages\Aktuality\Seznam.ascx"), Aktuality_Seznam)
            phContent.Controls.Add(ctrl)
            cTitle._Nadpis("Aktuality")
            bAdresaNalezena = True
            frmMain.DefaultButton = "ctl00$cmdSave"

        ElseIf sURL.Contains(gadrAktuality_upravit) Then

            gTopMenuSelected = _TopMenu.Aktuality

            Dim ctrl As Aktuality_Upravit = CType(LoadControl("~\Pages\Aktuality\Upravit.ascx"), Aktuality_Upravit)
            ctrl.cTitle = cTitle
            frmMain.DefaultButton = "ctl00$cmdSave"
            phContent.Controls.Add(ctrl)
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadraktuality_foto_upravit) Then

            gTopMenuSelected = _TopMenu.Aktuality

            Dim ctrl As Aktuality_foto_upravit = CType(LoadControl("~\Pages\Aktuality\Foto-upravit.ascx"), Aktuality_foto_upravit)
            ctrl.cTitle = cTitle
            frmMain.DefaultButton = "ctl00$cmdSave"
            phContent.Controls.Add(ctrl)
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadrAktuality_foto_odstranit) Then

            Response.Redirect("/Pages/Aktuality/Foto-odstranit.aspx?kat=" & Request.QueryString("kat") & "&id=" & Request.QueryString("id"))

        ElseIf sURL.Contains(gadrAktuality_odstranit) Then

            Response.Redirect("/Pages/Aktuality/Odstranit.aspx?id=" & Request.QueryString("id"))

        End If

    End Sub

#End Region

#Region "  PROJEKTY  "

    Sub Projekty(sURL As String, ByRef bAdresaNalezena As Boolean)

        If sURL.Contains(gadrProjekty_seznam) Then

            gTopMenuSelected = _TopMenu.Projekty : gSubMenuSelected = _SubMenu.Projekty_zaznamy
            Dim ctrl As Projekty_seznam = CType(LoadControl("~\Pages\Projekty\Seznam.ascx"), Projekty_seznam)
            phContent.Controls.Add(ctrl)
            cTitle._Nadpis("Reference")
            bAdresaNalezena = True
            frmMain.DefaultButton = "ctl00$cmdSave"

        ElseIf sURL.Contains(gadrProjekt_upravit) Then

            gTopMenuSelected = _TopMenu.Projekty : gSubMenuSelected = _SubMenu.Projekty_zaznamy

            Dim ctrl As Projekt_upravit = CType(LoadControl("~\Pages\Projekty\Upravit.ascx"), Projekt_upravit)
            ctrl.cTitle = cTitle
            frmMain.DefaultButton = "ctl00$cmdSave"
            phContent.Controls.Add(ctrl)
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadrProjekt_foto_upravit) Then

            gTopMenuSelected = _TopMenu.Projekty : gSubMenuSelected = _SubMenu.Projekty_zaznamy

            Dim ctrl As Projekty_foto_upravit = CType(LoadControl("~\Pages\Projekty\Foto-upravit.ascx"), Projekty_foto_upravit)
            ctrl.cTitle = cTitle
            frmMain.DefaultButton = "ctl00$cmdSave"
            phContent.Controls.Add(ctrl)
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadrProjekt_foto_odstranit) Then

            Response.Redirect("/Pages/Projekty/Foto-odstranit.aspx?strankaid=" & Request.QueryString("strankaid") & "&blokid=" & Request.QueryString("blokid") & "&id=" & Request.QueryString("id"))


        ElseIf sURL.Contains(gadrProjekt_odstranit) Then

            Response.Redirect("/Pages/Projekty/Odstranit.aspx?kat=" & Request.QueryString("kat") & "&id=" & Request.QueryString("id"))

        ElseIf sURL = gadrProjekty_kategorie_seznam Then

            gTopMenuSelected = _TopMenu.Projekty : gSubMenuSelected = _SubMenu.Projekty_roky
            Dim ctrl As Projekty_kategorie_seznam = CType(LoadControl("~\Pages\Projekty\Rocniky-seznam.ascx"), Projekty_kategorie_seznam)
            phContent.Controls.Add(ctrl)
            cTitle._Nadpis("Reference - kategorie")
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadrProjekty_kategorie_upravit) Then

            gTopMenuSelected = _TopMenu.Projekty : gSubMenuSelected = _SubMenu.Projekty_roky

            Dim ctrl As Projekty_rocnik_upravit = CType(LoadControl("~\Pages\Projekty\Rocnik-upravit.ascx"), Projekty_rocnik_upravit)
            ctrl.cTitle = cTitle
            frmMain.DefaultButton = "ctl00$cmdSave"
            phContent.Controls.Add(ctrl)
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadrProjekty_kategorie_odstranit) Then

            Response.Redirect("/Pages/Projekty/Rocnik-odstranit.aspx?id=" & Request.QueryString("id"))

        End If

    End Sub

#End Region

#Region "  SLUZBY  "

    Sub Sluzby(sURL As String, ByRef bAdresaNalezena As Boolean)

        If sURL = gadrSluzby Then

            gTopMenuSelected = _TopMenu.Sluzby
            Dim ctrl As Sluzby_Seznam = CType(LoadControl("~\Pages\Sluzby\Seznam.ascx"), Sluzby_Seznam)
            phContent.Controls.Add(ctrl)
            cTitle._Nadpis("Služby")
            bAdresaNalezena = True
            frmMain.DefaultButton = "ctl00$cmdSave"

        ElseIf sURL.Contains(gadrSluzby_upravit) Then

            gTopMenuSelected = _TopMenu.Sluzby

            Dim ctrl As Sluzby_Upravit = CType(LoadControl("~\Pages\Sluzby\Upravit.ascx"), Sluzby_Upravit)
            ctrl.cTitle = cTitle
            frmMain.DefaultButton = "ctl00$cmdSave"
            phContent.Controls.Add(ctrl)
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadrSluzby_odstranit) Then

            Response.Redirect("/Pages/Sluzby/Odstranit.aspx?id=" & Request.QueryString("id"))

        End If

    End Sub

#End Region

#Region "  O NAS  "

    Sub Onas(sURL As String, ByRef bAdresaNalezena As Boolean)

        If sURL = gadrOnas Then

            gTopMenuSelected = _TopMenu.Onas
            Dim ctrl As Onas_Seznam = CType(LoadControl("~\Pages\O-nas\Seznam.ascx"), Onas_Seznam)
            phContent.Controls.Add(ctrl)
            cTitle._Nadpis("O nás")
            bAdresaNalezena = True
            frmMain.DefaultButton = "ctl00$cmdSave"

        ElseIf sURL.Contains(gadrOnas_upravit) Then

            gTopMenuSelected = _TopMenu.Onas

            Dim ctrl As Onas_Upravit = CType(LoadControl("~\Pages\O-nas\Upravit.ascx"), Onas_Upravit)
            ctrl.cTitle = cTitle
            frmMain.DefaultButton = "ctl00$cmdSave"
            phContent.Controls.Add(ctrl)
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadrOnas_odstranit) Then

            Response.Redirect("/Pages/O-nas/Odstranit.aspx?id=" & Request.QueryString("id"))

        End If

    End Sub

#End Region

#Region "  KONTAKT  "

    Sub Kontakt(sURL As String, ByRef bAdresaNalezena As Boolean)

        If sURL = gadrKontakt Then

            gTopMenuSelected = _TopMenu.Kontakt : gSubMenuSelected = _SubMenu.Kontakt_kontaktni_udaje
            Dim ctrl As Kontakt_zaznam = CType(LoadControl("~\Pages\Kontakt\Zaznam.ascx"), Kontakt_zaznam)
            phContent.Controls.Add(ctrl)
            cTitle._Nadpis("Kontakt")
            bAdresaNalezena = True
            frmMain.DefaultButton = "ctl00$cmdSave"

        ElseIf sURL = gadrLide_seznam Then

            gTopMenuSelected = _TopMenu.Kontakt : gSubMenuSelected = _SubMenu.Kontakt_lide
            Dim ctrl As Lide_seznam = CType(LoadControl("~\Pages\Kontakt\Lide-seznam.ascx"), Lide_seznam)
            phContent.Controls.Add(ctrl)
            cTitle._Nadpis("Lidé")
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadrLide_upravit) Then

            gTopMenuSelected = _TopMenu.Kontakt : gSubMenuSelected = _SubMenu.Kontakt_lide

            Dim ctrl As Lide_upravit = CType(LoadControl("~\Pages\Kontakt\Lide-upravit.ascx"), Lide_upravit)
            ctrl.cTitle = cTitle
            frmMain.DefaultButton = "ctl00$cmdSave"
            phContent.Controls.Add(ctrl)
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadrLide_nadpis_upravit) Then

            gTopMenuSelected = _TopMenu.Kontakt : gSubMenuSelected = _SubMenu.Kontakt_lide

            Dim ctrl As Lide_nadpis_upravit = CType(LoadControl("~\Pages\Kontakt\Lide-nadpis-upravit.ascx"), Lide_nadpis_upravit)
            ctrl.cTitle = cTitle
            frmMain.DefaultButton = "ctl00$cmdSave"
            phContent.Controls.Add(ctrl)
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadrLide_podnadpis_upravit) Then

            gTopMenuSelected = _TopMenu.Kontakt : gSubMenuSelected = _SubMenu.Kontakt_lide

            Dim ctrl As Lide_podnadpis_upravit = CType(LoadControl("~\Pages\Kontakt\Lide-podnadpis-upravit.ascx"), Lide_podnadpis_upravit)
            ctrl.cTitle = cTitle
            frmMain.DefaultButton = "ctl00$cmdSave"
            phContent.Controls.Add(ctrl)
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadrLide_odstranit) Then

            Response.Redirect("/Pages/Kontakt/Lide-odstranit.aspx?id=" & Request.QueryString("id"))

        End If

    End Sub

#End Region

#Region "  NASTAVENI  "

    Sub Nastaveni(sURL As String, ByRef bAdresaNalezena As Boolean)

        If sURL = gadrNastaveni Then

            gTopMenuSelected = _TopMenu.Nastaveni : gSubMenuSelected = Nothing
            Dim ctrl As Nastaveni = CType(LoadControl("~\Pages\Nastaveni\Zaznam.ascx"), Nastaveni)
            frmMain.DefaultButton = "ctl00$cmdSave"
            phContent.Controls.Add(ctrl)
            cTitle._Nadpis("Nastavení")
            bAdresaNalezena = True

        End If

    End Sub

#End Region

#Region "  SYSTEMOVE ADRESY  "

    Sub Systemove_adresy(sURL As String, ByRef bAdresaNalezena As Boolean)

        If sURL = gadrZpravy Then '# ZPRAVY '''''''''''''''''''''''''''#

            gTopMenuSelected = Nothing
            Dim cZpravy As New PCSolution.PageZpravy
            cZpravy.Zobrazit(phContent)
            cTitle._Nadpis("Zprávy")
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadrUzivatelNastaveni) Then '# NASTAVENI UZIVATELE '''''''''''''''''''''''''''#

            gTopMenuSelected = Nothing
            Dim ctrl As GlobalPage_UzivatelNastaveni = CType(LoadControl("~\Globals\Pages\UzivatelNastaveni.ascx"), GlobalPage_UzivatelNastaveni)
            ctrl.sID = Request.QueryString("id")
            phContent.Controls.Add(ctrl)
            cTitle._Nadpis("Nastavení uživatele")
            bAdresaNalezena = True

        ElseIf sURL = gadrUzivatelSeznam Then '# SEZNAM UZIVATELU'''''''''''''''''''''''''''#

            gTopMenuSelected = Nothing
            Dim cUzivatel As New PCSolution.PageUzivatel
            cUzivatel.SeznamUzivatelu(phContent)
            cTitle._Nadpis("Seznam uživatelů")
            bAdresaNalezena = True

        ElseIf sURL.Contains(gadrUzivatelOdstranit) Then '# ODSTRANIT UZIVATELE'''''''''''''''''''''''''''#

            gTopMenuSelected = Nothing
            Dim cUzivatel As New PCSolution.PageUzivatel
            cUzivatel.OdstranitUzivatele(Request.QueryString("id"), phContent)
            bAdresaNalezena = True

        ElseIf sURL = gadrOdhlasit Then '# ODHLASIT '''''''''''''''''''''''''''#

            _UserID = ""
            _UserName = ""
            _UserRealName = ""

            Response.Redirect(gadrPrihlasit)

        End If

    End Sub

#End Region

End Class