Ps={JS:null,server:"https://topolls.com/",id_pr:"12",id_th:"4",id0:"topolls",idsl:"topolls_body",fSendRequest:false,fAllowChange:true,fviewResult:true,fmOut:false,Polls:null,tp:0,int:0,nr:0,beg:null,end:null,nextid:null,history:[],index:{},vote:function(int){Ps.addVote(int);Ps.fmOut=true;},first:function(){for(var key in Ps.Polls){if(typeof Ps.Polls[key].uq!='undefined'&&Ps.Polls[key].uq==0)return key;} return false;},gotp:function(tp){Ps.history.push(Ps.tp);if(typeof tp!='undefined'&&Ps.Polls[tp]){Ps.tp=tp;return true;}else{Ps.tp=Ps.first();return false;}},tshow:null,thide:null,tslide:null,load:function(np){if(Ps.Polls){for(var key in np){if(Ps.Polls[key]){Ps.Polls[key].dt=np[key].dt;}else{Ps.Polls[key]=np[key];Ps.end=key;}}}else{Ps.beg=np.beg;Ps.end=np.end;Ps.Polls=np;}},time:function(){return(new Date).getTime()},SlShow:function(){Tp.ge(Ps.idsl).style.display='block';clearTimeout(this.thide);obj=Tp.ge(Ps.idsl);var op=(obj.style.opacity)?parseFloat(obj.style.opacity):parseInt(obj.style.filter)/100;if(op<1) {op+=0.1;obj.style.opacity=op;obj.style.filter='alpha(opacity='+op*100+')';this.tshow=setTimeout(arguments.callee,40);}},SlHide:function(){function goSlHide(){obj=Tp.ge(Ps.idsl);var op=(obj.style.opacity)?parseFloat(obj.style.opacity):parseInt(obj.style.filter)/100;if(op>0) {clearTimeout(this.tshow);op-=0.1;obj.style.opacity=op;obj.style.filter='alpha(opacity='+op*100+')';this.thide=setTimeout(arguments.callee,50);}} Tp.ge(Ps.idsl).style.opacity=1;goSlHide();},Request:function(uri){var url=Ps.server+"go/poll.php?tm="+this.time()+"&j="+Ps.id_pr+"&t="+Ps.id_th;if(window.topolls_poll)url=url+"&p="+window.topolls_poll;if(Ps.Polls&&Ps.Polls[Ps.tp])url=url+"&q="+Ps.tp;if(uri)url=url+uri;this.fSendRequest=true;if(this.JS){this.JS.parentNode.removeChild(this.JS);} this.JS=document.createElement('script');this.JS.setAttribute('type','text/javascript');this.JS.setAttribute('src',url);document.getElementsByTagName('head')[0].appendChild(this.JS);},sendr:function(c){var com=c.replace(/&/g,'%26').replace(/\+/g,'%2B').replace(/\s/g,'+').replace(/#/g,'%23').replace(/\//g,'%2F').replace(/@/g,'%40');Ps.Request("&c="+com);},addVote:function(int){this.fviewResult=true;this.Polls[Ps.tp].dt.fv=true;Ps.Polls[Ps.tp].dt.ar[int]['rg']+=1;if(Ps.Polls[Ps.tp].dt.fj)Ps.Polls[Ps.tp].dt.ar[int]['rl']+=1;if(Ps.Polls[Ps.tp].dt.sr){this.showAR(true);} var uri=(Ps.Polls[Ps.tp].fj)?"&vl=":"&vg=";uri+=Ps.Polls[Ps.tp].dt.ar[int]['id'];if(Ps.Polls[Ps.tp].dt.ar[int]['dq']>0){Ps.nextid=Ps.Polls[Ps.tp].dt.ar[int]['dq'];}else if(Ps.Polls[Ps.tp].dq>0){Ps.nextid=Ps.Polls[Ps.tp].dq;} if(Ps.nextid&&typeof Ps.Polls[Ps.nextid]=='undefined'){uri=uri+"&dq="+Ps.nextid;} Ps.Request(uri);Ps.int=setTimeout(function(){Ps.changePoll();},5000);},delChilds:function(id){var t=Tp.ge(id);while(t.firstChild)t.removeChild(t.firstChild);},showAR:function(isres){Ps.Polls[Ps.tp].dt.rows=Ps.createROWS(isres);Tp.ge(Tp.ansres).innerHTML=Tp.block.tbody.Ins(Ps.Polls[Ps.tp].dt);Bt.sB();Ps.fmOut=false;if(Ps.Polls[Ps.tp].pq){Bt.picButton("tp4p",1);}else{Bt.picButton("tp4p",0);} if(!Ps.fviewResult){if(isres){Bt.picButton("tp1v",4);}else{Bt.picButton("tp1v",1);}}else{Bt.picButton("tp1v",0);} Bt.btoff("tp5s");Bt.btoff("tp6r");Bt.btoff("tp7r");if(Ps.tp==Ps.end){Bt.picButton("tp3n",0);}else{Bt.picButton("tp3n",1);} Bt.btoff("tp3n");Bt.formcomoff();this.SlShow();},changePoll:function(){Ps.int=0;if(Ps.tp){Ps.fviewResult=(Bt.on("tp0s"))?true:Ps.Polls[Ps.tp].dt.fv;window.setTimeout(function(){Ps.showAR(Ps.fviewResult);},700);}},slidePoll:function(){Ps.tslide=window.setTimeout(arguments.callee,5000);Ps.nextPoll();},loadPoll:function(nr){Ps.Request("&w="+nr);},nextPoll:function(){if(Ps.Polls){if(Ps.nextid&&Ps.Polls[Ps.nextid]){Ps.gotp(Ps.nextid);Ps.nextid=null;}else if(Ps.Polls[Ps.tp].dq){Ps.gotp(Ps.Polls[Ps.tp].dq);}else if(Ps.Polls[Ps.tp].nq){Ps.gotp(Ps.Polls[Ps.tp].nq);}else{Ps.gotp(Ps.beg);} if(!Ps.int)Ps.changePoll();}else{Ps.nr+=1;Ps.loadPoll(Ps.nr);}},previousPoll:function(){if(Ps.Polls){if(Ps.history){Ps.tp=Ps.history.pop();this.changePoll();}else{Bt.picButton("tp4p",0);}}},Returned:function(poll){if(this.Polls){Ps.load(poll);Ps.nextPoll();}else{Ps.load(poll);Ps.gotp(Ps.beg);} this.fSendRequest=false;},createROWS:function(isresult){function rsort(i,ii) {if(i['rg']>ii['rg']) return-1;else if(i['rg']0)?100/result[0]['rl']:0;var gk=(result[0]['rg']>0)?100/result[0]['rg']:0;for(var i=0;i0)?Tp.rows.resl*100/suml:0;Tp.rows.resgp=(sumg>0)?Tp.rows.resg*100/sumg:0;Tp.rows.reslpv=Tp.rows.resl*lk;Tp.rows.resgpv=Tp.rows.resg*gk;Tp.rows.id=i;if(isresult){html+=Tp.block.result.Ins(Tp.rows);}else{html+=Tp.block.radio.Ins(Tp.rows);}} Ps.Polls[Ps.tp].dt.stat=sumg;return html;},joinPoll:function(){}} Bt={tbody:1,b14:{"tp0b":[,[14,14],[1],[1,16,31,31,31],0,0],"tp1l":['logo',[60,15],[15],[0,0,0,0,0],0,0,"topolls","http://topolls.com"],"tp2m":['menu',,[31],[16,16,31],1,0,"m","Показати меню"],"tp3n":['next',,[91],[1,16,31],1,0,">","Наступне"],"tp4p":['prev',,[76],[1,16,31],0,0,"<","Попереднє"],"tp5s":['spam',,[151],[1,16,31],1,0,"x","Позначити як спам"],"tp6r":['rplus',,[181],[1,16,31],1,0,"+","Похвалити"],"tp7r":['rminus',,[166],[1,16,31],1,0,"-","Оскаржити"],"tp8c":['com',,[196],[1,16,31,30,31],1,0,"c","Додати коментар"],"tp9j":['join',,[46],[16,16,31],1,0,"+","Додати нове голосування"],"tp0s":['slide',,[136],[1,16,31,31,31],1,0,"s","Слайд-шоу"],"tp1v":['view',,[106],[1,16,31],0,0,"v","Показати результати"],"tp2l":['link',,[16],[16,16,31],1,0,"l","Перейти до обговорення"],"tp3o":['ok',[29,29],[31,31,150,150,120],[150,46,46,46,46],0,0,"O","Надіслати"]},bgpos:function(n,t){var kx=Bt.b14[n][2][t]?Bt.b14[n][2][t]:Bt.b14[n][2][0];var ky=Bt.b14[n][3][t]?Bt.b14[n][3][t]:Bt.b14.tp0b[3][t];return-kx+"px -"+ky+"px";},picButton:function(n,t){if(!(b=Tp.ge(n))){return false;} Bt.b14[n][4]=t;b.style.backgroundPosition=Bt.bgpos(n,t);},overButton:function(){if(Bt.b14[this.id][4]==1){Bt.picButton(this.id,2);}},outButton:function(){if(Bt.b14[this.id][4]==2){Bt.picButton(this.id,1);}},formcomon:function(){var b;if(!(b=Tp.ge(Ps.id0+'_formcom'))){return false;} Bt.picButton("tp3o",1);b.style.display="block";Bt.picButton("tp8c",4);},formcomoff:function(){var b;if(!(b=Tp.ge(Ps.id0+"_formcom"))){return false;} b.style.display="none";b.value="";Bt.picButton("tp8c",1);Bt.picButton("tp3o",0);},btoff:function(id){if(Bt.b14[id][4]==2){Bt.picButton(id,1);}},setok:function(n){Bt.picButton("tp3o",n);},on:function(id){if(Bt.b14[id][4]==4){return true;}else{return false;}},run:function(cl){function r(i,on){switch(i) {case"tp2l":window.open(Ps.server+'?p='+Ps.tp);break;case"tp3o":if(Bt.on("tp8c")&&(c=Tp.ge(Ps.id0+"_formcom").value)){Bt.formcomoff();Ps.sendr(c);}break;case"tp5s":Bt.picButton(i,1);Ps.Request("&a=x");Ps.Polls[Ps.tp].dt.sp=true;Ps.nextPoll();break;case"tp6r":Ps.Request("&a=1");break;case"tp7r":Ps.Request("&a=0");break;case"tp8c":if(on){Bt.formcomon();}else{Bt.formcomoff();}break;case"tp4p":Ps.previousPoll();break;case"tp3n":Ps.nextPoll();break;case"tp0s":if(on){Bt.picButton(i,4);Ps.slidePoll();}else {window.clearTimeout(Ps.tslide);Ps.tslide=null;Bt.picButton(i,1);Ps.fviewResult=Ps.Polls[Ps.tp].dt.fv;Ps.showAR(Ps.fviewResult);}break;case"tp1v":if(on){Ps.showAR(true);}else{Ps.showAR(false);}break;case"tp9j":window.open(Ps.server+"?a=addpoll&j="+Ps.id_pr+"&t="+Ps.id_th,'_blank');break;default:alert('Error: '+i);} Bt.b14[i][5]=on;} r(cl,(Bt.on(cl))?0:1);for(i in Bt.b14){if(Bt.on(i)&&i!=cl){r(i,0);}}},click:function(){if(Bt.b14[this.id][4]==0)return;Bt.run(this.id);},cB:function(id){var bt=document.createElement('a');bt.setAttribute('id',id);bt.setAttribute('title',Bt.b14[id][7]);bt.setAttribute('style',"");bt.style.display="block";bt.style.overflow="hidden";bt.style.width=Bt.b14[id][1]?Bt.b14[id][1][0]+"px":Bt.b14.tp0b[1][0]+"px";bt.style.height=Bt.b14[id][1]?Bt.b14[id][1][1]+"px":Bt.b14.tp0b[1][1]+"px";bt.style.backgroundImage="url("+Ps.server+"go/skin/knopky5.png)";bt.style.backgroundPosition=Bt.bgpos(id,Bt.b14[id][4]);bt.style.backgroundRepeat="no-repeat";return bt;},sB:function(){for(var id in Bt.b14){if(b=Tp.ge(Ps.id0+'_'+Bt.b14[id][0])){Ps.delChilds(Ps.id0+'_'+Bt.b14[id][0]);b.appendChild(Bt.cB(id));if(ba=Tp.ge(id)){ba.onclick=Bt.click;ba.onmouseover=Bt.overButton;ba.onmouseout=Bt.outButton;}}}}} function topolls(data){Ps.Returned(data);} Tp={ansres:"topolls_body",rows:{},ge:function(e){return(typeof e=='string')?document.getElementById(e):e;},block:function(name,str){this.name=name;this.tmpl=this.cT(str);},onl:function(o,t,l){if(o.addEventListener){o.addEventListener(t,l,false);return true;}else if(o.attachEvent){o.attachEvent('on'+t,l);return true;} return false;},mOut:function(){if(Ps.fmOut){Ps.nextPoll();}}} Tp.block.prototype={cT:function(str){str=str.replace(/\s|/gm," ");var re=/(?:(.*)<\/topolls\.\1>)?/i;while(x=re.exec(str)){str=str.replace(x[0],"{topolls."+x[1]+"}");Tp.block[x[1]]=new Tp.block(x[1],x[4]);} return str;},Ins:function(data){var re=/{topolls\.(\w*\d?),?(\d+)?}/;var str=this.tmpl;while(x=re.exec(str)){if(data[x[1]]!==undefined){str=str.replace(x[0],x[2]?Number(data[x[1]]).toFixed(x[2]):data[x[1]]);}else{str=str.replace(x[0],"");}} return str;}} Ps.loadPoll(1);Tp.onl(window,'load',function(){var timer=null;if(!Tp.ge(Tp.ansres)){Tp.ge("topolls").innerHTML="
\r\n \r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n";} Bt.sB();Tp.ge(Ps.id0).style.display='block';Tp.block.tbody=new Tp.block("tbody",Tp.ge(Tp.ansres).innerHTML);if(Ps.tp){Ps.showAR(Ps.Polls[Ps.tp].dt.fv);} else{Ps.nextPoll();} Tp.ge(Ps.id0).onmouseover=function(){if(timer)window.clearTimeout(timer);} Tp.ge(Ps.id0).onmouseout=function(){timer=window.setTimeout(Tp.mOut,100);}});