I have a bit of javascript that finds a link on the page and if it's the same link as the current page it changes the css to current. This works fine. But what I want to do is extend this so for instance lets same the link is mysite.com/blog/post. I want it to go up a directory i.e. mysite.com/blog find if that links on the page and if it is highlight it, hopefully that makes sense.The code I have is:

```
<script type="text/javascript">
$(document).ready( function () {
var path = location.pathname;
if ( path )
 $('#sidebar ul.archive a[href$="' + path + '"]').attr('class', 'current');
 }); 
</script>

```

So I'm thinking I just need to change the var path to find the link to the directory above, but can't figure out how I'd do that?