var Carousel=new Class({Implements:[Options,Events],options:{active:0,wait:!1,duration:500,auto:!1,fakeNav:!1,transition:Fx.Transitions.Quad.easeInOut,listClass:"nav",prevTxt:Locale.get("Carousel.Previous"),nextTxt:Locale.get("Carousel.Next"),view:3,onScrollEnd:function(){}},toElement:function(){return this.element},initialize:function(a,b){this.element=document.id(a),this.setOptions(b);if(!this.element.getChildren().length||this.element.getChildren().length<=this.options.view&&!this.options.fakeNav)return!1;this.initEffect(),this.max=this.element.getChildren().length-this.options.view,this.updateOffset(),this.construct(),this.autoDirection="Next",this.element.getChildren().length>this.options.view&&this.options.auto&&(this.auto=function(){this.autoScroll()}.periodical(this.options.auto*1e3,this));return!0},initEffect:function(){var a=new Fx.Scroll(this.element.getParent(),{wait:this.options.wait,duration:this.options.duration,transition:this.options.transition,onComplete:function(){this.fireEvent("onScrollEnd")}.bind(this)});if(this.options.active==0)a.set(0,0);else{var b=this.element.getChildren()[this.options.active].getPosition(this.element);a.set(b.x,b.y)}this.element.store("effect",a)},construct:function(){var a=new Element("ul",{"class":this.options.listClass}),b=["prev","next"];for(var c=0,d=b.length;c<d;c++){var e=(new Element("li",{"class":b[c]})).inject(a,"inside"),f=(new Element("a",{href:"#",html:this.options[b[c]+"Txt"]})).inject(e,"inside");this.element.getChildren().length<=this.options.view&&this.options.fakeNav?f.addClass("off").addEvent("click",function(a){a.stop()}):f.addEvent("click",this["goTo"+b[c].capitalize()].bind(this))}a.inject(this.element.getParent(),"after"),this.navLinks=a.getElements("a"),this.navPrevLink=this.navLinks[0],this.navNextLink=this.navLinks[1]},updateOffset:function(a){a||(a=0),this.options.active=Math.max(Math.min(this.options.active+a,this.max),0),this.prev=Math.max(this.options.active-this.options.view,0),this.next=Math.min(this.options.active+this.options.view,this.max)},goToNext:function(a){a&&a.stop(),a&&this.options.auto&&(this.auto&&clearInterval(this.auto),this.auto=function(){this.autoScroll()}.periodical(this.options.auto*1e3,this)),this.element.retrieve("effect").toElement(this.element.getChildren()[this.next]),this.updateOffset(this.options.view)},goToPrev:function(a){a&&a.stop(),a&&this.options.auto&&(this.auto&&clearInterval(this.auto),this.auto=function(){this.autoScroll()}.periodical(this.options.auto*1e3,this)),this.element.retrieve("effect").toElement(this.element.getChildren()[this.prev]),this.updateOffset(this.options.view*-1)},autoScroll:function(){this.autoDirection=="Next"&&this.next==this.options.active?this.autoDirection="Prev":this.autoDirection=="Prev"&&this.prev==this.options.active&&(this.autoDirection="Next"),this["goTo"+this.autoDirection]()}});(function(a){a.Overlay=new Class({Extends:Mask,options:{dataClass:"mask-data",data:{type:null,source:null}},show:function(){this.parent(),this.showData();return this},hide:function(){this.parent(),this.hideData();return this},showData:function(){this["show"+this.options.data.type.capitalize()]()},hideData:function(){this["hide"+this.options.data.type.capitalize()]()},showComplete:function(){if(this.hidden)return!1;this.data.addClass(this.options.dataClass).setStyles({left:"50%",position:"absolute",top:"50%",visibility:"hidden"}).inject(this.element,"after");var a=this.data.getSize(),b=window.getScroll();this.data.setStyles({margin:b.y-a.y/2+"px 0 0 "+(b.x-a.x/2)+"px",visibility:"visible"}),this.fireEvent("onComplete")},setSource:function(a){this.options.data.source=a;return this},showElement:function(){this.fireEvent("onLoadStart"),this.data=document.id(this.options.data.source),this.data.getParent()&&(this.dataPlaceholder=(new Element("span")).inject(this.data,"after")),this.fireEvent("onLoadEnd"),this.showComplete()},hideElement:function(){this.data.removeClass(this.options.dataClass).removeProperty("style"),this.dataPlaceholder?(this.data.inject(this.dataPlaceholder,"before"),this.dataPlaceholder.destroy()):this.data.destroy()},showUrl:function(){this.fireEvent("onLoadStart"),(new Request({url:this.options.data.source,onSuccess:function(a,b){this.data=new Element("div",{text:a}),this.fireEvent("onLoadEnd",[a,b]),this.showComplete()}.bind(this)})).send()},hideUrl:function(){this.data.destroy()},showImage:function(){this.fireEvent("onLoadStart"),Asset.image(this.options.data.source,{onLoad:function(){this.data=new Element("img",{src:this.options.data.source}),this.fireEvent("onLoadEnd"),this.showComplete()}.bind(this)})},hideImage:function(){this.data.destroy()}})})(this),OM.initPhotos=function(){(new Carousel(document.getElement("#photos .inner ul"),{prevTxt:Locale.get("Carousel.Previous"),nextTxt:Locale.get("Carousel.Next"),view:3,fakeNav:!0,onScrollEnd:function(){this.navLinks.removeClass("off"),this.options.active==0?this.navPrevLink.addClass("off"):this.options.active==this.max&&this.navNextLink.addClass("off")}})).navPrevLink.addClass("off")},OM.initSelectAutoSubmit=function(){var a=document.getElements('[data-autosubmit="true"]');a.each(function(a){var b=a.getParent("form");a.addEvent("change",function(a){b.submit()})})},OM.initCareer=function(){var a={root:document.id("career"),detailsContainers:document.getElements("#career .details-container"),competition:document.getElements(".compet"),active:[null,null]};a.root.addEvent("click:relay(.details)",function(b){el_target=b.stop().target,el_target.get("class").match("expand")?dataid=el_target.get("data-id"):dataid=$$(this).get("data-id").toString();var c=document.getElements('.expand[data-id="'+dataid+'"]'),d=a.detailsContainers.filter('[data-parent="'+dataid+'"]');console.log(a.active[0]),dataid==a.active[0]&&a.active[0]&&(c.removeClass("active"),d.removeClass("active")),dataid!=a.active[0]?(c.addClass("active"),d.addClass("active"),a.active=[dataid,null]):a.active=[null,null]});var b=new Overlay(null,{hideOnClick:!0,data:{type:"url",source:null},onLoadStart:function(){var a=window.getScroll();this.loadImg=(new Element("section#career-expand.block.mask-data.loading",{styles:{left:"50%",margin:a.y-255+"px 0 0 "+(a.x-470)+"px",position:"absolute",top:"50%"}})).inject(this.element,"after")},onLoadEnd:function(a){try{var b=JSON.decode(a),c='<section id="career-expand" class="block">\n\t\t\t\t\t<header>\n\t\t\t\t\t\t<h1>'+Locale.get("Career.Matches-played-in")+" "+b.season+" "+Locale.get("Career.by")+" "+b.name+'</h1>\n\t\t\t\t\t\t<button class="close" title="'+Locale.get("Career.Close")+'"><span>'+Locale.get("Career.Close")+'</span></button>\n\t\t\t\t\t</header>\n\t\t\t\t\t<div class="inner">\n\t\t\t\t\t<table>\n\t\t\t\t\t\t<thead>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>'+Locale.get("Career.Date")+"</th>\n\t\t\t\t\t\t\t\t<th>"+Locale.get("Career.Competition")+'</th>\n\t\t\t\t\t\t\t\t<th colspan="3">'+Locale.get("Career.Match")+"</th>\n\t\t\t\t\t\t\t\t<th>"+Locale.get("Career.Min-played")+"</th>\n\t\t\t\t\t\t\t\t<th>"+Locale.get("Career.Goals")+"</th>\n\t\t\t\t\t\t\t\t<th>"+Locale.get("Career.Passes")+"</th>\n\t\t\t\t\t\t\t\t<th>"+Locale.get("Career.Cards")+"</th>\n\t\t\t\t\t\t\t\t<th></th>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</thead>\n\t\t\t\t\t\t<tbody>";b.tabMatchs.forEach(function(a){c+='<tr>\n\t\t\t\t\t\t\t\t<td class="date">'+a.dateMatch+'</td>\n\t\t\t\t\t\t\t\t<td class="comp">',a.logoCompetition.match("competition-default.png")||(c+='<img src="'+a.logoCompetition+'" height="30" width="30" alt="" />'),c+='</td>\n\t\t\t\t\t\t\t\t<td class="team1">'+a.rootTeam+'<img src="'+a.rootTeamLogo+'" height="34" width="34" alt="'+a.rootTeam+'" /></td>\n\t\t\t\t\t\t\t\t<td class="score">'+a.score,a.prolongation==!0&&!a.penaltyScore&&!a.playmat?c+="&nbsp;<span>(ap)</span>":a.penaltyScore?c+="&nbsp;<span>"+a.penaltyScore+"</span>":a.playmat&&(c+="&nbsp;<span>"+a.playmat+"</span>"),c+='</td><td class="team2"><img src="'+a.opponentTeamLogo+'" height="34" width="34" alt="'+a.opponentTeam+'" />'+a.opponentTeam+'</td>\n\t\t\t\t\t\t\t\t<td class="time">'+a.tempJeu+'mn</td>\n\t\t\t\t\t\t\t\t<td class="goals">'+(a.nbGoal?'<span class="icon-goals"></span>'+(a.nbGoal>1?a.nbGoal:""):"")+'</td>\n\t\t\t\t\t\t\t\t<td class="passes">'+(a.nbPasses?'<span class="icon-passes"></span>'+(a.nbPasses>1?a.nbPasses:""):"")+'</td>\n\t\t\t\t\t\t\t\t<td class="cards">'+(a.nbYellowCard?'<span class="fakelabel yellow-cards">'+(a.nbYellowCard>1?a.nbYellowCard:"")+"</span>":"")+(a.redCard?'<span class="fakelabel red-cards">'+(a.redCard>1?a.redCard:""):"")+'</span></td>\n\t\t\t\t\t\t\t\t<td class="summary"><a href="'+a.linkAnalyse+'">'+Locale.get("Career.Match-summary")+"</a></td>\n\t\t\t\t\t\t\t</tr>"}),c+="\t</tbody>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</div>\n\t\t\t\t</section>"}catch(d){var c='<section id="career-expand" class="block">\n\t\t\t\t\t<header>\n\t\t\t\t\t\t<h1>'+Locale.get("Career.Loading-error")+'</h1>\n\t\t\t\t\t\t<button class="close" title="'+Locale.get("Career.Close")+'"><span>'+Locale.get("Career.Close")+'</span></button>\n\t\t\t\t\t</header>\n\t\t\t\t\t<p class="error">'+Locale.get("Career.Cannot-display-matches-details")+"</p>\n\t\t\t\t</section>"}this.data=Elements.from(c)[0],this.data.getElement(".close").addEvent("click",function(){this.hide()}.bind(this)),this.loadImg.destroy()}});a.root.addEvent("click:relay([data-expand])",function(a){var c=a.stop().target,d=c.get("data-expand");!d||b.setSource(d).show()})}
