﻿(function ()
{
	var window = this, undefined;

	soundManager.debugMode = false;
	soundManager.defaultOptions.volume = 33;
	soundManager.url = 'plugins/';
	

	// Temporary object in case the SoundManager isn't initialized before the first sound is played.
	window["Sound"] = {
		initialized: false,

		play: function (type)
		{
			return;
		}
	};

	// *** Private Constants ***

	soundManager.onload = function()
	{
		window["Sound"] = {
			// *** Public Constants ***

			BOX_MOVING:		[
								soundManager.createSound({ id: 'BOX_MOVING_1',			url: 'sounds/box_moving_1.mp3' }),
								soundManager.createSound({ id: 'BOX_MOVING_2',			url: 'sounds/box_moving_2.mp3' }),
								soundManager.createSound({ id: 'BOX_MOVING_3',			url: 'sounds/box_moving_3.mp3' }),
								soundManager.createSound({ id: 'BOX_MOVING_4',			url: 'sounds/box_moving_4.mp3' })
							],
			MERGED_BOX_MOVING:	[
								soundManager.createSound({ id: 'MERGED_BOX_MOVING_1',		url: 'sounds/merged_box_moving_1.mp3' }),
								soundManager.createSound({ id: 'MERGED_BOX_MOVING_2',		url: 'sounds/merged_box_moving_2.mp3' }),
								soundManager.createSound({ id: 'MERGED_BOX_MOVING_3',		url: 'sounds/merged_box_moving_3.mp3' }),
								soundManager.createSound({ id: 'MERGED_BOX_MOVING_4',		url: 'sounds/merged_box_moving_4.mp3' })
							],
			BOX_MOVING_BLOCKED:		soundManager.createSound({ id: 'BOX_MOVING_BLOCKED',		url: 'sounds/box_moving_blocked.mp3' }),
			BOX_MOVING_BLOCKED_TILT:	soundManager.createSound({ id: 'BOX_MOVING_BLOCKED_TILT',	url: 'sounds/box_moving_blocked_tilt.mp3' }),
			BOX_SWITCHING:			soundManager.createSound({ id: 'BOX_SWITCHING',			url: 'sounds/box_switching.mp3' }),
			BOX_SWITCHING_FAILED:	soundManager.createSound({ id: 'BOX_SWITCHING_FAILED',		url: 'sounds/box_switching_failed.mp3' }),
			BOX_MERGING:			soundManager.createSound({ id: 'BOX_MERGING',			url: 'sounds/box_merging.mp3' }),
			BOX_MERGING_FAILED:		soundManager.createSound({ id: 'BOX_MERGING_FAILED',		url: 'sounds/box_merging_failed.mp3' }),
			BOX_SPLITTING:			soundManager.createSound({ id: 'BOX_SPLITTING',			url: 'sounds/box_splitting.mp3' }),
			BOX_SPLITTING_FAILED:	soundManager.createSound({ id: 'BOX_SPLITTING_FAILED',		url: 'sounds/box_splitting_failed.mp3' }),
			BOX_MERGE_SPLIT:		soundManager.createSound({ id: 'BOX_MERGE_SPLIT',			url: 'sounds/box_merge_split.mp3' }),

			UNSUPPORTED_KEY_PRESSED:	soundManager.createSound({ id: 'UNSUPPORTED_KEY_PRESSED',	url: 'sounds/unsupported_key_pressed.mp3' }),

			// *** Variables ***

			initialized: true,

			// *** Functions ***

			play: function (type)
			{
				if ($.isArray(type))
				{
					type[$.rand(0, type.length - 1)].play();
				}
				else
				{
					type.play();
				}
			}
		}
	}
})();
