// Breadcrumb trail based on directory names
// Nick Negulescu, nnegulescu@fs.fed.us
// 07-10-2002 v. 1.5
// base = base URL of site w/out last "/" slash. e.g. http://me.com http://me.com/dir
// delStr = delimiter string
// defIndx = directory index page (e.g. 'index'/Apache 'Default'/IIS)
// cStyle = style sheet property for links
// tStyle = style sheet property for title page
// dStyle = style sheet property for delimiter string
// nl = 0, 1 (false, true) for printing page title on new line
// NOTE: lines commented out are for debugging purposes
// call the function in HTML by:
// <script language="JavaScript">
//  breadCrumbs("Site Name", "BASE.URL", "delimiter", "index", "style", "style", "style", "0");
/* </script> */
// 1.5: Mozilla/Netscape 6.0 fixes, takes site name as parameter
// 1.4: BC parses URL and capitalizes after "_" underscores
// 1.2: same as 1.1, minus the debugging info
// 1.0: Adopted based on code by PAUL DAVIS

function breadCrumbs(siteName, base, delStr, defIndx, cStyle, tStyle, dStyle, nl) {
    tStyle, dStyle = cStyle;
    loc = window.location.toString();
    subs = loc.substr(loc.indexOf(base) + base.length + 1).split("/");
    pageName = document.URL.slice(document.URL.lastIndexOf("/")+1, document.URL.lastIndexOf("."));
    document.write("<a href=\"" + getLoc(subs.length - 1) + "\" class=\"" + cStyle + "\">" + siteName + "</a>" + "<span class=\"" + dStyle + "\">" + delStr + "</span>");
    a = ((defIndx == pageName) || (pageName == "")) ? 2 : 1;
    for (i = 0; i < (subs.length - a); i++) {
        subs[i] = makeCaps(unescape(subs[i]));
        document.write("<a href=\"" + getLoc(subs.length - i - 2) + "\" class=\"" + cStyle + "\">" + subs[i] + "</a> " + "<span class=\"" + dStyle + "\">" + delStr + "</span>");
    }
    if (nl == 1) {
        document.write("<br>");
    }
    document.write("<span class=\"" + tStyle + "\">" + document.title + "</span>");

}

function makeCaps(a) {
    g = a.split("_");
    for (l = 0; l < g.length; l++) {
        g[l] = g[l].toUpperCase().slice(0, 1) + g[l].slice(1);
    }
    return g.join(" ");
}
 
function getLoc(c) {
    var d = "";
    if (c > 0) {
        for (k = 0; k < c; k++) {
            d = d + "../";
        }
    }
    if (d=="") {
      d = d + "./"; //Netscape 6 fix
    }
    return d;
}
