Auto-add first and last classes to nav menus

The new function adds CSS class names to the first and last items in nav menus. This is for the benefit of styling in Internet Explorer 6-8 which do not support the first-child and last-child pseudo-elements.