function setVote(b,a,c){return function(){a=a+"&vote="+c;new Ajax.Request(a,{method:"get",onSuccess:function(k){var e=k.responseText.evalJSON();var h=e.avgvote;var j=e.uservote;var f=e.totalvotes;if((h=parseFloat(h))){var d=h*20;b.down("li.current-rating").style.width=d+"%"}else{alert(k.responseText)}var i=b.up(".rating-container").id;var g=$(i).down(".rating-message");if(g.prevmsg!=""){g.innerHTML=g.prevmsg;g.prevmsg=""}g.down("span").innerHTML=f;if((j=parseInt(j))){var d=j*20;$(i+"-user").down(".star-rating").down("li.current-rating").style.width=d+"%"}else{alert(k.responseText)}}})}}function showMsg(b,a){return function(){if(b.prevmsg==""){b.prevmsg=b.innerHTML}var c=["Poor","Satisfactory","Good","Very good","Excellent"];b.update(c[a])}}function hideMsg(a){return function(){if(a.prevmsg!=""){a.update(a.prevmsg)}}}document.observe("dom:loaded",function(){$$(".star-rating").each(function(b){if(!b.hasClassName("locked")){var f=b.up(".rating-wrapper").id;var c="rating-";if(f&&f.indexOf(c)==0){f=f.substring(c.length);var e=Object.toQueryString({xpage:"plain",outputSyntax:"plain",doc:f});var a=new XWiki.Document("Ratings","XWiki").getURL("view",e);var d=b.up(".rating-container").down(".rating-message");b.select("a").each(function(h,g){Event.observe(h,"click",setVote(b,a,g+1));d.prevmsg="";Event.observe(h,"mouseover",showMsg(d,g));Event.observe(h,"mouseout",hideMsg(d))})}}})});