/** * Assorted site-level JavaScript utilities. *//** * Processes the current document's links and changes their style if their hrefs * match the given string. */var updateLinkStyles = function(pattern, className) {    var i;    for (i = 0; i < document.links.length; i += 1) {        if (document.links[i].href.match(pattern)) {            document.links[i].className = className;        }    }};/** * Prints the content of the current window. */var printThis = function() {    if (window.print) {        window.print();    }};/** * e-mails the URL of the current window. */var emailThis = function() {    window.location = "mailto:?subject=" + document.title + "&body=\n\t" + window.location + "\n";};/** * Updates the given object's HTML with the site's information. The second * argument, level, states how far down the document's URL to travel before * cutting out the rest; this allows a "root site" of sorts to be defined. A * level of zero will return only the URL's server name. */var updateSiteHome = function(id, level) {    // Extract the URL's protocol.    var protPath = document.URL.split("://");    var siteHome = protPath[0] + "://";    // Next, reconstruct the URL only up to the given level.    var steps = protPath[1].split("/");    for ( var i = 0; (i < level + 1) && (i < steps.length); i += 1) {        siteHome = siteHome + steps[i];        if ((i < level) && (i < steps.length - 1)) {            siteHome = siteHome + "/";        }    }    var siteBlock = document.getElementById(id);    siteBlock.innerHTML = siteHome;    siteBlock.href = siteHome;};/** * Updates the given object's HTML with the page's lastModified property. */var updateLastModified = function(id) {    var modBlock = document.getElementById(id);    modBlock.innerHTML = document.lastModified;};/** * Unconditionally makes the given element visible. */var makeVisible = function(element) {    element.visible = true;    element.style.display = "block";};/** * Unconditionally makes the given element invisible. */var makeInvisible = function(element) {    element.visible = false;    element.style.display = "none";};/** * Toggles the visibility or invisibility of the element with the given ID. */var hideAndSeek = function(id) {    var target = document.getElementById(id);    if (target.visible) {        makeInvisible(target);    } else {        makeVisible(target);    }};/** * Unconditionally makes the element with the given ID visible. */var makeIdVisible = function(id) {    makeVisible(document.getElementById(id));};/** * Unconditionally makes the element with the given ID invisible. */var makeIdInvisible = function(id) {    makeInvisible(document.getElementById(id));};
