﻿function LoadAdminContent(strUrl, parameters) {
    NavigateParameters('', false, '', strUrl, parameters, '#coluna_2');
}

function VerificaCampos(formId) {
    var valid = true;

    $('.obrigatorio').each(function() {
        if ($(this).val() != null && $(this).val().length <= 0) {
            $(this).prev().prev().css({ 'color': 'red', 'font-weight': 'bold' });
            valid = false;
        }
    });
    if (valid) {
        $(formId).submit();
    }
    else {
        alert('Preencha todos os campos obrigatórios.');
    }
}

function BlockPage(elemento, largura, altura) {
    if (largura == null)
        largura = 600;

    if (altura == null)
        altura = 500;

    $.blockUI({
        message: $(elemento),
        css: {
            width: largura,
            height: altura,
            top: (($(window).height() - altura) / 2),
            left: (($(window).width() - largura) / 2) + $(window).scrollLeft(),
            backgroundColor: '#FFF'
        }
    });
}

function CarregaPaginas(url, parameters, elemento) {
    $.ajax({
        type: 'POST',
        url: url,
        async: false,
        cache: false,
        data: parameters,
        success: function(html) {
            if (elemento != null) {
                $(elemento).empty();
                $(elemento).html(html);
            }
            else {
                alert(html);
            }
        },
        error: function(data, mensagem) {
            var erro = 'Erro ao carregar. Tente novamente.';
            if (elemento != null) {
                $(elemento).empty();
                $(elemento).html(erro);
            }
            else {
                alert(erro);
            }
        }
    });
}
