function goPage(pg,id){$("#ctmp").html('<span class="loading">Cargando...</span>');$("#ctmp").load('/script/comentario.php?idnoticia='+id+'&pagina='+pg)}function goPage2(pg,id){$("#ctmp").html('<span class="loading">Cargando...</span>');$("#ctmp").load('/script/comentariosup.php?idarticulo='+id+'&pagina='+pg)}function goPage3(pg,id){$("#ctmp").html('<span class="loading">Cargando...</span>');$("#ctmp").load('/script/comentarionota.php?idnota='+id+'&pagina='+pg)}function validmail(email){var str=email;var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; if(filter.test(str)){return true}else{return false}}function validRequired(form){valid=true;$('#'+form+' .required').each(function(i){if(!jQuery.trim($(this).val())){msg='';if($(this).attr("title"))msg=$(this).attr("title");else msg='El campo '+$(this).attr("name")+' es requerido, por favor llenelo';alert(msg);$(this).focus();valid=false;return false}else if($(this).hasClass("email")){if(!validmail(jQuery.trim($(this).val()))){alert('El email introducido no es una direccion valida');$(this).focus();valid=false;return false}}else if($(this).hasClass("compare")){if($("#"+$(this).attr("origen")).val()!=$("#"+$(this).attr("destino")).val()){alert("Los campos "+$("#"+$(this).attr("origen")).attr("name")+" y "+$("#"+$(this).attr("destino")).attr("name")+" deben tener valores iguales");$(this).focus();valid=false;return false}}});return valid}function resetFields(form){$('#'+form+' input:text').val('');$('#'+form+' textarea').val('')}$(document).ready(function(){$(".valid").submit(function(){id=$(this).attr("id");if(validRequired(id)){archivo="/comentar.php";$.post(archivo,{action:"comment",idarticulo:$("#idarticulo").val(),idnota:$("#idnota").val(),idnoticia:$('#idnoticia').val(),comentario:$("#comentario").val(),nombre:$("#nombre").val(),email:$("#email").val(),web:$("#web").val(),captcha_code:$("#captcha_code").val()},function(data){if(data==0){document.getElementById('captcha').src='/securimage/securimage_show.php?'+Math.random();alert('Error Captcha no coincide, por favor ingreselo de nuevo');$("#captcha_code").val('');$("#captcha_code").focus()}else{document.getElementById('captcha').src='/securimage/securimage_show.php?'+Math.random();$("#msg_status").html(data);resetFields(id)}},"text")}return false});$(".valid2").submit(function(){id=$(this).attr("id");if(!validRequired(id)){return false}return true})});
