$(document).ready(function() {
   // Interceptamos el evento submit
    $('#frmComentarios').submit(function() {
		var form = document.frmComentarios;
		var flag = false;
		var idnoticia = document.getElementById("idnoticia").value;
		var seccion = document.getElementById("seccion").value;
		if(form.nombreComent.value == "" || form.nombreComent.value == null) {
			alert("Debe ingresar nombre.");
			form.nombreComent.focus();
			return false;
		}
		if(form.emailComent.value == "" || form.emailComent.value == null) {
			alert("Debe Ingresar email.");
			form.emailComent.focus();
			return false;
		}
		if(form.comentarioComent.value == "" || form.comentarioComent.value == null) {
			alert("Debe Ingresar comentario.");
			form.comentarioComent.focus();
			return false;
		}
		var flag = true;
		if(flag) {
			$.ajax({
				type: 'POST',
				cache: false,
				url: $(this).attr('action'),
				data: $(this).serialize(),
				// CARGANDO
				beforeSend :function(){					
					$("#contFormComentarios").html('<img src="images/loading.gif" width="220" height="19" />');
				},
				// Mostramos un mensaje con la respuesta de PHP			
				success: function(data) {
						$.post("noticiasComentarios.php", function(data) {
							$("#contFormComentarios").html(data);
						});
						cargaPagina("noticiasComentariosLista.php?id="+idnoticia+"&seccion="+seccion, "contListaComent")
	//                $('#contEncuesta').html(data);
				},
				error: function(){
					 alert("El proceso ha fallado!");
				}
			})        
			return false;
		}
    });
})