$(document).ready(function(){
	
  $('#comment').validate();

	
	$("#submitComment").click(function(){	
		if ($("#comment").valid()) {
			
			$(this).hide();
			$("#comment li.submitbtn").append('<img src="images/loader.gif" alt="Loading" id="loading" />');
			
				var nameVal = $("#name").val();
				var messageVal = $("#message").val();

				$.post("sendComment.php",
					{ name: nameVal, message: messageVal },
						function(data){
							$("#comment").slideUp("normal", function() {				   
								//$("p.more").before('<h3>Gracias</h3>');		
								//$("#comments").fadeIn();	
							});
							
							$("p.more").before('<div class="added">Gracias <span class="newComment">' + nameVal + '</span></div>');
							$('p.more').hide();
							$(".added").animate({opacity: 0}, 3500, 
								function() {
									$("#comments").fadeIn("normal");
									//$('#commentForm').load('contacto.php #commentForm');	
									$('#comments').load('contacto.php #comments');								
								});
							
							
							/*$("p.more").before('<div class="added">' + nameVal + ' escribio: "<span class="newComment">' + messageVal + '</span>"</div>');
							$('p.more').hide();
							$(".added").animate({opacity: 0}, 3000, function() {
								$(".added").html("Gracias").animate({opacity: 1}, 3000, function() {
									$(".added").animate({opacity: 0}, 3000, function() {
									});
								});
							});*/
						}
				);
		}
		
		return false;
	});
	
	
	
						   
});