Imports CharterDotCom.CommonEntities.Library
Imports CharterDotCom.CommonEntities.Library.Enumerations
Imports CharterDotCom.CommonEntities.Library.EntityMemberServices
Imports CharterDotCom.CommonEntities.Library.EntitySupport
Imports CharterDotCom.CommonEntities.Library.EntitySearch
Imports CharterDotCom.CommonEntities.Library.EntityWebConfig
Imports CharterDotCom.CommonEntities.Library.Common
Imports CharterDotCom.WebSite.Library

Partial Class Controls_BrowseSupport
    Inherits System.Web.UI.UserControl
    Private _Category As MenuItem
    Private _isNewPanel As Boolean

    Public Property Productategory() As MenuItem
        Get
            Return _Category
        End Get

        Set(ByVal value As MenuItem)
            _Category = value
        End Set
    End Property

    Public Property isNewPanel() As Boolean
        Get
            Return _isNewPanel
        End Get

        Set(ByVal value As Boolean)
            _isNewPanel = value
        End Set
    End Property

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

        If Not IsPostBack Then

            Select Case True

                Case Request.Url.ToString().ToLower().Contains("order/reportservicetheft.aspx")
                    Me.Productategory = MenuItem.Internet
                Case Request.Url.ToString().ToLower().Contains("account/newkeyactivated.aspx")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("visitors/timeout.aspx")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("order/login.aspx")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("order/register.aspx")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("order/forgot.aspx")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("account/myaccount.aspx")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("order/localize.aspx")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("account/managewebspace.aspx")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("order/localize.aspx")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("account/manageemailaccounts.aspx")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("account/highspeedsecurity.aspx")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("account/managelogin.aspx")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("account/managewebspace.aspx")
                    Me.Productategory = MenuItem.MyAccount

                Case Request.Url.ToString().ToLower().Contains("idtheft/idtheft.aspx")
                    Me.Productategory = MenuItem.MyAccount

                    'JPirkey 3-30-10 Added the RetrieveUsername.aspx
                Case Request.Url.ToString().ToLower().Contains("order/retrieveusername.aspx")
                    Me.Productategory = MenuItem.MyAccount

                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=10")
                    Me.Productategory = MenuItem.Email
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=11")
                    Me.Productategory = MenuItem.Internet
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=61")
                    Me.Productategory = MenuItem.CableTV
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=62")
                    Me.Productategory = MenuItem.CableTV
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=63")
                    Me.Productategory = MenuItem.CableTV
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=64")
                    Me.Productategory = MenuItem.Internet
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=65")
                    Me.Productategory = MenuItem.Internet
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=66")
                    Me.Productategory = MenuItem.Internet
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=67")
                    Me.Productategory = MenuItem.Internet
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=68")
                    Me.Productategory = MenuItem.Internet
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=69")
                    Me.Productategory = MenuItem.Telephone
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=70")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=71")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=72")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=73")
                    Me.Productategory = MenuItem.Internet

                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=74")
                    '---------------------------------------------------------------------
                    ' Issue 10697:  Changed product category default.  JLN, 09/27/2010.
                    '---------------------------------------------------------------------
                    Me.Productategory = MenuItem.Internet
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=75")
                    '---------------------------------------------------------------------
                    ' Issue 10697:  Changed product category default.  JLN, 09/27/2010.
                    '---------------------------------------------------------------------
                    Me.Productategory = MenuItem.MyAccount

                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=76")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=77")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=78")
                    Me.Productategory = MenuItem.MyAccount
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=79")
                    Me.Productategory = MenuItem.Email
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=80")
                    Me.Productategory = MenuItem.Email

                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=2")
                    Me.Productategory = MenuItem.CableTV
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=3")
                    Me.Productategory = MenuItem.Internet
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=4")
                    Me.Productategory = MenuItem.Telephone
                Case Request.Url.ToString().ToLower().Contains("support.aspx?menuitem=8") AndAlso Request.QueryString("MenuItem") = "8"
                    '---------------------------------------------------------------------
                    ' Issue 15934:  Added addtional QueryString check so that case does
                    '               does not also catch MenuItem=8x.  JLN, 11/23/2011.
                    '---------------------------------------------------------------------
                    Me.Productategory = MenuItem.MyAccount

                Case Request.Url.ToString().ToLower().Contains("supportgettingstarted.aspx")
                    Me.Productategory = MenuItem.CableTV
                Case Request.Url.ToString().ToLower().Contains("supportgeneral.aspx?pagetype=3")
                    Me.Productategory = MenuItem.MyAccount

                Case Else
                    'Moved from Support.aspx.vb
                    If Not (Request.QueryString(QueryStringName.NonProductItem) Is Nothing) Then
                        Select Case CType(Request.QueryString(QueryStringName.NonProductItem), NonProductItem)
                            Case NonProductItem.SupportSecurity
                                Me.Productategory = MenuItem.Security
                            Case NonProductItem.SupportDownloads
                                Me.Productategory = MenuItem.Support
                        End Select
                    End If

            End Select

            '#############################################################################
            'M O D I F I C A T I O N   9/24/2007     ROD COPELAND
            '#############################################################################
            'PERFORMANCE CHANGE FOR THIS CONTROL IN THE MYACCOUNT SECTION. RIGHT NOW, IT 
            'LOOKS LIKE THIS CONTROL DOES A REMOTING CALL TO GET CONTENT EVERY TIME 
            'THE PAGE_LOAD IS CALLED, LOOKS TO BE UNNECESSARY. TO RESOLVE THIS ISSUE FOR 
            'THE MOST CRITICAL PLACE THAT DOESNT USE OUTPUT CACHING (THE MYACCOUNT SECTION 
            'AND ALL ITS PERSONALIZATION), DETERMINE IF THIS CONTROL IS BEING USED IN THE 
            'MYACCOUNT AREA, IF SO, THEN USE A CACHED COPY OF THE VALUE RATHER THAN DOING 
            'A REMOTING CALL TO GET THE SAME THING.  THIS LOGIC APPLIES TO MYACCOUNT PAGES 
            'ONLY RIGHT NOW SINCE THE TIME HASN'T BEEN ALLOCATED TO RESEARCH THE IMPLICATIONS 
            'OF CACHING THE CONTROL ALL OVER THE SITE.  THE CURRENT VERSION OF THE CONTROL 
            'IS FOR A GROUP OF USERS, NOT INDIVIDUALS SO, ITS USED IN A APPLICATION VARIABLE 
            'RATHER THAN SESSION.
            '#############################################################################

            Dim contentZone As String
            If isNewPanel Then
                contentZone = "Support:Home:TopRequest:SYCH"
            Else
                contentZone = "TopRequests"
            End If

            Dim requestCategory As String = String.Empty
            Select Case True
                Case Request.Url.ToString().ToLower().Contains("account/myaccount.aspx")
                    If Not (Application(contentZone & Me.Productategory) Is Nothing) Then
                        If Application(contentZone & Me.Productategory) <> "initialvalue" Then
                            '##############################################################
                            'USE THE CACHED VERSION RATHER THAN MAKING A REMOTING CALL OUT.
                            '##############################################################
                            requestCategory = Application(contentZone & Me.Productategory)
                        Else
                            '################################################################
                            'MAKE THE REMOTING CALL AND SET A CACHED VERSION OF THE CONTENT
                            '################################################################
                            Application(contentZone & Me.Productategory) = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                            requestCategory = Application(contentZone & MenuItem.MyAccount)
                        End If
                    Else
                        '################################################################
                        'MAKE THE REMOTING CALL AND SET A CACHED VERSION OF THE CONTENT
                        '################################################################
                        Application(contentZone & Me.Productategory) = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                        requestCategory = Application(contentZone & MenuItem.MyAccount)
                    End If
                Case Request.Url.ToString().ToLower().Contains("account/manageemailaccounts.aspx")
                    If Not (Application(contentZone & Me.Productategory) Is Nothing) Then
                        If Application(contentZone & Me.Productategory) <> "initialvalue" Then
                            '##############################################################
                            'USE THE CACHED VERSION RATHER THAN MAKING A REMOTING CALL OUT.
                            '##############################################################
                            requestCategory = Application(contentZone & Me.Productategory)
                        Else
                            '################################################################
                            'MAKE THE REMOTING CALL AND SET A CACHED VERSION OF THE CONTENT
                            '################################################################
                            Application(contentZone & Me.Productategory) = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                            requestCategory = Application(contentZone & MenuItem.MyAccount)
                        End If
                    Else
                        '################################################################
                        'MAKE THE REMOTING CALL AND SET A CACHED VERSION OF THE CONTENT
                        '################################################################
                        Application(contentZone & Me.Productategory) = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                        requestCategory = Application(contentZone & MenuItem.MyAccount)
                    End If
                Case Request.Url.ToString().ToLower().Contains("account/highspeedsecurity.aspx")
                    If Not (Application(contentZone & Me.Productategory) Is Nothing) Then
                        If Application(contentZone & Me.Productategory) <> "initialvalue" Then
                            '##############################################################
                            'USE THE CACHED VERSION RATHER THAN MAKING A REMOTING CALL OUT.
                            '##############################################################
                            requestCategory = Application(contentZone & Me.Productategory)
                        Else
                            '################################################################
                            'MAKE THE REMOTING CALL AND SET A CACHED VERSION OF THE CONTENT
                            '################################################################
                            Application(contentZone & Me.Productategory) = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                            requestCategory = Application(contentZone & MenuItem.MyAccount)
                        End If
                    Else
                        '################################################################
                        'MAKE THE REMOTING CALL AND SET A CACHED VERSION OF THE CONTENT
                        '################################################################
                        Application(contentZone & Me.Productategory) = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                        requestCategory = Application(contentZone & MenuItem.MyAccount)
                    End If
                Case Request.Url.ToString().ToLower().Contains("account/newkeyactivated.aspx")
                    If Not (Application(contentZone & Me.Productategory) Is Nothing) Then
                        If Application(contentZone & Me.Productategory) <> "initialvalue" Then
                            '##############################################################
                            'USE THE CACHED VERSION RATHER THAN MAKING A REMOTING CALL OUT.
                            '##############################################################
                            requestCategory = Application(contentZone & Me.Productategory)
                        Else
                            '################################################################
                            'MAKE THE REMOTING CALL AND SET A CACHED VERSION OF THE CONTENT
                            '################################################################
                            Application(contentZone & Me.Productategory) = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                            requestCategory = Application(contentZone & MenuItem.MyAccount)
                        End If
                    Else
                        '################################################################
                        'MAKE THE REMOTING CALL AND SET A CACHED VERSION OF THE CONTENT
                        '################################################################
                        Application(contentZone & Me.Productategory) = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                        requestCategory = Application(contentZone & MenuItem.MyAccount)
                    End If
                Case Request.Url.ToString().ToLower().Contains("account/managelogin.aspx")
                    If Not (Application(contentZone & Me.Productategory) Is Nothing) Then
                        If Application(contentZone & Me.Productategory) <> "initialvalue" Then
                            '##############################################################
                            'USE THE CACHED VERSION RATHER THAN MAKING A REMOTING CALL OUT.
                            '##############################################################
                            requestCategory = Application(contentZone & Me.Productategory)
                        Else
                            '################################################################
                            'MAKE THE REMOTING CALL AND SET A CACHED VERSION OF THE CONTENT
                            '################################################################
                            Application(contentZone & Me.Productategory) = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                            requestCategory = Application(contentZone & MenuItem.MyAccount)
                        End If
                    Else
                        '################################################################
                        'MAKE THE REMOTING CALL AND SET A CACHED VERSION OF THE CONTENT
                        '################################################################
                        Application(contentZone & Me.Productategory) = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                        requestCategory = Application(contentZone & MenuItem.MyAccount)
                    End If
                Case Request.Url.ToString().ToLower().Contains("account/internettools.aspx")
                    If Not (Application(contentZone & Me.Productategory) Is Nothing) Then
                        If Application(contentZone & Me.Productategory) <> "initialvalue" Then
                            '##############################################################
                            'USE THE CACHED VERSION RATHER THAN MAKING A REMOTING CALL OUT.
                            '##############################################################
                            requestCategory = Application(contentZone & Me.Productategory)
                        Else
                            '################################################################
                            'MAKE THE REMOTING CALL AND SET A CACHED VERSION OF THE CONTENT
                            '################################################################
                            Application(contentZone & Me.Productategory) = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                            requestCategory = Application(contentZone & MenuItem.MyAccount)
                        End If
                    Else
                        '################################################################
                        'MAKE THE REMOTING CALL AND SET A CACHED VERSION OF THE CONTENT
                        '################################################################
                        Application(contentZone & Me.Productategory) = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                        requestCategory = Application(contentZone & MenuItem.MyAccount)
                    End If
                Case Request.Url.ToString().ToLower().Contains("account/managewebspace.aspx") OrElse _
                     Request.Url.ToString().ToLower().Contains("account/redeemcoupon.aspx")
                    '---------------------------------------------------------------------
                    ' Issue 11612:  Added RedeemCoupon.aspx.  JLN, 11/29/2010.
                    '---------------------------------------------------------------------
                    If Not (Application(contentZone & Me.Productategory) Is Nothing) Then
                        If Application(contentZone & Me.Productategory) <> "initialvalue" Then
                            '##############################################################
                            'USE THE CACHED VERSION RATHER THAN MAKING A REMOTING CALL OUT.
                            '##############################################################
                            requestCategory = Application(contentZone & Me.Productategory)
                        Else
                            '################################################################
                            'MAKE THE REMOTING CALL AND SET A CACHED VERSION OF THE CONTENT
                            '################################################################
                            Application(contentZone & Me.Productategory) = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                            requestCategory = Application(contentZone & MenuItem.MyAccount)
                        End If
                    Else
                        '################################################################
                        'MAKE THE REMOTING CALL AND SET A CACHED VERSION OF THE CONTENT
                        '################################################################
                        Application(contentZone & Me.Productategory) = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                        requestCategory = Application(contentZone & MenuItem.MyAccount)
                    End If


                Case Request.Url.ToString().ToLower().Contains("order/reportservicetheft.aspx")
                    requestCategory = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                Case Request.Url.ToString().ToLower().Contains("order/login.aspx")
                    requestCategory = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                Case Request.Url.ToString().ToLower().Contains("order/retrieveusername.aspx") 'JPirkey: added
                    requestCategory = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                Case Request.Url.ToString().ToLower().Contains("order/register.aspx")
                    requestCategory = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                Case Request.Url.ToString().ToLower().Contains("order/forgot.aspx")
                    requestCategory = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                Case Request.Url.ToString().ToLower().Contains("visitors/timeout.aspx")
                    requestCategory = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                Case Request.Url.ToString().ToLower().Contains("customers/support.aspx")
                    requestCategory = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                Case Request.Url.ToString().ToLower().Contains("order/localize.aspx")
                    requestCategory = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                Case Request.Url.ToString().ToLower().Contains("customers/supportgeneral.aspx")
                    requestCategory = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                Case Request.Url.ToString().ToLower().Contains("customers/contactus.aspx")
                    requestCategory = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                Case Request.Url.ToString().ToLower().Contains("customers/supportgettingstarted.aspx")
                    requestCategory = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                Case Request.Url.ToString().ToLower().Contains("visitors/searchsite.aspx")
                    requestCategory = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)
                Case Request.Url.ToString().ToLower().Contains("customers/searchsupport.aspx")
                    requestCategory = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)

                Case Request.Url.ToString().ToLower().Contains("idtheft/idtheft.aspx")
                    requestCategory = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Other)

                Case Else
                    '#########################################
                    'FOR ANYTHING OTHER THAN MYACCOUNT PAGES.
                    '#########################################
                    requestCategory = ContentManager.Instance.GetContent(contentZone, 1, OwnerType.Bundle)
            End Select
            '#############################################################################

            If isNewPanel Then
                SupportTopRequestWithAskAQuestion.Visible = True
                SupportTopRequestOnly.Visible = False
                ltrContentSupportTopRequestContent.Text = requestCategory
            Else
                SupportTopRequestWithAskAQuestion.Visible = False
                SupportTopRequestOnly.Visible = True
                ltrContent.Text = requestCategory
            End If

        End If

    End Sub

    Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        Try
            Dim scriptblock As New StringBuilder
            Select Case Productategory
                Case MenuItem.CableTV
                    scriptblock.Append("<SCRIPT>")
                    scriptblock.Append("fnDisplay('cable');")
                    scriptblock.Append("fnDisplayHelpfulLinks('cable');")
                    scriptblock.Append("</SCRIPT>")
                Case MenuItem.Telephone
                    scriptblock.Append("<SCRIPT>")
                    scriptblock.Append("fnDisplay('telephone');")
                    scriptblock.Append("fnDisplayHelpfulLinks('telephone');")
                    scriptblock.Append("</SCRIPT>")
                Case MenuItem.Email
                    scriptblock.Append("<SCRIPT>")
                    scriptblock.Append("fnDisplay('email');")
                    scriptblock.Append("fnDisplayHelpfulLinks('email');")
                    scriptblock.Append("</SCRIPT>")
                Case MenuItem.MyAccount
                    scriptblock.Append("<SCRIPT>")
                    scriptblock.Append("fnDisplay('account');")
                    scriptblock.Append("fnDisplayHelpfulLinks('account');")
                    scriptblock.Append("</SCRIPT>")
                Case MenuItem.Security
                    scriptblock.Append("<SCRIPT>")
                    scriptblock.Append("fnDisplay('onlinesecurity');")
                    scriptblock.Append("fnDisplayHelpfulLinks('onlinesecurity');")
                    scriptblock.Append("</SCRIPT>")
                Case MenuItem.Internet
                    scriptblock.Append("<SCRIPT>")
                    scriptblock.Append("fnDisplay('internet');")
                    scriptblock.Append("fnDisplayHelpfulLinks('internet');")
                    scriptblock.Append("</SCRIPT>")
                Case Else
                    scriptblock.Append("<SCRIPT>")
                    scriptblock.Append("fnDisplay('internet');")
                    scriptblock.Append("fnDisplayHelpfulLinks('default');")
                    scriptblock.Append("</SCRIPT>")
            End Select
            Page.ClientScript.RegisterStartupScript(Me.GetType(), "QuickLinksScript", scriptblock.ToString())
            Dim strQuery As String
            If Request.QueryString(QueryStringName.Category) IsNot Nothing Then
                strQuery = Trim(Request.QueryString(QueryStringName.Category))
                scriptblock = New StringBuilder()
                scriptblock.Append("<SCRIPT>")
                scriptblock.Append("fnOpen('" & strQuery.ToLower() & "')")
                scriptblock.Append("</SCRIPT>")
                Page.ClientScript.RegisterStartupScript(Me.GetType(), "CategoryExpandScript", scriptblock.ToString())
            End If
        Catch ex As Exception
        End Try
    End Sub
End Class
