$(document).ready(function()
{
	// =============== COMENTARIOS

	$("#addCommentError").hide();
	$("#loader").hide();					    
	
	$("#commentForm").validate();
	$("form#commentForm").submit(function ()
	    {
	    	if ($("#commentForm").valid())
	    	{
				$("#addCommentError").hide(""); // inicializar mensajes de error
				
	    		$("#comentarios").hide();
				$("#nuevo_comentario").hide();
				
				$("#loader").show(); 					
								
				$.ajax({
					   type: "POST",
					   url: '/hoteles/ajax_add_comment',
					   data: $(this).serialize(),
					   success: function(result)
						   { 						   		
						   		$.scrollTo($("#comentarios"), 800);
						   						   		
						   		$("#comentarios").load(url_hotel_comments);
						   		
						   		$("#loader").hide();
						   		
						   		$("#comentarios").show("fast");	
						   		$("#nuevo_comentario").show("slow");	
						   			
						   		// inicializar formulario	
						   		$("#comment_autor").val("");	
						   		$("#comment_email").val("");				
						   		$("#comment_comentario").val("");						   		
		
					   }, 
				       error: function (xhr, ajaxOptions, thrownError)
						   { 					   		
						   		$("#loader").hide();
						   		$("#addCommentError").html(xhr.responseText);
					   			$("#addCommentError").show();
					   			$("#comentarios").show("slow");	
					   			$("#nuevo_comentario").show("slow");
	
					   			$.scrollTo($("#nuevo_comentario"), 800);
						   		
						   } // end error			   
						   
			
						}); // $.ajax	
			}
			return false; // devolvemos siempre false, porque no se hace el submit
	    }
	); // submit

	
});	// ready	