function initMenus() {
  $('.menuparent2 ul').hide();
  $.each($('.menuparent2 a'), function(){
    $('#' + this.id + '.expandfirst ul:first').show();
  });
  $('.menuparent2 a').click(function() {
      var checkElement = $(this).next();
      var parent = this.parentNode.parentNode.id;
      
      if($('#' + parent).hasClass('noaccordion')) {
        $(this).next().slideToggle('normal');
        return false;
      }
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        if($('#' + parent).hasClass('collapsible')) {
        $('#' + parent + ' ul:visible').slideUp('normal');
        }
        return false;
      }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('#' + parent + ' ul:visible').slideUp('normal');      
        if(checkElement.prev().attr("href")=="javascript:;"){
            checkElement.slideDown('normal');
        }
      }
      
    
  });
}


$(document).ready(function(){
  

$("#CadastrovisitaCursoId").hide();
$(".CadastrovisitaCurso").hide();
$("#CadastrovisitaCategoria").bind('change', function(){
                $("#CadastrovisitaCursoId").append('<option>Carregando...</option>');
                $(".Curso").show();
                $("#CadastrovisitaCursoId").show();
		$("#loading").ajaxStart(function(){
                    $(this).show();
					$("#CadastrovisitaCursoId").css({width: "0%"}).animate({width: "165px"}, 'slow');
                                        $(".CadastrovisitaCurso").css({width: "0%"}).animate({width: "165px"}, 'slow'); 
                });
	
        $.ajax({
            type: "POST",
            url: '/cursos/listar/' + $(this).val(),
            dataType: 'json',
           data: null,
            success: function(data){
				//$("#EntradaValorCusto").css({width: "0%"}).animate({width: "165px"}, 'slow'); 
				//$("#cke_contents_EntradaDescricaoServico").empty().val(data.Produto.descricao_servico);
                var options = '';
               
                $.each(data, function(i, item){
					//alert(item.Curso.id);
                    options += '<option value="' + item.Curso.id + '">' + item.Curso.nome +
                    '</option>'; // Cada item da lista concatenados
                });
                
                $("#CadastrovisitaCursoId").empty().append(options);
                
                $("#loading").ajaxStop(function(){
                    $(this).hide();
					
                });
            }
        });
    });

// Canal do Interessado
$("#CanaldointeressadoCursoId").hide();
$(".CanaldointeressadoCurso").hide();
$("#CanaldointeressadoCategoria").bind('change', function(){
                $("#CanaldointeressadoCursoId").append('<option>Carregando...</option>');
                $(".Curso").show();
                $("#CanaldointeressadoCursoId").show();
		$("#loading").ajaxStart(function(){
                    $(this).show();
					$("#CanaldointeressadoCursoId").css({width: "0%"}).animate({width: "165px"}, 'slow');
                                        $(".CanaldointeressadoCurso").css({width: "0%"}).animate({width: "165px"}, 'slow'); 
                });
	
        $.ajax({
            type: "POST",
            url: '/cursos/listar/' + $(this).val(),
            dataType: 'json',
           data: null,
            success: function(data){
				//$("#EntradaValorCusto").css({width: "0%"}).animate({width: "165px"}, 'slow'); 
				//$("#cke_contents_EntradaDescricaoServico").empty().val(data.Produto.descricao_servico);
                var options = '';
               
                $.each(data, function(i, item){
					//alert(item.Curso.id);
                    options += '<option value="' + item.Curso.id + '">' + item.Curso.nome +
                    '</option>'; // Cada item da lista concatenados
                });
                
                $("#CanaldointeressadoCursoId").empty().append(options);
                
                $("#loading").ajaxStop(function(){
                    $(this).hide();
					
                });
            }
        });
    });


  
//$("select, input:checkbox, input:radio, input:file, input:text").uniform();
  // Menu Nossos Cursos
  $("ul.subnav").parent().append('<span></span>'); //adiciona o Tag vazio depois da ul.subnav
  $("ul#menu li:last-child").css({background: 'none'}); //não mostra o separador do último li
  $("ul#menu li span, ul#menu li a").click(function(){ //Quando for clicado...
      //Os seguintes eventos são aplicados ao subnav próprio (o subnav movamente acima e para baixo)
      $(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down subnav no click
      $(this).parent().hover(function(){
      }, function(){
          $(this).parent().find("ul.subnav").slideUp('fast'); //Esconde o submenu quando o mouse sair de foco
      });
  }).hover(function(){
      $(this).addClass("subhover"); //Adiciona class "subhover"
  }, function(){ //Quando sair de foto
      $(this).removeClass("subhover"); //Remove class "subhover"
  });
  //Fim do Menu
  
  //Ativa a funcionalidade "sanfona" do menu
  initMenus();
  
  
  //Adiciona e remove a classe que representa o mouseover
  /*$('.menuparent2').mouseover(function() {
        $(this).addClass("over");
  });
  
  $('.menuparent2').mouseout(function() {
        $(this).removeClass("over")
  });*/
  
  
  //Jquery da pagina Dicas
  $("li.dicasToggle p").hide();
  $.each($('ul'), function(){
    $('li.dicasToggle:first p').show();
  });
  $("li.dicasToggle h2").click(function () {
			$('li.dicasToggle p:visible').hide();
      $(this).next().toggle("normal");     
  });
  $('li.dicasToggle h2').mouseover(function() {$(this).addClass("overLink");});
  $('li.dicasToggle h2').mouseout(function() {$(this).removeClass("overLink");});
  //Fim da pagina Dicas
  
  //Jquery da pagina Downloads
  $(".downloadToggle  p, .listaDownloads").hide();
  $.each($('.downloadToggle h2'), function(){
    $('.downloadToggle:first p').show();
  });
  
  $(".downloadToggle h2").click(function () {
      $(this).next().toggle("normal");
      $(this).next().next().toggle("normal");
      $(this).next().next().next().toggle("normal");
      $('.downloadToggle p:visible').hide();
      $("input[name='newsletter']").next().text(" is newsletter");
  });
  
  $('.downloadToggle h2').mouseover(function() {$(this).addClass("overLink");});
  $('.downloadToggle h2').mouseout(function() {$(this).removeClass("overLink");});

  //Fim da pagina Downloads
  
  //Jquery para pagina A ETEP > Diferencias
  $(".diferenciais p,.diferenciais ul").hide();
  $.each($('div.diferenciais h2'), function(){
    $('div.diferenciais p:first').show();
  });
  $("div.diferenciais h2").click(function () {
	    $('div.diferenciais p:visible').hide();
      $(this).next().toggle("normal");     
  });
  $('.diferenciais h2').mouseover(function() {$(this).addClass("overLink");});
  $('.diferenciais h2').mouseout(function() {$(this).removeClass("overLink");});
  //FIM - query para pagina A ETEP > Diferencias
  
  //Jquery para pagina A ETEP > Unidades
   $(".unidades ul ").hide();
  $(".unidades ul").prev().click(function () {
      $(this).next().toggle("normal");     
  });

  $('.unidades ul').prev().mouseover(function() {$(this).addClass("overLink");});
  $('.unidades ul').prev().mouseout(function() {$(this).removeClass("overLink");});
  //FIM - Jquery para pagina A ETEP > Unidades
  
  


  //Jquery para pagina A ETEP > Projetos
  $(".projetos p,.projetos ul").hide();
  $.each($('div.projetos h2'), function(){
    $('div.projetos p:first').show();
  });
  $(".projetos h2").click(function () {
			$('.projetos p:visible').hide();
      $(this).next().toggle("normal");     
  });
  $('.projetos h2').mouseover(function() {$(this).addClass("overLink");});
  $('.projetos h2').mouseout(function() {$(this).removeClass("overLink");});
  //FIM - query para pagina A ETEP > Projetos
  
  
  //Jquery para pagina A ETEP > Projetos
  $(".programas-de-bolsa-e-credito-educativo p,.programas-de-bolsa-e-credito-educativo ul").hide();
  $.each($('div.programas-de-bolsa-e-credito-educativo h2'), function(){
    $('div.programas-de-bolsa-e-credito-educativo p:first').show();
  });
  $(".programas-de-bolsa-e-credito-educativo h2").click(function () {
      $(this).next().toggle("normal");     
  });
  $('.programas-de-bolsa-e-credito-educativo h2').mouseover(function() {$(this).addClass("overLink");});
  $('.programas-de-bolsa-e-credito-educativo h2').mouseout(function() {$(this).removeClass("overLink");});
  //FIM - query para pagina A ETEP > Projetos
  
  
  
  //Jquery para pagina Canal do Aluno > Portal Medio Tecnico > Mural
  //$(".mural p,.mural ul, .mural li a").hide();
  $.each($('div.mural h2'), function(){
    $('div.mural p:first').show();
  });
  $(".mural h2").click(function () {
      $(this).next().toggle("normal");
      $(this).next().next().toggle("normal");
  });
  
  $('.mural h2').mouseover(function() {$(this).addClass("overLink");});
  $('.mural h2').mouseout(function() {$(this).removeClass("overLink");});
  //FIM - query para pagina Canal do Aluno > Portal Medio Tecnico > Mural
  
  /*$('div.noticia h2').mouseover(function() {$(this).addClass("overLink");});
  $('div.noticia h2').mouseout(function() {$(this).removeClass("overLink");});*/
  
});
