var dragger = null;
jQuery(document).ready(function(){
    $(document).pngFix();    
    $("#sortable").sortable({
        update : function () {
			var overlay = $("<div id='modal-overlay'></div>");
			$("body").append(overlay)
			overlay.fadeIn(150);
            serial = $('#sortable').sortable('serialize');
            $.ajax({
                url: "/Admin/ShowGalleri/Sort/"+jQuery(this).attr("class").replace("sort_","").replace(" ui-sortable","")+"",
                type: "post",
                data: serial,
                error: function(){
                    alert("theres an error with AJAX");
                },
				success: function() {
					window.location = window.location.pathname
				}
            });
        }
    });
    $('a[title="Slet"]').click(function() {
        return confirm("Ønsker du at slette objektet?");
    });
    $("#dragable").draggable({
        containment: "parent",
        scroll: true,
        cursor: 'crosshair',
        stop: function(event, ui) {
            var left = $(this).position().left - $(this).parent().position().left
            var top = $(this).position().top - $(this).parent().position().top
            $("input[name='left']").val(left);
            $("input[name='top']").val(top);
        }
    });
	
});
