$(function ()
{
    var zindex = 10;

    $(".dragg").draggable({
        start: function () {
            zindex++;
            $(this).css('z-index', zindex);
        }
    });

    var drop = function (event, ui) {
            $(this).data('value', ui.draggable.data('value'));
            ui.draggable.attr('style', 'visibility:hidden;');
            $(this).addClass(ui.draggable.data('secondclass')+" sprite");
    };

    $(".target_g").droppable({
        accept: ".g",
        tolerance: "pointer",
        drop: drop
    });
});