$(function ()
{
    var zindex = 10;

    $('main').append('<div class="textbox less sprite btn dragg" data-dropped="0" data-value="<"></div>');
    $('main').append('<div class="textbox more sprite btn dragg" data-dropped="0" data-value=">"></div>');

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

    var drop = function (event, ui) {
	if (ui.draggable.data('dropped') === 0) {
	    ui.draggable.data('dropped', 1).attr("data-dropped", "1");
	    $(this).data('value', ui.draggable.data('value'));
	    var a = $(this).attr('id');
	    var b = a.substr(1, 1);
	    if (b === "1") {
		check1();
	    }
	}
    };

    var out = function (event, ui) {
	if (ui.draggable.data('dropped') === 1) {
	    ui.draggable.data('dropped', 0).attr("data-dropped", "0");
	    $(this).data('value', 0);
	}
    };

    $(".target").droppable({
	accept: ".textbox",
	tolerance: "pointer",
	drop: drop,
	out: out
    });

    function check1() {
	var t11 = $("#t11").data('value');
	if (t11 === '<')
	{
	    $('#jplayer_well').jPlayer('play');
	    $("#z1 > *").css("border-bottom-color", "#35B105");
	} else {
	    if (t11 !== 0) {
		$('#jplayer_wrong').jPlayer('play');
		$("#z1 > *").css("border-bottom-color", "#DA251C");
	    }
	}
    }
});