var rating; var voto_id; var on_ajax = false; $(document).ready(function() { $(".votacion").click(function(e) { e.preventDefault(); if (on_ajax) return false; on_ajax = true; var tmp = $(this).attr("id").split("_"); var value = tmp[1]; $("#loadingUtil").removeClass("hidden"); $.ajax({ type: 'POST', url: 'http://www.innatia.tv/scripts/ajax.php', data: 'a=videos_votacion_add_vote&p=el-rio-ganges-en-la-india-377&v='+value, success: function(result) { res = eval('('+result+')'); on_ajax = false; $("#loadingUtil").addClass("hidden"); voto_id = res["vid"]; rating = value == 's' ? 1 : -1; $("#opina").hide(); $("#satisfacion_resultado_"+value).addClass(res["r"] > 0 ? 'green' : 'red'); $("#s_puntos_"+value).text(res["r"]); $("#s_total_"+value).text(res["q"]); $("#satisfaccion_"+value).show().removeClass("hidden"); } }); }); $(".button_satisfaccion").click(function(e) { e.preventDefault(); if (on_ajax) return false; var tmp = $(this).attr("id").split("_"); var id = tmp[2]; var n = jQuery.trim($("#textarea_name_satisfaccion_"+id).val()).replace(/&/g, "%26"); var e = jQuery.trim($("#textarea_email_satisfaccion_"+id).val()).replace(/&/g, "%26"); var t = jQuery.trim($("#textarea_satisfaccion_"+id).val()).replace(/&/g, "%26"); if (e == 'Tu Email') e = ''; if (e != '' && !(/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.([A-Za-z0-9_.]+[A-za-z])+$/.test(e))) { alert("El mail no es una valido!"); return false; } if (n == '' || n == 'Tu Nombre' || t == '') { alert("Debe completar todos los campos!"); return false; } on_ajax = true; $("#loading_"+id).removeClass("hidden"); $.ajax({ type: 'POST', url: 'http://www.innatia.tv/scripts/ajax.php', data: 'a=videos-satisfaccion_comentario&p=el-rio-ganges-en-la-india-377&vid='+voto_id+'&r='+rating+'&n='+n+'&e='+e+'&t='+t, success: function(result) { res = eval('('+result+')'); on_ajax = false; $("#loading_"+id).addClass("hidden"); if (res["success"] == 1) { $("#div_satisfaccion_"+id).hide(); $("#opinaGracias").show().removeClass("hidden"); if(typeof comment_add == 'function') comment_add(-1, 1, n, t); } else alert("Error: "+res["error"]); } }); }); });