SBN.Poll=Class.create();SBN.Poll.prototype={initialize:function(a){this.poll_container=$(a);this.max_width=this.poll_container.getWidth();this.update_interval=13;this.duration=2000;this.options=[];this.poll_background_image_length=800},animateResults:function(c){c=Object.extend({renderImmediately:false},c);if(c.renderImmediately){this.duration=0}var b=[];var a=Selector.findChildElements(this.poll_container,[".poll_option"]);a.each(function(d){var e=Selector.findChildElements(d,[".poll_option_bar"]).first();e.poll_option_percentage=Selector.findChildElements(d,[".poll_option_percentage"]).first();e.percentage=e.poll_option_percentage.innerHTML.replace("%","");e.max_width=this.max_width*e.percentage/100;e.vote_count_container=Selector.findChildElements(d,[".vote_count"]).first();e.vote_count=e.vote_count_container.innerHTML;this.options.push(e);e.poll_option_percentage.innerHTML="0%";e.poll_option_percentage.show()}.bind(this));this.startTime=new Date().getTime();this.from=0;this.to=1;this.timer=setInterval(this.step.bind(this),this.update_interval)},step:function(){var f=new Date().getTime();if(f>=this.duration+this.startTime){clearInterval(this.timer);this.timer=null;this.now=this.to;this.options.each(function(h){h.poll_option_percentage.innerHTML=h.percentage+"%";h.vote_count_container.innerHTML=h.vote_count;var g=(h.percentage/100*this.max_width)-this.poll_background_image_length;h.style.backgroundPosition=g+"px"}.bind(this))}else{var c=(f-this.startTime)/(this.duration);var a=((-Math.cos(c*Math.PI)/2)+0.5)*(this.to-this.from)+this.from;for(var d=0;d<this.options.length;++d){var e=this.options[d];e.poll_option_percentage.innerHTML=Math.round((a*e.percentage))+"%";e.vote_count_container.innerHTML=Math.round(a*e.vote_count);var b=(a*e.max_width)-this.poll_background_image_length;e.style.backgroundPosition=b+"px"}}}};