function setErrors(response, formId, successId)
{
	J('.error').html('');
	
	for(i in response.errors)
		J('#'+response.errors[i].name+'-block .error').html(response.errors[i].message);
	
	return false;
}

function uploadImage(URL, formElement)
{
	J.ajaxFileUpload
	(
		{
			url: URL,
			fileElementId: formElement,
			dataType: 'json',
			success: function (data, status) {
				setErrors(data);
			},
			error: function (data, status, e) {
				alert(e);
			}
		}
	);
}
