var DaveOxley =
{
  description: 'daveoxley.co.uk Javascript library',
  prototypeVersion: parseFloat(Prototype.Version.split(".")[0] + "." + Prototype.Version.split(".")[1])
}

if((typeof Prototype=='undefined') || DaveOxley.prototypeVersion < 1.5)
      throw("WebEssence requires the Prototype JavaScript framework >= 1.5");

/** Page class. This class wraps all methods for a single page.
 */
DaveOxley.Page = Class.create();

DaveOxley.Page.prototype =
{
    /** Constructor for Page.
     */
    initialize: function(options)
    {
        this.onloads = new Array();
        this.done_onload = false;
        this.setOptions(options);
    },

    /** Function to add onload functions during page rendering */
    addOnload: function(onload_func)
    {
        if (!this.done_onload)
            this.onloads.push(onload_func);
        else
            onload_func();
    },

    /** Function to process onload functions */
    processOnLoad: function()
    {
        for (var i = 0; i < this.onloads.length; i++)
            this.onloads[i]();
        this.done_onload = true;
    },

    setOptions: function(options)
    {
        this.options = {
             servlet_url        : null
        }
        Object.extend(this.options, options || {});
    }
}

var onloads = new Array();

function bodyOnLoad() {
    for ( var i = 0 ; i < onloads.length ; i++ )
        onloads[i]();
}

