/* 
 * CLEAR Namespaces
 */

CLEAR = window.CLEAR || {};

/*
 * Bootstrapping code
 * 
 * This should be included directly after the opening <body> tag.
 * 
 * If a module required a <script> tag in the middle of the page
 * markup, queue up the code in a function so that jQuery and other
 * dependencies are available for the code runs.
 * 
 * Usage:
 * 
 * <script type="text/javascript">
 * 		CLEAR.queue(function() {
 * 			// do something with jQuery, etc
 * 		});
 * </script>
 * 
 * ...
 * 
 * $(document).ready(function() {
 * 		CLEAR.unqueue();
 * });
 * 
 */
(function(CLEAR) {
	
	document.body.className += " js-enabled";
	
	var queue = [];
	
	CLEAR.queue = function() {
		for (var i = -1, func; func = arguments[++i];) {
			queue[queue.length] = func;
		}
	};
	
	CLEAR.unqueue = function() {
		var func;
		while (func = queue.shift()) {
			func();
		}
		
		// Nullify
		for (var i = queue.length - 1; i >= 0; i--) {
			queue[i] = null;
		}
		
		queue = null;
	};
	
}(CLEAR));