<form>
    <div class="ui-body ui-body-a ui-corner-all">
        <label for="username"><?php echo __("LOGIN_USERNAME"); ?></label>
        <input type="text" name="LoginForm[username]" id="username" value="" autocomplete="off" autocapitalize="none">
        <label for="password"><?php echo __("LOGIN_PASSWORD"); ?></label>
        <input type="password" data-clear-btn="true" name="LoginForm[password]" id="password" value="" autocomplete="off" autocapitalize="none">
    </div>
    <button id="submit" class="ui-btn ui-shadow"><?php echo __("LOGIN_LOGIN_BUTTON"); ?></button>    
<!--    <button id="showNormalView" data-role="footer" data-position="fixed" style="padding: 8px;"><?php echo __("LOGIN_SHOW_NORMAL_VIEW"); ?></button>-->
</form>
<style>
    
</style>
<script>
    $("#submit").on("click", function() {
        $.ajax({
            url:"<?php echo url('site/AjaxLogin'); ?>",
            type: "POST",
            dataType: "json",
            data:{
                'LoginForm[username]': $('#username').val(),
                'LoginForm[password]': $('#password').val()
            },
            /*error: function(jqXHR,textStatus,errorThrown)
            {
                alert("test : "+jqXHR.responseText);
                alert("statusText: "+textStatus);
                alert("statusText: "+errorThrown);
            }, */
            success: function(data)
            {
                if(data.logedIn){
                    window.location = data.returnUrl;
                } else {
                    alert("invalid credentials");
                }
            }
        });
        return false;
    });

    $("#showNormalView").on("click", function () {
        $.ajax({
            url: "<?php echo url('site/changeMobileView'); ?>",
            type: "POST",
            dataType: "json",
            data: {
                'showMobile': 'false'
            },
            success: function (data)
            {
                if (data === "refresh") {
                    window.location.reload();
                }
            }
        });
        return false;
    });
</script>