<!DOCTYPE html>
<html>

<head>
    <title>Welcome to KiSSFLOW</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="shortcut icon" href="https://dtvnwsyj9z2ds.cloudfront.net/8777/wiz/flow/static/shared/images/favicon.ico" type="image/x-icon">
    <link rel="icon" href="https://dtvnwsyj9z2ds.cloudfront.net/8777/wiz/flow/static/shared/images/favicon.ico" type="image/x-icon">

    <!-- PWA Meta Tags -->
    <meta name="theme-color" content="#43a047">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="default">
    <meta name="apple-mobile-web-app-title" content="KiSSFLOW">

    <!-- PWA Manifest -->
    <link rel="manifest" href="/common/pwa/manifest.json">

    <!-- Apple Touch Icons -->
    <link rel="apple-touch-icon" href="/common/pwa/icons/icon-152x152.png">
    <link rel="apple-touch-icon" sizes="180x180" href="/common/pwa/icons/icon-192x192.png">

    <!-- MS Tile -->
    <meta name="msapplication-TileImage" content="/common/pwa/icons/icon-144x144.png">
    <meta name="msapplication-TileColor" content="#43a047">

    <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" />
    <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/css/materialize.min.css" />
    <link rel="stylesheet" type="text/css" href="https://dtvnwsyj9z2ds.cloudfront.net/8777/wiz/flow/static/shared/css/login.css" />
    <link rel='stylesheet' type='text/css' href='//fonts.googleapis.com/css?family=Roboto:100,400,300,500,700' />
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.14.0/jquery.validate.min.js"></script>
    
    <script>
    $(document).ready(function() {
        if (document.location.href.indexOf('createUser') > 0) {
            showSection('createAccount');
        } else {
            showSection('maincontainer');
        }
        // if (!$('.errormsg').text().trim().length) {
        //      $('div.errorMsg').hide();
        // }
        $('#emailId,#passwd, #samlId ').focus(function() {
            $('div.errorMsg').hide();
        });


        var loginValidation = $("#loginForm").validate({
            rules: {
                emailId: {
                    required: true,
                    ValidateMail: true
                }
            },
            messages: {
                emailId: "Please enter a valid email id",
                passwd: "Please enter a valid password"
            },
            invalidHandler: function(event, validator) {
                $('div.errorMsg').hide();
            },
            errorClass: "errorMsg"
        });
        var createValidation = $("#createAccount").validate({
            rules: {
                newEmail: {
                    required: true,
                    ValidateMail: true
                }
            },
            messages: {
                newEmail: "Please enter a valid email id"
            },
            invalidHandler: function(event, validator) {
                $('div.errorMsg').hide();
            },
            errorClass: "errorMsg"
        });

        var forgotPasswordValidation = $("#forgotPassword").validate({
            rules: {
                emailId: {
                    required: true,
                    ValidateMail: true
                }
            },
            invalidHandler: function(event, validator) {
                $('div.errorMsg').hide();
            },
            errorClass: "errorMsg"
        });
    });

    $.validator.addMethod("ValidateMail", function(value) {
        return isValidEmailAddress(value);
    }, 'Please enter a valid email id');

    function isValidEmailAddress(emailAddress) {
        var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
        return pattern.test(emailAddress.trim());
    };

/*    function validateuser() {
        var emailId = $('#newEmail').val();
        var validuser = true;
        var urlpath = '/$metadata.getApplication().getSheetId()/f/ping?invoke=&emailId=' + emailId
        jQuery.ajax({
            type: "POST",
            url: urlpath,
            async: false,
            dataType: "jsonp",
            timeout: 30000,
            error: function(XMLHttpRequest, textStatus, errorThrown) {},
            success: function(data) {
                if (data == 0) {
                    $('.errorMsg').text('The email id already exists.');
                    //validuser=false;
                    loginValidation.resetForm();
                } else {
                    $('.errorMsg').text('');
                }
            }
        });
        return validuser;
    }*/

    function resetPassword() {
        $('.forgotPassword #email').val($('.maincontainer #emailId').val());
        showSection('forgotPassword');
    }

    function samlLogin() {
        $("#loginForm").attr('action', '/redirectToLogin').unbind('submit').submit()

    }

    function showSection(sectionId) {
        $('.container').hide();
        $('.' + sectionId).show();
    }

    function redirectToHome() {
        var queryStr = location.search;
        window.location.href = 'https://kissflow.com/' + queryStr;
    }

    function redirectToLogin() {
        window.location.href = 'https://' + window.location.host;
    }

    var onloadCallback = function() {
        grecaptcha.render('captcha_container', {
            'sitekey': '6LfOCxsTAAAAADHdR-ZIO5OhDYmOlS3HbDU9y92E',
            'theme': 'light'
        });
    };
    </script>
    
</head>

