/*
 * JS for posterdetail generated by Appery.io
 *
 */

Appery.getProjectGUID = function() {
    return '8f17a3a7-092a-4731-9c40-cef53ddb40ee';
}

function navigateTo(outcome, useAjax) {
    Appery.navigateTo(outcome, useAjax);
}

function adjustContentHeight() {
    Appery.adjustContentHeight();
}

function adjustContentHeightWithPadding() {
    Appery.adjustContentHeightWithPadding();
}

function setDetailContent(pageUrl) {
    Appery.setDetailContent(pageUrl);
}

Appery.AppPages = [{
    "name": "posterdetail",
    "location": "posterdetail.html"
}];

posterdetail_js = function(runBeforeShow) { /* Object & array with components "name-to-id" mapping */
    var n2id_buf = {
        'mobilegrid_41': 'posterdetail_mobilegrid_41',
        'mobilegridcell_42': 'posterdetail_mobilegridcell_42',
        'mobileimage_51': 'posterdetail_mobileimage_51',
        'mobilegrid_7': 'posterdetail_mobilegrid_7',
        'mobilegridcell_8': 'posterdetail_mobilegridcell_8',
        'mobileimage_32': 'posterdetail_mobileimage_32',
        'mobilegridcell_9': 'posterdetail_mobilegridcell_9',
        'mobiletextinput_73': 'posterdetail_mobiletextinput_73',
        'mobiletextinput_74': 'posterdetail_mobiletextinput_74',
        'video_52': 'posterdetail_video_52',
        'mobilegrid_66': 'posterdetail_mobilegrid_66',
        'mobilegridcell_67': 'posterdetail_mobilegridcell_67',
        'mobilebutton_60': 'posterdetail_mobilebutton_60',
        'mobilebutton_61': 'posterdetail_mobilebutton_61',
        'mobilebutton_62': 'posterdetail_mobilebutton_62',
        'mobilebutton_65': 'posterdetail_mobilebutton_65',
        'mobilebutton_63': 'posterdetail_mobilebutton_63',
        'mobilebutton_64': 'posterdetail_mobilebutton_64',
        'mobilegridcell_71': 'posterdetail_mobilegridcell_71',
        'mobilegrid_33': 'posterdetail_mobilegrid_33',
        'mobilegridcell_34': 'posterdetail_mobilegridcell_34',
        'mobileimage_46': 'posterdetail_mobileimage_46',
        'mobilegridcell_35': 'posterdetail_mobilegridcell_35',
        'mobileimage_47': 'posterdetail_mobileimage_47',
        'mobilegridcell_38': 'posterdetail_mobilegridcell_38',
        'mobileimage_48': 'posterdetail_mobileimage_48',
        'mobilegridcell_39': 'posterdetail_mobilegridcell_39',
        'mobileimage_49': 'posterdetail_mobileimage_49',
        'mobilegridcell_40': 'posterdetail_mobilegridcell_40',
        'mobileimage_50': 'posterdetail_mobileimage_50'
    };

    if ("n2id" in window && window.n2id !== undefined) {
        $.extend(n2id, n2id_buf);
    } else {
        window.n2id = n2id_buf;
    }

    if (navigator.userAgent.indexOf("IEMobile") != -1) {
        //Fixing issue https://github.com/jquery/jquery-mobile/issues/5424 on Windows Phone
        $("div[data-role=page] div[data-role=footer]").css("bottom", "-36px");
    }

    if (Appery.getTargetPlatform == "I") {
        $.each(window.n2id, function(name, id) {
            var elApperyRole = $("#" + id).attr("data-role");
            if (elApperyRole != "appery_label" && elApperyRole != "appery_link") {
                var appleDataSelector = "#" + id + "[x-apple-data-detectors], #" + id + " [x-apple-data-detectors]";
                $(appleDataSelector).attr("x-apple-data-detectors", "false");
            }
        });
    }

    Appery.CurrentScreen = 'posterdetail';

    /*
     * Nonvisual components
     */
    var datasources = [];

    /*
     * Events and handlers
     */

    // Before Show
    posterdetail_beforeshow = function() {
        Appery.CurrentScreen = "posterdetail";
        for (var idx = 0; idx < datasources.length; idx++) {
            datasources[idx].__setupDisplay();
        }
    }

    // On Load
    screen_3671_onLoad = posterdetail_onLoad = function() {
        screen_3671_elementsExtraJS();

        // TODO fire device events only if necessary (with JS logic)
        posterdetail_deviceEvents();
        posterdetail_windowEvents();
        screen_3671_elementsEvents();
    }

    // screen window events
    screen_3671_windowEvents = posterdetail_windowEvents = function() {

        $('#posterdetail').bind('pageshow orientationchange', function() {
            adjustContentHeightWithPadding();
        });

    }

    // device events
    posterdetail_deviceEvents = function() {

        document.addEventListener("deviceready", function() {

        });
    }

    // screen elements extra js
    screen_3671_elementsExtraJS = posterdetail_elementsExtraJS = function() {
        // screen (posterdetail) extra code

    }

    // screen elements handler
    screen_3671_elementsEvents = posterdetail_elementsEvents = function() {

        $("a :input,a a,a fieldset label").live({
            click: function(event) {
                event.stopPropagation();
            }
        });

    }

    $("#posterdetail").die("pagebeforeshow").live("pagebeforeshow", function(event, ui) {
        posterdetail_beforeshow();
    });

    if (runBeforeShow) {
        posterdetail_beforeshow();
    } else {
        posterdetail_onLoad();
    }

}

$("#posterdetail").die("pageinit").live("pageinit", function(event, ui) {
    Appery.processSelectMenu($(this));
    posterdetail_js();
});