Есть код, нужно перетаскиванием составить мозаику, код с каждым правильным или не правильным ответом увеличивает счётчик, но при аболютно любых действиях срабатывает FalseAnswer. Помогите пожалуйста!
<script type="text/javascript">
$( init );
var i = 0;
var g = 0;
function init() {
$('.otvet_first').draggable({
snap: ".droppable_first"
});
$('.otvet_second').draggable({
snap: ".droppable_second"
});
$('.otvet_third').draggable({
snap: ".droppable_third"
});
$('.otvet_four').draggable({
snap: ".droppable_four"
});
$( ".droppable_first" ).droppable({
drop: function (e, ui) {
switch(ui.draggable.attr('class')) {
case 'otvet_first':
i++;
g++;
break;
default:
g++;
}
if (g >= 4) {
if (i >= 4) {
$('#TrueAnswer').arcticmodal();
}
else {
$('#FalseAnswer').arcticmodal();
};
};
}
});
$( ".droppable_second" ).droppable({
drop: function (e, ui) {
switch(ui.draggable.attr('class')) {
case 'otvet_second':
i++;
g++;
break;
default:
g++;
}
if (g >= 4) {
if (i >= 4) {
$('#TrueAnswer').arcticmodal();
}
else {
$('#FalseAnswer').arcticmodal();
};
};
}
});
$( ".droppable_third" ).droppable({
drop: function (e, ui) {
switch(ui.draggable.attr('class')) {
case 'otvet_third':
i++;
g++;
break;
default:
g++;
}
if (g >= 4) {
if (i >= 4) {
$('#TrueAnswer').arcticmodal();
}
else {
$('#FalseAnswer').arcticmodal();
};
};
}
});
$( ".droppable_four" ).droppable({
drop: function (e, ui) {
switch(ui.draggable.attr('class')) {
case 'otvet_four':
i++;
g++;
break;
default:
g++;
}
if (g >= 4) {
if (i >= 4) {
$('#TrueAnswer').arcticmodal();
}
else {
$('#FalseAnswer').arcticmodal();
};
};
}
});
}
</script>