function sack(file){this.xmlhttp=null;this.resetData=function(){this.method="POST";this.queryStringSeparator="?";this.argumentSeparator="&";this.URLString="";this.encodeURIString=true;this.execute=false;this.element=null;this.elementObj=null;this.requestFile=file;this.vars=new Object();this.responseStatus=new Array(2)};this.resetFunctions=function(){this.onLoading=function(){};this.onLoaded=function(){};this.onInteractive=function(){};this.onCompletion=function(){};this.onError=function(){};this.onFail=function(){}};this.reset=function(){this.resetFunctions();this.resetData()};this.createAJAX=function(){try{this.xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(e1){try{this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(e2){this.xmlhttp=null}}if(!this.xmlhttp){if(typeof XMLHttpRequest!="undefined"){this.xmlhttp=new XMLHttpRequest()}else{this.failed=true}}};this.setVar=function(name,value){this.vars[name]=Array(value,false)};this.encVar=function(name,value,returnvars){if(true==returnvars){return Array(encodeURIComponent(name),encodeURIComponent(value))}else{this.vars[encodeURIComponent(name)]=Array(encodeURIComponent(value),true)}};this.processURLString=function(string,encode){encoded=encodeURIComponent(this.argumentSeparator);regexp=new RegExp(this.argumentSeparator+"|"+encoded);varArray=string.split(regexp);for(i=0;i<varArray.length;i++){urlVars=varArray[i].split("=");if(true==encode){this.encVar(urlVars[0],urlVars[1])}else{this.setVar(urlVars[0],urlVars[1])}}};this.createURLString=function(urlstring){if(this.encodeURIString&&this.URLString.length){this.processURLString(this.URLString,true)}if(urlstring){if(this.URLString.length){this.URLString+=this.argumentSeparator+urlstring}else{this.URLString=urlstring}}this.setVar("rndval",new Date().getTime());urlstringtemp=new Array();for(key in this.vars){if(false==this.vars[key][1]&&true==this.encodeURIString){encoded=this.encVar(key,this.vars[key][0],true);delete this.vars[key];this.vars[encoded[0]]=Array(encoded[1],true);key=encoded[0]}urlstringtemp[urlstringtemp.length]=key+"="+this.vars[key][0]}if(urlstring){this.URLString+=this.argumentSeparator+urlstringtemp.join(this.argumentSeparator)}else{this.URLString+=urlstringtemp.join(this.argumentSeparator)}};this.runResponse=function(){eval(this.response)};this.runAJAX=function(urlstring){if(this.failed){this.onFail()}else{this.createURLString(urlstring);if(this.element){this.elementObj=document.getElementById(this.element)}if(this.xmlhttp){var self=this;if(this.method=="GET"){totalurlstring=this.requestFile+this.queryStringSeparator+this.URLString;this.xmlhttp.open(this.method,totalurlstring,true)}else{this.xmlhttp.open(this.method,this.requestFile,true);try{this.xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}catch(e){}}this.xmlhttp.onreadystatechange=function(){switch(self.xmlhttp.readyState){case 1:self.onLoading();break;case 2:self.onLoaded();break;case 3:self.onInteractive();break;case 4:self.response=self.xmlhttp.responseText;self.responseXML=self.xmlhttp.responseXML;self.responseStatus[0]=self.xmlhttp.status;self.responseStatus[1]=self.xmlhttp.statusText;if(self.execute){self.runResponse()}if(self.elementObj){elemNodeName=self.elementObj.nodeName;elemNodeName.toLowerCase();if(elemNodeName=="input"||elemNodeName=="select"||elemNodeName=="option"||elemNodeName=="textarea"){self.elementObj.value=self.response}else{self.elementObj.innerHTML=self.response}}if(self.responseStatus[0]=="200"){self.onCompletion()}else{self.onError()}self.URLString="";break}};this.xmlhttp.send(this.URLString)}}};this.reset();this.createAJAX()}var serverSideFile="/ajax/poller.php";var voteLeftImage="/images/poll/graph_middle_1.gif";var voteRightImage="/images/poll/graph_middle_1.gif";var voteCenterImage="/images/poll/graph_middle_1.gif";var graphMaxWidth=130;var graphMinWidth=20;var pollScrollSpeed=1;var useCookiesToRememberCastedVotes=true;var txt_totalVotes="Всего проголосовало: ";var ajaxObjects=new Array();var pollVotes=new Array();var pollVoteCounted=new Array();var totalVotes=new Array();var preloadedImages=new Array();preloadedImages[0]=new Image();preloadedImages[0].src=voteLeftImage;preloadedImages[1]=new Image();preloadedImages[1].src=voteRightImage;preloadedImages[2]=new Image();preloadedImages[2].src=voteCenterImage;function Poller_Get_Cookie(c){var d=document.cookie.indexOf(c+"=");var a=d+c.length+1;if((!d)&&(c!=document.cookie.substring(0,c.length))){return null}if(d==-1){return null}var b=document.cookie.indexOf(";",a);if(b==-1){b=document.cookie.length}return unescape(document.cookie.substring(a,b))}function Poller_Set_Cookie(b,f,c,j,d,a){c=c*60*60*24*1000;var e=new Date();var g=new Date(e.getTime()+(c));var h=b+"="+escape(f)+((c)?";expires="+g.toGMTString():"")+((j)?";path="+j:"")+((d)?";domain="+d:"")+((a)?";secure":"");document.cookie=h}function showVoteResults(o,k){document.getElementById("poller_waitMessage"+o).style.display="none";var c=ajaxObjects[k].response;c=c.replace(/\n/gi,"");var e=new RegExp("^.*?<pollerTitle>(.*?)<.*$","gi");var t=c.replace(e,"$1");var g=document.getElementById("poller_results"+o);var n=document.createElement("P");n.className="result_pollerTitle";n.innerHTML=t;g.appendChild(n);var b=c.split(/<option>/gi);pollVotes[o]=new Array();totalVotes[o]=0;for(var a=1;a<b.length;a++){var h=b[a].split(/</gi);var p=false;for(var j=0;j<h.length;j++){if(h[j].substring(0,1)!="/"){var u=h[j].replace(/^(.*?)>.*$/gi,"$1");var l=h[j].replace(/^.*?>(.*)$/gi,"$1");if(u.indexOf("optionText")>=0){var d=document.createElement("P");d.className="result_pollerOption";d.innerHTML=l;g.appendChild(d)}if(u.indexOf("optionId")>=0){p=l/1}if(u.indexOf("votes")>=0){var s=document.createElement("DIV");s.className="result_pollGraph";g.appendChild(s);var q=document.createElement("IMG");q.src=voteLeftImage;s.appendChild(q);var f=document.createElement("DIV");f.style.backgroundImage="url('"+voteCenterImage+"')";f.innerHTML="0%";f.id="result_voteTxt"+p;s.appendChild(f);var r=document.createElement("IMG");r.src=voteRightImage;s.appendChild(r);pollVotes[o][p]=l;totalVotes[o]=totalVotes[o]/1+l/1}}}}var m=document.createElement("P");m.className="result_totalVotes";m.innerHTML=txt_totalVotes+totalVotes[o];s.appendChild(m);setPercentageVotes(o);slideVotes(o,0)}function setPercentageVotes(c){for(var b in pollVotes[c]){pollVotes[c][b]=Math.round((pollVotes[c][b]/totalVotes[c])*100)}var a=0;for(var b in pollVotes[c]){a=a+pollVotes[c][b]/1}pollVotes[c][b]=pollVotes[c][b]+(100-a)}function slideVotes(d,a){a=a/1+1;for(var c in pollVotes[d]){if(pollVotes[d][c]>=a){var b=document.getElementById("result_voteTxt"+c);b.innerHTML=a+"%";b.style.width=Math.max(graphMinWidth,Math.round(a/100*graphMaxWidth))+"px"}}if(a<100){setTimeout('slideVotes("'+d+'","'+a+'")',pollScrollSpeed)}}function prepareForPollResults(a){document.getElementById("poller_waitMessage"+a).style.display="block";document.getElementById("poller_question"+a).style.display="none"}function castMyVote(f,a){var d=a.elements["vote["+f+"]"];var c=false;for(var e=0;e<d.length;e++){if(d[e].checked){c=d[e].value}}Poller_Set_Cookie("dhtmlgoodies_poller_"+f,"1",6000000);if(c){var b=ajaxObjects.length;ajaxObjects[b]=new sack();ajaxObjects[b].requestFile=serverSideFile+"?pollId="+f+"&optionId="+c;prepareForPollResults(f);ajaxObjects[b].onCompletion=function(){showVoteResults(f,b)};ajaxObjects[b].runAJAX()}}function displayResultsWithoutVoting(b){var a=ajaxObjects.length;ajaxObjects[a]=new sack();ajaxObjects[a].requestFile=serverSideFile+"?pollId="+b;prepareForPollResults(b);ajaxObjects[a].onCompletion=function(){showVoteResults(b,a)};ajaxObjects[a].runAJAX()};