<%@ Control Language="VB" AutoEventWireup="false" CodeFile="LookForService.ascx.vb"
    Inherits="Controls_LookForService" %>
<asp:Panel ID="pnlBeforeFind" runat="server">
    <asp:Substitution ID="Substitution1" MethodName="GetLookForService" runat="Server"></asp:Substitution>
</asp:Panel>
<asp:Panel ID="pnlAfterFind" runat="server">
</asp:Panel>
<asp:Panel ID="pnlChange" runat="server" DefaultButton="btnChange">
    <table cellpadding="5" cellspacing="0">
        <tr>
            <td>
                Change the zip code to find service in another area:
                <asp:TextBox ID="txtChange" runat="server" Width="100px"></asp:TextBox>
            </td>
            <td style="text-align: right">
                <asp:Button ID="btnChange" runat="server" Text="Change Zip Code" Width="125px" />
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:RequiredFieldValidator ID="vldChangeRequired" runat="server" ControlToValidate="txtChange"
                    Display="Dynamic">
					Please enter your zip code.
                </asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="vldChangeRegEx" runat="server" ControlToValidate="txtChange"
                    Display="Dynamic" ValidationExpression="\d{5}(-\d{4})?">
					Please enter a valid zip code.
                </asp:RegularExpressionValidator>
            </td>
        </tr>
    </table>
</asp:Panel>

<script language="javascript" type="text/javascript">
function Arealize()
	{
		if ((document.getElementById("ucLookForService_txtZipCode").value)=="" || (document.getElementById("ucLookForService_txtZipCode").value)=="zip code")
		{	
		document.getElementById("errorMsgForEmptyZipcode").style.visibility='visible';			
		}
		else
		{
			var isValid;
			isValid= isValidZipCode(String(document.getElementById("ucLookForService_txtZipCode").value));
			if(!isValid)
			{				
				document.getElementById("errorMsgForEmptyZipcode").style.visibility='visible';			
			}
			else
			{
			location.href="../Visitors/LocalArea.aspx?zipcode=" +  document.getElementById("ucLookForService_txtZipCode").value ;
			}
		}	
	}
	
	function isValidZipCode(value)
	 {
		 var regExp = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
		 return (regExp.test(value));
	 }
	
	function checkEnter(e)
	{
		var charCode;
		charCode= e.keyCode;
		if (charCode==13)
			{
				Arealize();
			}
	}
</script>

