function check_upload(obj) { 
	if (obj.val() != '') {
		regex = /(gif|GIF|jpg|JPG|jpeg|JPEG|png|PNG)$/i;
		result = regex.test(obj.val());
		if (result == 0) {
			error(POPRAWNY_FORMAT + "<br />  -gif<br /> -jpg/jpeg<br />  -png<br />");
			obj.val("");
			return 0;
		} else {
			return 1;
		}
	} else {
		error(WYBIERZ_FOTO);
		return 0;
	}
}
var optionsFile  = { 
    beforeSubmit:  	showRequestFile, 
    success:       	showResponseFile,  
    url:      		URL_UPLOAD,       
    type:     		'post'
}
	
function addFile(){
		if ($('#foto_file').val()) {
			if(check_upload($('#foto_file')))
			$('#add_file').ajaxSubmit(optionsFile);
		}
}

function showRequestFile(formData, jqForm, options)  { 
	notice_load();
	return true; 
} 

function showResponseFile(responseText, statusText)  {
	remove_notice_and_error();
	$('#foto_box #data').html(responseText);
	$('#foto_box #data').slideDown(100);
	remove_notice_load();
}

function delete_file(el) { //el - numer zdjęcia
	$.ajax({
		type: 'POST',
		url: URL_DEL+"&element="+el,
		success: function(s) {
			$('#foto_box #data #image_'+el).slideUp(100);
			$('#foto_box #data #image_'+el).html("");
			remove_notice_load();
		},
		 beforeSend: function(){
		 	notice_load();
		 }
	});
}

