var trailMenu = new Object();

trailMenu["archives"]   = "Article Archives";
trailMenu["subluxation"]   = "Subluxations";
trailMenu["brennandc"]   = "Home";


function makeTrailMenu() {
    var parseStart, volDelim, parseEnd;
    var output = "<ul>";
    var path= location.pathname;
    var separator = "&nbsp;&raquo;&nbsp;";
    var re = /\\/g;
    
    
    path = path.replace(re, "/");
    
    // Ensure the port is specified if hosted on Tomcat server using 8080, otherwise 80 is assumed.
    var trail = location.protocol + "//" + location.hostname;
    var leaves = path.split("/");
    
    if (location.protocol.indexOf("file") != -1) {
        parseStart = 1;
        volDelim = "/";
    } else {
        parseStart = 0;
        volDelim = "";
    }
    
    if (leaves[leaves.length-1] == "" || leaves[leaves.length-1] == "index.html" ||
        leaves[leaves.length-1] == "index.php") {
        parseEnd = leaves.length-1;
    } else {
        parseEnd = leaves.length;
    }
    
    for (var i= parseStart; i < parseEnd; i++) {
        output += "<li>";
        if (i == parseStart) {
            trail += "/" + leaves[i] + volDelim;
            output += "<a href='" + trail + "'>";
            output += "Brennan Chiropractic Home";
        } else if (i == parseEnd -1) {
            output += document.title;
            separator = "";
        } else {
            trail += leaves[i] + "/";
            output += "<a href='" + trail + "'>";
            output += trailMenu[leaves[i]];
        }
        output += "</a>" + separator;
    }
    
    output += "</ul><hr>";
    return output;
}