var tx_odarticles_pi1_article_poll=new Class({initialize:function(a){this.key="tx_odarticles_pi1";this.ajaxPageType=110315;if(!a||!a.articleUid){return}this.articleUid=a.articleUid;this.url={path:false,params:false};this.url.path=unescape(document.location.href.split("#")[0]);this.url.params=this.url.path.split("?");this.url.path=this.url.params[0];if(!this.url.params[1]){this.url.params=new Array()}else{this.url.params=this.url.params[1].split("&");this.url.params.each(function(c,b){this.url.params[b]=c.split("=")}.bindWithEvent(this))}if(this.articleUid<=0){return}this.main()},main:function(){var a=Cookie.read(this.key+"_articlesVotedPolls");if(a){a=a.split(",")}else{a=new Array()}if(a.contains(this.articleUid.toString())){return}$$("span").each(function(d){if(!d.className){return}var c=d.className.split(" ");var b;c.each(function(f){if(!f||typeof(f)!="string"||!f.test("^"+this.key+"_poll_answer_\\d+$")){return}b=f.substr((this.key+"_poll_answer_").length).toInt()}.bindWithEvent(this));if(!b){return}var e=new Element("a",{href:"#"});e.addEvent("click",this.startRequest.bindWithEvent(this,b));e.adopt(d.childNodes);d.adopt(e)}.bindWithEvent(this))},startRequest:function(c,a){c.stop();$$("span").each(function(g){if(!g.className){return}var f=g.className.split(" ");var e;f.each(function(i){if(!i||typeof(i)!="string"||!i.test("^"+this.key+"_poll_answer_\\d+$")){return}e=i.substr((this.key+"_poll_answer_").length).toInt()}.bindWithEvent(this));if(!e){return}var h=g.getElement("a");g.innerHTML=h.innerHTML}.bindWithEvent(this));var d="";this.url.params.each(function(e){if(e[0]=="cHash"){return}d+="&"+e[0]+"="+e[1]}.bindWithEvent(this));this.switchLoader(document.getElement("."+this.key+"_poll_answer_loader_"+a),"inline");var b=new Request.JSON({url:this.url.path+"?type="+this.ajaxPageType+d+"&"+this.key+"[poll_answer_uid]="+a,noCache:true,userData:{answerUid:a},onSuccess:function(e){this.updateVotes(b,e)}.bindWithEvent(this),onFailure:function(){this.switchLoader(document.getElement("."+this.key+"_poll_answer_loader_"+a),"none")}.bindWithEvent(this)});b.send()},updateVotes:function(a,b){this.switchLoader(document.getElement("."+this.key+"_poll_answer_loader_"+a.options.userData.answerUid),"none");if(!b){return}if(b.pollAnswersVotes&&b.pollAnswersVotes.length){b.pollAnswersVotes.each(function(c){if(!c.uid||c.uid<=0){return}if(document.getElement("#"+this.key+"_poll_answer_votes_"+c.uid)&&c.votes){document.getElement("#"+this.key+"_poll_answer_votes_"+c.uid).set("text",c.votes)}if(document.getElement("#"+this.key+"_poll_answer_votes_in_percent_"+c.uid)&&c.votesInPercents){document.getElement("#"+this.key+"_poll_answer_votes_in_percent_"+c.uid).set("text",c.votesInPercents)}if(document.getElement("#"+this.key+"_poll_answer_votes_in_pixels_"+c.uid)&&c.votesInPixels){document.getElement("#"+this.key+"_poll_answer_votes_in_pixels_"+c.uid).setStyle("padding-right",c.votesInPixels)}}.bindWithEvent(this))}if(document.getElement("#"+this.key+"_poll_total_votes")&&b.pollTotalVotes){document.getElement("#"+this.key+"_poll_total_votes").set("text",b.pollTotalVotes)}},switchLoader:function(a,b){if(a){a.setStyle("display",b)}}});var tx_odarticles_pi1_articles_rating=new Class({initialize:function(){this.key="tx_odarticles_pi1";this.ajaxPageType=110309;this.url={path:false,params:false};this.url.path=unescape(document.location.href.split("#")[0]);this.url.params=this.url.path.split("?");this.url.path=this.url.params[0];if(!this.url.params[1]){this.url.params=new Array()}else{this.url.params=this.url.params[1].split("&");this.url.params.each(function(b,a){this.url.params[a]=b.split("=")}.bindWithEvent(this))}this.main()},main:function(){var a=Cookie.read(this.key+"_articlesRatingUpdated");if(a){a=a.split(",")}else{a=new Array()}$$("span").each(function(b){var d=this.getSpanData(b);if(!d.uid||a.contains(d.uid.toString())){return}var c=new Element("a",{href:"#"});c.addEvent("click",this.startRequest.bindWithEvent(this,d));c.adopt(b.childNodes);b.adopt(c)}.bindWithEvent(this))},startRequest:function(c,b){c.stop();this.disableLink(b.uid,this.key+"_rating_add_");this.disableLink(b.uid,this.key+"_rating_take_");var d="";this.url.params.each(function(e){if(e[0]=="cHash"||e[0]==this.key+"[uid]"){return}d+="&"+e[0]+"="+e[1]}.bindWithEvent(this));this.switchLoader(document.getElement("."+this.key+"_rating_loader_"+b.uid),"inline");var a=new Request.JSON({url:this.url.path+"?type="+this.ajaxPageType+d+"&"+this.key+"[uid]="+b.uid+"&"+this.key+"["+b.param+"]=1",noCache:true,userData:{uid:b.uid},onSuccess:function(e){this.updateRating(a,e)}.bindWithEvent(this),onFailure:function(){this.switchLoader(document.getElement("."+this.key+"_rating_loader_"+b.uid),"none")}.bindWithEvent(this)});a.send()},updateRating:function(a,b){this.switchLoader(document.getElement("."+this.key+"_rating_loader_"+a.options.userData.uid),"none");if(!b){return}if(document.getElement("."+this.key+"_rating_positive_"+a.options.userData.uid)&&b.ratingPositive){document.getElement("."+this.key+"_rating_positive_"+a.options.userData.uid).set("text",b.ratingPositive)}if(document.getElement("."+this.key+"_rating_negative_"+a.options.userData.uid)&&b.ratingNegative){document.getElement("."+this.key+"_rating_negative_"+a.options.userData.uid).set("text",b.ratingNegative)}},disableLink:function(a,c){var b=document.getElement("span."+c+a);if(b){var d=b.getElement("a");if(d){b.innerHTML=d.innerHTML}}},getSpanData:function(b){var a=b.className.split(" ");var c={};c.uid=false;a.each(function(e){if(!e||typeof(e)!="string"){return}var d=0;if(e.test("^"+this.key+"_rating_add_\\d+$")){c.param="rating_add";d=(this.key+"_rating_add_").length}else{if(e.test("^"+this.key+"_rating_take_\\d+$")){c.param="rating_take";d=(this.key+"_rating_take_").length}}if(c.param){c.uid=e.substr(d).toInt()}}.bindWithEvent(this));return c},switchLoader:function(a,b){if(a){a.setStyle("display",b)}}});var tx_odarticles_pi1_play_video=new Class({initialize:function(a){this.key="tx_odarticles_pi1";if(a.closeText){this.closeText=a.closeText}else{this.closeText="[close]"}if(a.closeImage){this.closeImage=a.closeImage}if(a.playImage){this.playImage=a.playImage}this.main()},main:function(){this.container=new Element("div",{id:this.key+"_video",styles:{display:"none",position:"absolute",left:0,top:0,zIndex:100}});$$("body").adopt(this.container);this.background=new Element("div",{styles:{display:"block",opacity:0,position:"absolute",left:0,top:0,backgroundColor:"#000",zIndex:98,width:window.getScrollWidth(),height:window.getScrollHeight()-1}});this.effectBackground=new Fx.Tween(this.background,{duration:"300",transition:Fx.Transitions.Sine.easeOut});$$("body").adopt(this.background);var links=$$("."+this.key+"_play_video");if(!links||links.length==0){return}links.each(function(link){if(link.href.lastIndexOf("#")<=0){return}var contentId=parseInt(link.href.substr(link.href.lastIndexOf("#")+6));if(!contentId||contentId<=0){return}try{eval("var swfobject = s"+contentId)}catch(e){}if(!swfobject){return}var d=new Element("div",{id:this.key+"_c"+contentId,styles:{display:"none",position:"absolute",zIndex:101,padding:"25px",backgroundColor:"#fff",visibility:"hidden"}});this.container.adopt(d);if(this.closeImage){var close=new Element("img",{src:this.closeImage,alt:this.closeText,title:this.closeText,styles:{display:"block",position:"absolute",right:5,top:5,cursor:"pointer"}});$(this.key+"_c"+contentId).adopt(close);close.addEvent("click",this.closeVideo.bindWithEvent(this,{contentId:contentId,swfobject:swfobject}))}this.container.removeEvents("click");this.container.addEvent("click",this.closeVideo.bindWithEvent(this,{contentId:contentId,swfobject:swfobject}));var p=new Element("p",{id:this.key+"_p"+contentId,styles:{padding:"0",margin:"0"}});d.adopt(p);link.addEvent("click",this.playVideo.bindWithEvent(this,{contentId:contentId,swfobject:swfobject}));if(this.playImage){var img=link.getElements("img")[0];if(!img){return}var size=img.getSize();var span=new Element("span",{styles:{width:size.x,height:size.y,background:'url("'+this.playImage+'") no-repeat scroll center center transparent',display:"block",left:0,position:"absolute",top:0,zIndex:2}});link.adopt(span)}},this)},playVideo:function(b,a){b.stop();this.effectBackground.start("opacity","0.6");$(this.key+"_c"+a.contentId).removeEvents("click");$(this.key+"_c"+a.contentId).addEvent("click",function(c){c.stop()});a.swfobject.addVariable("autostart","true");a.swfobject.write(this.key+"_p"+a.contentId);(function(){this.container.setStyles({display:"block",width:window.getScrollWidth(),height:window.getScrollHeight()-1});$(this.key+"_c"+a.contentId).setStyles({display:"block"});var d=$(this.key+"_c"+a.contentId).getSize();var c=$$("body")[0].getSize();$(this.key+"_c"+a.contentId).setStyles({left:parseInt(window.getScrollLeft()+c.x/2-(d.x)/2),top:parseInt(window.getScrollTop()+c.y/2-(d.y)/2),visibility:"visible"})}.bindWithEvent(this)).delay(300)},closeVideo:function(b,a){this.effectBackground.start("opacity","0");$(this.key+"_c"+a.contentId).setStyle("display","none");this.container.setStyle("display","none");a.swfobject.addVariable("autostart","false");a.swfobject.write("odfmp"+a.contentId)}});
