$(document).ready ( function() {
//resto
$("#form_comentario").submit( function() {
//Comprobamos que no hay error de validación
var error_validacion = false;
$("input, select, textarea", this).each( function() {
if ($(this).hasClass("error")) {
error_validacion = true;
}
});
if (!error_validacion) {
var idf = $("#id_foro").val();
var idn = $("#id_noti").val();
var nom = $("#nombre").val();
var mail= $("#email").val();
var com = $("#comentario").val();
nom = trataEspeciales(nom,true);
com = convierte_saltos_de_linea(com);
com = trataEspeciales(com,true);
nom = trataEspeciales(nom,true);
com = procesos(com,221);
$("#capa_formulario").load("http://www.gigantes.com/captcha/captcha_noticia.asp", {id_foro:idf, id_noti:idn, nombre:nom, email:mail, comentario:com}, function() {
$("#form_comentario").submit( function() {
var error = false;
$("input, select, textarea", "#form_comentario").each( function() {
if ($(this).attr("class")) {
if (!validateField(this)) error = true;
}
});
if (!error) {
$("#texto_captcha").val($("#texto_captcha").val().toUpperCase());
url = "http://www.gigantes.com/foros/insertar_comentario_x.asp";
texto_captcha = $("#texto_captcha").val();
$.post(url, { nombre:nom, email:mail, comentario:com, texto_captcha:texto_captcha, id_foro:idf, noticia:idn }, resultado_form_comentario);
return false;
} else {
return false;
}
});
});
return false;
} else {
return false;
}
});
});
function resultado_form_comentario(data) {
$("#capa_formulario").html(data);
}
function ventana_condiciones() {
window.open("","condiciones","width=400,height=550");
}
function convierte_saltos_de_linea(cadena) {
texto = cadena;
if (navigator.platform=="Win32" && navigator.appName!="Netscape") {
rExp = /(\r\n)+/gi;
texto = texto.replace(rExp,"<br />")
}
else if (navigator.platform=="MacPPC" && texto.charAt(texto.length-1)!='\r') {
rExp = /(\n)+/gi;
texto = texto.replace(rExp,"<br />")
}
else if (navigator.appName=="Netscape") {
rExp = /(\n)+/gi;
texto = texto.replace(rExp,"<br />")
}
else {
rExp = /[\f\n\r]+/gi;
texto = texto.replace(rExp,"<br />")
}
return texto;
}
function recargar_captcha(host){
aleatorio = aleatorio = Math.random() * 1000;
src="http://" + host + "/captcha/captcha.asp?var=" + aleatorio + "";
$('#captcha').attr("src", src);
return false;
}
