<!--

var rIkgf=true;
var hZVgG=true;
waJSQuery(window).ready(function(){
Zoulj();
});
function ptlGY(){
var url='wa_dyn_blog.php';
return url;
}
function Zoulj(){
rIkgf=document.webaca_is_preview;
hZVgG=CONST_WA_GLOBAL_SETTINGS.blogs_settings.has_email;
waJSQuery('.wa-blog').each(function(){
var dUKPH=waJSQuery(this);
var RZsXY=extractParamInfo(dUKPH,'blog_id');
var JqMrF=dUKPH.find('.wa-but-txt');
var kWMRV=JqMrF.html();
dUKPH.data('origin_html',kWMRV);
dUKPH.css('cursor','pointer');
dUKPH.click(function(){
UCAcO(RZsXY);
});
if(rIkgf){
eDOiH(RZsXY,0);
}
else{
if(JqMrF!=undefined&&kWMRV!=undefined){
JqMrF.html(kWMRV.replace(/%/g,''));
}
uBgAH(RZsXY);
}
});
}
function cLlLv(NQSBl,kfrJV,aXOjt){
var vnPrn=_toJSON(NQSBl);
if(vnPrn.success==false)
{
var EHrkx=vnPrn.error;
WA_Dialog.alert(vnPrn.error);
return;
}
var mctcs=vnPrn.json.blogs;
var hhMHw=0;
var SEHhk=0;
var xpQZw='';
for(var RZsXY in mctcs){
var dUKPH=mctcs[ RZsXY ];
hhMHw+=_objectKeysCount(dUKPH);
for(var lcHUA in dUKPH){
var lUpcq=dUKPH[ lcHUA ];
lUpcq.EMAIL=_HTMLEntities(lUpcq.EMAIL);
if(!hZVgG){
lUpcq.EMAIL='';
}
else{
if(lUpcq.EMAIL=='http://'){
lUpcq.EMAIL='';
}
if(lUpcq.EMAIL.length>0){
var sMRPm=lUpcq.EMAIL;
var RNmpc=lUpcq.EMAIL;
if((lUpcq.EMAIL.indexOf('@')>0)&&(lUpcq.EMAIL.indexOf('mailto:')<0)){
RNmpc='mailto:'+lUpcq.EMAIL;
sMRPm=lUpcq.EMAIL;
}
lUpcq.EMAIL='<a href="{0}" target="_blank">{1}</a>'.format(RNmpc,sMRPm);
}
}
xpQZw+='<span style="text-decoration:none;font-size:13px;"><b>{0}</b> </span>'.format(_HTMLEntities(lUpcq.AUTHOR));
if(lUpcq.EMAIL.length>0){
xpQZw+='<span style="color:#0000ff;text-decoration:underline;font-size:13px;">{0} </span>'.format(lUpcq.EMAIL);
}
xpQZw+='<span style="color:#0000ff;text-decoration:none;font-size:11px;">{0} </span>'.format(lUpcq.CREATED);
xpQZw+='<br>';
xpQZw+='<span style="font-size:13px;">{0}</span>'.format(_HTMLEntities(lUpcq.COMMENT).replace(/\r?\n|\r/g,'<br />'));
if(SEHhk<hhMHw-1){
xpQZw+='<hr>';
}
SEHhk++;
}
}
if(hhMHw==0){
xpQZw+='<span >{0}</span>'.format(Translator.tr('No comments in this blog!'));
}
else{
xpQZw='<div style="width:100%;height:100%;overflow:auto">{0}</div>'.format(xpQZw);
}
aXOjt.writeContent(xpQZw);
}
function VqELN(kfrJV){
var aXOjt=new WA_Dialog();
aXOjt.progress();
kfrJV.action='post_comment';
waJSQuery.post(ptlGY(),kfrJV).success(function(NQSBl){
var vnPrn=_toJSON(NQSBl);
if(vnPrn.error!=undefined){
WA_Dialog.alert(vnPrn.error);
}
if(vnPrn.success){
WA_Dialog.alert(Translator.tr('Post message successfully'));
uBgAH(kfrJV.id_article);
}
}).error(function(){
WA_Dialog.alert('*error retrieving blog datas');
})
;
}
function NfqNS(kfrJV){
var GQHAV=kfrJV.id_article;
var aXOjt=new WA_Dialog();
aXOjt.YaYSQ=function(GQHAV){
var oemiN=waJSQuery('#wa-blog-form');
var lpJSk=oemiN.find('input,textarea');
var Svhgm=false;
lpJSk.each(function(){
var MduQC=waJSQuery(this);
MduQC.val(waJSQuery.trim(MduQC.val()));
if(MduQC.attr('id')!='email'){
if(MduQC.val().length==0){
MduQC.css('backgroundColor','#ff0000');
MduQC.focus();
Svhgm=true;
return false;
}
}
});
if(Svhgm==true){
return;
}
var qaIgu=waJSQuery('#author').val();
var lUpcq=waJSQuery('#comment').val();
var jZBhp=waJSQuery('#email').val();
var kfrJV={
id_article:GQHAV,author:qaIgu,comment:lUpcq,email:jZBhp
};
VqELN(kfrJV);
};
aXOjt.onCustomKeypress=function(avrhC){
return false;
};
aXOjt.RpBrl=function(GQHAV){
this.addButton(Translator.tr('Submit message'),this.YaYSQ,this,GQHAV);
var mAGGq='text-decoration: none; font-weight: bold; font-size: 12px;';
var qWqpf='';
if(hZVgG){
qWqpf=('<tr><td align=left style="{0}">'+'{1}<br>'+'<input name="email" id="email" type=text>'+'<br><br><br>'+'</td></tr>').format(mAGGq,Translator.tr('Blog url'))
;
}
this.initializeWindow(500,500);
var SPNnN=('<form id="wa-blog-form">'+'<table border="0" cellpadding="0" cellspacing="0"  style="width: 90%;">'+'<tr><td align="left" style="{0}">'+'{1}<br>'+'<input name="author" id="author" type="text">'+'<br><br>'+'</td></tr>{2}'+'<tr><td align="center" style="{0}">'+'<textarea name="comment" id="comment" style="width: 100%; height: 100px;" ></textarea>'+'</td></tr>'+'</table>'+'</form>').format(mAGGq,Translator.tr('Blog author'),qWqpf)
;
this.writeContent(SPNnN);
var oemiN=waJSQuery('#wa-blog-form');
var lpJSk=oemiN.find('input,textarea');
lpJSk.each(function(i){
var MduQC=waJSQuery(this);
MduQC.change(function(){
MduQC.css('backgroundColor','');
});
});
};
aXOjt.RpBrl(GQHAV);
}
function UCAcO(RZsXY){
if(rIkgf){
WA_Dialog.alert(Translator.tr('Operation not allowed in preview mode'));
return;
}
var aXOjt=new WA_Dialog();
aXOjt.addButton(Translator.tr('Send a message'),NfqNS,aXOjt,{id_article:RZsXY});
aXOjt.initializeWindow(650,550);
var xpQZw=('<table border="0" cellpadding="0" cellspacing="0"  style="width:100%;">'+'<tr>'+'<td align="center">{0}</td>'+'</tr>'+'</table>').format('Loading messages...')
;
aXOjt.writeContent(xpQZw);
var kfrJV={list_id:RZsXY,action:'get_comments'};
waJSQuery.ajax({
url:ptlGY(),data:kfrJV,
success:function(NQSBl){
cLlLv(NQSBl,kfrJV,aXOjt);
},error:function(FSsHj,hQTfa,QdLXR){
WA_Dialog.alert('Cannot get blog comments: '+hQTfa+' - '+QdLXR);
}
});
}
function eDOiH(RZsXY,hhMHw){
waJSQuery('.wa-blog').each(function(){
var oGiJE=waJSQuery(this);
var kwikD=extractParamInfo(oGiJE,'blog_id');
if(kwikD==RZsXY){
var TKLfQ=oGiJE.data('origin_html');
var JqMrF=oGiJE.find('.wa-but-txt');
if(TKLfQ!=undefined&&JqMrF!=undefined){
JqMrF.html(TKLfQ.replace(/%/g,hhMHw));
}
}
});
}
function nuAOU(NQSBl,kfrJV){
var vnPrn=_toJSON(NQSBl);
if(vnPrn.error!=undefined){
}
if(vnPrn.success){
if(_objectKeysCount(vnPrn.json.blogs)==0){
eDOiH(kfrJV.list_id,0);
}
else{
for(var RZsXY in vnPrn.json.blogs){
var dUKPH=vnPrn.json.blogs[ RZsXY ];
var GQHAV=dUKPH.ID_ARTICLE;
var hhMHw=parseInt(dUKPH.NB);
eDOiH(GQHAV,hhMHw);
}
}
}
else{
}
}
function uBgAH(GQHAV){
var kfrJV={action:'refresh_counter_comments'};
if(GQHAV!=undefined){
kfrJV.list_id=GQHAV;
}
waJSQuery.ajax({
url:ptlGY(),data:kfrJV,
success:function(NQSBl){
nuAOU(NQSBl,kfrJV);
},error:function(FSsHj,hQTfa,QdLXR){
}
});
}

-->
