$(document).ready(function() {
	$('#status').hide();
	$('div.image_update').hide();
	$("table").find("#image_atual").click(function() {
		var valor = $(this).attr("name");
		$("div#" + valor).show();
	});
	$("#editar input[type=file]").change(function() {
		var html = $.ajax({
			type: "POST",
			url: "check.php",
			data: "file=" + $(this).val(),
			async: false
			}).responseText;
		var input = $(this).get();
		if(html!="") {
			$(input).next("#error").html(html);
			$("#editar input[type=submit]").attr("disabled", "disabled");
		} 
		else
		{
			$(input).next("#error").empty();
			$("#editar input[type=submit]").removeAttr("disabled");
		}
	});
	$('#editar').ajaxForm({
        success: function(data) {
			$('#status').fadeIn();
        }
    });
	$('input[type=submit]').click(function() {
			$(this).ajaxStart(function() {
				$('form#editar').block({ 
                message: '<h1>Processando...</h1>', 
                css: { border: '3px solid #a00' } 
	            }); 
			});
	});
	$('#editar').ajaxStop(function() {
			$('form#editar').unblock();
	});
});
