$(document).ready(function() {
    $("#leftnavcontainer a").each(function(i, link) {
        // This regular expression has 2 requirements:
        //     1. Paths are absolute. i.e. begin with a slash
        //        (The protocol and server name are optional.)
        //     2. The index page is named one of the following:
        //            a. index.htm
        //            b. index.html
        //            c. index.shtm
        //            d. index.shtml
        var page_regex = /^(?:(?:https?:\/\/)?[^\/]+)?((?:\/[^\/]+?)+?)\/?(?:index\.s?html?)?$/i;
        
        var link_href     = page_regex.exec($(link).attr("href"));
        var document_href = page_regex.exec(document.location.href);
        
        if (null != link_href && null != document_href && link_href[1] == document_href[1]) {
            $(link).addClass("current");
        }
    });
});

