pc_comments_div_hidden=true;pc_comments_p_hidden=true;pc_comments_form_hidden=false;pc_comments_count=0;function formatItem(obj,cont){var item='<li class="new-user-msg" id="comment_'+obj.mid+'"><dl class="f-wrap"><dt class="f-wrap"><span class="icon i-comment"></span><strong><a href="'+obj.friendLink+'">'+obj.friendName+"</a> "+i18n.Escribio+'</strong> <span class="datetime">- '+obj.messageDate+'</span></dt><dd class="user-pic"><a class="thumb" href="'+obj.friendLink+'"><img width="50" src="'+obj.imgSrc+'" /></a></dd><dd class="user-msg">';if(obj.canDelete){item+='<a href="javascript:void(0);" class="link-close" onclick="javascript:deleteComment(\''+cont+"', "+fpid+", "+obj.aid+","+obj.pid+","+obj.mid+');"><span class="icon i-close">X</span></a>';if(obj.uid){item+='<a href="#" class="link-close openwin" src="layers/pages_block_user.php?fpid='+fpid+"&uid="+obj.uid+'"><span class="txt">'+i18n.Bloquear+"</span></a>"}}item+="<p>"+obj.messageText+"</p></dd></dl></li>";return item}function addComment(message,div){if(message.error){window.alert(message.error);return}var cnt=formatItem(message,div);$(div).append(cnt);if(pc_comments_div_hidden){$("#comments_container").show();pc_comments_div_hidden=false}pc_comments_count++;if(pc_comments_count>=pc_max_messages&&!pc_comments_form_hidden){$("#comments_form_div").hide();pc_comments_form_hidden=true}$("#board_cant_msgs").html(String(total_messages[photo_id].length+1));$("dd.user-msg .link-close .txt").css("visibility","hidden");$("dd.user-msg").hover(function(){$(this).find(".link-close .txt").css("visibility","visible")},function(){$(this).find(".link-close .txt").css("visibility","hidden")});$("#ex2").jqmAddTrigger("a.openwin")}var photo_length_msg;var photo_trim_msg;function postComment(u,a,p,t,d,cu){var ta=$(t).get(0);if($.trim($("#new_comment").val())==""){if(!photo_length_msg){alert(i18n["Por favor, ingresa un mensaje para enviar"])}return false}if($("#new_comment").val().length>5000){if(!photo_length_msg){alert(i18n["Por favor, ingresa un mensaje de menor tamanio."])}return false}$("#submit").attr("disabled",true);val=$("#submit").attr("value");$("#submit").attr("value",i18n.Enviando+"...");$.ajax({url:"pages_album_add_photo_message.php",type:"POST",data:{u:u,a:a,p:p,c:ta.value,cu:cu},dataType:"json",error:function(){alert(i18n["No se pudo agregar el comentario, por favor intente nuevamente en unos minutos."]);$("#submit").attr("disabled",false);$("#submit").attr("value",val)},success:function(m){addComment(m,d);ta.value="";total_messages[p][total_messages[p].length]=m;$("#submit").attr("disabled",false);$("#submit").attr("value",val);if(pc_comments_count>=pc_max_messages){$("#comments_full_p").show()}total_comments++;$(".total_comments").html(total_comments)}})}function loadComments(a,p,d,l){pc_comments_div_hidden=true;pc_comments_p_hidden=true;pc_comments_form_hidden=false;pc_comments_count=0;if(l!=null){$.each(l,function(i,n){addComment(n,d)});if(!pc_comments_form_hidden){$("#comments_form_div").show();$("#comments_full_p").hide()}return}$.ajax({url:"pages_album_get_photo_messages.php",type:"POST",data:{a:a,p:p},dataType:"json",error:function(){},success:function(m){$.each(m,function(i,n){addComment(false,n,d)})}})}function removeComment(m,div,mid){if(m.result!="OK"){window.alert(m.result);return}$("#comment_"+mid).hide();pc_comments_count--;$("#board_cant_msgs").html(String(total_messages[photo_id].length-1));if(pc_comments_count==0){document.getElementById("comments_container").style.display="none";pc_comments_div_hidden=true}if(pc_comments_count<=pc_max_messages&&pc_comments_form_hidden){$("#comments_form_div").show();$("#comments_full_p").hide();pc_comments_form_hidden=false}}function deleteComment(div,fpid,aid,pid,mid){if(!window.confirm(i18n["Esta seguro?"])){return}$.ajax({url:"pages_album_delete_photo_message.php",type:"POST",data:{fpid:fpid,a:aid,p:pid,m:mid},dataType:"json",error:function(){alert(i18n["No se pudo borrar el comentario, por favor intente nuevamente en unos minutos."])},success:function(m){removeComment(m,div,mid);total_comments--;$(".total_comments").html(total_comments);for(i in total_messages[photo_id]){if(total_messages[photo_id][i]["mid"]==mid){delete total_messages[photo_id][i]}}j=0;temp_messages=new Array();for(i in total_messages[photo_id]){temp_messages[j]=total_messages[photo_id][i];j++}total_messages[photo_id]=temp_messages}})};