function initMenu() {
  $('#menu ul').hide();

  url = location.href.split('/');
  url = url[url.length - 1];

  $('#menu  li').each(function() {
    ul = $(this).find('ul');

    if ($(ul).length == 0 ) {
      a = $(this).find('a:eq(0)');
      if ($(a).attr('href') == url) {
        $(a).addClass('destacado');
      }          
    } else {
      $(ul).find('li').each(function() {
        if ($(this).find('a').attr('href') == url) {
          $(this).find('a').addClass('destacado');
          $(this).parent().show();
        }
      });
    }
  });

  $('#menu li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
      }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {	
	$(this).parent().parent().find('ul:visible').slideUp('normal');	
        checkElement.slideDown('normal');
        return false;
      }
    }
  );
}
$(document).ready(function() { initMenu();});

