var ThumbRater=new Class({hasClicked:false,initialize:function(B,A){this.ratings={up:B,down:A};this.ratings.up.addEvent("click",function(C){C.stop();this.processRating(C.target,1);}.bind(this));this.ratings.down.addEvent("click",function(C){C.stop();this.processRating(C.target,0);}.bind(this));},processRating:function(A,C){if(this.hasClicked){return false;}else{this.hasClicked=true;}var B=$(A).get("href").split("?");this.rate_request=new Request.JSON({url:B[0],method:"post",data:B[1],onSuccess:this.postRating.bind(this)}).send();
},postRating:function(A){}});var VideoThumbRater=new Class({Extends:ThumbRater,initialize:function(B,A,C){this.response_location=C;this.parent(B,A);},postRating:function(B){if($chk(B.error_msg)){alert(B.error_msg);}else{this.ratings.up.set("class","thumb_up");this.ratings.down.set("class","thumb_down");if(B.thumb_value.toInt()==1||B.thumb_value.toInt()==0){var C=B.thumb_value.toInt()==1?this.ratings.up:this.ratings.down;C.addClass("selected");var A=new Element("div",{"class":"module thumb_rater_response",styles:{display:"block"}}).grab(new Element("div",{"class":"body"}).grab(new Element("span",{text:B.thumbs.thumbs_up+" out of "+B.thumbs.thumbs_total+" users enjoyed this video."}))).inject(this.response_location.getElement("div.useract_modules .ua_wrap .ua_wrap .ua_wrap"),"bottom");
this.response_location.addClass("useract_opened");A.setStyle("height",A.getSize().y).slide("hide").slide("in");(function(){A.get("slide").slideOut().chain(function(){this.response_location.removeClass("useract_opened");}.bind(this));}.bind(this)).delay(8000);}}}});var CommentThumbRater=new Class({Extends:ThumbRater,postRating:function(A){if($chk(A.error_msg)){alert(A.error_msg);return false;}$("thumbs_up_"+A.ref_id).set("html",A.thumbs["thumbs_up"]);$("thumbs_down_"+A.ref_id).set("html",A.thumbs["thumbs_down"]);
if(A.thumbs["thumbs_diff"]>0){$("thumbs_diff_"+A.ref_id).addClass("positive").removeClass("negative").set("html","<span>+</span>"+A.thumbs["thumbs_diff"]);}else{if(A.thumbs["thumbs_diff"]<0){$("thumbs_diff_"+A.ref_id).addClass("negative").removeClass("positive").set("html",A.thumbs["thumbs_diff"]);}else{$("thumbs_diff_"+A.ref_id).removeProperty("class").set("html",A.thumbs["thumbs_diff"]);}}if(A.dw_url){new Element("img",{alt:"",src:A.dw_url+"http://dw.com.com/i/b.gif","class":"tracking_gif"}).inject($(document.body).getFirst(),"before");
}}});