function imageSubmit() {
	$("#image_submit_id").attr('disabled', 'disabled');
	$("#image_errors_id").hide();
	$("#image_loading_id").show();
	
	$.ajaxUpload
	({
		url: '/modules/photos/photos.php',
		secureuri: false,
		uploadform: imageForm,
		type: 'POST',
		dataType: 'html',
		success: function (data, status)
		{
			result = eval("(" + data + ")");
			if (result['error'] != '')
			{
				$("#image_errors_id").html(result['error']);
				$("#image_errors_id").show();
			}
			if (result['src'] != null) {
				html = '<div class="unit" style="background-image:url(\'' + result['src'] + '.jpg\'); width:'+ result['width'] + 'px; height:'+ result['height'] + 'px;"><a href="" onclick="imageDelete(this, ' + result['id'] + '); return false;"><img src="/templates/img/icons/delete_image.gif"></a></div>';
				$('#photos_id').append(html);

				$("#image_upload_id").attr('value', '');
			}
			$("#image_submit_id").attr('disabled', '');
			$("#image_loading_id").hide();
		},
		error: function (data, status, e)
		{
			$("#image_submit_id").attr('disabled', '');
			$("#image_loading_id").hide();
			$("#image_errors_id").hide();
			alert('Error...');
		}
	});
}

function imageDelete(obj, id)
{
	if (confirm('Удалить изображение?'))
	{
		$("#image_errors_id").hide();
		$("#image_loading_id").show();
		$.post (
			'/modules/photos/photos.php',
			{
				operation: 'delete',
				id: id
			},
			function (data, status)
			{
				if (data == 1)
				{
					$(obj.parentNode).remove();
				}
				$("#image_loading_id").hide();
			}
		);
	}
}
