function markActiveLink() {

    //Look through all the links in the sidebar
   $("ul#categorias li a").filter(function() {

      //Take the current URL and split it into chunks at each slash
      var currentURL = window.location.toString().split("/");

      //return true if the bit after the last slash is the current page name
       return $(this).attr("id") == currentURL[currentURL.length - 1] || $(this).attr("id") == currentURL[currentURL.length - 2] || $(this).attr("id") == currentURL[currentURL.length - 3];

    //when the filter function is done, you're left with the links that match.
    }).addClass("active");

   //Afterwards, look back through the links. If none of them were marked,
   //mark your default one.
   if($("ul#categorias li a").hasClass("active") == false) {
      $("ul#categorias li a#home").addClass("active");
    }
 }
 
 $(document).ready(function() {

    markActiveLink();
	
});
