var JsLoader=new Object();
JsLoader.IsLoading = false;
JsLoader.Queue=new Array();

JsLoader.AddScript=function(scriptPath){
	JsLoader.Queue[JsLoader.Queue.length]=scriptPath;
};

JsLoader.CheckQueue=function(){
	if (this.Queue.length>0){
		if( !this.IsLoading ){
			this.IsLoading=true;
			var sScriptPath=this.Queue[0];
			var oTempArray=new Array();
			
			for (var i=1;i<this.Queue.length;i++){
				oTempArray[i-1]=this.Queue[i];
			}
			this.Queue=oTempArray;
			
			var e;
			if (sScriptPath.lastIndexOf('.css')>0){
				e=document.createElement('LINK');
				e.rel='stylesheet';
				e.type='text/css';
			}else{
				e=document.createElement("script");
				e.type="text/javascript";
			};
			document.getElementsByTagName("head")[0].appendChild(e);
			
			if (e.tagName=='LINK'){
				e.href=sScriptPath;
			}else{
				e.src=sScriptPath;
			};

			e.onload=e.onreadystatechange=function(){
				JsLoader.IsLoading = false;
				JsLoader.CheckQueue();
			};
		}
	}
};

JsLoader.Load = function(){
	JsLoader.CheckQueue();
}