var DOMAIN;var PATH="/";var cookVote="nikeos.userVote",cookPoll="nikeos.pollId";var uniqueID=Math.round(Math.random()*(360*60));var pollID=0;var date=new Date();date.setTime(date.getTime()+(3*24*60*60*1000));var addedHeight=(JQ.browser.msie&&JQ.browser.version<7)?0:8;function checkPollCookies(){if(JQ.cookie(cookPoll)==pollID&&JQ.cookie(cookVote)>0){return false}return true}function processResponse(response){var self=this;var index=0;var $pollInfo=JQ(".poll-text");this.setPollCookie=function(response){try{tracking.click(track_site+">blog>poll-vote");JQ.cookie(cookVote,uniqueID,{path:PATH,domain:DOMAIN,expires:date});JQ.cookie(cookPoll,pollID,{path:PATH,domain:DOMAIN,expires:date});self.fadeOutPoll()}catch(e){console.log("type error: ",e);alert("Something went wrong and there is no actual error.")}};this.fadeOutPoll=function(){JQ("#latest-poll").find("span.radio").css("visibility","hidden");JQ("#latest-poll").fadeOut("slow",self.showResults)};this.showResults=function(){JQ("#latest-poll-results").css({display:"block"});var newHeight=(JQ("#latest-poll-results").position().top-JQ("#right_polls_top").position().top)+JQ("#latest-poll-results").height()+addedHeight;JQ("#latest-poll-results").parent().css({height:newHeight+"px"});JQ("#latest-poll-results").fadeIn("fast",self.grow)};self.grow=function(){var choice=parseInt(JQ("input.poll-option:checked").attr("value"),10);var total=parseInt(JQ($pollInfo[0]).attr("class").match(/total-(\S*)/)[1],10)+1;if(index==$pollInfo.length){return false}else{var pollBar='<div class="poll-bar" style="width: 0;"></div>';var $update=JQ("#latest-poll-result-"+index);$update.find("div.poll-bar-wrap").append(pollBar);var count=parseInt($update.find("div.poll-text").attr("class").match(/count-(\S*)/)[1],10);if(choice==index){count++}perc=Math.round(100*(count/total));NIKEOS.log("count: %i, index: %i, perc: ",count,index,perc);$update.find("span.poll-percentage").html(perc+"%");$update.find("div.poll-bar").animate({width:perc+"%"},500,self.grow);index++}};self.setPollCookie()}JQ(document).ready(function(){pollID=JQ("#poll-poll-id").attr("value");JQ("body").addClass(site_data.settings.platypus_lang_locale);JQ("a.more").add("a.less").click(function(){var $this=JQ(this);var $div=JQ("#lesstags");$div.toggle();if($div.is(":visible")){$this.attr("title",text_less).attr("class","less").html(text_less+'&nbsp;<img src="'+img_less+'" />')}else{$this.attr("title",text_more).attr("class","more").html(text_more+'&nbsp;<img src="'+img_more+'" />')}return false});if(checkPollCookies()){var clicked=false;JQ("div.poll-bar-wrap").empty();JQ("span.poll-percentage").empty();JQ("#button-vote").click(function(){NIKEOS.log("%a is the value of clicked",clicked);if(clicked){return false}if(JQ("input.poll-option:checked").length>0){clicked=true;var soapBody=new SOAPObject("addAnonymousVote");soapBody.ns="http://jivesoftware.com/webservices";soapBody.appendChild(new SOAPObject("pollID")).val(pollID);soapBody.appendChild(new SOAPObject("index")).val(JQ("input.poll-option:checked").attr("value"));soapBody.appendChild(new SOAPObject("uniqueID")).val(uniqueID);var sr=new SOAPRequest("/rpc/soap/PollService",soapBody);SOAPClient.SOAPServer="/rpc/soap/PollService";JQ("input.poll-option").disabled=true;SOAPClient.SendRequest(sr,processResponse);return false}else{console.log("Please select an option before you vote");alert(poll_error);return false}})}else{JQ("#latest-poll").css("display","none");JQ("#latest-poll-results").css({display:"block"});var newHeight=(JQ("#latest-poll-results").position().top-JQ("#right_polls_top").position().top)+JQ("#latest-poll-results").height()+addedHeight;JQ("#latest-poll-results").parent().css({height:newHeight+"px"});NIKEOS.log("%a is the new height",newHeight)}});
