$(function () {
	
		$("#blogsubmit").click(function() {
			$("#feedback").append("<img src=images/ajax-loader.gif' id='loading' alt='...Carrengando...' />").show();
			var text = $("#fcomment").val();
			var name = $("#fname").val();
			var code = $("#captcha_code").val();
			var comm = $(this).attr("comment");
			var dept = $(this).attr("dept");
			$.post("query.php", { method: "comment", page: "0", fcomment: text, fname: name, captcha_code: code, cid: comm, did: dept}, 
			function(data) {
				if (data == "success") {
					$("#feedback").html("Comentario enviado com sucesso. Por favor, aguarde ate que um de nossos administradores revisem seu comentario.");//<br><a href='#' id='again'>Enviar outro comentario.</a>");
					$("#fcomment").val(" ");
					$("#fname").val(" ");
					$("#captcha").attr("src","securimage/securimage_show.php?" + Math.random());
					$("#form").hide();
				}
				else if (data == "emptyerror") {
					$("#feedback").html("Por favor, preencha todos os campos antes de enviar seu comentario.");
				}
				else if (data == "captchaerror") {
					$("#feedback").html("O texto nao e igual a imagem. Tente outra vez.");
				}
				else {
					$("#feedback").html(data);
				}
			});
			$("#captcha").attr("src","securimage/securimage_show.php?" + Math.random());
			$("#loading").remove();
			return false;
		});
		
		$("#again").click(function() {
			$("#form").show();
		});
		
		/*$(".bgd").hover(
			function() {
				$(this).css("background-color", "#BEB592");
				//$('#author').html("<img src='images/ajax-loader.gif' id='loading' alt='...Carregando...' />").show();
				//var t = $(this).attr('title');
				//$.post("query.php", { method: "ministry", id: t },
				//function(data) {			
				//	$('#author').html(data); 
				//});
				return false;
		},
			function () {
				$(this).css("background-color", "#ECEADF");
		});*/
		
		$("#reload").click(function() {
			$("#captcha").attr("src","securimage/securimage_show.php?" + Math.random());
			return false;
		});
		
		$("#again").click(function() {
			return false;
		});
	
	});