Imports CharterDotCom.CommonEntities.Library.Enumerations
Imports CharterDotCom.WebSite.Library

Partial Class Controls_searchSupport
    Inherits System.Web.UI.UserControl

    Private _SearchMode As SearchMode

    Public Property Mode() As SearchMode
        Get
            Return _SearchMode
        End Get

        Set(ByVal value As SearchMode)
            _SearchMode = value
        End Set
    End Property

    Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        Select Case Mode
            Case SearchMode.SupportAgain
                Me.pnlSite.Visible = False
                Me.pnlSiteAgain.Visible = True
            Case SearchMode.Support
                Me.pnlSite.Visible = True
                Me.pnlSiteAgain.Visible = False
            Case SearchMode.Unspecified
                Me.pnlSite.Visible = False
                Me.pnlSiteAgain.Visible = False
        End Select
    End Sub

    Protected Sub SearchSupport(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgSearch.Click, imgSearchAgain.Click
        Dim q As String = ""
        Select Case Mode
            Case SearchMode.SupportAgain
                q = Me.txtSupportSearchAgain.Value.Trim
            Case Else
                q = Me.txtSupportSearch.Value.Trim
        End Select

        Dim SearchSupportURL As String

        If (Application("SupportSearchURL") Is Nothing) Then
            SearchSupportURL = ContentManager.Instance.GetContent("Support:Home:SearchSupportURL", "1", OwnerType.Other)
            If Not (SearchSupportURL Is Nothing) Then
                Application.Lock()
                Application("SupportSearchURL") = SearchSupportURL
                Application.UnLock()
            End If
        Else
            SearchSupportURL = Application("SupportSearchURL")
        End If

        If (SearchSupportURL <> Nothing) Then
            SearchSupportURL = SearchSupportURL & Server.UrlEncode(q) + " inurl:/customers/"
            Response.Redirect(SearchSupportURL)
        End If

    End Sub
End Class
