Imports System
Imports System.Net
Imports System.Data

Partial Class Visitors_ChatLive
    Inherits CharterCMSPage

    Dim chatmapping As String
    Dim orderID As String
    Dim userfname As String = ""
    Dim phoneNum As String = ""
    Dim reformatPhone As String = ""
    Dim mailaddress As String = ""
    Dim userlname As String = ""
    ' issue 25578
    Private Const cPricingOrderServices As String = "20955"

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

        If Not Page.IsPostBack Then
            chatmapping = Request.QueryString("Chattype")
            orderID = Request.QueryString("orderID")
            If (chatmapping IsNot Nothing) Then
                If chatmapping.ToUpper() <> "CHATWINDOW" Then
                    If orderID IsNot Nothing Then
                        'set control values on form
                        fname.Value = Request.QueryString("user")
                        lname.Value = Request.QueryString("lname")
                        phoneNum = Request.QueryString("phone")
                        reformatPhone = Left(phoneNum, 3) & "-" & Mid(phoneNum, 4, 3) & "-" & Right(phoneNum, 4)
                        phone.Value = reformatPhone
                        mailaddress = Request.QueryString("mail")
                        email.Value = mailaddress.Replace(" ", "")
                        'set chat support group/department to 20955 (Pricing/Order Services)
                        rdoPricingOrderServices.Checked = True
                        di.Value = cPricingOrderServices
                        pnlChatSupportGroup.Visible = False
                        pnlNoChatSupportGroup.Visible = True
                    Else
                        'set chat support group and queue number
                        setChatSupportGroupAndQueueNumber()
                    End If
                End If
            End If
            If Request.QueryString("u") IsNot Nothing Then
                fname.Value = Request.QueryString("u")
            End If
            If Request.QueryString("ln") IsNot Nothing Then
                lname.Value = Request.QueryString("ln")
            End If
            If Request.QueryString("m") IsNot Nothing Then
                email.Value = Request.QueryString("m")
            End If
            If Request.QueryString("p") IsNot Nothing Then
                phone.Value = Request.QueryString("p")
            End If
            If Request.QueryString("d") IsNot Nothing Then
                di.Value = Request.QueryString("d")
                setChatSupportGroup(Request.QueryString("d"))
            End If

            '###############################
            ' show two different 'intro' panels based on whether 
            ' an ORDER ID came across....
            '###############################

            If Request.QueryString("o") Is Nothing Then
                pnlOrderVerbiage.Visible = False
                pnlRegularVerbiage.Visible = True
                optionaldata.Value = orderID
            Else
                pnlOrderVerbiage.Visible = True
                pnlRegularVerbiage.Visible = False
                optionaldata.Value = Request.QueryString("o")
            End If

        End If

    End Sub

    Private Sub setChatSupportGroupAndQueueNumber()

        Select Case chatmapping.ToUpper()
            Case Is = "Q_21175"
                rdoTelephone.Checked = True
                di.Value = "21175"
            Case Is = "Q_20956"
                rdoInternet.Checked = True
                di.Value = "20956"
            Case Is = "Q_21193"
                rdoCable.Checked = True
                di.Value = "21193"
                pnlChatSupportGroup.Visible = False
                pnlNoChatSupportGroup.Visible = True
            Case Is = "Q_21853"
                rdoPricingOrderServices.Checked = True
                di.Value = cPricingOrderServices
                pnlChatSupportGroup.Visible = False
                pnlNoChatSupportGroup.Visible = True
            Case Is = "Q_20957"
                rdoCable.Checked = True
                di.Value = "20957"
            Case Is = "Q_22753"
                rdoMyAccount.Checked = True
                di.Value = "22753"
            Case Is = "Q_23170"
                rdoMyAccount.Checked = True
                di.Value = "23170"
            Case Is = "SALES_Q_21790"
                rdoCable.Checked = True
                di.Value = "21790"
                pnlChatSupportGroup.Visible = False
                pnlNoChatSupportGroup.Visible = True
            Case Is = "SALES_Q_21791"
                rdoInternet.Checked = True
                di.Value = "21791"
                pnlChatSupportGroup.Visible = False
                pnlNoChatSupportGroup.Visible = True
            Case Is = "SALES_Q_21792"
                rdoTelephone.Checked = True
                di.Value = "21792"
                pnlChatSupportGroup.Visible = False
                pnlNoChatSupportGroup.Visible = True
            Case Is = "SALES_Q_21853"
                rdoPricingOrderServices.Checked = True
                di.Value = cPricingOrderServices
                pnlChatSupportGroup.Visible = False
                pnlNoChatSupportGroup.Visible = True
            Case Is = "SALES"
                rdoPricingOrderServices.Checked = True
                di.Value = cPricingOrderServices
                pnlChatSupportGroup.Visible = False
                pnlNoChatSupportGroup.Visible = True
            Case Is = "DIGCABLE"
                rdoCable.Checked = True
                di.Value = "20957"
            Case Is = "HSI"
                rdoInternet.Checked = True
                di.Value = "20956"
            Case Is = "TELEPHONE"
                rdoTelephone.Checked = True
                di.Value = "21175"
            Case Is = "BILLING"
                rdoBillingInquiries.Checked = True
                di.Value = "23511"
            Case Is = "Q_23511"
                rdoBillingInquiries.Checked = True
                di.Value = "23511"
