title: Create global Object from inside Prototype dom loaded event
body: <p>I want to create an object that is globally accessible after the DOM has loaded. My approach is to use prototypes dom:loaded event and instantiate the Object. </p>
  
  <p>The JavaScript Code: </p>
  
  <pre><code>document.observe("dom:loaded", function() {
  
      var globalPAO = new picArrayObject();
      alert(globalPAO.picArray[0]); // alerts [object HTMLDivElement]
  });
  
  var picArrayObject = function () {
  
      var myPic1 = document.getElementById('pic1');
      var myPic2 = document.getElementById('pic2');
      var myPic3 = document.getElementById('pic3');
  
      function construct() {
          this.picArray = [myPic1,myPic2,myPic3];
      }
  
  return new construct();
  }
  
  myTrigger.onClick = function () {
  
      alert(globalPAO.picArray[0]); // alerts nothing
  }
  </code></pre>
  
  <p>Try it yourself: <a href="http://jsfiddle.net/vEGXH/2" rel="nofollow noreferrer">http://jsfiddle.net/vEGXH/2</a></p>