if(!c8) {
	alert('Please load c8config.js before any other c8 libraries!');
}
/* Loader function for dynamically loaded bits */
c8.Utils = {
		LoadJS: function(url, callback) {
		    var script = document.createElement("script")
		    script.type = "text/javascript";
		    if (script.readyState) { // IE Does things differently, surprise suprise
		        script.onreadystatechange = function(){
		            if (script.readyState == "loaded" || script.readyState == "complete"){
		                script.onreadystatechange = null;
		                if(callback && typeof(callback) == 'function') { callback(); }
		            }
		        };
		    } else {  
		        script.onload = function(){ if(callback && typeof(callback) == 'function') { callback(); } };
		    }
		    script.src = url;
		    document.getElementsByTagName("head")[0].appendChild(script);
		},
		
		Debug: function(t) {
			if(typeof(console) == 'object' && c8.Config.Debug == true) {
				console.log(t);
			}
		},
		
		ArrayToPost: function(o) {
			var _result = [ ];
			for(var i in o) { _result.push(i + '=' + o[i]); }
			return _result.join('&');
		},
		
		Init: function() {
			for(var load in c8.Config.AutoLoad) {
				this.LoadJS(c8.Config.AutoLoad[load]);
			}
		},
		
		Popup: function(url,name,opts) {
			if(opts) {
				p = window.open(url,name,opts);
			} else {
				p = window.open(url,name);
			}
                        if(p == undefined || (p && p.closed)) {
				alert('Please enable browser popup windows to proceed.');
				return false;
			} else {
				if(window.focus) { p.focus(); }
				return p;
			}
		}
}

c8.Utils.Init();
