
// Handling of onload for different brwosers
// from http://dean.edwards.name/weblog/2006/06/again/
// http://dean.edwards.name/weblog/2005/09/busted/

// For Mozilla browsers
if (document.addEventListener) {
  document.addEventListener("DOMContentLoaded", initialize, false);
}

// For webkit browsers
if (/WebKit/i.test(navigator.userAgent)) { // sniff
  var _timer = setInterval(function() {
    if (/loaded|complete/.test(document.readyState)) {
      clearInterval(_timer);
      initialize(); // call the onload handler
    }
  }, 10);
}

// for Internet Explorer (using conditional comments)
/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
  if (this.readyState == "complete") {
    initialize(); // call the onload handler
  }
};
/*@end @*/

// from http://ckon.wordpress.com/2008/07/25/stop-using-windowonload-in-javascript/
if (window.attachEvent) {window.attachEvent('onload', initialize);}
else if (window.addEventListener) {window.addEventListener('load', initialize, false);}
else {document.addEventListener('load', initialize, false);}

// Everyon else
window.onload = initialize;
window.onunload = GUnload;


