var cont;
$(function () {
    $('#ID_Matricula').change(function () {
        if ($(this).val()) {
            $.getJSON('Funcoes.php?Function=35&search=', {ID_Matricula: $(this).val(), ajax: 'true'}, function (j) {
                var Tabela = "";
                for (var a = 0; a < cont; a++) {
                    $("#00" + a).remove();
                }
                cont = j.length;
                for (var i = 0; i < cont; i++) {
                    Tabela = Tabela +
                            "<tr id='00" + i + "' class='gradeU'>" +
                            "    <td style='text-align: center;'> " + j[i].ContextoEducacional + " </td>" +
                            "    <td style='text-align: center;'> " + j[i].Identificador + " </td>" +
                            "    <td> " + j[i].Disciplina + " </td>" +
                            "    <td style='text-align: center;'> " + j[i].Pri_Etapa + " </td>" +
                            "    <td style='text-align: center;'> " + j[i].Seg_Etapa + " </td>" +
                            "    <td style='text-align: center;'> " + j[i].Terc_Etapa + " </td>" +
                            "    <td style='text-align: center;'> " + j[i].Situacao + " </td>" +
                            "</tr>";
                }
                if (Tabela != "") {
                    $("#Table_Ini").remove();
                    $("#dataTables-example tbody").append(Tabela);
                } else {
                    $("#Table_Ini").remove();
                    $("#dataTables-example tbody").append("<tr id='Table_Ini'><td colspan='7'>Nenhum registro encontrado</tr>");
                }
            });
        }
    });
});
$('#pageAnt').click(function () {
    history.back()
});
$('#CloseModal').click(function () {
    $("#Erro").hide();
});

$('#BT_closeModal').click(function () {
    $("#Erro").hide();
});