[#5599] Fixed and cleaned up nav-bar selection logic

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 8a06566..f95aae0 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -445,6 +445,8 @@
                         ordinal = anchored_tools.keys().index(entry.tool_name.lower())
                     else:
                         ordinal = int(ac.options.get('ordinal', 0)) + delta_ordinal
+                    if self.is_nbhd_project and entry.label == 'Admin':
+                        entry.matching_urls.append('%s_admin/' % self.url())
                     if ordinal > max_ordinal:
                         max_ordinal = ordinal
                     entries.append({'ordinal':ordinal,'entry':entry})
diff --git a/Allura/allura/templates/jinja_master/top_nav.html b/Allura/allura/templates/jinja_master/top_nav.html
index 47ef332..8ef4621 100644
--- a/Allura/allura/templates/jinja_master/top_nav.html
+++ b/Allura/allura/templates/jinja_master/top_nav.html
@@ -19,18 +19,7 @@
 {% if c.project %}
 <ul class="dropdown">
   {% for s in c.project.grouped_navbar_entries() %}
-    {% set selected = False %}
-    {% if s.label == 'Home' %}
-      {% set url_length = s.url|length %}
-      {% if request.url.rfind(s.url, -url_length) != -1 %}
-        {% set selected = True %}
-      {% endif %}
-    {% else %}
-      {% if s.matches_url(request) or c.project.neighborhood.url()+'_admin' in request.upath_info %}
-        {% set selected = True %}
-      {% endif %}
-    {% endif %}
-    <li class="{% if selected %}selected{% endif %}">
+    <li class="{% if s.matches_url(request) %}selected{% endif %}">
         <a href="{{s.url}}" class="ui-icon-{{s.ui_icon or 'admin'}}">
             {{s.label}}
         </a>
@@ -38,11 +27,7 @@
         {% if grouped_tool_count %}
             <ul>
                 {%for tool in s.children%}
-                    {% set selected = False %}
-                    {% if tool.matches_url(request) or c.project.neighborhood.url()+'_admin' in request.upath_info%}
-                        {% set selected = True %}
-                    {% endif %}
-                    <li class="{% if selected %}selected{% endif %}"><a href="{{tool.url}}">{{tool.label}}</a></li>
+                    <li class="{% if tool.matches_url(request) %}selected{% endif %}"><a href="{{tool.url}}">{{tool.label}}</a></li>
                 {%endfor%}
             </ul>
         {% endif %}