
$(function()
	{
		var counter = 1, value = 0;
		$('#jplayer').on($.jPlayer.event.ended,function(event){
			var src = _.last(event.jPlayer.status.src.split('/'));
			if(src === 'file.mp3')
			{
			setTimeout(function()
				{
				$('#jplayer').jPlayer('setMedia', {mp3: './media/814-1.mp3'}).jPlayer('play');
				$('.next').fadeIn();
				},100);
			}
		});

		$('.q' + counter).fadeIn(1);
			$('.answ').click(function(){
				value = $(this).data('value');
				if	(value === 1){
					$('#jplayer_well').jPlayer('play');
					$('.q' + counter).fadeOut(1);
					counter++;
					$('.q' + counter).fadeIn(1);
                                        $('#jplayer_well').jPlayer('play');	
                                        
                                if (counter === 7){ 
                                    $('.qu').fadeOut(1);                     
                                 
                                    $('.bravo').fadeIn(1000);
                                    
                                }        
			if(counter < 1) { 
				counter = 1;
			}
			else if  (counter > 6) {
				counter = 7;
			}
			
					setTimeout(function()
						{
							if(counter !== 7) {$('#jplayer').jPlayer('setMedia', {mp3: './media/814-'+counter+'.mp3'}).jPlayer('play');}
							else{}
						},2100);
			
				} 
				else 
				{
				$('#jplayer_wrong').jPlayer('play');
				}
			});
			
	});
