
$(function()
	{
	var drop = [0,0,0,0,0];

	$('#jplayer').on($.jPlayer.event.ready,function()
		{

			$('#jplayer').jPlayer('setMedia', {mp3: './media/file3.mp3'});

		});





	$('.elements > *,.marks > *').each(function()
	{
	var $this = $(this);
	$this.attr('data-dropped',0);
	$this.draggable(
		{
		containment: $('main'),
		cursor: 'move',
		//revert: true,
		opacity: .7
		});
	});



	$('.warp > *').each(function()
		{
		var $this = $(this);

		$this.droppable(
			{
			accept: $('.elements > *,.marks > *'),
			addClasses: false,
			out: function(event,ui)
				{
					   if (ui.draggable.attr('data-dropped') === "1")
                                            {
                                            ui.draggable.attr( 'data-dropped', "0");

							if (drop[$(event.target).data('index')] === ui.draggable.text()) drop[$(event.target).data('index')] = 0;

                                            }

				},
			drop: function(event,ui)
				{
					   if (ui.draggable.attr('data-dropped') === "0")
                                            {
                                            ui.draggable.attr( 'data-dropped', "1");

							drop[$(event.target).data('index')] = ui.draggable.text();



                                            }


				}
			});
		});





	/**
	 * Check
	 */
	$('.footer_game .check').click(function(e)
		{
		e.preventDefault();
		var ok = true;




		if (!(  (drop[0] === "7") && (drop[2] === "3") && (drop[1]==="\u2013")  && (drop[3]==="=") && (drop[4]==="4")  )) ok = false;





		if(ok)
			{
			$('#jplayer_well').jPlayer('play');
			}
		else
			{
			$('#jplayer_wrong').jPlayer('play');
			}
		});



	});
