
/* Merged Plone Javascript file
 * This file is dynamically assembled from separate parts.
 * Some of these parts have 3rd party licenses or copyright information attached
 * Such information is valid for that section,
 * not for the entire composite file
 * originating files are separated by - filename.js -
 */

/* - formsubmithelpers.js - */
// http://www.history.ucla.edu/portal_javascripts/formsubmithelpers.js?original=1
function inputSubmitOnClick(event){if(!event) var event=window.event;if(hasClassName(this,'submitting')){return confirm(window.form_resubmit_message)} else{addClassName(this,'submitting')}
return true}
function registerSubmitHandler(){var nodes=cssQuery('input[type=submit]');for(var i=0;i<nodes.length;i++){var node=nodes[i];if(!node.onclick){node.onclick=inputSubmitOnClick}}}
registerPloneFunction(registerSubmitHandler);

/* - reloadBooks.js - */
// Script by Keith for refreshing images generated by bookcover_script
function reloadBooks(loader)
{
    // Stop further onload calls, setTimeout will take it from here
    if (loader)
        loader.onload = "";

    // If the thumbnail list hasn't been retrieved yet, get it now
    if (!this.bookcovers || !this.dest)
    {
        this.bookcovers = document.getElementById("bookcovers");
        this.dest = document.getElementById("thumb_dest");

        // If source or destination isn't found, stop further calls
        if (!this.bookcovers || !this.dest)
            return;

        // Set up initial image
        pos = Math.floor(Math.random() * this.bookcovers.childNodes.length);
        this.dest.appendChild(this.bookcovers.childNodes[pos]);
    }

    // Choose an image from thumbs and swap with an "active" image
    oldimg = this.dest.childNodes[0];
    pos = Math.floor(Math.random() * this.bookcovers.childNodes.length);
    newimg = this.bookcovers.childNodes[pos];
    this.bookcovers.appendChild(this.dest.replaceChild(newimg, oldimg));

    // Set function to run again in 5 seconds
    setTimeout("reloadBooks(null)", 5000);
}
