<div id="apploadershade" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 100000; background-color: rgba(0,0,0,0.5); display: none;"></div>
<iframe id="appframe" src="" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 99999; border: 0px;"></iframe>

<script>
    function launchapp(id, api, url, icon, title) {
        $.post(url + api, {
            username: localStorage.getItem("username"),
            key: localStorage.getItem("key"),
            password: localStorage.getItem("password"),
            action: "start_session"
        }, function (data) {
            if (data.status === 'OK') {
                $('#appframe').on("load", function () {
                    $('#apploadershade').css('display', 'block');
                    $.get("css/sidemenu.css", function (style) {
                        $('#appframe').contents().find('head').append("<style>" + style + "</style>");
                        $.get("js/sidemenu.js", function (script) {
                            script = script.replace("%%USERNAME%%", userinfo.realname);
                            script = script.replace("%%LOGO%%", icon);
                            $('#appframe').contents().find('body').append("<script>" + script + "<\/script>");
                            $('#apploadershade').css('display', 'none');
                        });
                    });
                });
                $('#appframe').attr('src', url);
            } else {
                navigator.notification.alert(data.msg, null, "Error", 'Dismiss');
                openscreen("home");
            }
        }, "json").fail(function () {
            navigator.notification.alert("Could not connect to the server.  Try again later.", null, "Error", 'Dismiss');
            openscreen("home");
        });
    }
</script>