 var MyLoadEvents = [];
 
 function DOMLoadInit() 
  {
     
      // kill the timer
      if (window.MyLoadtimer) 
      {
          clearInterval(window.MyLoadtimer);
          window.MyLoadtimer = null;
      }
      
      // execute each function in the stack in the order they were added
      for (var i=0;i < MyLoadEvents.length;i++) 
      {
          MyLoadEvents[i]();
      }
      MyLoadEvents = [];
      

   }
  
function addDOMLoadEvent(func)
 {
   if (MyLoadEvents.length == 0)
   {
      // for Mozilla/Opera9
      if (document.addEventListener) 
      {
          document.addEventListener("DOMContentLoaded", DOMLoadInit, false);
      }
      
      // for Safari
      if (/WebKit/i.test(navigator.userAgent)) 
      { // sniff
          window.MyLoadtimer = setInterval(function() 
          {
              if (/loaded|complete/.test(document.readyState)) 
              {
                  DOMLoadInit(); // call the onload handler
              }
          }, 10);
      }

      // for Internet Explorer
      /*@cc_on @*/
      /*@if (@_win32)
          document.onreadystatechange = function() {
              if (this.readyState == "complete") {
                  DOMLoadInit(); // call the onload handler
              }
          };
      /*@end @*/
      
      // for other browsers
      window.onload = DOMLoadInit;
 
     // add function to event stack
     MyLoadEvents.push(func);
    
   }
}
   
 