// footer.js:  contains a single JavaScript function, returnFooter, 
// which is used to return an HTML string to any HTML page, which 
// is intended to be used as the bottom of the page, thus standardizing 
// the look of all pages.
// Input argument (optional) may be used to specify the date-time at 
// which the calling page was last modified.

function returnFooter (dateTimeModified) {
    var siteDate  = "09/28/2009";  // update this each time the site is changed
    var connected = true;          // false only on my local machine, when offline
    var home      = "http://users.rcn.com/jtcraw/";

    // initial value (to be added on to below):
    var footer    = "\n<hr><table align=center>\n<tr><td colspan=5 align=center>";

    if (returnFooter.arguments.length > 0) {
        var dateTime = new Date (dateTimeModified);

        var month = dateTime.getMonth() + 1;  // because January = 0
        var day   = dateTime.getDate();
        var year  = dateTime.getFullYear();

        // add a zero if appropriate:
        if (month < 10) month = "0" + month;
        if ( day  < 10) day   = "0" + day;

        // check for Y2K problems:
        if (year < 1000) year += 1900;
        if (year < 1990) year += 100;

        var dateString = month + "/" + day + "/" + year;

        footer += "This page last modified ";
        footer += dateString + ";  s";

    } else {
        footer += "S";
    }
    footer += "ite last updated " + siteDate + "</td></tr>\n<tr><td >";

    if (!connected) home = "file://C:/jtc/websites/jtcraw/export/index.html";

    footer += "<a href=\"" + home + "\" target=\"_top\" >";
    footer += "home</a> \n";

    if (!connected) home = "file://C:/jtc/websites/jtcraw/export/";

    footer += "</td>\n<td align=right > \n";
    footer += "<a href=\"" + home + "whatsNew.html\" target=\"_top\">what's new</a> \n";

    footer += "</td>\n<td align=right > \n";

    // include the applet to update the hit counter:
    if (connected) {
        footer += "<applet ARCHIVE=\"http://counter.bloke.com/Counter.zip\" \n";
        footer += "        CODEBASE=\"http://counter.bloke.com/\" \n";
        footer += "        CODE=\"Counter.class\" WIDTH=75 HEIGHT=20 > \n";
        footer += "  <param name=URL value=\"http://www.ultranet.com/~jtcraw/\"> \n";
        footer += "  <param name=reset value=\"0\"> \n";
        footer += "  <param name=img value=\"/default.gif\"> \n";
        footer += "</applet>";

    // when running offline, use a "fake" counter image, to give the same format:
    } else {
        footer += "<img src=\"file://C:/jtc/websites/jtcraw/fakeCounter.jpg\""
                  + " width=75 height=20 >";
    }

    footer += "</td>\n<td align=left > \n";
    footer += "<a href=\"" + home + "hits.html\" target=\"_top\">hits</a>\n";

    footer += "</td>\n<td align=right >\n";
    footer += "<a href=\"mailto:John T Crawford <johnTcrawford@gmail.com>\" >";
    footer += "e-mail</a>";

    footer += "</td>\n</tr></table> \n";
    return footer;
}