<body>
    
    <div class="wrapper">
        <!-- Login Section -->
        <div class="loginForm left">
            <a href="https://kissflow.com/" target="_blank" class="logoContainer">
                <img src="https://dtvnwsyj9z2ds.cloudfront.net/8777/wiz/flow/static/shared/images/logo.png" alt="logo" title="logo" />
            </a>
            <!-- login frm section -->
            <div class="loginContent maincontainer container">
                <form method="post" id="loginForm" action="/checkCredentials" class="formWrapper">
                    <div class="input-field">
                        <input type="text" value='' id='emailId' name='emailId' autocomplete="off" />
                        <label for="user_name" class="active">Username</label>
                    </div>
                    <div class="input-field password">
                        <input type="password" value='' id='passwd' name='passwd' autocomplete="off" />
                        <label class="active" for="password">Password</label>
                    </div>
                    
                    <div class="errorMsg common">
                        This link is expired. Please reset the password again. 
                    </div>
                    <div class="submit">
                        <button type="submit" id="submitButton" class="waves-effect waves-light btn">Sign in</button> 
                    </div>                  
                    <p class="LoginText">Or</p>
                    <div class="otherLoginButton">
                        
                        <a class="googleButton left" href="/login/google-oauth2?continue=/Application001/f/home&amp;redirect_data=3rdBaVTbsXeDsdapnZR0ndgCkiSxm857%2FOEm2kzfwUouRhVhY9sGZzBo%2F4lC8osFml80mpvpf20qO4l4oN8Cyg%3D%3D">                                
                            <img class="googleIcons icons" src="https://dtvnwsyj9z2ds.cloudfront.net/8777/wiz/flow/static/shared/images/google.png" alt="google login" title="google login" />
                           <span>Sign in with Google</span>
                        </a>
                        
                        <a class="officeButton left" href="https://app.kissflow.com/login/azure?continue=/Application001/f/home">
                            <img class="officeicon icons" src="https://dtvnwsyj9z2ds.cloudfront.net/8777/wiz/flow/static/shared/images/office.png" alt="google login" title="google login" />
                             <span>Sign in with Office 365</span>
                        </a>
                        <div class="clearfix"></div>
                        <a class="samlButton" href="javascript:void(0)" onclick="samlLogin()">
                            <img class="officeicon icons" src="https://dtvnwsyj9z2ds.cloudfront.net/8777/wiz/flow/static/shared/images/saml.png" alt="google login" title="google login" />
                            <span>Sign in with Single sign-on</span>
                        </a>
                    </div>                    
                    <a href="javascript:void(0)" class="forgotPwd center" onclick="resetPassword()">Forgot Password?</a>
                    <div class="row">
                        <input type="hidden" value="27248d61-8635-4b71-9273-6ebf544b2509" name="_csrf" />
                        <input name='forward' type='hidden' value='/Application001/f/home&amp;redirect_data=3rdBaVTbsXeDsdapnZR0ndgCkiSxm857%2FOEm2kzfwUouRhVhY9sGZzBo%2F4lC8osFml80mpvpf20qO4l4oN8Cyg%3D%3D' id='forward' />
                    </div>
                </form>
            </div>
            <!-- ********** Forgot Password Section starts here  **********-->
            <div class="loginContent forgotPassword container" style="display: none">
                <form method="post" action="/forgotPassword" id='forgotPassword' class="formWrapper">
                    <div class="forgotPwdMsg">
                        <p>We will send forgot password link to your email address!</p>
                    </div>
                    
                    <div class="input-field">
                        <input id="email" type="text" name="emailId" id="emailId" class=" text" autocomplete="off" />
                        <label for="email">Email</label>
                    </div>
                   
                    <input type="hidden" value="27248d61-8635-4b71-9273-6ebf544b2509" name="_csrf" />
                    <div class="submit">
                        <button type="submit" class="waves-effect waves-light btn">Send Email</button>
                        <a href="" onclick="redirectToLogin()" class="waves-effect waves-light btn">Back</a>
                    </div>
                </form>
            </div>
            <!--********** Forgot Password Section ends here  ********** -->
            <!-- ********** Reset Password Section starts here  **********
            <div class ="loginContent forgotContent">
                <form class="col l12 formWrapper" action="#">
                    <div class="row">
                      <div class="input-field l12">
                       <input id="password" type="password" class="validate">
                            <label class="active" for="password">New Password</label>
                      </div>
                    </div>
                    <div class="row">
                      <div class="input-field l12">
                        <input id="password" type="password" class="validate">
                            <label class="active" for="password">Confirm Password</label>
                      </div>
                    </div>
                    <div class="submit">
                        <button type="submit" class="waves-effect waves-light btn">Submit</button>
                    </div>
                </form>
            </div>
            ********** Reset Password Section ends here  ********** -->
        </div>
        <div class="loginImage left">
            <img src="https://dtvnwsyj9z2ds.cloudfront.net/8777/wiz/flow/static/shared/images/side-image.png" alt="Home office Image" title="Home office Image">
        </div>
        <div class="clearfix"></div>
    </div>
    <!--end of code-->
    <script>
    /*! device.js 0.2.7 */
    (function() {
        var a, b, c, d, e, f, g, h, i, j;
        b = window.device, a = {}, window.device = a, d = window.document.documentElement, j = window.navigator.userAgent.toLowerCase(), a.ios = function() {
            return a.iphone() || a.ipod() || a.ipad()
        }, a.iphone = function() {
            return !a.windows() && e("iphone")
        }, a.ipod = function() {
            return e("ipod")
        }, a.ipad = function() {
            return e("ipad")
        }, a.android = function() {
            return !a.windows() && e("android")
        }, a.androidPhone = function() {
            return a.android() && e("mobile")
        }, a.androidTablet = function() {
            return a.android() && !e("mobile")
        }, a.blackberry = function() {
            return e("blackberry") || e("bb10") || e("rim")
        }, a.blackberryPhone = function() {
            return a.blackberry() && !e("tablet")
        }, a.blackberryTablet = function() {
            return a.blackberry() && e("tablet")
        }, a.windows = function() {
            return e("windows")
        }, a.windowsPhone = function() {
            return a.windows() && e("phone")
        }, a.windowsTablet = function() {
            return a.windows() && e("touch") && !a.windowsPhone()
        }, a.fxos = function() {
            return (e("(mobile;") || e("(tablet;")) && e("; rv:")
        }, a.fxosPhone = function() {
            return a.fxos() && e("mobile")
        }, a.fxosTablet = function() {
            return a.fxos() && e("tablet")
        }, a.meego = function() {
            return e("meego")
        }, a.cordova = function() {
            return window.cordova && "file:" === location.protocol
        }, a.nodeWebkit = function() {
            return "object" == typeof window.process
        }, a.mobile = function() {
            return a.androidPhone() || a.iphone() || a.ipod() || a.windowsPhone() || a.blackberryPhone() || a.fxosPhone() || a.meego()
        }, a.tablet = function() {
            return a.ipad() || a.androidTablet() || a.blackberryTablet() || a.windowsTablet() || a.fxosTablet()
        }, a.desktop = function() {
            return !a.tablet() && !a.mobile()
        }, a.television = function() {
            var a;
            for (television = ["googletv", "viera", "smarttv", "internet.tv", "netcast", "nettv", "appletv", "boxee", "kylo", "roku", "dlnadoc", "roku", "pov_tv", "hbbtv", "ce-html"], a = 0; a < television.length;) {
                if (e(television[a])) return !0;
                a++
            }
            return !1
        }, a.portrait = function() {
            return window.innerHeight / window.innerWidth > 1
        }, a.landscape = function() {
            return window.innerHeight / window.innerWidth < 1
        }, a.noConflict = function() {
            return window.device = b, this
        }, e = function(a) {
            return -1 !== j.indexOf(a)
        }, g = function(a) {
            var b;
            return b = new RegExp(a, "i"), d.className.match(b)
        }, c = function(a) {
            var b = null;
            g(a) || (b = d.className.replace(/^\s+|\s+$/g, ""), d.className = b + " " + a)
        }, i = function(a) {
            g(a) && (d.className = d.className.replace(" " + a, ""))
        }, a.ios() ? a.ipad() ? c("ios ipad tablet") : a.iphone() ? c("ios iphone mobile") : a.ipod() && c("ios ipod mobile") : a.android() ? c(a.androidTablet() ? "android tablet" : "android mobile") : a.blackberry() ? c(a.blackberryTablet() ? "blackberry tablet" : "blackberry mobile") : a.windows() ? c(a.windowsTablet() ? "windows tablet" : a.windowsPhone() ? "windows mobile" : "desktop") : a.fxos() ? c(a.fxosTablet() ? "fxos tablet" : "fxos mobile") : a.meego() ? c("meego mobile") : a.nodeWebkit() ? c("node-webkit") : a.television() ? c("television") : a.desktop() && c("desktop"), a.cordova() && c("cordova"), f = function() {
            a.landscape() ? (i("portrait"), c("landscape")) : (i("landscape"), c("portrait"))
        }, h = Object.prototype.hasOwnProperty.call(window, "onorientationchange") ? "orientationchange" : "resize", window.addEventListener ? window.addEventListener(h, f, !1) : window.attachEvent ? window.attachEvent(h, f) : window[h] = f, f(), "function" == typeof define && "object" == typeof define.amd && define.amd ? define(function() {
            return a
        }) : "undefined" != typeof module && module.exports ? module.exports = a : window.device = a
    }).call(this);
    </script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/js/materialize.min.js"></script>
    <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>

    <!-- Service Worker Registration -->
    <script>
    if ('serviceWorker' in navigator) {
        window.addEventListener('load', function() {
            navigator.serviceWorker.register('/sw.js', { scope: '/' })
                .then(function(reg) { console.log('SW registered:', reg.scope); })
                .catch(function(err) { console.log('SW registration failed:', err); });
        });
    }
    </script>
</BODY>

</HTML>