Imports CommonBLEntities
Imports CharterDotCom.Library

Partial Class Controls_LookForService
	Inherits System.Web.UI.UserControl

	Public Property Mode() As LookForServiceMode
		Get
			If ViewState(Me.ID & "_Mode") Is Nothing Then
				Return False
			Else
				Return CType(ViewState(Me.ID & "_Mode"), LookForServiceMode)
			End If
		End Get

		Set(ByVal value As LookForServiceMode)
			ViewState(Me.ID & "_Mode") = 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
			'vldZipCodeRequired.ValidationGroup = Me.ID
			'vldZipCodeRegEx.ValidationGroup = Me.ID
			'btnFind.ValidationGroup = Me.ID

			vldChangeRequired.ValidationGroup = Me.ID
			vldChangeRegEx.ValidationGroup = Me.ID
			btnChange.ValidationGroup = Me.ID
		End If

		'txtZipCode.Attributes.Add("onfocus", "clearDefault(this)")
	End Sub

	Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
    Dim areaName As String

		'pnlBeforeFind.Visible = False
		'pnlAfterFind.Visible = False
		pnlChange.Visible = False

		'Dim areaCookie As HttpCookie = HttpContext.Current.Request.Cookies(CookieKey.AreaName)
		'Dim zipcookie As HttpCookie = HttpContext.Current.Request.Cookies(CookieKey.LocalZip)
		Select Case Mode
			Case LookForServiceMode.Find
				'   If Not areaCookie Is Nothing Then
				'     areaName = "Charter " & areaCookie.Value
				''ltrArea.Text = areaName
				''ltrArea2.Text = areaName
				''lnkArea.Text = areaName

				'     pnlAfterFind.Visible = True
				'   Else
				'     If Not zipcookie Is Nothing Then
				'	' txtZipCode.Text = zipcookie.Value
				'     End If
				'     pnlBeforeFind.Visible = True
				'   End If
			Case LookForServiceMode.Change
				pnlChange.Visible = True
				pnlBeforeFind.Visible = False
			Case Else
				pnlChange.Visible = False
				pnlBeforeFind.Visible = True
				' do nothing
		End Select
	End Sub

	Protected Sub btnFind_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)	'Handles btnFind.Click
		'If Page.IsValid Then
		'	AccountManager.Instance.Arealize(txtZipCode.Text)
		'	Response.Redirect("../Visitors/Localarea.aspx")
		'End If
	End Sub

	Protected Sub btnChange_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnChange.Click
		If Page.IsValid Then
			'AccountManager.Instance.Arealize(txtChange.Text)
			Response.Redirect("../Visitors/Localarea.aspx?zipcode=" + txtChange.Text)
		End If
	End Sub

	Shared Function GetLookForService(ByVal context As HttpContext) As String
		Dim areaName As String

		Dim areaCookie As HttpCookie = HttpContext.Current.Request.Cookies(CookieKey.AreaName)
		Dim zipcookie As HttpCookie = HttpContext.Current.Request.Cookies(CookieKey.LocalZip)

		If Not areaCookie Is Nothing Then
			areaName = "Charter " & areaCookie.Value
			Return "<div id=""ctl00_cphRight_ucLookForService_pnlAfterFind"">" & _
			"<div class=""roundedFlexible"">" & _
			"<div class=""roundedTopLeft""><div class=""roundedTopRight""><div class=""roundedBotRight""><div class=""roundedBotLeft"">" & _
			"<div class=""solidRounded""><div class=""solidRoundedTop""><div></div></div>" & _
			"<div id=""solidRoundedContent"" class=""green"">" & _
			"<h2 class=""medGray"">" & areaName & "</h2>" & _
			"</div>" & _
			"<div class=""solidRoundedBot"" id=""flat""><div></div></div></div>	" & _
			"<div class=""flatHeader"">" & _
			"<p class=""squished"">Return to " & areaName & " to get information about your local services.</p>" & _
			"<a id=""ctl00_cphRight_ucLookForService_lnkArea"" href=""LocalArea.aspx"">" & areaName & "</a>" & _
			"</div>" & _
			"</div></div></div></div>" & _
			"</div>" & _
			"</div>"
		Else
			If Not zipcookie Is Nothing Then
                Return "<div id=""ucLookForService_pnlBeforeFind"" onkeypress=""javascript:return WebForm_FireDefaultButton(event, 'ucLookForService_btnFind')"">" & _
                "<div class=""roundedFlexible"">" & _
                "<div class=""roundedTopLeft"" id=""gray""><div class=""roundedTopRight"" id=""gray""><div class=""roundedBotRight"" id=""gray""><div class=""roundedBotLeft"" id=""gray"">" & _
                "<h2 class=""green"">Looking for Service?</h2><br/>" & _
                "<span class=""centered"">" & _
                "<div>" & _
                "<span id=""ucLookForService_vldZipCodeRequired"" style=""color:Red;display:none;""> <img src='../Images/error-icon_small.gif' /> Please enter Zip Code</span>" & _
                "<span id=""ucLookForService_vldZipCodeRegEx"" style=""color:Red;display:none;""> <img src='../Images/error-icon_small.gif'/> Please enter Zip Code</span>" & _
                "</div>" & _
                "<div class=""zipCode"">" & _
                "<input name=""ucLookForService$txtZipCode"" type=""text"" value=""" & zipcookie.Value & """ maxlength=""10"" size=""10"" id=""ucLookForService_txtZipCode"" onfocus=""clearDefault(this)"" />" & _
                "<input type=""image"" name=""ucLookForService$btnFind"" id=""ucLookForService_btnFind""  class=""imageButton"" src=""../Images/but_find.gif"" alt=""Find"" align=""absbottom"" onclick=""javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ucLookForService$btnFind&quot;, &quot;&quot;, true, &quot;ucLookForService&quot;, &quot;&quot;, false, false))"" style=""border-width:0px;"" />" & _
                "</div>" & _
                "</span>" & _
                "</div></div></div></div>" & _
                "</div>" & _
                "</div>"
			Else
                Return "<div id=""ucLookForService_pnlBeforeFind"" onkeypress=""javascript:return WebForm_FireDefaultButton(event, 'ucLookForService_btnFind')"">" & _
                "<div class=""roundedFlexible"">" & _
                "<div class=""roundedTopLeft"" id=""gray""><div class=""roundedTopRight"" id=""gray""><div class=""roundedBotRight"" id=""gray""><div class=""roundedBotLeft"" id=""gray"">" & _
                "<h2 class=""green"">Looking for Service?</h2><br/>" & _
                "<span class=""centered"">" & _
                "<div class=""zipCode"">" & _
                "<div id=""img1""><input name=""ucLookForService$txtZipCode"" onKeyPress=""checkEnter(event)"" type=""text"" tabindex=""1000"" value=""zip code"" maxlength=""10"" size=""10"" id=""ucLookForService_txtZipCode"" onfocus=""clearDefault(this)"" />" & _
                "     <img src=""../Images/but_find.gif"" onclick=""javascript:Arealize()"" tabindex=""1001"" alt=""Find"" align=""absbottom"" style=""border-width:0px;""></div>" & _
                "<span id=""errorMsgForEmptyZipcode"" style=""visibility:hidden""><img id=""errorimg"" src=""../Images/error-icon_small.gif""> Please enter a valid Zip Code</span><br/>" & _
                "</div>" & _
                "</span>" & _
                "</div></div></div></div>" & _
                "</div>" & _
                "</div>"
            End If
            '' db: removed this line from above two else blocks
            '' '"<p class=""map""><img src=""../Images/map_smGreen.gif"" alt=""US Map"" /></p>" & _
		End If
	End Function

End Class
