/*
 * JS for Remote generated by Exadel Tiggzi
 *
 * Created on: Wednesday, November 14, 2012, 02:27:18 PM (PST)
 */
/************************************
 * JS API provided by Exadel Tiggzi  *
 ************************************/
/* Setting project environment indicator */
Tiggr.env = "bundle";
Tiggr.getProjectGUID = function() {
    return 'fbde6832-9b47-4871-ab62-30592a1248e5';
}
Tiggr.getTargetPlatform = function() {
    return '0';
}

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

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

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

function setDetailContent(pageUrl) {
    Tiggr.setDetailContent(pageUrl);
}
/**********************
 * SECURITY CONTEXTS  *
 **********************/
/*******************************
 *      SERVICE SETTINGS        *
 ********************************/
var Settings = {
    "Host IP": "127.0.0.1"
}
/*************************
 *      SERVICES          *
 *************************/
var RESTServiceCONTROL_PREVIOUS = new Tiggr.RestService({
    xhrFields: {
        // The 'xhrFields' property sets additional fields on the XMLHttpRequest.
        // This can be used to set the 'withCredentials' property.
        // Set the value to 'true' if you'd like to pass cookies to the server.
        // If this is enabled, your server must respond with the header
        // 'Access-Control-Allow-Credentials: true'.
        withCredentials: true
    },
    'url': 'http://127.0.0.1:8082/cmds?Control(Previous)',
    'dataType': 'xml',
    'type': 'post',
    'contentType': 'application/x-www-form-urlencoded',
    'serviceSettings': Settings
});
var RESTServiceShowMovie = new Tiggr.RestService({
    xhrFields: {
        // The 'xhrFields' property sets additional fields on the XMLHttpRequest.
        // This can be used to set the 'withCredentials' property.
        // Set the value to 'true' if you'd like to pass cookies to the server.
        // If this is enabled, your server must respond with the header
        // 'Access-Control-Allow-Credentials: true'.
        withCredentials: true
    },
    'url': 'http://127.0.0.1:8082',
    'dataType': 'xml',
    'type': 'post',
    'contentType': 'application/x-www-form-urlencoded',
});
var RESTGetCache = new Tiggr.RestService({
    xhrFields: {
        // The 'xhrFields' property sets additional fields on the XMLHttpRequest.
        // This can be used to set the 'withCredentials' property.
        // Set the value to 'true' if you'd like to pass cookies to the server.
        // If this is enabled, your server must respond with the header
        // 'Access-Control-Allow-Credentials: true'.
        withCredentials: true
    },
    'url': 'http://127.0.0.1:8082/cmds?getCache',
    'dataType': 'xml',
    'type': 'post',
    'contentType': 'application/x-www-form-urlencoded',
});
createSpinner("files/resources/lib/jquerymobile/images/ajax-loader.gif");
Tiggr.AppPages = [{
    "name": "PosterCache",
    "location": "PosterCache.html"
}, {
    "name": "Remote",
    "location": "Remote.html"
}, {
    "name": "DeleteDialog",
    "location": "DeleteDialog.html"
}];
j_17_js = function(runBeforeShow) { /* Object & array with components "name-to-id" mapping */
    var n2id_buf = {
        'mobilegrid17': 'j_21',
        'mobilegridcell306': 'j_22',
        'mobilebutton3': 'j_23',
        'mobilegridcell307': 'j_24',
        'mobilebutton4': 'j_25',
        'mobilegrid19': 'j_26',
        'mobilegridcell324': 'j_27',
        'mobilebutton6': 'j_28',
        'mobilegridcell326': 'j_29',
        'mobilebutton7': 'j_30',
        'mobilegridcell327': 'j_31',
        'mobilebutton8': 'j_32',
        'mobilegridcell328': 'j_33',
        'mobilegrid20': 'j_34',
        'mobilegridcell325': 'j_35',
        'mobilelabel2': 'j_36',
        'mobilegridcell325': 'j_37',
        'mobiletogglePause': 'j_38',
        'mobilegridcell329': 'j_39',
        'mobilegrid18': 'j_40',
        'mobilegridcell322': 'j_41',
        'mobilelabel1': 'j_42',
        'mobilegridcell323': 'j_43',
        'mobiletoggleCustomList': 'j_44',
        'mobilegridcell330': 'j_45',
        'selectCustomList': 'j_46',
        'selectmenuitem1': 'j_47',
        'mobilenavbar3': 'j_49',
        'mobilenavbaritem7': 'j_50',
        'mobilenavbaritem8': 'j_51',
        'mobilenavbaritem9': 'j_52'
    };
    if ("n2id" in window && window.n2id !== undefined) {
        $.extend(n2id, n2id_buf);
    } else {
        window.n2id = n2id_buf;
    }
    Tiggr.CurrentScreen = 'j_17';
    /*************************
     * NONVISUAL COMPONENTS  *
     *************************/
    var datasources = [];
    restCONTROL = new Tiggr.DataSource(RESTServiceCONTROL_PREVIOUS, {
        'onComplete': function(jqXHR, textStatus) {
            $t.refreshScreenFormElements("j_17");
        },
        'onSuccess': function(data) {},
        'onError': function(jqXHR, textStatus, errorThrown) {},
        'responseMapping': [],
        'requestMapping': []
    });
    datasources.push(restCONTROL);
    /************************
     * EVENTS AND HANDLERS  *
     ************************/
    j_17_beforeshow = function() {
        Tiggr.CurrentScreen = 'j_17';
        for (var idx = 0; idx < datasources.length; idx++) {
            datasources[idx].__setupDisplay();
        }
    }
    // screen onload
    screen_2136_onLoad = j_17_onLoad = function() {
        screen_2136_elementsExtraJS();
        j_17_windowEvents();
        screen_2136_elementsEvents();
    }
    // screen window events
    screen_2136_windowEvents = j_17_windowEvents = function() {
        $('#j_17').bind('pageshow orientationchange', function() {
            adjustContentHeightWithPadding();
        });
    }
    // screen elements extra js
    screen_2136_elementsExtraJS = j_17_elementsExtraJS = function() {
        // screen (screen-2136) extra code
        $("#j_38").parent().find("a.ui-slider-handle").attr("tabindex", "5");
        $("#j_44").parent().find("a.ui-slider-handle").attr("tabindex", "5");
        $("#j_46").parent().find("a.ui-btn").attr("tabindex", "6");
    }
    // screen elements handler
    screen_2136_elementsEvents = j_17_elementsEvents = function() {
        $("a :input,a a,a fieldset label").live({
            click: function(event) {
                event.stopPropagation();
            }
        });
        $('#j_48 [name="mobilenavbaritem7"]').die().live({
            click: function() {
                if (!$(this).attr('disabled')) {
                    Tiggr.navigateTo('Remote', {
                        transition: 'flip',
                        reverse: false
                    });
                }
            },
        });
        $('#j_48 [name="mobilenavbaritem8"]').die().live({
            click: function() {
                if (!$(this).attr('disabled')) {
                    Tiggr.navigateTo('PosterCache', {
                        transition: 'flip',
                        reverse: false
                    });
                }
            },
        });
        $('#j_48 [name="mobilenavbaritem9"]').die().live({
            click: function() {
                if (!$(this).attr('disabled')) {
                    alert('Please define properly Page for this action');
                }
            },
        });
    }
    $("#j_17").die("pagebeforeshow").live("pagebeforeshow", function(event, ui) {
        j_17_beforeshow();
    });
    if (runBeforeShow) {
        j_17_beforeshow();
    } else {
        j_17_onLoad();
    }
}
$("#j_17").die("pageinit").live("pageinit", function(event, ui) {
    j_17_js();
});