function updateCoords(c) {
	$('#x').val(c.x);
	$('#y').val(c.y);
	$('#w').val(c.w);
	$('#h').val(c.h);
};

function checkCoords() 
{ 
  if ($('#x').val() != '') return true; 
  alert('Maak eerst een selectie.'); 
  return false; 
}; 

function createSortable(id, itemsClass, action, direction){
	$(id).sortable({ 
        items: itemsClass,
        delay: 10,
        distance: 0,
        axis: direction,
        opacity: 0.5,
        placeholder: 'ui-placeholder',
        change: function(event, ui) {  },
		update: function(e, ui){
			$("#JQresult").html('Updaten...');
            $.ajax({
                type: "POST",
                url: webroot + '/' + action,
                data: "itemId=&newOrder="+$(id).sortable('toArray'),
                error: function(msg){
                    $("#JQresult").html(msg);
                },
                success: function(msg){
                    $("#JQresult").html(msg);
                }
            });
		}
    });
}

function createTableSortable(table, action) {
	$(table).sortable({ 
		items: 'tr', 
		placeholder: 'ui-state-highlight', 
		axis: 'y', 
		handle: '.handle',
		items: 'tr:not(.ui-state-disabled)',
		update: function(e, ui){
            $.ajax({
                type: "POST",
                url: webroot+action,
                data: "itemId=&newOrder="+$(table).sortable('toArray'),
                error: function(msg){
                    $("#JQresult").html(msg);
                },
                success: function(msg){
                    $("#JQresult").html(msg);
                }
            });
		}
	});
}
