/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$(document).ready(function(){

        $("#rodape").corner();
                
     $("#anolectivo").change(function(){
                // carregar os periodos
                var ano = $(this).val();
                // get por ajax
                 $("#link").html('');
                 $("#periodo").html('');
                 $("#turma").html('');
        $.ajax({
                  cache: false,
                  timeout : 10000,
                  url: "ajax.php",
                  global: false,
                  type: "POST",
                  data: ({ano : ano,  cl: 'pautas', pedido : 1}),
                  dataType: "html",
                  success: function(data)
                  {
                                // constroi
                                $("#periodo").html(data);
                                //loadPeriodo();
                    },
                    error : function()
                      {
                      }
              }); // ajax
              

     });

     //function loadPeriodo()
     //{

          $("#periodo").change(function(){

                // carregar os periodos
                var periodo = $(this).val();
                // get por ajax
                if (periodo != 0)
                {
                        $("#turma").html('');
                        $("#turma").html('a obter dados...');
                        $.ajax({
                                  cache: false,
                                  timeout : 10000,
                                  url: "ajax.php",
                                  global: false,
                                  type: "POST",
                                  data: ({periodo : periodo,  cl: 'pautas', pedido : 2}),
                                  dataType: "html",
                                  success: function(data)
                                  {
                                        // constroi
                                        $("#turma").html(data);
                                        //getFilePauta();
                                    },
                                    error : function()
                                      {
                                      }
                              }); // ajax
                              
                }
          });
//     }

                $("#turma").change(function(){
                // carregar os periodos
                var file = $(this).val();
                if (file != 0)
                        $("#link").html('<br /><a href="upload/pautas/' + file + '" target="_blank"><img src="imagens/icons/pdf_icon.gif" border="0" alt="ver ficheiro" /> ver pauta </a>').fadeIn();

                });


});

