////////////////////////////////
// base.js -- random utilities


////////////////////////////////
// IDedObj object

// constructor finds DOM object with the given id
function IDedObj(id) {
   if (document.getElementById) {
      // yay, DOM2-compliant
      this.dom = document.getElementById(id);
      if (!this.dom) return;
      this.style = this.dom.style;
   }
   else if (document.all) {
      // IE
      this.dom = document.all[id];
      if (!this.dom) return;
      this.style = this.dom.style;
   }
   else if (document.layers) {
      // Netscape 4
      this.dom = document.layers[id];
      this.style = this.dom;
   }
}

////////////////////////////////
// load hook

var load_hooks = [];
var unload_hooks = [];

// arrange for fn(loadevent) to be called on page load
function add_load_hook(fn) {
   load_hooks.push(fn); 
}
function add_unload_hook(fn) {
   unload_hooks.push(fn); 
}


window.onload = function (e) {
   var hooks = load_hooks;
   if (!e) e = window.event; 
   load_hooks = [];
   for (var fn in hooks) { hooks[fn](e); }
};

window.onunload = function (e) {
   var hooks = unload_hooks;
   if (!e) e = window.event; 
   unload_hooks = [];
   for (var fn in hooks) { hooks[fn](e); }
};

