
$(function()
	{
var turn = 0;
var pair = {kind: [0,0]};
var click = function()
		{
		$(this).addClass('select').off('click');
			if (turn === 0) {
				pair.kind[0]=$(this).data('kind');
				turn = 1;
			}else if (turn === 1)
				{
				pair.kind[1]=$(this).data('kind');
				$('.click:not(.no)').off('click');
				turn = 0;
					if (pair.kind[0] === pair.kind[1])
						{
							$('#jplayer_well').jPlayer('play');
							var a = $(".ppl[data-kind='"+pair.kind[0]+"']");
							var b = $(".book[data-kind='"+pair.kind[0]+"']");
							var top = a.position().top + (a.height() -(a.height() - 220)) - (b.height() / 2);
							var left = a.position().left + (a.width() / 2) - (b.width() / 2);

							if (pair.kind[0] === 18) {
								left=5.5;
								top=432.5;
							}
							if (pair.kind[0] === 20) {
								left=752;
								top=368;
							}

							$(".book[data-kind='"+pair.kind[0]+"']").animate({top:top,left:left},500)

							$("[data-kind='"+pair.kind[0]+"']").each(function(){
								$(this).addClass('no').removeClass('select');

							});
							setTimeout(function()
								{
								$('.click:not(.no)').on('click',click);
								},2000);

						} else if (pair.kind[0] !== pair.kind[1]) {
							$('#jplayer_wrong').jPlayer('play');
								setTimeout(function()
								{
								$('.click:not(.no)').removeClass('select');
								$('.click:not(.no)').on('click',click);
								},2000);
						}

				}

		}


	$('.click:not(.no)').click(click);


	});
