/*
File: bootsrap.js

About: Version
	1.0

Description:
	Sets up some basic functionality at the top of the document, including:
	* Add a 'js' class to the HTML element for styling hooks
	* add queue and unqueue functions for queuing inline scripts
	* Perform the HTML5 shiv for styling HTML5 elements in IE8 and earlier
	
Last Modified:
	- $Date: 2011/09/22 19:00:50 $
	- $Revision: 1.6 $
	- $LastChangedBy: NA+josh.glasman $

*/

/**
	Declare CC Namespace if need be
*/
window.CC = window.CC || {};

(function(){
	
	
	var rootClasses = [],	// Set up an array of classes which we'll tack onto the html element
		queue = [],			// Set up a queue for functions that need to be called before all javascript has been loaded.
		platform = window.navigator.platform.toLowerCase(),
		elems, i, elem;
	
	// We've obviously got javascript working if we're executing this, so,
	rootClasses.push('js');

	// Get the platform
	if (platform.match(/win/)) {
		rootClasses.push('windows');
	} else if (platform.match(/mac/)) {
		rootClasses.push('mac');
	} else if (platform.match(/linux/)) {
		rootClasses.push('linux');
	}
	
	// Add a 'js' class to the HTML element for styling hooks
	try {
		document.getElementsByTagName('html')[0].className += (' ' + rootClasses.join(' '));
	} catch(e) {}
	
	// Set up the webfont loading events - This is primarily to fight the FOUT in Firefox.
	try {
		WebFont.load({
			custom: {
				families: ['HelveticaNeueLTCom35Thin','HelveticaNeueLTCom45Light','HelveticaNeueLTCom55Roman','HelveticaNeueLTCom75Bold'],
				urls : ['/fonts/helvneue.css']
			}
		});
	} catch(e) {}
	
	/*
	method: CC.queue
	 	Adds functions to a queuer to be deployed once the DOM is ready

	Parameters:
		arguments - the function (or functions) to add to the queue
	*/
	CC.queue = function() {
		for (var i = -1, func; func = arguments[++i];) {
			queue[queue.length] = func;
		}
	};

	/*
	method: CC.unqueue
	 	Fires each queued function
	*/
	CC.unqueue = function() {
		var func;
		while (func = queue.shift()) {
			func();
		}
	};
	
	// Enable HTML 5 elements for styling in IE:
	if (!(!/*@cc_on!@*/0) ) {
		
		elems = 'abbr article aside audio canvas datalist details summary eventsource figcaption figure footer header hgroup mark menu meter nav output progress section svg time video'.split(' ');

		//alert(elems);
		i = elems.length+1;
		
		while ( --i ) {
			elem = document.createElement( elems[i] );
		}
		elem = null;
	}
})();
