/* http://dean.edwards.name/weblog/2005/09/busted/
This script is used to create an event for DomContentLoaded, which executes PRIOR to the page onLoad event.  It is ideal to run this initialization javascript on the DomContentLoaded (refered to in this script as the Init() function) because it minimizes the possibility of browser flicker.  

There is an issue with IE though, which is why we check the page protocol.  For HTTPS pages, an external script is included to get around the issue that
javascript:void(); executes an HTTP request, giving a "Page contains unsecure items" warning.  By including the external script, we get around this issue.  We only do this when needed though, which is on the HTTPS pages, since this method has the potential to introduce page flicker due to the time needed to load an external script.
*/

/* DO NOT DELETE THIS BLOCK!!! */
/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32) {
	var loc = document.location.toString();
	var index = loc.indexOf(":");
	var protocol = loc.substring(0,index);

	if (protocol == "https") {
		document.write("<script defer src=/html-inf/scripts/ie_sslInit.js><\/script>");
	}
	else {
		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") {
				init(); // call the onload handler
			}
		}
	}
};
/*@end @*/

/* for Mozilla/Opera9 */
if (document.addEventListener) {
	document.addEventListener("DOMContentLoaded", init, false);
}

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
	var _timer = setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
			init(); // call the onload handler
		}
	}, 10);
}

/* for other browsers */
window.onload = init;

function init() {
	// quit if this function has already been called
	if (arguments.callee.done) return;

	// flag this function so we don't do the same thing twice
	arguments.callee.done = true;

	// kill the timer
	if (_timer) clearInterval(_timer);

	// do stuff
	prep();
};
