Imports CharterDotCom.CommonEntities.Library.Enumerations
Imports CharterDotCom.WebSite.Library
Imports CharterDotCom.CommonEntities.Library
' Imports CharterDotCom.Common.Logging

Partial Class Visitors_ProductLanding
    Inherits CharterCMSPage

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        Try
            If Not (Request.QueryString(QueryStringName.MenuItem) Is Nothing) Then
                Dim _menuItem As MenuItem
                _menuItem = CType(Request.QueryString(QueryStringName.MenuItem), MenuItem)
                If _menuItem >= MenuItem.menuItem30 Then
                    SetContentKeysMenu30to60(_menuItem)
                Else
                    Select Case _menuItem
                        Case MenuItem.CableTV, MenuItem.CableDVR, MenuItem.CableHD, MenuItem.CableOnDemand, MenuItem.CablePackagesAndChannels, MenuItem.CablePayPerView
                            SetContentKeysCable(_menuItem)
                        Case MenuItem.Internet, MenuItem.InternetHomeNetworking, MenuItem.InternetServices
                            SetContentKeysInternet(_menuItem)
                        Case MenuItem.Telephone, MenuItem.TelephoneFeatures, MenuItem.TelephoneInternationalCallingPlans, MenuItem.TelephoneWorldwide250Plan
                            SetContentKeysTelephone(_menuItem)
                        Case MenuItem.Bundles
                            SetContentKeysBundles(_menuItem)
                        Case Else
                            SetContentKeysCable(_menuItem)
                    End Select
                End If
            ElseIf Not (Request.QueryString(QueryStringName.ProductItem) Is Nothing) Then
                If IsNumeric(Request.QueryString(QueryStringName.ProductItem)) Then
                    Dim _productProductItem As ProductItem
                    _productProductItem = CType(Request.QueryString(QueryStringName.ProductItem), ProductItem)

                    Select Case _productProductItem
                        Case ProductItem.CableTV
                            CustomContent2.ContentKey = "ProductDetail:CableTV:Body"
                        Case ProductItem.BasicCableTV
                            CustomContent2.ContentKey = "ProductDetail:BasicCableTV:Body"
                        Case ProductItem.DigitalCableTV
                            CustomContent2.ContentKey = "ProductDetail:DigitalCableTV:Body"
                        Case ProductItem.HighDefinitionTV
                            CustomContent2.ContentKey = "ProductDetail:HighDefinitionTV:Body"
                        Case ProductItem.DigitalVideoRecorder
                            CustomContent2.ContentKey = "ProductDetail:DigitalVideoRecorder:Body"
                        Case ProductItem.Unspecified
                            CustomContent2.ContentKey = ""
                        Case ProductItem.Internet
                            CustomContent2.ContentKey = ""
                        Case ProductItem.Telephone
                            CustomContent2.ContentKey = "ProductDetail:Telephone:Disclaimer"
                        Case ProductItem.BasicCableTV
                            CustomContent2.ContentKey = ""
                        Case ProductItem.PayPerView
                            CustomContent2.ContentKey = "ProductDetail:PayPerView:Body"     ''
                        Case ProductItem.VideoOnDemand
                            CustomContent2.ContentKey = "ProductDetail:VideoOnDemand:Body"  ''
                        Case ProductItem.InteractiveTV      '=10 moved from bottom
                            CustomContent2.ContentKey = "ProductDetail:InteractiveTV:Body"  ''
                            CustomContent7.Visible = True
                            CustomContent7.ContentKey = "ProductsPage:RightColumn:Announcements"
                        Case ProductItem.Email
                            CustomContent2.ContentKey = ""
                        Case ProductItem.PPV_Programming
                            CustomContent2.ContentKey = ""
                        Case ProductItem.VOD_Programming_Main
                            CustomContent2.ContentKey = "ProductDetail:CableTV:VOD:Main:Body"
                        Case ProductItem.VOD_Programming_Movies
                            CustomContent2.ContentKey = "ProductDetail:CableTV:VOD:Movies:Body"
                        Case ProductItem.VOD_Programming_Free
                            CustomContent2.ContentKey = "ProductDetail:CableTV:VOD:Free:Body"
                        Case ProductItem.VOD_Programming_Premium
                            CustomContent2.ContentKey = "ProductDetail:CableTV:VOD:Premium:Body"
                        Case ProductItem.VOD_Programming_Subscription
                            CustomContent2.ContentKey = "ProductDetail:CableTV:VOD:Subscription:Body"
                    End Select
                    CustomContent1.Visible = False
                    CustomContent2.Visible = True
                Else
                    Dim urlValue As String = Server.UrlEncode(Request.QueryString(QueryStringName.ProductItem)).Replace("-", ":")
                    CustomContent2.ContentKey = urlValue.ToString()
                    CustomContent1.Visible = False
                    CustomContent2.Visible = True
                End If
            End If
        Catch ex As Exception
            Throw New CharterUIException("Neither MenuItem nor ProductItem query string is specified for the Product page.")
        End Try
    End Sub

    Private Sub SetContentKeysCable(ByVal _section As MenuItem)

        Select Case _section
            Case MenuItem.CableTV
                'Cable / Special Offers
                'TODO: specify the contentkey
                Me.CustomContent1.ContentKey = "product:cable:promoheroflash"
                Me.CustomContent6.ContentKey = "product:cable:DVR:bottomrightpromotion"
                Me.CustomContent4.ContentKey = "product:cable:DVR:bottomleftpromotion"
                Me.CustomContent5.ContentKey = "product:cable:programmingflash"
            Case MenuItem.CablePackagesAndChannels
                'Cable / Cable Packages & Channels
                'TODO: specify the contentkey
                Me.CustomContent1.ContentKey = "product:cable:packagesheroflash"
                Me.CustomContent6.ContentKey = "product:cable:pkgschannels:bottomrightpromotion"
                Me.CustomContent4.ContentKey = "product:cable:DVR:bottomleftpromotion"
                Me.CustomContent5.ContentKey = "product:cable:programmingflash"
            Case MenuItem.CableOnDemand
                'Cable / OnDemand
                'TODO: specify the contentkey
                Me.CustomContent1.ContentKey = "product:cable:ondemandheroflash"
                Me.CustomContent6.ContentKey = "product:cable:OnDemand:bottomrightpromotion"
                Me.CustomContent4.ContentKey = "product:cable:DVR:bottomleftpromotion"
                Me.CustomContent5.ContentKey = "product:cable:programmingflash"
            Case MenuItem.CablePayPerView
                'Cable / Pay Per View 
                'TODO: specify the contentkey
                Me.CustomContent1.ContentKey = "product:cable:payperviewheroflash"
                Me.CustomContent6.ContentKey = "product:cable:PayPerView:bottomrightpromotion"
                Me.CustomContent4.ContentKey = "product:cable:DVR:bottomleftpromotion"
                Me.CustomContent5.ContentKey = "product:cable:programmingflash"
            Case MenuItem.CableDVR
                'Cable / DVR
                Me.CustomContent1.ContentKey = "product:cable:DVR:MiddleLeft"
                Me.CustomContent6.ContentKey = "product:cable:DVR:bottomrightpromotion"
                Me.CustomContent5.ContentKey = "product:cable:programmingflash"
                Me.CustomContent4.ContentKey = "product:cable:DVR:bottomleftpromotion"
            Case MenuItem.CableHD
                'Cable / HD
                Me.CustomContent1.ContentKey = "product:cable:HD:MiddleLeft"
                Me.CustomContent4.ContentKey = "product:cable:HD:bottomleftpromotion"
                Me.CustomContent5.ContentKey = "product:cable:programmingflash"
                Me.CustomContent6.ContentKey = "product:cable:HD:bottomrightpromotion"
            Case Else
                'Cable / Special Offers
                'TODO: specify the contentkey
                Me.CustomContent1.ContentKey = "product:cable:promoheroflash"
                Me.CustomContent4.ContentKey = "product:cable:DVR:bottomleftpromotion"
                Me.CustomContent5.ContentKey = "product:cable:programmingflash"
                Me.CustomContent6.ContentKey = "product:cable:DVR:bottomrightpromotion"
        End Select

    End Sub

    Private Sub SetContentKeysMenu30to60(ByVal _section As MenuItem)
        'This routine is to show the future static content pages for menuitem 30 and 60
        Dim contentKey As String = "product:" & _section.ToString().Trim()

        Me.leftTopCont.Visible = False
        Me.leftBotCont.Visible = False
        Me.litMenuItem30to60.Visible = True

        If _section >= MenuItem.menuItem30 And _section <= MenuItem.menuItem60 Then
            GetCMSContent(contentKey, Me.litMenuItem30to60)
            Me.CustomContent5.ContentKey = "product:internet:sploffers:CustomersSaying"
            Me.CustomContent6.ContentKey = "product:internet:sploffers:bottomRightPromotion"
        End If

    End Sub

    Private Sub SetContentKeysInternet(ByVal _section As MenuItem)
        Select Case _section
            Case MenuItem.Internet
                'Internet / Special Offers
                Me.CustomContent1.ContentKey = "product:internet:offersheroflash"
                Me.CustomContent4.ContentKey = "product:internet:sploffers:bottomLeftPromotion"
                Me.CustomContent5.ContentKey = "product:internet:sploffers:CustomersSaying"
                Me.CustomContent6.ContentKey = "product:internet:sploffers:bottomRightPromotion"
            Case MenuItem.InternetServices
                'Internet / Internet Services
                Me.CustomContent1.ContentKey = "product:internet:servicesheroflash"
                Me.CustomContent4.ContentKey = "product:internet:services:bottomLeftPromotion"
                Me.CustomContent5.ContentKey = "product:internet:services:CustomersSaying"
                Me.CustomContent6.ContentKey = "product:internet:services:bottomRightPromotion"
            Case MenuItem.InternetHomeNetworking
                'Internet / Home Networking
                Me.CustomContent1.ContentKey = "product:internet:homenetwork:HomeNetworking"
                Me.CustomContent4.ContentKey = "product:internet:homenetwork:bottomLeftPromotion"
                Me.CustomContent5.ContentKey = "product:internet:homenetwork:CustomersSaying"
                Me.CustomContent6.ContentKey = "product:internet:homenetwork:bottomRightPromotion"
            Case Else
                'Internet / Special Offers
                Me.CustomContent1.ContentKey = "product:internet:offersheroflash"
                Me.CustomContent4.ContentKey = "product:internet:sploffers:bottomLeftPromotion"
                Me.CustomContent5.ContentKey = "product:internet:sploffers:CustomersSaying"
                Me.CustomContent6.ContentKey = "product:internet:sploffers:bottomRightPromotion"

        End Select
    End Sub

    Private Sub GetCMSContent(ByVal userControlName As String, ByRef literalControl As Literal)
        Dim cmsContent As String = String.Empty
        cmsContent = ContentManager.Instance.GetContent(userControlName, "1", OwnerType.Other)
        If Not (cmsContent Is Nothing) Then
            literalControl.Text = cmsContent
        Else
            literalControl.Text = "content not found: " & userControlName
        End If
    End Sub

    Private Sub SetContentKeysTelephone(ByVal _section As MenuItem)

        Select Case _section
            Case MenuItem.Telephone
                'Phone / Special Offers
                'TODO: specify the contentkey
                Me.CustomContent1.ContentKey = "product:telephone:offersheroflash"
                Me.CustomContent4.ContentKey = "product:phone:sploffers:bottomLeftPromotion"
                Me.CustomContent5.ContentKey = "product:phone:sploffers:customerssaying"
                Me.CustomContent6.ContentKey = "product:phone:sploffers:bottomRightPromotion"
            Case MenuItem.TelephoneFeatures
                'Phone / Features
                Me.CustomContent1.ContentKey = "product:phone:features:Features"
                Me.CustomContent4.ContentKey = "product:phone:features:bottomLeftPromotion"
                Me.CustomContent5.ContentKey = "product:phone:features:CustomersSaying"
                Me.CustomContent6.ContentKey = "product:phone:features:bottomRightPromotion"
            Case MenuItem.TelephoneInternationalCallingPlans
                'Phone / International Calling Plans
                Me.CustomContent1.ContentKey = "product:telephone:intlcallingheroflash"
                Me.CustomContent4.ContentKey = "product:phone:intlcallplans:bottomLeftPromotion"
                Me.CustomContent5.ContentKey = "product:phone:intlcallplans:CustomersSaying"
                Me.CustomContent6.ContentKey = "product:phone:intlcallplans:bottomRightPromotion"
            Case MenuItem.TelephoneWorldwide250Plan
                'Phone / Worldwide 250 Plan
                Me.CustomContent1.ContentKey = "product:telephone:ww250heroflash"
                Me.CustomContent4.ContentKey = "product:phone:world250plan:bottomLeftPromotion"
                Me.CustomContent5.ContentKey = "product:phone:world250plan:CustomersSaying"
                Me.CustomContent6.ContentKey = "product:phone:world250plan:bottomRightPromotion"
            Case Else
                'Phone / Special Offers
                'TODO: specify the contentkey
                Me.CustomContent1.ContentKey = "product:telephone:offersheroflash"
                Me.CustomContent4.ContentKey = "product:phone:sploffers:bottomLeftPromotion"
                Me.CustomContent5.ContentKey = "product:phone:sploffers:CustomersSaying"
                Me.CustomContent6.ContentKey = "product:phone:sploffers:bottomRightPromotion"
        End Select
    End Sub

    Private Sub SetContentKeysBundles(ByVal _section As MenuItem)
        Select Case _section
            Case MenuItem.Bundles
                'Bundles / Special Offers
                Me.CustomContent1.ContentKey = "product:bundles:offersheroflash"
                Me.CustomContent4.ContentKey = "product:bundles:sploffers:bottomLeftPromotion"
                Me.CustomContent5.ContentKey = "product:bundles:sploffers:CustomersSaying"
                Me.CustomContent6.ContentKey = "product:bundles:sploffers:bottomRightPromotion"
            Case Else
                'Bundles / Special Offers
                Me.CustomContent1.ContentKey = "product:bundles:offersheroflash"
                Me.CustomContent4.ContentKey = "product:bundles:sploffers:bottomLeftPromotion"
                Me.CustomContent5.ContentKey = "product:bundles:sploffers:CustomersSaying"
                Me.CustomContent6.ContentKey = "product:bundles:sploffers:bottomRightPromotion"
        End Select
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim _menuItem As MenuItem
        Dim _productItem As ProductItem
        Dim _nonProductItem As NonProductItem
        Dim Outputcache As Integer = 0
        Dim masterpage As Home = CType(Me.Master, Home)
        Dim _supportItem As ProductItem = ProductItem.Unspecified

        'Logger.WebLog("\UI\Visitors\Products")

        Try

            If Not IsPostBack Then
                _menuItem = MenuItem.Unspecified
                _productItem = ProductItem.Unspecified
                _nonProductItem = NonProductItem.Unspecified

                If Not (Request.QueryString(QueryStringName.MenuItem) Is Nothing) Then
                    _menuItem = CType(Request.QueryString(QueryStringName.MenuItem), MenuItem)

                    Select Case _menuItem
                        Case MenuItem.CableTV
                            MyBase.SetTemplate(8)
                            _productItem = ProductItem.CableTV
                            _supportItem = _productItem
                            Outputcache = 1
                        Case MenuItem.Internet
                            MyBase.SetTemplate(9)
                            _productItem = ProductItem.Internet
                            _supportItem = _productItem
                            Outputcache = 2
                        Case MenuItem.Telephone
                            MyBase.SetTemplate(10)
                            _productItem = ProductItem.Telephone
                            _supportItem = _productItem
                            Outputcache = 3
                    End Select

                ElseIf Not (Request.QueryString(QueryStringName.ProductItem) Is Nothing) Then
                    _productItem = CType(Request.QueryString(QueryStringName.ProductItem), ProductItem)
                    _supportItem = _productItem

                    Select Case _productItem
                        Case ProductItem.CableTV, ProductItem.BasicCableTV, ProductItem.DigitalCableTV, ProductItem.HighDefinitionTV, ProductItem.DigitalVideoRecorder
                            _menuItem = MenuItem.CableTV
                            MyBase.SetTemplate(8)
                            Outputcache = 1
                        Case ProductItem.PayPerView, ProductItem.VideoOnDemand, ProductItem.InteractiveTV
                            _menuItem = MenuItem.CableTV
                            MyBase.SetTemplate(8)
                            Outputcache = 1
                        Case ProductItem.Internet
                            MyBase.SetTemplate(9)
                            _menuItem = MenuItem.Internet
                            Outputcache = 2
                        Case ProductItem.Telephone
                            MyBase.SetTemplate(10)
                            _menuItem = MenuItem.Telephone
                            'ucPhonePortability.Visible = True
                            ''ucPhonePortabilityFootNote.Visible = True
                            'ucTelephoneDisclaimer.Visible = True
                            Outputcache = 3
                        Case ProductItem.VOD_Programming_Main
                            _menuItem = MenuItem.CableTV
                            MyBase.SetTemplate(21)
                            Outputcache = 1
                            masterpage.HBXMLC = "/products/cabletv/digitalcable/vod/"
                            masterpage.HBXPageName = "vod programming main"
                            'Me.ucPPVProgrammingMain.Visible = True
                            _supportItem = ProductItem.VideoOnDemand
                        Case ProductItem.VOD_Programming_Movies
                            _menuItem = MenuItem.CableTV
                            MyBase.SetTemplate(22)
                            Outputcache = 1
                            masterpage.HBXMLC = "/products/cabletv/digitalcable/vod/"
                            masterpage.HBXPageName = "vod programming movies"
                            'Me.ucPPVProgrammingMovies.Visible = True
                            _supportItem = ProductItem.VideoOnDemand
                        Case ProductItem.VOD_Programming_Free
                            _menuItem = MenuItem.CableTV
                            MyBase.SetTemplate(23)
                            Outputcache = 1
                            masterpage.HBXMLC = "/products/cabletv/digitalcable/vod/"
                            masterpage.HBXPageName = "vod programming free"
                            'Me.ucPPVProgrammingFree.Visible = True
                            _supportItem = ProductItem.VideoOnDemand
                        Case ProductItem.VOD_Programming_Premium
                            _menuItem = MenuItem.CableTV
                            MyBase.SetTemplate(24)
                            Outputcache = 1
                            masterpage.HBXMLC = "/products/cabletv/digitalcable/vod/"
                            masterpage.HBXPageName = "vod programming premium"
                            'Me.ucPPVProgrammingPremium.Visible = True
                            _supportItem = ProductItem.VideoOnDemand
                        Case ProductItem.VOD_Programming_Subscription
                            _menuItem = MenuItem.CableTV
                            MyBase.SetTemplate(25)
                            Outputcache = 1
                            masterpage.HBXMLC = "/products/cabletv/digitalcable/vod/"
                            masterpage.HBXPageName = "vod programming subscription"
                            'Me.ucPPVProgrammingSubscription.Visible = True
                            _supportItem = ProductItem.VideoOnDemand
                        Case ProductItem.PPV_Programming
                            _menuItem = MenuItem.CableTV
                            MyBase.SetTemplate(26)
                            Outputcache = 1
                            masterpage.HBXMLC = "/products/cabletv/digitalcable/ppv/"
                            masterpage.HBXPageName = "ppv programming"
                            'Me.ucPPVProgramming.Visible = True
                            _supportItem = ProductItem.PayPerView
                    End Select
                Else
                    Throw New CharterUIException("Neither MenuItem nor ProductItem query string is specified for the Product page.")
                End If
            End If


            Dim d As DateTime = CachedControls.getExpireDate()
            Select Case Outputcache
                Case 1
                    If HttpContext.Current.Cache.Item("Template8") Is Nothing Then
                        HttpContext.Current.Cache.Insert("Template8", DateTime.Now, Nothing, d, System.TimeSpan.Zero, System.Web.Caching.CacheItemPriority.NotRemovable, Nothing)
                    End If
                    Response.AddCacheItemDependency("Template8")
                    If Application(Request.Url.LocalPath) Is Nothing Then
                        Application.Add(Request.Url.LocalPath, "Template8")
                    End If
                Case 2
                    If HttpContext.Current.Cache.Item("Template9") Is Nothing Then
                        HttpContext.Current.Cache.Insert("Template9", DateTime.Now, Nothing, d, System.TimeSpan.Zero, System.Web.Caching.CacheItemPriority.NotRemovable, Nothing)
                    End If
                    Response.AddCacheItemDependency("Template9")
                    If Application(Request.Url.LocalPath) Is Nothing Then
                        Application.Add(Request.Url.LocalPath, "Template9")
                    End If
                Case 3
                    If HttpContext.Current.Cache.Item("Template10") Is Nothing Then
                        HttpContext.Current.Cache.Insert("Template10", DateTime.Now, Nothing, d, System.TimeSpan.Zero, System.Web.Caching.CacheItemPriority.NotRemovable, Nothing)
                    End If
                    Response.AddCacheItemDependency("Template10")
                    If Application(Request.Url.LocalPath) Is Nothing Then
                        Application.Add(Request.Url.LocalPath, "Template10")
                    End If
                Case Else
                    Response.AddCacheItemDependency(CacheKey.OutputCacheDurationKey)
            End Select


            '#############################################################################
            'MODIFICATION   ROD COPELAND    MARCH 25, 2008
            'THIS CHANGE WAS ADDED TO SHOW THE ANNOUNCEMENTS CONTENT ONLY ON THE SPORTS 
            'PROGRAMMING/INTERACTIVE TV PAGE.
            ' Moved to top - naqib 
            ''#############################################################################
            'Select Case True
            '    Case Request.Url.ToString().ToLower().Contains("visitors/products.aspx?productitem=10")
            '        CustomContent7.Visible = True
            '        CustomContent7.ContentKey = "ProductsPage:RightColumn:Announcements"
            'End Select

        Catch ex As Exception
            Throw New CharterUIException("Neither MenuItem nor ProductItem query string is specified for the Product page.")
        End Try
    End Sub

End Class
