// Copied and adapted from http://www.javascriptkit.com/dhtmltutors/domready.shtml
// Adrian Kirk-Burnnand

var alreadyrunflag=0 //flag to indicate whether target function has already been run
var runMethods = []; //assume this js is loaded first and in subsequent js files they append (runMethods.push) references to functions to this array

if (document.addEventListener)
  document.addEventListener("DOMContentLoaded", function(){alreadyrunflag=1; domcontentloaded();}, false)
else if (document.all && !window.opera){
  document.write('<script type="text/javascript" id="contentloadtag" defer="defer" src="javascript:void(0)"><\/script>')
  var contentloadtag=document.getElementById("contentloadtag")
  contentloadtag.onreadystatechange=function(){
    if (this.readyState=="complete"){
      alreadyrunflag=1;
      domcontentloaded();
    }
  }
}

window.onload=function(){
  setTimeout("if (!alreadyrunflag){domcontentloaded();}", 0)
}

function domcontentloaded()
{
	for(var i = 0; i < runMethods.length; i++)
	{
		runMethods[i]();
	}
}
