
var CommentsAjaxLoader=new Class({path:null,_comments:null,initialize:function(path){this.path=path;this._comments=new Hash();},addNoComments:function(idContent,contenedor){if(!$defined(idContent)){return;}
this._comments.include(idContent,contenedor);},process:function(){var salida=[];$each(this._comments,function(key,value){salida.include(value);});salida.join(',');this.requestCommentsNumber(salida);},requestCommentsNumber:function(identificadores){if(!$defined(identificadores)){return;}
new Request.XML({'url':this.path+'/index.php/services/comments','method':'post'}).addEvent('success',this.handleRequestCommentsNumber.bindWithEvent(this)).send('action=requestNoComments&content='+identificadores);},handleRequestCommentsNumber:function(text,xml){var erres=xml.getElements('r');$each(this._comments,function(key,value){this.renderNoComments(key,'0');},this);$each(erres,function(key,value){var total=key.getElementsByTagName('total');if(total.length==0){return;}
total=total[0].firstChild.nodeValue;this.renderNoComments(this._comments[key.get('id')],total);},this);},renderNoComments:function(id,total){$each($$(id),function(el){var texto='';if(total==0){texto='¡comenta!';}
else if(total==1){texto=total+' comentario';}
else{texto=total+' comentarios';}
el.set('html',texto);},this);}});