﻿var callBacks = [];

fastLoadOnload = function()
{
  var callBacksLen = callBacks.length;
  for (var i = 0; i < callBacksLen; i++)
    callBacks[i]();
  
  callBacks = null;
}
  
fastLoadAdd = function(callBack)
{
  callBacks.push(callBack);
}

/*@cc_on @*/
/*@if (@_win32)
document.write('<script id="__ie" defer src="' + ((location.protocol == 'https:') ? '//0' : 'javascript:void(0)') + '"><\/script>');
document.getElementById('__ie').onreadystatechange = function(){if (this.readyState == 'complete') { fastLoadOnload(); }};
var hooked = true;
/*@end @*/

if (/WebKit|khtml/i.test(navigator.userAgent))
{
  var fastLoadTimer = setInterval(function()
  {
    if (/loaded|complete/.test(document.readyState))
    {
      clearInterval(fastLoadTimer);
      fastLoadTimer = null;
      fastLoadOnload();
    }
  }, 10);
}
else if (document.addEventListener)
  document.addEventListener('DOMContentLoaded', fastLoadOnload, false);
else if (!hooked)
  addEvent(window, 'load', fastLoadOnload);

