// check for jQuery exists
if (typeof jQuery != 'undefined')
{
	$.getScript = function(url, callback, cache)
	{
		cache = typeof cache == 'undefined' ? true : cache;

		$.ajax({
			type: "GET",
			url: url,
			success: callback,
			dataType: "script",
			cache: cache
		});
	};

	$.extend($, {
		nds: {

			// track registered modules
			modules: [],

			// load a module and do callback
			load: function(module, callback, cache, external)
			{
				// load multiple modules
				if (typeof module == 'object') {
					// do callback after last item
					var call = (module.length > 1) ? function() { $.nds.load(module, callback, cache, external); } : callback;
					this.get(module[0], call, cache, external);
					module.shift();
				}
				// load single module
				else {
					this.get(module, callback, cache, external);
				}
			},

			// get module source and execute callback
			get: function(module, callback, cache, external)
			{
				if (!this.modules[module])
				{
					$.getScript('/content/web/js/' + module + '.js', function(data, status) {

						if (status == 'success') {

							$.nds.register(module);

							if (typeof callback == 'function') {
								callback();
							}
						}
					}, cache);
				}
			},

			// register loaded modules
			register: function(name)
			{
				this.modules[name] = true;
			}
		}
	});

	// load fonts and font-style
	var fonts = [
		'fonts/typeface',
		'fonts/eurostile_lt_std_bold.typeface',
		'fonts/eurostile_lt_std_condensed.typeface',
		'fonts/eurostile_lt_std_demi.typeface',
		'fonts/eurostile_lt_std_medium.typeface'
	];

	$.nds.load(fonts, function() {
		_typeface_js.configure({ disableSelection: true });
		_typeface_js.initialize();
	}, false);

	// load global nds scripts
	$.nds.load('nds/ajax');
	$.nds.load('nds/nds');
}
