function expandNavItem(eventObject) {
  if ($(this).children('ul').length >= 1) {
    $($(this).children('ul')[0]).addClass('visible');
  }
}

function contractNavItem(eventObject) {
  if ($(this).children('ul').length >= 1) {
    $($(this).children('ul')[0]).removeClass('visible');
  }
}

$(document).ready(function() {
  $('#main-nav ul li.has-children').hover(expandNavItem, contractNavItem);
});