var anyrate={url:CLAjaxPreffix+"/common/",data:{},ev_cache:Array(),ev_posts_cache:Array(),ev_user_rates_cache:Array(),msg:{"-1":{},"-2":{},"-3":{}},comments_section:"event_comments",rate:function(a,b){switch(a){case"blog_post":this.perform(a,b);break;case"rate_user":this.perform(a,b);break;case"rate_comment":this.perform(a,b);break}},perform:function(a,b){this.data.mode=a;jQuery.post(anyrate.url+"any_rate",anyrate.data,function(c){if(c.good>0){if(b!=undefined){b(c)}}else{if(c.good==-1){jQuery.msgbox({bgcolor:"#000",opacity:0.6,inSpeed:0}).show({message:anyrate.msg["-1"]["text"],showCaption:false,autoClose:2000})}if(c.good==-2){if(Loginpopup!=undefined&&Loginpopup){Loginpopup.Show()}else{jQuery.msgbox({bgcolor:"#000",opacity:0.6,inSpeed:0}).setButton({caption:"Ясно"},function(){jQuery.msgbox.close()}).show({caption:anyrate.msg["-2"]["caption"],message:anyrate.msg["-2"]["text"]})}}if(c.good==-3){jQuery.msgbox({bgcolor:"#000",opacity:0.6,inSpeed:0}).show({message:anyrate.msg["-3"]["text"],showCaption:false,autoClose:2000})}}},"json")},rate_comment:function(a,b){if(this.ev_cache[a]!=undefined&&this.ev_cache[a]!=0){return false}if(b==undefined){b=0}var c="#comment_"+a+" .comment_rating .num";if(b>0){after_rate=function(){c=Util.modify_value(c,1);c.removeClass("good").removeClass("bad");if(parseInt(c.text())>0){c.addClass("good")}c.siblings(".up").addClass("you_voted_up");anyrate.ev_cache[a]=b}}else{if(b<0){after_rate=function(){c=Util.modify_value(c,-1);c.removeClass("good").removeClass("bad");if(parseInt(c.text())<0){c.addClass("bad")}c.siblings(".down").addClass("you_voted_down");anyrate.ev_cache[a]=b}}}this.msg["-1"]["text"]="Вы уже голосовали! О.о";this.msg["-2"]["caption"]="Ой...";this.msg["-2"]["text"]='<p style="text-align:center;font-size:10pt;">Только зарегистрированные пользователи могут голосовать!<br /><br /><a href="'+CL_ACCOUNTS_DOMAIN+"/login?returl="+document.location.href+'">Войти</a> <a href="'+CL_ACCOUNTS_DOMAIN+"/register?returl="+document.location.href+'">Зарегистрироваться</a></p>';this.msg["-3"]["text"]="Это Ваш комментарий, поэтому Вы не можете за него голосовать!";this.data={comment_id:a,comments_section:this.comments_section,type:b};return this.rate("rate_comment",after_rate)},show_comment:function(a){var b=jQuery("#comment_"+a);b.children(".show_btn").fadeOut(150,function(){jQuery(this).siblings(".comment_container").fadeIn(150)});return false},rate_blog_post:function(a,b){if(this.ev_posts_cache[a]!=undefined&&this.ev_posts_cache[a]!=0){return false}if(b==undefined){b=0}var c="#post_"+a+" .blog_post_rating .num";if(b>0){after_rate=function(){c=Util.modify_value(c,1);c.removeClass("good").removeClass("bad");if(parseInt(c.text())>0){c.addClass("good")}c.siblings(".up").addClass("you_voted_up");anyrate.ev_posts_cache[a]=b}}else{if(b<0){after_rate=function(){c=Util.modify_value(c,-1);c.removeClass("good").removeClass("bad");if(parseInt(c.text())<0){c.addClass("bad")}c.siblings(".down").addClass("you_voted_down");anyrate.ev_posts_cache[a]=b}}}this.msg["-1"]["text"]="Вы уже оценили эту запись!";this.msg["-2"]["caption"]="Ой...";this.msg["-2"]["text"]='<p style="text-align:center;font-size:10pt;">Только зарегистрированные пользователи могут голосовать!<br /><br /><a href="'+CL_ACCOUNTS_DOMAIN+"/login?returl="+document.location.href+'">Войти</a> <a href="'+CL_ACCOUNTS_DOMAIN+"/register?returl="+document.location.href+'">Зарегистрироваться</a></p>';this.msg["-3"]["text"]="Вы не можете оценивать свои записи...";this.data={post_id:a,type:b};return this.rate("blog_post",after_rate)},rate_user:function(a,c){if(this.ev_user_rates_cache[a]!=undefined&&this.ev_user_rates_cache[a]!=0){return false}if(c==undefined){c=0}var f="#user_karma .num";var d=CL_STAT_DOMAIN+"/my/user_page/";if(c>0){after_rate=function(e){USER_KARMA+=INC_USER_KARMA+e.offset;b(f,USER_KARMA);var g=jQuery("#user_karma .buttons");g.children(".up").children("img").attr("src",d+"karma_up_after.png");g.children(".down").children("img").attr("src",d+"karma_down_pass.png");anyrate.ev_user_rates_cache[a]=c;jQuery.msgbox().close()}}else{if(c<0){after_rate=function(e){USER_KARMA+=DEC_USER_KARMA-e.offset;b(f,USER_KARMA);var g=jQuery("#user_karma .buttons");g.children(".down").children("img").attr("src",d+"karma_down_after.png");g.children(".up").children("img").attr("src",d+"karma_up_pass.png");anyrate.ev_user_rates_cache[a]=c;jQuery.msgbox().close()}}}function b(e,g){var h=(g+"").split(".");jQuery(e+" .l").text(h[0]).siblings(".r").text(","+Util.format(h[1],5))}this.msg["-1"]["text"]="Эх, Вы уже оценили этого пользователя";this.msg["-2"]["caption"]="Ой...";this.msg["-2"]["text"]='<p style="text-align:center;font-size:10pt;">Только зарегистрированные пользователи могут голосовать!<br /><br /><a href="'+CL_ACCOUNTS_DOMAIN+"/login?returl="+document.location.href+'">Войти</a> <a href="'+CL_ACCOUNTS_DOMAIN+"/register?returl="+document.location.href+'">Зарегистрироваться</a></p>';this.msg["-3"]["text"]="Упс, Вы не можете изменить свою карму...";this.data={user_id:a,type:c};jQuery.msgbox({bgcolor:"#000",opacity:0.6,inSpeed:0}).setButton({caption:"Оценить",xstyle:"margin-right:25px;"},function(){anyrate.rate("rate_user",after_rate)}).setButton({caption:"Отменить",xstyle:"font-weight:bold"},function(){jQuery.msgbox.close()}).show({caption:"Хорошо подумали?",message:'<div style="font-size:10pt;"><p>Оценить пользователя Вы можете <strong>только один раз</strong>.</p><p>О выборе Вашей оценки, положительной или отрицательной, знать будете только Вы.</p></div>'});return false}};
