$(function()
{
var count = 8;
var addClass ='';
var click = function()
	{
		if ($(this).data('right') === 1) addClass = 'good';
			else addClass = 'wrong';
		$(this).parent().find('.result').addClass(addClass).fadeIn();
		count--;
		if (count === 0)
		{

			var good = $('.result.good').length;
			
			if (good === 8) {
			$('#jplayer_well').jPlayer('play');
			}
			else
			{	
				$('.click').unbind('click');
				$('#jplayer_wrong').jPlayer('play');
				setTimeout(function() {
				count = $('.result.wrong').length;
				$('.result.wrong').removeClass('wrong').fadeOut();
				$('.click').click(click);
				},2000);
			}

		}
	};
$('.click').click(click);
});