Imports Microsoft.VisualBasic
Imports System.Text

Namespace Utilities
    Public Class Javascript

        ' issue 25578
        Private Const cPricingOrderServices As String = "20955"

        Public Shared Function LoginTimeoutScript(ByVal lMinutes As Int32) As String
            Dim sb As StringBuilder = New StringBuilder()
            Dim lSeconds As Int32 = (lMinutes * 60) + 1

            sb.Append("<script language=""JavaScript"" type =""text/javascript"">" & vbCrLf)
            sb.Append("var refreshinterval=" & lSeconds.ToString & ";" & vbCrLf)
            sb.Append("var starttime;" & vbCrLf)
            sb.Append("var nowtime;" & vbCrLf)
            sb.Append("var reloadseconds=0;" & vbCrLf)
            sb.Append("var secondssinceloaded=0;" & vbCrLf)
            sb.Append("function starttime() {" & vbCrLf)
            sb.Append("    starttime=new Date();" & vbCrLf)
            sb.Append("    starttime=starttime.getTime();" & vbCrLf)
            sb.Append("    countdown();" & vbCrLf)
            sb.Append("}" & vbCrLf)
            sb.Append("function countdown() {" & vbCrLf)
            sb.Append("    nowtime= new Date();" & vbCrLf)
            sb.Append("    nowtime=nowtime.getTime();" & vbCrLf)
            sb.Append("    secondssinceloaded=(nowtime-starttime)/1000;" & vbCrLf)
            sb.Append("    reloadseconds=Math.round(refreshinterval-secondssinceloaded);" & vbCrLf)
            sb.Append("    if (refreshinterval>=secondssinceloaded) {" & vbCrLf)
            sb.Append("        var timer=setTimeout('countdown()',1000);" & vbCrLf)
            sb.Append("    }" & vbCrLf)
            sb.Append("    else {" & vbCrLf)
            sb.Append("        clearTimeout(timer);" & vbCrLf)
            sb.Append("        window.location.reload(true);" & vbCrLf)
            sb.Append("    }" & vbCrLf)
            sb.Append("}" & vbCrLf)
            sb.Append("</script>")

            Return sb.ToString
        End Function

        Public Shared Function StartLoginTimeoutScript() As String
            Dim sb As StringBuilder = New StringBuilder()

            sb.Append("<script language=""JavaScript"" type =""text/javascript"">" & vbCrLf)
            sb.Append("starttime();" & vbCrLf)
            sb.Append("</script>")

            Return sb.ToString
        End Function

        Public Shared Function RedirectoURL(ByVal url As String) As String
            Dim sb As StringBuilder = New StringBuilder()

            sb.Append("<script language=""JavaScript"" type =""text/javascript"">" & vbCrLf)
            sb.Append(" setTimeout(""window.location='" + url + "'"", 5000)" & vbCrLf)
            sb.Append("</script>")
            Return sb.ToString
        End Function

        Public Shared Function getQueueID(ByVal strProductInterest As String) As String
            '##############################################################################
            'MODIFICATION   ROD COPELAND    FEB 17, 2009    ISSUE ID: 8210
            'ALLOW CHAT DEPARTMENT SELECTIONS TO BE DYNAMICALLY ROUTED TO A SPECIFIC IS 
            'CHAT QUEUE BASED ON DAY, TIME OF DAY, AND PRODUCT INTEREST.  ALLOW FOR 
            'MULTIPLE ROUTING SCHEDULES TO EXIST SO THAT A SELECTION COULD CONCEIVABLY 
            'BE ROUTED TO SEVERAL DIFFERENT QUEUES THROUGHOUT THE DAY.
            '##############################################################################
            If strProductInterest IsNot Nothing Then
                Select Case strProductInterest.Trim().ToLower()
                    Case "cable"
                        Select Case Now.DayOfWeek
                            Case DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday
                                Select Case True
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 0).Ticks
                                        'BETWEEN 12AM AND 12PM
                                        'QUEUE: 20957
                                        Return "20957"
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 1).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 23, 59, 59).Ticks
                                        'BETWEEN 12PM AND 11:59PM
                                        'QUEUE: 20957
                                        Return "20957"
                                End Select

                            Case DayOfWeek.Saturday, DayOfWeek.Sunday
                                Select Case True
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 0).Ticks
                                        'BETWEEN 12AM AND 12PM
                                        'QUEUE: 20957
                                        Return "20957"
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 1).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 23, 59, 59).Ticks
                                        'BETWEEN 12PM AND 11:59PM
                                        'QUEUE: 20957
                                        Return "20957"
                                End Select
                        End Select
                    Case "internet"
                        Select Case Now.DayOfWeek
                            Case DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday
                                Select Case True
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 0).Ticks
                                        'BETWEEN 12AM AND 12PM
                                        'QUEUE: 20956
                                        Return "20956"
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 1).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 23, 59, 59).Ticks
                                        'BETWEEN 12PM AND 11:59PM
                                        'QUEUE: 20956
                                        Return "20956"
                                End Select

                            Case DayOfWeek.Saturday, DayOfWeek.Sunday
                                Select Case True
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 0).Ticks
                                        'BETWEEN 12AM AND 12PM
                                        'QUEUE: 20956
                                        Return "20956"
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 1).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 23, 59, 59).Ticks
                                        'BETWEEN 12PM AND 11:59PM
                                        'QUEUE: 20956
                                        Return "20956"
                                End Select
                        End Select
                    Case "telephone"
                        Select Case Now.DayOfWeek
                            Case DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday
                                Select Case True
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 7, 59, 59).Ticks
                                        'BETWEEN 12AM AND 7:59AM
                                        'QUEUE: 40267
                                        Return "40267"
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 8, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 22, 59, 59).Ticks
                                        'BETWEEN 8AM AND 11PM
                                        'QUEUE: 21175
                                        Return "21175"
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 23, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 23, 59, 59).Ticks
                                        'BETWEEN 11PM AND 11:59PM
                                        'QUEUE: 40267
                                        Return "40267"

                                End Select

                            Case DayOfWeek.Saturday, DayOfWeek.Sunday
                                Select Case True
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 8, 59, 59).Ticks
                                        'BETWEEN 12AM AND 8:59AM
                                        'QUEUE: 40267
                                        Return "40267"
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 9, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 17, 59, 59).Ticks
                                        'BETWEEN 9AM AND 6PM
                                        'QUEUE: 21175
                                        Return "21175"
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 18, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 23, 59, 59).Ticks
                                        'BETWEEN 6PM AND 11:59PM
                                        'QUEUE: 40267
                                        Return "40267"

                                End Select
                        End Select
                    Case "pricing/ordering"
                        Select Case Now.DayOfWeek
                            Case DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday
                                Select Case True
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 0).Ticks
                                        'BETWEEN 12AM AND 12PM
                                        Return cPricingOrderServices
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 1).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 23, 59, 59).Ticks
                                        'BETWEEN 12PM AND 11:59PM
                                        Return cPricingOrderServices
                                End Select

                            Case DayOfWeek.Saturday, DayOfWeek.Sunday
                                Select Case True
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 0).Ticks
                                        'BETWEEN 12AM AND 12PM
                                        Return cPricingOrderServices
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 1).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 23, 59, 59).Ticks
                                        'BETWEEN 12PM AND 11:59PM
                                        Return cPricingOrderServices
                                End Select
                        End Select
                    Case "myaccount"
                        Select Case Now.DayOfWeek
                            Case DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday
                                Select Case True
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 0).Ticks
                                        'BETWEEN 12AM AND 12PM
                                        'QUEUE: 23170
                                        Return "23170"
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 1).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 23, 59, 59).Ticks
                                        'BETWEEN 12PM AND 11:59PM
                                        'QUEUE: 23170
                                        Return "23170"
                                End Select

                            Case DayOfWeek.Saturday, DayOfWeek.Sunday
                                Select Case True
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 0).Ticks
                                        'BETWEEN 12AM AND 12PM
                                        'QUEUE: 23170
                                        Return "23170"
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 1).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 23, 59, 59).Ticks
                                        'BETWEEN 12PM AND 11:59PM
                                        'QUEUE: 23170
                                        Return "23170"
                                End Select
                        End Select
                    Case "billing"
                        Select Case Now.DayOfWeek
                            Case DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday
                                Select Case True
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 0).Ticks
                                        'BETWEEN 12AM AND 12PM
                                        'QUEUE: 23511
                                        Return "23511"
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 1).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 23, 59, 59).Ticks
                                        'BETWEEN 12PM AND 11:59PM
                                        'QUEUE: 23511
                                        Return "23511"
                                End Select

                            Case DayOfWeek.Saturday, DayOfWeek.Sunday
                                Select Case True
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 0).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 0).Ticks
                                        'BETWEEN 12AM AND 12PM
                                        'QUEUE: 23511
                                        Return "23511"
                                    Case Now.Ticks > New DateTime(Now.Year, Now.Month, Now.Day, 12, 0, 1).Ticks AndAlso Now.Ticks < New DateTime(Now.Year, Now.Month, Now.Day, 23, 59, 59).Ticks
                                        'BETWEEN 12PM AND 11:59PM
                                        'QUEUE: 23511
                                        Return "23511"
                                End Select
                        End Select
                    Case "transfer"
                        '-----------------------------------------------------------------------------------------------------
                        ' ISSUE #12742  03-23-2011  JLN
                        '-----------------------------------------------------------------------------------------------------
                        ' Description:  Add new option to chat entry page - Transfer/Change Services.
                        '      Change:  Added new radio button to ChatLive.aspx and AskCharterChatLiveGeneralQuestion.aspx
                        '               pages.  Added "transfer" to this case structure to return corresponding queue-id.
                        '-----------------------------------------------------------------------------------------------------
                        Return "38509"
                End Select
            End If

            Return "20957" 'Default queue value 


        End Function

    End Class



End Namespace
