$(document).ready(function(){

$(".sortable").sortable({
	update: function(event, ui){
		var id = $(this).attr("id").split("_");
		var unq = get_unq($(this).attr("id"));
		var a = id[2].split('-');
		var items = new Array();
		var i = 0;
		$(this).children().each(function(){
			items[i++] = get_unq($(this).attr("id"));
		});
		switch (id[2]) {
			case 'sort-files' :
				var url = g_path+"services/js/"+g_auth+"/data/"+unq+"/sort-files/"+items.join(',');
				$.getJSON(url, function(json){
					if (json.stat == "ok") {};
				});
			break;
		}
	},
});

$("[id^='dataSetClick_']").click(function(event){
	var id = $(this).attr("id").split("_");
	switch (id[2]) {
		case 'filedata-detach' :
			var a = id[2].split('-');
			var unq = get_unq($(this).attr("id"));
			var url = g_path+"services/js/"+g_auth+"/filedata/"+unq+"/detach";
			$.getJSON(url, function(json){
				if (json.stat == "ok") {
					$("#filedata_" + unq).fadeOut();
				};
			});
		break;
	}
	event.preventDefault();
});

});
