/*
 * A class to handle Load events. Also a place for utils
 */

//To prevent about us bug... Some links were posted on facebook with a trailing /
if(window.location.toString().indexOf('about-us/') > -1)
{
	window.location = window.location.toString().replace('about-us/', 'about-us');
}

//prevent IE error on console.log
if (typeof(console) === 'undefined') {
	var console = { log : function(){} };
}

function using(dep,callback) {
	var outputDep = [];
	
	$.each(dep, function(){ 
		if(this.indexOf('Controller') > -1) outputDep.push( srcURL + "/Controllers/" + this + '.js' );
		else if(this.indexOf('View') > -1) outputDep.push( srcURL + "/Views/" + this + '.js' );
		else if(this.indexOf('Model') > -1) outputDep.push( srcURL + "/Models/" + this + '.js'  );
		else outputDep.push( srcURL + "/" + this + '.js'  );
	});
	
	require(outputDep, callback);
}

function BootStrapperController()
{	
	document.application_state = 'loading';
	//require all the controllers
	using([	'NavigationController',
		   		'ViewController',
					'AjaxController'], onDependenciesLoaded);
					
	function onDependenciesLoaded()
	{		
		NavigationController();
		ViewController();
	}
}


