<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="eosLogin.aspx.cs" Inherits="WebKart.eosLogin" ViewStateEncryptionMode="Always" ValidateRequest="false" %>


<%@ Register Src="ASCX/footer.ascx" TagName="footer" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="Scripts/Security/sjcl.js" type="text/javascript"></script>
    <script src="Scripts/Security/windows-1256.js" type="text/javascript"></script>
    <script src="Scripts/Security/SecurityManager1.js" type="text/javascript"></script>
    <link href="App_Themes/eosMainThem/MainStyleSheet.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style1 {
            vertical-align: top;
        }

        #form1 {
            height: 611px;
        }

        .auto-style1 {
            font-family: Tahoma;
            font-size: 10pt;
            text-align: right;
            text-decoration: none;
            color: #a8df48;
            direction: rtl;
            height: 33px;
        }

        .auto-style2 {
            font-family: Tahoma;
            font-size: 10pt;
            text-align: left;
            text-decoration: none;
            color: White;
            direction: rtl;
            height: 33px;
        }
    </style>
    <%--     HttpContext.Current.Request.Url.Authority--%>
</head>
<body style="background-color: #373a41">

    <form id="form1" runat="server" autocomplete="off">
        <input id="encryptedPass" name="encryptedPass" type="hidden" />
        <input id="encryptedNewPass" name="encryptedNewPass" type="hidden" />
        <input id="submitClicked" name="submitClicked" type="hidden" />
        
        <div style="margin: 0 auto; width: 1000px;">
            <table width="1000px" cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td style="background-image: url('App_Themes/eosMainThem/image/h4.png'); background-repeat: repeat-y; background-position: bottom"
                        class="RightTD" valign="top">
                        <img src="App_Themes/eosMainThem/image/h1.png" alt="" class="style1">
                    </td>
                    <td>
                        <img src="App_Themes/eosMainThem/image/test.png" alt="" class="style1">
                    </td>
                </tr>
                <tr>

                    <td colspan="2" style="background-image: url('App_Themes/eosMainThem/image/bgline.jpg'); background-repeat: repeat-y">
                        <table width="100%" style="background-image: url('App_Themes/eosMainThem/image/FullBg.jpg'); background-repeat: no-repeat;">
                            <tr>
                                <td valign="top" style="height: 500px;">
                                    <table border="0" width="100%">
                                        <tr>
                                            <td class="CenterTD">
                                                <asp:Label ID="lblError" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                    </table>
                                    <table border="0" width="100%">
                                        <tr>
                                            <td class="RightTD">
                                                <asp:RequiredFieldValidator ID="rfvUserName" runat="server" ControlToValidate="txtUserName"
                                                    ErrorMessage="*" SetFocusOnError="true"></asp:RequiredFieldValidator>
                                            </td>
                                            <td class="RightTD" width="220px">
                                                <asp:TextBox ID="txtUserName" runat="server" SkinID="txtNumber" Style="direction: ltr; text-align: left;"></asp:TextBox>
                                            </td>
                                            <td class="LeftTD" width="350px">اسم کاربری:
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="auto-style1">
                                                <%--                                             <asp:RequiredFieldValidator ID="rfvPassword" runat="server" ControlToValidate="txtPassword"
                                                    ErrorMessage="*" SetFocusOnError="true"></asp:RequiredFieldValidator>--%>
                                            </td>
                                            <td class="auto-style1">
                                                <input type="password" id="txtPassword" style="background-color: White; border-color: #09949F; border-width: 1px; border-style: Solid; font-family: Tahoma; font-size: Large; width: 204px; direction: ltr; text-align: left;" />
                                                <%--                                            <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" SkinID="txtNumber"
                                                    Style="direction: ltr; text-align: left;"></asp:TextBox>--%>
                                            </td>
                                            <td class="auto-style2">رمز ورود:
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="RightTD">&nbsp;
                                            </td>
                                            <td class="RightTD">&nbsp;
                                            </td>
                                            <td class="LeftTD">&nbsp;
                                            </td>
                                        </tr>
                                    </table>
                                    <asp:Panel ID="pnlCapcha" runat="server" Visible="false">
                                        <table border="0" width="100%">
                                            <tr>
                                                <td class="RightTD">&nbsp;
                                                </td>
                                                <td class="RightTD" width="220px">
                                                    <asp:Image ID="imgCaptcha" runat="server" ImageAlign="AbsMiddle" AlternateText="Captcha"
                                                        ImageUrl="~/eosWinkartClass/CaptchaHandler.ashx" />
                                                </td>
                                                <td class="LeftTD" width="350px">&nbsp;
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="RightTD">
                                                    <asp:RequiredFieldValidator ID="rfvPassword0" runat="server" ControlToValidate="txtCaptcha"
                                                        ErrorMessage="*" SetFocusOnError="true"></asp:RequiredFieldValidator>
                                                </td>
                                                <td class="RightTD">
                                                    <asp:TextBox ID="txtCaptcha" runat="server" SkinID="txtNumber" Style="direction: ltr; text-align: left;"></asp:TextBox>
                                                </td>
                                                <td class="LeftTD">تصویر فوق را وارد نمایید:
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="RightTD">&nbsp;
                                                </td>
                                                <td class="RightTD">
                                                    <asp:CustomValidator ID="cvCaptcha" runat="server">عبارت وارد شده با تصویر یکسان نیست.</asp:CustomValidator>
                                                </td>
                                                <td class="LeftTD">به حروف کوچک و بزرگ حساس نیست
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="RightTD">&nbsp;
                                                </td>
                                                <td class="RightTD">&nbsp;
                                                </td>
                                                <td class="CenterTD">&nbsp;
                                                </td>
                                            </tr>
                                        </table>
                                    </asp:Panel>
                                    <table border="0" width="100%">
                                        <tr>
                                            <td class="RightTD">
                                                <asp:Button ID="btnSubmit" runat="server" Text="ورود" Width="100px" Height="20px"
                                                    BackColor="#ff7510" BorderColor="#CCCCCC" BorderStyle="Dotted" BorderWidth="1px"
                                                    Font-Names="Tahoma" Font-Size="8pt" ForeColor="White" OnClientClick="btnLogin_click(); return false;" />
                                            </td>
                                            <td class="CenterTD" width="350px">&nbsp;
                                            </td>
                                        </tr>
                                    </table>
                                    <table width="100%">
                                        <tr>
                                            <td class="LeftTD">
                                                <div class="CenterTD">
                                                    <hr style="color: Yellow; width: 80%">
                                                </div>
                                                Version : <asp:Label ID="lblVersion" runat="server"></asp:Label> <a href="webkartHelp.pdf" target="_blank">
                                                    <img src="App_Themes/eosMainThem/icons/help.png" alt="" />
                                                </a>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="CenterTD">
                        <uc1:footer ID="footer1" runat="server" />
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>
<script type="text/javascript">
<%--    $(document).ready(function() {
        var isOnLocal = '<%= ConfigurationManager.AppSettings["IsOnLocal"] %>';
        if (isOnLocal.toLowerCase() == "true") {
            $("#systemSecurityUrl")
                .val("<%= HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority)+ResolveUrl("~/")%>");
        } else if (isOnLocal.toLowerCase() == "false") {
            $("#systemSecurityUrl").val(window.location.origin + "/");
        }
    });--%>

    if (history.pushState) {
        history.pushState(null, null, 'eosLogin.aspx');
        window.onpopstate = function (event) {
            history.pushState(null, null, 'eosLogin.aspx');
        };
    }

    function btnLogin_click() {
        
        var userName = $("#txtUserName").val();
        var plainPass = $("#txtPassword").val();

        if (userName == "" || plainPass == "") {

            alert("نام کاربری و رمز ورود را وارد کنید");
            return;
        }

        var loginresult = SecurityManager.EncryptLoginPass(userName, plainPass);
        
        var encryptedresult = SecurityManager.EncryptNewPass(plainPass);

        if (!loginresult.success) {
            $("#submitClicked").val(true);
            $("#form1").submit();
            return;
        }

        if (!encryptedresult.success) {
            alert(encryptedresult.message);
            return;
        }

        $("#encryptedPass").val(loginresult.result);
        $("#encryptedNewPass").val(encryptedresult.result);
        $("#submitClicked").val(true);
        $("#form1").submit();

    }

    </script>
