$(function() {
    var startupView = "Login";

    // Uncomment the line below to disable platform-specific look and feel and to use the Generic theme for all devices
    // DevExpress.devices.current({ platform: "generic" });

    if(DevExpress.devices.real().platform === "win8") {
        $("body").css("background-color", "#000");
    }

    $(document).on("deviceready", function () {
        navigator.splashscreen.hide();
        if (window.devextremeaddon) {
            window.devextremeaddon.setup();
        }
        $(document).on("backbutton", function () {
            DevExpress.processHardwareBackButton();
        });
    });

    function onNavigatingBack(e) {
        if(e.isHardwareButton && !Nuvolar_Scanner_Android.app.canBack()) {
            e.cancel = true;
            exitApp();
        }
    }
   
    function exitApp() {
        switch (DevExpress.devices.real().platform) {
            case "android":
                navigator.app.exitApp();
                break;
            case "win8":
                window.external.Notify("DevExpress.ExitApp");
                break;
        }
    }

    Nuvolar_Scanner_Android.app = new DevExpress.framework.html.HtmlApplication({
        namespace: Nuvolar_Scanner_Android,
        layoutSet: DevExpress.framework.html.layoutSets[Nuvolar_Scanner_Android.config.layoutSet],
        animationSet: DevExpress.framework.html.animationSets[Nuvolar_Scanner_Android.config.animationSet],
        //navigation: navigation, //Nuvolar_Scanner_Android.config.
        commandMapping: Nuvolar_Scanner_Android.config.commandMapping,
        navigateToRootViewMode: "resetHistory",
        useViewTitleAsBackText: true,
        disableViewCache: true
    });

    $(window).unload(function() {
        Nuvolar_Scanner_Android.app.saveState();
    });

    Nuvolar_Scanner_Android.app.router.register(":view/:id", { view: startupView, id: undefined });
    Nuvolar_Scanner_Android.app.on("navigatingBack", onNavigatingBack);
    Nuvolar_Scanner_Android.app.navigate();
});