/* argonne.js, Ken Teh, Aug 2006
 */
function path2crumb(apath)
{
    var s, t;

    t = apath.replace(/_/g, " ");
    s = t.replace(/\b\w+\b/g, function(word) {
            return word.substring(0, 1).toUpperCase() +
                word.substring(1);
        });
    return s;
}

function breadcrumbs()
{
    var crumbs = new Array();
    var href, s, paths;
    var i, j, k;

    href = window.location.protocol;
    href += '//' + window.location.hostname;
    crumbs[0] = '<a href="http://www.anl.gov">Argonne</a> > <a href="' + href + '">Physics</a>';

    s = window.location.pathname.slice(1);
    paths = s.split('/');
    k = paths.length - 1;
    for (i = 0, j = 1; i < k; ++i, ++j) {
        href += '/' + paths[i];
        s = path2crumb(paths[i]);
        crumbs[j] = '<a href="' + href + '">';
        crumbs[j] += s + '</a>';
    }

    /* If the last paths element is not empty and is not 'index.*', add it
     * to the crumbs trail.
     *
     * /kt Sep 2006/ Dont show the path leaf on the breadcrumbs trail.
    s = paths[k];
    if (paths[k].length > 0 && paths[k].slice(0, 6) != "index.") {
        href += '/' + paths[k];
        crumbs[j] = '<a href="' + href + '">';
        crumbs[j] += paths[k] + '</a>';
    }
     */

    s = crumbs.join("&nbsp;&gt;&nbsp;");
    document.write(s);
}

function iedropdown(aNode)
{
    /* Griffith and Webb's menu drop-downs (suckerfish drop-downs) for
     * Internet Explorer.  Leave test of browser to the caller since this is
     * a recursive function.
     */
     for (var i = 0; i < aNode.childNodes.length; ++i) {
        var cNode = aNode.childNodes[i];
        if (cNode.nodeName == "UL") iedropdown(cNode);
        if (cNode.nodeName == "LI" && cNode.className != "separator") {
            cNode.onmouseover = function() {
                this.className += " over";
            }
            cNode.onmouseout = function() {
                this.className = this.className.replace(" over", "");
            }
            iedropdown(cNode);
        }
     }
}
