var controlsList = ['Window', 'Canvas'];
var libsList = ['ThreeJS'];
var controlsLoaded = 0;
var controlsLength = controlsList.length * 2 + 1 + libsList.length;

for(var k in controlsList) {
	$.ajax({type:'GET',cache:false,url:'controls/'+controlsList[k]+'.js?v='+FA_VERSION+FA_FIXPACK,dataType:'script',success: function(){
		if(++controlsLoaded == controlsLength) boot();
		$('#loadingBarSlider').stop().animate({'width':controlsLoaded/controlsLength*100+'%'},2000);
	}});
	$.ajax({type:'GET',cache:false,url:'theme/elite/'+controlsList[k]+'/main.css?v='+FA_VERSION+FA_FIXPACK,success: function(d){
		if(++controlsLoaded == controlsLength) boot();
		$('#themeStyle').append(d);
		$('#loadingBarSlider').stop().animate({'width':controlsLoaded/controlsLength*100+'%'},2000);
	}});
}
for(var k in libsList) {
	$.ajax({type:'GET',cache:false,url:'libs/'+libsList[k]+'.js?v='+FA_VERSION+FA_FIXPACK,dataType:'script',success: function(){
		if(++controlsLoaded == controlsLength) boot();
		$('#loadingBarSlider').stop().animate({'width':controlsLoaded/controlsLength*100+'%'},2000);
	}});
}

perpImg('images/loginbg.jpg', function() {
	if(++controlsLoaded == controlsLength) boot();
	$('#loadingBarSlider').stop().animate({'width':controlsLoaded/controlsLength*100+'%'},2000);
});

function boot() {
	setTimeout(function() {
		$.ajax({type:'GET',cache:false,url:'apps/com.elitecloud.system/main.js?v='+FA_VERSION+FA_FIXPACK,dataType:'script',success: function(){
			$('#loadingDiv').remove();
			$(window).off('resize').on('resize', function() {
				for(var k in RESOLUTIONCHANGE) {
					RESOLUTIONCHANGE[k](window.innerWidth, window.innerHeight);
				}
			});
		}});
	}, 4000);
}