<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Masters/AgentMaster.Master"
    CodeBehind="AddUsers.aspx.cs" Inherits="CasheeremitAgent.Account.AddUsers" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cpHead" runat="server">
    <script type="text/javascript">

        function swalalert(val, typ) {
            swal({
                title: "",
                text: val,
                type: typ,
                showConfirmButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "OK",
                closeOnConfirm: true
            });
        }


        function ShowAvailUserName() {

            $.ajax({
                type: "POST",
                url: "AddUsers.aspx/CheckUserName",
                data: '{userName: "' + $("#<%=txtUsername.ClientID%>")[0].value + '" }',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccessU
            });
        }

        function OnSuccessU(response) {
            var mesg1 = $("#mesgUser")[0];

            switch (response.d) {
                case "true":
                    //mesg.style.color = "green";
                    mesg1.className = "spn_msg_H";
                    mesg1.innerHTML = "";
                    break;
                case "false":
                    document.getElementById("<%=txtUsername.ClientID %>").value = "";
                    mesg1.className = "spn_msg_V";
                    mesg1.style.color = "red";
                    mesg1.innerHTML = "UserName already exists";
                    break;
                case "error":
                    mesg1.class = "spn_msg_V";
                    mesg1.style.color = "red";
                    mesg1.innerHTML = "Error occured";
                    break;
            }
        }



        function ShowAvailMobile() {

            $.ajax({
                type: "POST",
                url: "AddUsers.aspx/CheckMobile",
                data: '{mobile: "' + $("#<%=txtMobile.ClientID%>")[0].value + '" }',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccessM
            });
        }

        function OnSuccessM(response) {
            var mesg1 = $("#mesgmob")[0];

            switch (response.d) {
                case "true":
                    //mesg.style.color = "green";
                    mesg1.className = "spn_msg_H";
                    mesg1.innerHTML = "";
                    break;
                case "false":
                    document.getElementById("<%=txtMobile.ClientID %>").value = "";
                    mesg1.className = "spn_msg_V";
                    mesg1.style.color = "red";
                    mesg1.innerHTML = "Mobile Number already exists";
                    break;
                case "error":
                    mesg1.class = "spn_msg_V";
                    mesg1.style.color = "red";
                    mesg1.innerHTML = "Error occured";
                    break;
            }
        }

        function DisplayWaiting(validationgroup) {
            
            if (Validate(validationgroup) == 'success') {
                $find('<%=ModalPopupExtender2.ClientID %>').show();
                setTimeout('document.images["imgLoad"].src = "../Styles/images/loading.gif"', 10);
            }
        }
        function Validate(validationgroupname) {

            if (Page_ClientValidate(validationgroupname)) {
                return 'success';
            }
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpLyremit" runat="server">
    <asp:ScriptManager ID="smgr" runat="server">
    </asp:ScriptManager>
    <div id="Div1" runat="server" class="col-md-12">
       
        <div class="clearfix">
            &nbsp;</div>
        <div class="bluHD col-md-12">
            User Profile</div>
        <div class="col-md-12 vinobox ">
            <div class="clearfix">
                &nbsp;</div>
            <div class="col-md-6">
                <div class="row mrgBot10">
                    <div class=" col-md-3">
                        Title <span class="starRed">*</span>
                    </div>
                    <div class=" col-md-7">
                        <asp:DropDownList ID="ddlTitle" runat="server" CssClass="form-control">
                            <asp:ListItem Selected="True" Value="0" Text="Select"></asp:ListItem>
                            <asp:ListItem Value="Mr" Text="Mr"></asp:ListItem>
                            <asp:ListItem Value="Mrs" Text="Mrs"></asp:ListItem>
                            <asp:ListItem Value="Ms" Text="Ms"></asp:ListItem>
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="reqTitle" runat="server" ControlToValidate="ddlTitle"
                            Display="Dynamic" CssClass="errMsg" ErrorMessage="Select a Title" ValidationGroup="submit"
                            InitialValue="0" Font-Size="X-Small"></asp:RequiredFieldValidator>
                    </div>
                </div>
                <div class="row mrgBot10">
                    <div class=" col-md-3">
                        First Name <span class="starRed">*</span>
                    </div>
                    <div class=" col-md-7">
                        <asp:TextBox ID="txtFirstName" MaxLength="50" runat="server" CssClass="txtboxM"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="reqFirstName" runat="server" ControlToValidate="txtFirstName"
                            CssClass="errMsg" ValidationGroup="submit" Font-Size="X-Small" Display="Dynamic"
                            ErrorMessage="Enter FirstName"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="regFirstName" runat="server" ValidationGroup="submit"
                            ControlToValidate="txtFirstName" Display="Dynamic" class="errMsg" ErrorMessage="Please enter a valid FirstName"
                            ValidationExpression="^(([a-zA-Z]\s?){1,50})$"></asp:RegularExpressionValidator>
                    </div>
                </div>
                <div class="row mrgBot10">
                    <div class=" col-md-3">
                        Last Name <span class="starRed">*</span>
                    </div>
                    <div class=" col-md-7">
                        <asp:TextBox ID="txtLastName" MaxLength="50" runat="server" CssClass="txtboxM"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="reqLastName" runat="server" ControlToValidate="txtLastName"
                            CssClass="errMsg" ValidationGroup="submit" Font-Size="X-Small" Display="Dynamic"
                            ErrorMessage="Enter LastName"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="regLastName" runat="server" ControlToValidate="txtLastName"
                            ErrorMessage="Please enter a valid LastName" Display="Dynamic" class="errMsg"
                            ValidationGroup="submit" ValidationExpression="^(([a-zA-Z]\s?){1,50})$"></asp:RegularExpressionValidator>
                    </div>
                </div>
                <div class="row mrgBot10">
                    <div class=" col-md-3">
                        Telephone <span class="starRed">*</span>
                    </div>
                    <div class=" col-md-7">
                        <asp:TextBox ID="txtTelephone" MaxLength="15" runat="server" CssClass="txtboxM"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="reqTelephone" runat="server" ControlToValidate="txtTelephone"
                            CssClass="errMsg" ValidationGroup="submit" Font-Size="X-Small" Display="Dynamic"
                            ErrorMessage="Enter Telephone"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="regTelephone" runat="server" ControlToValidate="txtTelephone"
                            CssClass="errMsg" ValidationGroup="submit" ErrorMessage="Please enter valid TelephoneNo"
                            Display="Dynamic" Font-Size="X-Small" ValidationExpression="^([0-9]{1,15})$"></asp:RegularExpressionValidator>
                    </div>
                </div>
                <div class="row mrgBot10">
                    <div class=" col-md-3">
                        Mobile <span class="starRed">*</span>
                    </div>
                    <div class=" col-md-7">
                        <span style="float: left; width: 45px;">
                            <asp:TextBox ID="txtmobilecode" Enabled="false" runat="server" MaxLength="3" CssClass="txtboxM"></asp:TextBox></span>
                        <asp:TextBox ID="txtMobile" Style="width: 77%; margin-left: 59px;" MaxLength="15"
                            runat="server" CssClass="form-control" autocomplete="off" onchange="ShowAvailMobile();"></asp:TextBox>
                        <span id="mesgmob" class=""></span>
                        <asp:RequiredFieldValidator ID="reqMobile" runat="server" ControlToValidate="txtMobile"
                            CssClass="errMsg" ValidationGroup="submit" Font-Size="X-Small" Display="Dynamic"
                            ErrorMessage="Enter Mobile"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="regMobile" CssClass="errMsg" runat="server" ControlToValidate="txtMobile"
                            ValidationGroup="submit" ErrorMessage="Please enter valid MobileNo" Display="Dynamic"
                            Font-Size="X-Small" ValidationExpression="^([0-9]{1,12})$"></asp:RegularExpressionValidator>
                        <asp:Label ID="lblDuplcateMob" runat="server" Visible="false" Text="MobileNo Already Exists"
                            ForeColor="Red"></asp:Label>
                    </div>
                </div>
                <div class="row mrgBot10">
                    <div class=" col-md-3">
                        User Name <span class="starRed">*</span>
                    </div>
                    <div class=" col-md-7">
                        <asp:TextBox ID="txtUsername" runat="server" MaxLength="20" onchange="ShowAvailUserName();"
                            autocomplete="off" CssClass="txtboxM"></asp:TextBox>
                        <span id="mesgUser" class=""></span>
                        <asp:RequiredFieldValidator ID="reqUserName" runat="server" ControlToValidate="txtUsername"
                            CssClass="errMsg" ValidationGroup="submit" Display="Dynamic" Font-Size="X-Small"
                            ErrorMessage="Enter UserName"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="regUsername" runat="server" ControlToValidate="txtUsername"
                            ErrorMessage="Enter Valid Username" ValidationExpression="^(([a-z1-9A-Z]?){5,20})$"
                            CssClass="errMsg" Display="Dynamic" ValidationGroup="submit" Font-Size="X-Small"></asp:RegularExpressionValidator>
                        <asp:Label ID="lblFailed" runat="server" Visible="false" Text="Username Already Exists"
                            ForeColor="Red"></asp:Label>
                        <input type="text" style="visibility: hidden;" name="username" autocomplete="off" />
                    </div>
                </div>
                <div class="row mrgBot10">
                    <div class=" col-md-3">
                        Password <span class="starRed">*</span>
                    </div>
                    <div class=" col-md-7">
                        <input id="txtPassword" type="password" runat="server" class="txtboxM" maxlength="25"
                            autocomplete="off" autocompletetype="Disabled" oncopy="return false;" onpaste="return false;"
                            oncut="return false;" />
                        <asp:RequiredFieldValidator ID="reqPassword" runat="server" ControlToValidate="txtPassword"
                            CssClass="errMsg" ValidationGroup="submit" Font-Size="X-Small" Display="Dynamic"
                            ErrorMessage="Enter Password"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="regPassword" runat="server" ControlToValidate="txtPassword"
                            Display="Dynamic" ValidationGroup="submit" CssClass="errMsg" ErrorMessage="Password must be minimum 5 characters."
                            Font-Size="X-Small" ValidationExpression="^[\s\S]{5,}$">
                        </asp:RegularExpressionValidator>
                        <input type="password" style="visibility: hidden;" name="pwd" autocomplete="off" />
                    </div>
                </div>
            </div>
            <div class="col-md-6">
                <div class="row mrgBot10">
                    <div class=" col-md-3">
                        Email ID <span class="starRed">*</span>
                    </div>
                    <div class=" col-md-7">
                        <asp:TextBox ID="txtEmail" runat="server" CssClass="txtboxM"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="reqEmail" runat="server" ControlToValidate="txtEmail"
                            Display="Dynamic" CssClass="errMsg" ErrorMessage="Enter Email" ValidationGroup="submit"
                            Font-Size="X-Small"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="regEmailID" runat="server" ControlToValidate="txtEmail"
                            ValidationGroup="submit" Display="Dynamic" CssClass="errMsg" ErrorMessage="Enter valid Email Address"
                            Font-Size="X-Small" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">
                        </asp:RegularExpressionValidator>
                    </div>
                </div>
                <div class="row mrgBot10">
                    <div class=" col-md-3">
                        House No <span class="starRed">*</span>
                    </div>
                    <div class="col-md-7">
                        <asp:TextBox ID="txtHouseno" runat="server" MaxLength="10" CssClass="txtboxM"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="reqHouse" runat="server" ControlToValidate="txtHouseno"
                            CssClass="errMsg" ValidationGroup="submit" Font-Size="X-Small" Display="Dynamic"
                            ErrorMessage="Enter House No"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="reg" CssClass="errMsg" runat="server" ControlToValidate="txtHouseno"
                            ValidationGroup="submit" ErrorMessage="Please enter valid House No" Display="Dynamic"
                            Font-Size="X-Small" ValidationExpression="^([0-9]{1,10})$"></asp:RegularExpressionValidator>
                    </div>
                </div>
                <div class="row mrgBot10">
                    <div class=" col-md-3">
                        Address1 <span class="starRed">*</span>
                    </div>
                    <div class="col-md-7">
                        <asp:TextBox ID="txtAddress1" MaxLength="50" runat="server" CssClass="txtboxM"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="reqAddress1" runat="server" ControlToValidate="txtAddress1"
                            Display="Dynamic" CssClass="errMsg" ErrorMessage="Enter Address" ValidationGroup="submit"
                            Font-Size="X-Small"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="regAdr1" CssClass="errMsg" runat="server" ControlToValidate="txtAddress1"
                            ValidationGroup="submit" ErrorMessage="Please enter valid Address 1" Display="Dynamic"
                            Font-Size="X-Small" ValidationExpression="^([a-zA-Z ]{3,50})$"></asp:RegularExpressionValidator>
                    </div>
                </div>
                <div class="row mrgBot10">
                    <div class=" col-md-3">
                        Address2
                    </div>
                    <div class="col-md-7">
                        <asp:TextBox ID="txtAddress2" runat="server" MaxLength="50" CssClass="txtboxM"></asp:TextBox>
                        <asp:RegularExpressionValidator ID="regAdr2" CssClass="errMsg" runat="server" ControlToValidate="txtAddress2"
                            ValidationGroup="submit" ErrorMessage="Please enter valid Address 2" Display="Dynamic"
                            Font-Size="X-Small" ValidationExpression="^([a-zA-Z ]{3,50})$"></asp:RegularExpressionValidator>
                    </div>
                </div>
                <div class="row mrgBot10">
                    <div class=" col-md-3">
                        City <span class="starRed">*</span>
                    </div>
                    <div class="col-md-7">
                        <asp:TextBox ID="txtCity" MaxLength="50" runat="server" CssClass="txtboxM"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="reqCity" runat="server" ControlToValidate="txtCity"
                            Display="Dynamic" CssClass="errMsg" ErrorMessage="Enter City" ValidationGroup="submit"
                            Font-Size="X-Small"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" CssClass="errMsg"
                            runat="server" ControlToValidate="txtCity" ValidationGroup="submit" ErrorMessage="Please enter valid City"
                            Display="Dynamic" Font-Size="X-Small" ValidationExpression="^([a-zA-Z ]{3,50})$"></asp:RegularExpressionValidator>
                    </div>
                </div>
                <div class="row mrgBot10">
                    <div class=" col-md-3">
                        County <span class="starRed">*</span>
                    </div>
                    <div class="col-md-7">
                        <asp:TextBox ID="txtState" MaxLength="50" runat="server" CssClass="txtboxM"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtState"
                            CssClass="errMsg" ValidationGroup="submit" Font-Size="X-Small" Display="Dynamic"
                            ErrorMessage="Enter State"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator3" CssClass="errMsg"
                            runat="server" ControlToValidate="txtState" ValidationGroup="submit" ErrorMessage="Please enter valid State"
                            Display="Dynamic" Font-Size="X-Small" ValidationExpression="^([a-zA-Z ]{3,50})$"></asp:RegularExpressionValidator>
                    </div>
                </div>
                <div class="row mrgBot10">
                    <div class=" col-md-3">
                        PostCode/ZipCode <span class="starRed">*</span>
                    </div>
                    <div class=" col-md-7">
                        <asp:TextBox ID="txtPostCode" MaxLength="8" runat="server" CssClass="txtboxM"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="reqPostCode" runat="server" ControlToValidate="txtPostCode"
                            CssClass="errMsg" ErrorMessage="Enter PostCode" ValidationGroup="submit" Display="Dynamic"
                            Font-Size="X-Small"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="regPostcode" CssClass="errMsg" runat="server"
                            ControlToValidate="txtPostCode" ValidationGroup="submit" ErrorMessage="Please enter valid Postcode"
                            Display="Dynamic" Font-Size="X-Small" ValidationExpression="^([a-zA-Z0-9 ]{5,8})$"></asp:RegularExpressionValidator>
                    </div>
                </div>
                <div class="row mrgBot10">
                    <div class=" col-md-3">
                        Country <span class="starRed">*</span>
                    </div>
                    <div class=" col-md-7">
                        <asp:DropDownList ID="ddlCountry" runat="server" CssClass="txtboxM">
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="reqCountry" runat="server" ControlToValidate="ddlCountry"
                            Display="Dynamic" CssClass="errMsg" ErrorMessage="Select a Country" ValidationGroup="submit"
                            InitialValue="0" Font-Size="X-Small"></asp:RequiredFieldValidator>
                    </div>
                </div>
            </div>
            <div class="clearfix">
                &nbsp;</div>
            <div class="col-md-8 ">
                <div class="col-md-3">
                    <asp:Button ID="btnsubmit" runat="server" Text="Submit" class="btnB" OnClick="btnsubmit_click" OnClientClick="DisplayWaiting('submit');"
                        ValidationGroup="submit" /></div>
                <div class="col-md-6">
                    <asp:Button ID="btnClear" runat="server" Text="Clear" class="btnG" OnClick="btnClear_click"
                        ValidationGroup="Clear" />
                </div>
            </div>
            <%-- <div style="font-size: 12px; margin: 15px; color: #fc490e;">
            Kindly Note: • To change your personal details, Please contact our customer services
            0207 132 0015
        </div>--%>
        </div>

         <div id="dvProgressbar">
            <asp:Button runat="server" ID="Button1" Style="display: none" />
            <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Style="display: none">
                <div class="modal1">
                    <div class="center1">
                        <!-- Start -->
                        <img id="imgLoad" alt="Please wait....." src="../Styles/images/loading.gif" />
                        <!-- End -->
                        <asp:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="Button1"
                            PopupControlID="Panel1" BackgroundCssClass="modalBackground" DropShadow="false" />
                    </div>
                </div>
            </asp:Panel>
        </div>
    </div>
</asp:Content>
