require.config({
	paths: {
		jquery: "libraries/jquery/jquery-1.8.0",
		jqueryUI: "libraries/jquery/jquery-ui-1.8.23",
		jqueryPreloadCssImages: "libraries/jquery/preloadCssImages.jQuery_v5",
		underscore: "libraries/underscore/underscore-1.3.3",
		backbone: "libraries/backbone/backbone-0.9.2",
		templates: "../templates",
		text: "libraries/require/text-2.0.1"
	},

	shim: {
		underscore: {
			exports: "_"
		},

		backbone: {
			deps: ['underscore', 'jquery'],
			exports: "Backbone"
		},

		jqueryUI: ['jquery'],

		jqueryPreloadCssImages: ['jquery']
	}
});

require([
	"underscore",
	"jquery",
	"backbone",
	"jqueryUI",
	"jqueryPreloadCssImages",
	"soundOutput/soundOutput",
	"sequencer/scheduler",
	"tracks/trackCollection",
	"commandMap",
	"application/applicationView",
	"./keyboardShortcuts",
	"./documentListeners",
	"utilities/functionChain",
	"text!templates/unsupported.html"
], function (_, $, Backbone, jqueryUI, jqueryPreloadCssImages, SoundOutput, Scheduler, TrackCollection, commandMap, ApplicationView, keyboardShortcuts, documentListeners, functionChain, unsupportedTemplateString) {
	$.preloadCssImages();

	var eventBus = _.clone(Backbone.Events);

	var commandContext = {
		eventBus: eventBus
	};

	_.each(commandMap, function (mappings, event) {
		_.each(mappings, function (map) {
			if (map.guards) {
				eventBus.on(event, function () {
					functionChain(map.guards, commandContext, arguments, map.successCommand, map.failureCommand);
				});
			} else {
				eventBus.on(event, map.successCommand, commandContext);
			}
		});
	});

	if (window.webkitAudioContext) {
		var context = new webkitAudioContext();

		commandContext.scheduler = new Scheduler(context);
		commandContext.selectedTrackModel = null;
		commandContext.sequenceLength = 16;
		commandContext.sequencePosition = 0;
		commandContext.soundOutput = new SoundOutput(context);
		commandContext.trackCollection = new TrackCollection();

		var notes;

		commandContext.scheduler.on("update", function (delaySeconds) {
			commandContext.trackCollection.each(function (trackModel) {
				notes = trackModel.get("sequencer").next();

				trackModel.get("instrumentManager").processNotes(notes, function (buffer, note, volume) {
					commandContext.soundOutput.playBuffer(buffer, note, volume, delaySeconds);
				});
			});

			commandContext.sequencePosition++;

			if (commandContext.sequencePosition >= commandContext.sequenceLength)
				commandContext.sequencePosition = 0;
		});

		var applicationView = new ApplicationView({
			eventBus: eventBus,
			el: "#container",
			model: {
				scheduler: commandContext.scheduler,
				soundOutput: commandContext.soundOutput,
				trackCollection: commandContext.trackCollection
			}
		});

		keyboardShortcuts(eventBus);
		documentListeners(eventBus);

		applicationView.render();

		eventBus.trigger("initialize");
	} else {
		var unsupported = $(unsupportedTemplateString);

		$("#description").append(unsupported);

		unsupported.hide();
		unsupported.fadeIn(1200);
	}
});

@@ -2950,41 +2950,128 @@
 %0A%0A%09%09
-unsupported.hide();%0A%09%09unsupported
+// filter(%22*%22) required as of Firefox 15.0%0A%09%09// see http://bugs.jquery.com/ticket/12462%0A%09%09unsupported.filter(%22*%22).hide()
 .fad

Fix newlines in unsupported template causing error in Firefox.