function currentPage() {
    // return the current page after stripping
    // off the rest of the path
    // e.g. http://www.abc.com/aaa/bbb/ccc/page.html
    // returns "page.html"

    // get current URL in plain text

    var url = unescape(window.location.href);
    var xend   = url.length;
    var xstart = url.lastIndexOf("/")+1;
    var currPage = url.substring(xstart,xend);
    return currPage;
}

function getPageNames() {
    // define the page names in a function
    // so that other .js files can access them
    var pageNames = new Array("Home",
                              "About us",
                              "Join us",
                              "Events",
                              "Resources",
                              "Contact Us");
    return pageNames;
}

function getPageFilenames() {
    var pageFilenames = new Array("index.html",
                                  "about.html",
                                  "join.html",
                                  "events.html",
                                  "resources.html",
                                  "contact.html");
    return pageFilenames
}

var pageNames     = getPageNames();
var pageFilenames = getPageFilenames();

// keep track of the link status
var status = new Array();
var allInactive = 1;

// loop over all links to find the active one
for (ii=0; ii<pageNames.length; ii++) {
    status[ii] = "inactive";
    if (currentPage() == pageFilenames[ii]) {
        status[ii] = "active";
        allInactive = 0;
    }
}

if (allInactive) {
    status[0] = "active";
}

// then write the links
document.write('<ul class="links">');
for (ii=0; ii<pageNames.length; ii++) {
    document.write('   <li><a class='+status[ii]+' href="'+pageFilenames[ii]+'">'+pageNames[ii]+'</a></li>');
}
document.write('</ul>');
