// Multiple onload event handler
var loader={

  // Add() - adds a function to the onload queue
  add:function(func) {

    // Store this function in the queue.
    loader.loadlist[loader.loadlist.length] = func;

    // If addEventListener() is supported, add our function to
    // the the list as a 'load' event.
    if ('undefined' != typeof(window.addEventListener)) {
      window.addEventListener('load', func, false);

    // Otherwise, we'll define our own function.
    } else if (!loader.done) {

      // If readystatechange is available, use that
      if ('undefined' != typeof(document.onreadystatechange)) {
        document.onreadystatechange = loader.onload;
      }

      // Remember we did this part
      loader.setDone = true;
    }
  },

  // Onload() - custom handler for IE browsers
  onload:function() {

    // Check if readyState is available
    if ('undefined' != typeof(document.readyState)) {

      // Check if the document had already loaded and quit if it has
      if (isMac ? (document.readyState != 'interactive') : (document.readyState != 'complete')) {
        return;
      }
    }

    // Loop through list and run the functions
    for (var i=0; i<loader.loadlist.length; i++) {
      loader.loadlist[i]();
    }
  },

  // To remember we have set up
  // the handler already
  done:false,

  // To store the list of events
  // we want to run
  loadlist:[]
};
