$(document).ready(function() { 
	$.get("_token.php", function(txt) {
		$("#commentForm").append('<input type="hidden" name="ts" value="'+txt+'" />');
	});	

	// show a simple loading indicator
	var loader = $('#loader').hide();
	jQuery().ajaxStart(function() {
		loader.show();
	}).ajaxStop(function() {
		loader.hide();
	}).ajaxError(function(a, b, e) {
		throw e;
	});

	var v = jQuery("#commentForm").validate({
		showErrors: function(errorMap, errorList) {
			$("#warning").html("Su formulario contiene " + this.numberOfInvalids() + " error/es. ");
			this.defaultShowErrors();
		},
		debug: false,
		errorElement: "em",
		errorContainer: $("#warning"),
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				target: "#resultado-envio",
				clearForm: true,
				resetForm: true
			});
		}
	});
});
