var $=jQuery.noConflict();(function(n){function r(){i=navigator.cookieEnabled?!0:!1;i||alert("Cookies are required for the polls. Please enable cookies in your browser settings and reload page.")}function u(i){n.each(i.Choices,function(t,i){n("#choice_"+i.ChoiceId).hide();n("#progressbar_"+i.ChoiceId).attr("aria-valuenow",i.Percent);n("#progressbar_"+i.ChoiceId).width(i.Percent+"%");n("#votes_"+i.ChoiceId).html(i.Percent+"%")});n("#progressbar_"+t).addClass("progress-bar-danger");n("#pollContent_"+pollID).find("p.hidden").each(function(){n(this).removeClass("hidden")});n("#pollContent_"+pollID).find(".progress").each(function(){n(this).show()});n("#vote_"+pollID).hide();n("#totalVotes_"+pollID).html(i.TotalVotes);n("#totalVotesSection_"+pollID).show()}function f(n,t,i){var r,u;i?(r=new Date,r.setTime(r.getTime()+i*864e5),u="; expires="+r.toGMTString(),document.cookie=n+"="+t+u+"; path=/;"):(u="",document.cookie=n+"="+t+u+"; path=/;")}var i,t;n(document).ready(function(){r();n('input[name="poll_'+pollID+'"]').click(function(){n("#vote_"+pollID).is(":disabled")&&i&&n("#vote_"+pollID).prop("disabled",!1);t=n(this).val()});n("#vote_"+pollID).click(function(){n(this).prop("disabled",!0);n("#showPollResults_"+pollID).hide();n.ajax({url:CmsBaseUri+"/api/poll/vote/"+pollID+"/"+t,type:"POST"}).done(function(n){n!=undefined&&n.Choices!=undefined?n.Error?alert(n.Error):(f("Poll_"+pollID,t,365),u(n)):alert("An error has occurred, please try again later.")}).fail(function(){alert("Updating the poll failed, please try again later.")})});n("#showPollResults_"+pollID).click(function(){return n("#pollContent_"+pollID).find('div[id^="choice_"]').each(function(){n(this).hide()}),n("#pollContent_"+pollID).find("p.hidden").each(function(){n(this).removeClass("hidden")}),n("#pollContent_"+pollID).find(".progress").each(function(){n(this).show()}),n("#vote_"+pollID).hide(),n(this).hide(),n("#totalVotesSection_"+pollID).show(),!1})})})(jQuery)