Simple Accordion. Need to set active class.

Simple Accordion. Need to set active class.

function initMenus() {
   $('ul.menu ul').hide();
   $.each($('ul.menu'), function(){
      $('#' + this.id + '.expandfirst ul:first').show();
   });
   $('ul.menu li 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').removeClass("ul-active");
            checkElement.slideDown('normal').addClass("ul-active");
            return false;
         }
      }
   );
}
$(document).ready(function() {initMenus();});


I'm absolute JS noob. I managed to add active class to the level 2 menu, but couldn't find where to add addClass and removeClass to for the main triggers (a tags).

I'd appreciate any help. Thanks in advance.