/**
** PS v.1.1.0
**/

var DOMLoader = (function () {
	
	// private and static variables
	var $_a_Handlers = [];
	var $_b_IsExecuting = false;
	var $_i_Timer = null;
	
	// on load single handler
	var $_f_CallHandlers = function () {
		
		// declare variables
		var $i;
		
		// change execution flag
		$_b_IsExecuting = true;
		
		// loop through each handler
		for ($i = 0; $i < $_a_Handlers.length; ++$i) {
			
			// execute it
			$_a_Handlers [$i] ();
		}
	}
	
	// Dean Edwards/Matthias Miller/John Resig
	// modified from: http://dean.edwards.name/weblog/2006/06/again/
	
	/* Latest Modern Browsers - Firefox / Opera / Safari / Chrome / Flock - may be others; haven't tested */
	if ((document.addEventListener)) {
		document.addEventListener ('DOMContentLoaded', $_f_CallHandlers, false);
	
	} else if ((navigator.userAgent.toLowerCase ().indexOf ('webkit') >= 0)) {
		// for Safari -- tested and works without this branch of code -- leaving it intact just in case
		// sniff
		
		$_i_Timer = setInterval (function() {
			
			if ((document.readyState.indexOf ('loaded') >= 0) || (document.readyState.indexOf ('complete') >= 0)) {
				clearInterval ($_i_Timer);
				$_i_Timer = null;
				$_f_CallHandlers (); // call the onload handler
			}
		}, 10);
	} else {
		
		/* for Internet Explorer */
		/*@cc_on @*/
		/*@if ((@_win32) || (@_win64))
			
			document.write ('<script type="text/javascript" id="__ie_onload" defer="defer" src="javascript:void(0)"><\/script>');
			var $_o_Script = document.getElementById ('__ie_onload');
			$_o_Script.onreadystatechange = function () {
				if ((this.readyState == 'complete')) {
					$_f_CallHandlers (); // call the onload handler
				}
			};
			
		@else @*/
		
			/* for other browsers */
			window.onload = $_f_CallHandlers;
		/*@end @*/
		
	}
	
	// create object
	var $__object = {
		addEvent : function ($pf_Handler) {
			if ((!$_b_IsExecuting)) $_a_Handlers [$_a_Handlers.length] = $pf_Handler;
		}
	};
	
	// return object
	return $__object;
}) ();
