Navbar that adds and removes classes
Is hard to evaluate without the html  but, considere introduce toggleClass.

$element.toggleClass(className, condition);


http://api.jquery.com/toggleClass/

If your jQuery version doesn´t allow it, you can introduce as a separate function:

function toggleClass($element, class, condition) {
   condition ? $element.addClass(class) : $element.removeClass(class);
}


and the full solution: http://jsfiddle.net/cbhvteon/1/