'            Case Is = "Q_38509"
'                '-----------------------------------------------------------------------------------------------------
'                ' ISSUE #12742  03-23-2011  JLN
'                '-----------------------------------------------------------------------------------------------------
'                ' Description:  Add new option to chat entry page - Transfer/Change Services.
'                '      Change:  Added new radio button (rdoTransfer) to page.  Added "chattype=Q_38509" querystring
'                '               option to this case structure to pre-select corresponding queue-id.
'                '-----------------------------------------------------------------------------------------------------
'                rdoTransfer.Checked = True
'                di.Value = "38509"
            Case Else
                rdoCable.Checked = True
                di.Value = "20957"
        End Select

    End Sub

    Private Sub setChatSupportGroup(ByVal departmentNumber As String)
        Select Case departmentNumber
            Case Is = "26240" 'Diana O - cust care requested this addition under issue ID 6400  6/12/2009   Rod Copeland
                rdoCable.Checked = True
                '############################################
                rdoBillingInquiries.Disabled = True
                rdoInternet.Disabled = True
                rdoMyAccount.Disabled = True
                rdoPricingOrderServices.Disabled = True
                rdoTelephone.Disabled = True
                '############################################
            Case Is = "20933" 'Diana O - cust care requested this addition under issue ID 6400  6/12/2009   Rod Copeland
                rdoInternet.Checked = True
            Case Is = "21102" 'Diana O - cust care requested this addition under issue ID 6400  6/12/2009   Rod Copeland
                rdoTelephone.Checked = True
            Case Is = "20932" 'Diana O - cust care requested this addition under issue ID 6400  6/12/2009   Rod Copeland
                rdoPricingOrderServices.Checked = True
            Case Is = "20935" 'Diana O - cust care requested this addition under issue ID 6400  6/12/2009   Rod Copeland
                rdoBillingInquiries.Checked = True
            Case Is = "21175"
                rdoTelephone.Checked = True
            Case Is = "20956"
                rdoInternet.Checked = True
            Case Is = "21193"
                rdoCable.Checked = True
                pnlChatSupportGroup.Visible = False
                pnlNoChatSupportGroup.Visible = True
            Case Is = cPricingOrderServices
                rdoPricingOrderServices.Checked = True
            Case Is = "23170"
                rdoMyAccount.Checked = True
            Case Is = "23511"
                rdoBillingInquiries.Checked = True
            Case Is = "21790"
                rdoCable.Checked = True
                pnlChatSupportGroup.Visible = False
                pnlNoChatSupportGroup.Visible = True
            Case Is = "21791"
                rdoInternet.Checked = True
                pnlChatSupportGroup.Visible = False
                pnlNoChatSupportGroup.Visible = True
            Case Is = "21792"
                rdoTelephone.Checked = True
                pnlChatSupportGroup.Visible = False
                pnlNoChatSupportGroup.Visible = True
'            Case Is = "38509"
'                '-----------------------------------------------------------------------------------------------------
'                ' ISSUE #12742  03-23-2011  JLN
'                '-----------------------------------------------------------------------------------------------------
'                ' Description:  Add new option to chat entry page - Transfer/Change Services.
'                '      Change:  Added new radio button (rdoTransfer) to page.  Added "d=38509" querystring option
'                '               to this case structure to pre-select corresponding queue-id.
'                '-----------------------------------------------------------------------------------------------------
'                rdoTransfer.Checked = True
            Case Else
                rdoCable.Checked = True
        End Select

    End Sub

End Class