var _isMobile = false;

function LoadingOn(completeCallback) {

    SetarZIndex();
    if(completeCallback)
        $('#load-screen').fadeIn('slow', completeCallback);
    else
        $('#load-screen').fadeIn();
}
function LoadingOff() {
    $('#load-screen').delay(500).fadeOut();
}

// Força Z-index máximo sobre os elementos HTML's
function SetarZIndex() {
    var $parent = $('#load-screen').parent();
    var $elementsOnSameLevel = $parent.children();

    var heighestZIndex = 0;
    $.each($elementsOnSameLevel, function (index, element) {
        var zIndexOfElement = $(element).css('z-index');
        if (zIndexOfElement) {
            var zIndexOfElementAsNumber = parseInt(zIndexOfElement) || 0;
            if (zIndexOfElementAsNumber > heighestZIndex) {
                heighestZIndex = zIndexOfElementAsNumber;
            }
        }
    });
    var currentZIndex = $('#load-screen').css('z-index');

    if (currentZIndex < heighestZIndex) {
        $('#load-screen').css('z-index', heighestZIndex + 1);
    }
}