$(function(){ 

var zindex = 10, counter = 0;
		var drop = function (event, ui) {
			var x = ui.draggable.data('value');
			var y = $(this).data('value');
			
					
					var top = $(this).position().top;
					var left = $(this).position().left;	
                                        
                                       
					
					ui.draggable
							.draggable({revert: false})
							.draggable("option", "disabled", true);	
							
					ui.draggable.animate({
						top: top, 
						left: left
					}, 900);
		if (x != y) {	counter++;if(counter == 2){$('#jplayer_wrong').jPlayer('play');
                    setTimeout(function(){$("#drag1").animate({
                                                top: 189,
                                                left: 270
                                            }, 900)
							.draggable({revert: true})
							.draggable("option", "disabled", false);
                                            $("#drag2").animate({
                                                top: 189,
                                                left: 526
                                            }, 900)
							.draggable({revert: true})
							.draggable("option", "disabled", false);}, 1000);
                                        counter=0;    
                                        }
                } else {
				counter++;if(counter == 2){
                                    $('#jplayer_well').jPlayer('play');
                                ui.draggable
							.draggable({revert: false})
							.draggable("option", "disabled", true);
			}
                        }
		};
			
			
$('.dragz').draggable({
	start: function () {
		zindex++;
		$(this).css('z-index', zindex);
	},
	revert: true,
	revertDuration: 800
});
$('.dropz').droppable({
	accept: ".dragz",
	tolerance: "touch",
	drop: drop
});	
});
