var prev=0;
jQuery.nginxUploadProgress = function(e, nginx_progress_url, progress_bar_id, uuid) {
	$.ajax({
		type: "GET",
		url: nginx_progress_url,
		dataType: "json",
		beforeSend: function(xhr) {
			xhr.setRequestHeader("X-Progress-ID", uuid);
		},
		success: function(upload) {
			/* change the width if the inner progress-bar */
			if (upload.state == 'uploading') {
				bar = $('#'+progress_bar_id);
				w = Math.floor((upload.received / upload.size)*100);
				bar.width(w + '%');
				speed=(upload.received-prev)
				$('#speed').html(speed+" Кб/с");
				prev=upload.received;
			}
			/* we are done, stop the interval */
			if (upload.state == 'done') {
				window.clearTimeout(e.timer);
			}
		}
	});
};